[
  {
    "path": ".gitignore",
    "content": "build\nrelease\n"
  },
  {
    "path": "Formula/spotctl.rb",
    "content": "class Spotctl < Formula\n  desc \"A CLI to Spotify\"\n  homepage \"https://github.com/jingweno/spotctl\"\n  version \"1.0.1\"\n  sha256 \"a0276bd0c0fb65e7b24885f17d3547276dcf9b059b9507abe51edfa5f5388f89\"\n  url \"https://github.com/jingweno/spotctl/releases/download/v1.0.1/darwin-amd64-1.0.1.tar.gz\"\n\n  def install\n    bin.install \"spotctl\"\n  end\nend\n"
  },
  {
    "path": "Gopkg.toml",
    "content": "\n# Gopkg.toml example\n#\n# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md\n# for detailed Gopkg.toml documentation.\n#\n# required = [\"github.com/user/thing/cmd/thing\"]\n# ignored = [\"github.com/user/project/pkgX\", \"bitbucket.org/user/project/pkgA/pkgY\"]\n#\n# [[constraint]]\n#   name = \"github.com/user/project\"\n#   version = \"1.0.0\"\n#\n# [[constraint]]\n#   name = \"github.com/user/project2\"\n#   branch = \"dev\"\n#   source = \"github.com/myfork/project2\"\n#\n# [[override]]\n#  name = \"github.com/x/y\"\n#  version = \"2.4.0\"\n\n\n[[constraint]]\n  name = \"github.com/spf13/cobra\"\n  branch = \"master\"\n\n[[constraint]]\n  branch = \"master\"\n  name = \"github.com/zmb3/spotify\"\n\n[[constraint]]\n  branch = \"master\"\n  name = \"github.com/gizak/termui\"\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2018 Jingwen Owen Ou\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Spotctl\n\n`spotctl` is command-line interface to control Spotify from your favorite terminal.\n\n## Demo\n\nOne of the highlights is that `spotctl player` shows a real-time Spotify player that allows you to control it, right in your terminal!\n\n[![asciicast](https://asciinema.org/a/154262.png)](https://asciinema.org/a/154262)\n\n## Installation\n\n## Homebrew\n\nIf you're on a Mac, you can install with [Homebrew](https://brew.sh/):\n\n```\nbrew install https://raw.githubusercontent.com/jingweno/spotctl/master/Formula/spotctl.rb\n```\n\n## Download\n\nYou can download the latest release for your operating system [here](https://github.com/jingweno/spotctl/releases).\n\n## Manual Installation\n\n`spotctl` needs to connect to Spotify's API in order to control it.\nTo manually build it, you first need to sign up (or into) Spotify's developer site and [create an Application](https://developer.spotify.com/my-applications/#!/applications/create).\nOnce you've done so, you can find its Client ID and Client Secret values and run the following command:\n\n```\nSPOTIFY_CLIENT_ID=XXX SPOTIFY_CLIENT_SECRET=YYY ./bin/build\n```\n\n## Running\n\n**Please make sure the Spotify app is opened before running any `spotctl` commands**, since it talks to the Spotify API which in turns talks to the Spotify app in your local box.\nHere is a list of available commands:\n\n```\n$ spotctl -h\nA command-line interface to Spotify.\n\nUsage:\n  spotctl [command]\n\nAvailable Commands:\n  help        Help about any command\n  login       Login with your Spotify credentials\n  logout      Clear your local Spotify credentials\n  next        Skip to the next track\n  pause       Pause Spotify playback\n  play        Resume playback or play a track, album, artist or playlist by name\n  player      Show the live player panel\n  prev        Return to the previous track\n  repeat      Toggle repeat playback mode\n  shuffle     Toggle shuffle playback mode\n  status      Show the current player status\n  version     Show version.\n  vol         Set or return volume percentage\n\nFlags:\n  -h, --help   help for spotctl\n\nUse \"spotctl [command] --help\" for more information about a command.\n```\n\n## License\n\n[MIT](https://github.com/jingweno/spotctl/blob/master/LICENSE)\n"
  },
  {
    "path": "bin/package",
    "content": "#!/bin/bash -e\n\nversion() {\n  ver=\"$(git describe --tags HEAD 2>/dev/null || true)\"\n\n  if [ -z \"$ver\" ]; then\n    ver=\"$(grep version version.go | head -1 | cut -d '\"' -f2)\"\n    sha=\"$(git rev-parse --short HEAD 2>/dev/null || true)\"\n    [ -z \"$sha\" ] || ver=\"${ver}-g${sha}\"\n  fi\n\n  echo \"${ver#v}\"\n}\n\ncompress() {\n  cd release\n\n  for dir in */\n  do\n    base=$(basename \"$dir\")\n    cp ../README.md ../LICENSE $dir\n\n    echo \"Compressing $base\"\n\n    tar -zcf \"${base}.tar.gz\" \"$dir\"\n    rm -rf $dir\n  done\n\n  echo\n\n  ls -all\n}\n\nOSARCH=\"darwin/amd64 linux/amd64 linux/386 windows/amd64 windows/386\"\n\ncd cmd/spotctl\necho \"Packaging spotctl $(version)\"\n\ngo get -u github.com/mitchellh/gox\n\ngox -osarch=\"$OSARCH\" \\\n  -ldflags \"-X main.spotifyClientID=$SPOTIFY_CLIENT_ID -X main.spotifyClientSecret=$SPOTIFY_CLIENT_SECRET -X main.version=$(version)\" \\\n  -output=\"../../release/{{.OS}}-{{.Arch}}-$(version)/{{.Dir}}\"\n\necho\n\ncd -\n\ncompress\n"
  },
  {
    "path": "cmd/spotctl/auth.go",
    "content": "package main\n\nimport (\n\t\"crypto/rand\"\n\t\"encoding/base64\"\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\t\"os\"\n\n\t\"github.com/spf13/cobra\"\n\t\"github.com/zmb3/spotify\"\n\t\"golang.org/x/oauth2\"\n)\n\nvar loginCmd = &cobra.Command{\n\tUse:   \"login\",\n\tShort: \"Login with your Spotify credentials\",\n\tRunE:  login,\n}\n\nvar logoutCmd = &cobra.Command{\n\tUse:   \"logout\",\n\tShort: \"Clear your local Spotify credentials\",\n\tRunE:  login,\n}\n\nfunc login(cmd *cobra.Command, args []string) error {\n\tstate, err := generateRandomString(32)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tch := make(chan *oauth2.Token)\n\n\thttp.Handle(\"/callback\", &authHandler{state: state, ch: ch, auth: auth})\n\tgo http.ListenAndServe(\"localhost:10028\", nil)\n\n\turl := auth.AuthURL(state)\n\tfmt.Println(\"Please log in to Spotify by visiting the following page in your browser:\", url)\n\n\ttok := <-ch\n\n\tif err := saveToken(tok); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc logout(cmd *cobra.Command, args []string) error {\n\tos.Remove(tokenPath)\n\treturn nil\n}\n\ntype authHandler struct {\n\tstate string\n\tch    chan *oauth2.Token\n\tauth  spotify.Authenticator\n}\n\nfunc (a *authHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\ttok, err := a.auth.Token(a.state, r)\n\tif err != nil {\n\t\thttp.Error(w, \"Couldn't get token\", http.StatusForbidden)\n\t\tlog.Fatal(err)\n\t}\n\n\tif st := r.FormValue(\"state\"); st != a.state {\n\t\thttp.NotFound(w, r)\n\t\tlog.Fatalf(\"State mismatch: %s != %s\\n\", st, a.state)\n\t}\n\n\tfmt.Fprintf(w, \"Login successfully. Please return to your terminal.\")\n\n\ta.ch <- tok\n}\n\nfunc generateRandomBytes(n int) ([]byte, error) {\n\tb := make([]byte, n)\n\t_, err := rand.Read(b)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn b, nil\n}\n\nfunc generateRandomString(s int) (string, error) {\n\tb, err := generateRandomBytes(s)\n\treturn base64.URLEncoding.EncodeToString(b), err\n}\n"
  },
  {
    "path": "cmd/spotctl/ctl.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/spf13/cobra\"\n\t\"github.com/zmb3/spotify\"\n)\n\nvar (\n\tplayCmdFlagType string\n\tdeviceNameFlag  string\n)\n\nvar playCmd = &cobra.Command{\n\tUse:   \"play [name]\",\n\tShort: \"Resume playback or play a track, album, artist or playlist by name\",\n\tLong:  `Resume playback or find a track, album, artist or playlist by name and play it. The search type can be specified with --type.`,\n\tRunE:  play,\n}\n\nvar pauseCmd = &cobra.Command{\n\tUse:   \"pause\",\n\tShort: \"Pause Spotify playback\",\n\tRunE:  pause,\n}\n\nvar nextCmd = &cobra.Command{\n\tUse:   \"next\",\n\tShort: \"Skip to the next track\",\n\tRunE:  next,\n}\n\nvar prevCmd = &cobra.Command{\n\tUse:   \"prev\",\n\tShort: \"Return to the previous track\",\n\tRunE:  prev,\n}\n\nvar volCmd = &cobra.Command{\n\tUse:   \"vol [up|down|amount]\",\n\tShort: \"Set or return volume percentage\",\n\tLong:  `Set volume percentage to an amount between 0 and 100. If arg is up, volume is increased by 10%. If arg is down, volume is decreased by 10%. If no arg is provided, current volume percentage is returned.`,\n\tRunE:  vol,\n}\n\nvar statusCmd = &cobra.Command{\n\tUse:   \"status\",\n\tShort: \"Show the current player status\",\n\tRunE:  status,\n}\n\nvar shuffleCmd = &cobra.Command{\n\tUse:   \"shuffle\",\n\tShort: \"Toggle shuffle playback mode\",\n\tRunE:  shuffle,\n}\n\nvar repeatCmd = &cobra.Command{\n\tUse:   \"repeat\",\n\tShort: \"Toggle repeat playback mode\",\n\tRunE:  repeat,\n}\n\nvar devicesCmd = &cobra.Command{\n\tUse:   \"devices\",\n\tShort: \"Show list of available devices\",\n\tRunE:  devices,\n}\n\nfunc shuffle(cmd *cobra.Command, args []string) error {\n\tstate, err := client.PlayerState()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn client.Shuffle(!state.ShuffleState)\n}\n\nfunc repeat(cmd *cobra.Command, args []string) error {\n\tstate, err := client.PlayerState()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar repeat string\n\tif state.RepeatState == \"off\" {\n\t\trepeat = \"track\"\n\t} else if state.RepeatState == \"track\" {\n\t\trepeat = \"context\"\n\t} else if state.RepeatState == \"context\" {\n\t\trepeat = \"off\"\n\t} else {\n\t\treturn fmt.Errorf(\"unsupported repeat state %s\", state.RepeatState)\n\t}\n\n\topt := &spotify.PlayOptions{\n\t\tDeviceID: findDeviceByName(deviceNameFlag),\n\t}\n\treturn client.RepeatOpt(repeat, opt)\n}\n\nfunc play(cmd *cobra.Command, args []string) error {\n\tvar (\n\t\topt = &spotify.PlayOptions{}\n\t\terr error\n\t)\n\n\tif len(args) > 0 {\n\t\t// if args start with a spotify ID, play it directly, otherwise search for songs\n\t\tif strings.Contains(args[0], \"spotify:\") {\n\t\t\topt = playByID(args[0]) // only play the first id\n\t\t} else {\n\t\t\topt, err = searchToPlay(strings.Join(args, \" \"), playCmdFlagType)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\topt.DeviceID = findDeviceByName(deviceNameFlag)\n\n\treturn client.PlayOpt(opt)\n}\n\nfunc devices(cmd *cobra.Command, args []string) error {\n\tdevices, err := client.PlayerDevices()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, device := range devices {\n\t\tactive := \"\"\n\t\tif device.Active {\n\t\t\tactive = \"* \"\n\t\t}\n\t\tfmt.Printf(\"%s%s - %s (volume %d%%)\\n\", active, device.Name, device.Type, device.Volume)\n\t}\n\n\treturn nil\n}\n\nfunc vol(cmd *cobra.Command, args []string) error {\n\tstate, err := client.PlayerState()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(args) == 0 {\n\t\tfmt.Printf(\"Current volume is %d%%.\\n\", state.Device.Volume)\n\t\treturn nil\n\t}\n\n\tvar currVolume int\n\tswitch vol := args[0]; vol {\n\tcase \"up\":\n\t\tcurrVolume = state.Device.Volume + 10\n\tcase \"down\":\n\t\tcurrVolume = state.Device.Volume - 10\n\tdefault:\n\t\tcurrVolume, err = strconv.Atoi(vol)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif currVolume < 0 {\n\t\tcurrVolume = 0\n\t}\n\n\tif currVolume > 100 {\n\t\tcurrVolume = 100\n\t}\n\n\topt := &spotify.PlayOptions{\n\t\tDeviceID: findDeviceByName(deviceNameFlag),\n\t}\n\treturn client.VolumeOpt(currVolume, opt)\n}\n\nfunc pause(cmd *cobra.Command, args []string) error {\n\topt := &spotify.PlayOptions{\n\t\tDeviceID: findDeviceByName(deviceNameFlag),\n\t}\n\treturn client.PauseOpt(opt)\n}\n\nfunc next(cmd *cobra.Command, args []string) error {\n\topt := &spotify.PlayOptions{\n\t\tDeviceID: findDeviceByName(deviceNameFlag),\n\t}\n\treturn client.NextOpt(opt)\n}\n\nfunc prev(cmd *cobra.Command, args []string) error {\n\topt := &spotify.PlayOptions{\n\t\tDeviceID: findDeviceByName(deviceNameFlag),\n\t}\n\treturn client.PreviousOpt(opt)\n}\n\nfunc status(cmd *cobra.Command, args []string) error {\n\tstate, err := client.PlayerState()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif state.Playing && state.Item != nil {\n\t\tvar artists []string\n\t\tfor _, a := range state.Item.Artists {\n\t\t\tartists = append(artists, a.Name)\n\t\t}\n\n\t\tfmt.Printf(\"Spotify is currently playing on %s.\\n\", state.Device.Name)\n\t\tfmt.Printf(\"Artist: %s\\n\", strings.Join(artists, \", \"))\n\t\tfmt.Printf(\"Album: %s\\n\", state.Item.Album.Name)\n\t\tfmt.Printf(\"Track: %s\\n\", state.Item.Name)\n\t\tfmt.Printf(\"Position: %s / %s\\n\", durationToStr(state.Progress), durationToStr(state.Item.Duration))\n\t} else {\n\t\tfmt.Println(\"Spotify is currently paused.\")\n\t}\n\n\treturn nil\n}\n\n// findDeviceByName finds the device by name.\n// If name is empty, the first Computer device ID is returned if it's available;\n// otherwise it returns the first device ID.\nfunc findDeviceByName(name string) *spotify.ID {\n\tdevices, err := client.PlayerDevices()\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\tfor _, device := range devices {\n\t\tif name != \"\" && device.Name == name {\n\t\t\treturn &device.ID\n\t\t} else if device.Type == \"Computer\" {\n\t\t\treturn &device.ID\n\t\t}\n\t}\n\n\tif len(devices) > 0 {\n\t\treturn &devices[0].ID\n\t}\n\n\treturn nil\n}\n\nfunc playByID(id string) *spotify.PlayOptions {\n\tvar (\n\t\turis    []spotify.URI\n\t\tcontext *spotify.URI\n\t)\n\n\tif strings.Contains(id, \"spotify:track\") {\n\t\turis = append(uris, spotify.URI(id))\n\t} else {\n\t\turi := spotify.URI(id)\n\t\tcontext = &uri\n\t}\n\n\treturn &spotify.PlayOptions{\n\t\tPlaybackContext: context,\n\t\tURIs:            uris,\n\t}\n}\n\nfunc searchToPlay(query, t string) (*spotify.PlayOptions, error) {\n\tvar st spotify.SearchType\n\tswitch t {\n\tcase \"track\":\n\t\tst = spotify.SearchTypeTrack\n\tcase \"album\":\n\t\tst = spotify.SearchTypeAlbum\n\tcase \"artist\":\n\t\tst = spotify.SearchTypeArtist\n\tcase \"playlist\":\n\t\tst = spotify.SearchTypePlaylist\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported search type %s\", t)\n\t}\n\n\tresult, err := client.Search(query, st)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar opt *spotify.PlayOptions\n\tswitch t {\n\tcase \"track\":\n\t\tif result.Tracks != nil && len(result.Tracks.Tracks) > 0 {\n\t\t\topt = &spotify.PlayOptions{\n\t\t\t\tURIs: []spotify.URI{result.Tracks.Tracks[0].URI},\n\t\t\t}\n\t\t}\n\tcase \"album\":\n\t\tif result.Albums != nil && len(result.Albums.Albums) > 0 {\n\t\t\topt = &spotify.PlayOptions{\n\t\t\t\tPlaybackContext: &result.Albums.Albums[0].URI,\n\t\t\t}\n\t\t}\n\tcase \"artist\":\n\t\tif result.Artists != nil && len(result.Artists.Artists) > 0 {\n\t\t\topt = &spotify.PlayOptions{\n\t\t\t\tPlaybackContext: &result.Artists.Artists[0].URI,\n\t\t\t}\n\t\t}\n\tcase \"playlist\":\n\t\tif result.Playlists != nil && len(result.Playlists.Playlists) > 0 {\n\t\t\topt = &spotify.PlayOptions{\n\t\t\t\tPlaybackContext: &result.Playlists.Playlists[0].URI,\n\t\t\t}\n\t\t}\n\t}\n\n\treturn opt, nil\n}\n"
  },
  {
    "path": "cmd/spotctl/main.go",
    "content": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"os/user\"\n\t\"path/filepath\"\n\n\t\"github.com/spf13/cobra\"\n\t\"github.com/zmb3/spotify\"\n\t\"golang.org/x/oauth2\"\n)\n\nconst (\n\tredirectURI = \"http://localhost:10028/callback\"\n)\n\nvar (\n\tspotifyClientID     string\n\tspotifyClientSecret string\n)\n\nvar (\n\tauth      spotify.Authenticator\n\ttoken     *oauth2.Token\n\tclient    spotify.Client\n\ttokenPath string\n)\n\nvar rootCmd = &cobra.Command{\n\tUse:               \"spotctl\",\n\tShort:             \"A command-line interface to Spotify.\",\n\tPersistentPreRun:  preRootCmd,\n\tPersistentPostRun: postRootCmd,\n}\n\nvar versionCmd = &cobra.Command{\n\tUse:   \"version\",\n\tShort: \"Show version.\",\n\tRun:   ver,\n}\n\nfunc ver(cmd *cobra.Command, args []string) {\n\tfmt.Println(version)\n}\n\nfunc main() {\n\trootCmd.AddCommand(loginCmd)\n\trootCmd.AddCommand(logoutCmd)\n\trootCmd.AddCommand(devicesCmd)\n\trootCmd.AddCommand(playCmd)\n\trootCmd.AddCommand(pauseCmd)\n\trootCmd.AddCommand(nextCmd)\n\trootCmd.AddCommand(prevCmd)\n\trootCmd.AddCommand(volCmd)\n\trootCmd.AddCommand(shuffleCmd)\n\trootCmd.AddCommand(repeatCmd)\n\trootCmd.AddCommand(statusCmd)\n\trootCmd.AddCommand(playerCmd)\n\trootCmd.AddCommand(versionCmd)\n\n\tplayCmd.PersistentFlags().StringVarP(&playCmdFlagType, \"type\", \"t\", \"track\", \"the type of [name] to play: track, album, artist or playlist.\")\n\tplayCmd.PersistentFlags().StringVarP(&deviceNameFlag, \"device\", \"d\", \"\", \"the name of device\")\n\tpauseCmd.PersistentFlags().StringVarP(&deviceNameFlag, \"device\", \"d\", \"\", \"the name of device\")\n\tnextCmd.PersistentFlags().StringVarP(&deviceNameFlag, \"device\", \"d\", \"\", \"the name of device\")\n\tprevCmd.PersistentFlags().StringVarP(&deviceNameFlag, \"device\", \"d\", \"\", \"the name of device\")\n\tvolCmd.PersistentFlags().StringVarP(&deviceNameFlag, \"device\", \"d\", \"\", \"the name of device\")\n\tshuffleCmd.PersistentFlags().StringVarP(&deviceNameFlag, \"device\", \"d\", \"\", \"the name of device\")\n\trepeatCmd.PersistentFlags().StringVarP(&deviceNameFlag, \"device\", \"d\", \"\", \"the name of device\")\n\tplayerCmd.PersistentFlags().StringVarP(&deviceNameFlag, \"device\", \"d\", \"\", \"the name of device\")\n\n\tif err := rootCmd.Execute(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nfunc preRootCmd(cmd *cobra.Command, args []string) {\n\tusr, err := user.Current()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\ttokenPath = filepath.Join(usr.HomeDir, \".spotctl\")\n\tauth = spotify.NewAuthenticator(\n\t\tredirectURI,\n\t\tspotify.ScopeUserReadCurrentlyPlaying,\n\t\tspotify.ScopeUserReadPlaybackState,\n\t\tspotify.ScopeUserModifyPlaybackState,\n\t)\n\tauth.SetAuthInfo(spotifyClientID, spotifyClientSecret)\n\n\t// skip reading token if this is a login/logout command\n\tif cmd.Use == \"login\" || cmd.Use == \"logout\" {\n\t\treturn\n\t}\n\n\ttoken, err = readToken()\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\tif err := login(cmd, args); err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\n\t\t\t// read token one more time\n\t\t\ttoken, err = readToken()\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}\n\n\tclient = auth.NewClient(token)\n}\n\nfunc postRootCmd(cmd *cobra.Command, args []string) {\n\t// skip reading token if this is a login/logout command\n\tif cmd.Use == \"login\" || cmd.Use == \"logout\" {\n\t\treturn\n\t}\n\n\ttokenInUse, err := client.Token()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tif tokenInUse != token {\n\t\tif err := saveToken(tokenInUse); err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}\n}\n\nfunc saveToken(tok *oauth2.Token) error {\n\tf, err := os.OpenFile(tokenPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\tenc := json.NewEncoder(f)\n\treturn enc.Encode(tok)\n}\n\nfunc readToken() (*oauth2.Token, error) {\n\tcontent, err := ioutil.ReadFile(tokenPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar tok oauth2.Token\n\tif err := json.Unmarshal(content, &tok); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &tok, nil\n}\n"
  },
  {
    "path": "cmd/spotctl/player.go",
    "content": "package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"strings\"\n\t\"time\"\n\n\tui \"github.com/gizak/termui\"\n\t\"github.com/spf13/cobra\"\n)\n\nvar playerCmd = &cobra.Command{\n\tUse:   \"player\",\n\tShort: \"Show the live player panel\",\n\tRunE:  player,\n}\n\nfunc player(cmd *cobra.Command, args []string) error {\n\tif err := ui.Init(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer ui.Close()\n\n\tsongList := ui.NewList()\n\tsongList.Border = false\n\tsongList.X = 0\n\tsongList.Y = 0\n\tsongList.Height = 2\n\tsongList.Width = 40\n\n\tctlList := ui.NewList()\n\tctlList.Border = false\n\tctlList.X = 0\n\tctlList.Y = 3\n\tctlList.Height = 2\n\tctlList.Width = 40\n\n\tcurrPosLabel := ui.NewPar(\"\")\n\tcurrPosLabel.X = 0\n\tcurrPosLabel.Y = 6\n\tcurrPosLabel.Width = 6\n\tcurrPosLabel.Border = false\n\n\tprogressGauge := ui.NewGauge()\n\tprogressGauge.LabelAlign = ui.AlignCenter\n\tprogressGauge.Height = 2\n\tprogressGauge.Y = 6\n\tprogressGauge.X = 6\n\tprogressGauge.Width = 30\n\tprogressGauge.Border = false\n\tprogressGauge.Label = \"\"\n\tprogressGauge.Percent = 0\n\tprogressGauge.PaddingBottom = 1\n\n\ttotalSecLabel := ui.NewPar(\"\")\n\ttotalSecLabel.X = 38\n\ttotalSecLabel.Y = 6\n\ttotalSecLabel.Width = 6\n\ttotalSecLabel.Border = false\n\n\tvolGauge := ui.NewGauge()\n\tvolGauge.LabelAlign = ui.AlignCenter\n\tvolGauge.Height = 2\n\tvolGauge.Y = 8\n\tvolGauge.X = 0\n\tvolGauge.Width = 44\n\tvolGauge.Border = false\n\tvolGauge.BarColor = ui.ColorBlue\n\tvolGauge.PaddingBottom = 1\n\n\thelpLabel := ui.NewPar(\"Press q - quit, p - play/pause, l/h - next/previous track, j/k - vol up/down, s - shuffle, r - repeat.\")\n\thelpLabel.X = 0\n\thelpLabel.Y = 10\n\thelpLabel.Width = 40\n\thelpLabel.Height = 5\n\thelpLabel.Border = false\n\thelpLabel.WrapLength = 40\n\n\tdraw := func() {\n\t\tui.Render(\n\t\t\tsongList,\n\t\t\tctlList,\n\t\t\tcurrPosLabel,\n\t\t\tprogressGauge,\n\t\t\ttotalSecLabel,\n\t\t\tvolGauge,\n\t\t\thelpLabel,\n\t\t)\n\t}\n\n\tui.Handle(\"/sys/kbd/q\", func(ui.Event) {\n\t\tui.StopLoop()\n\t})\n\n\tui.Handle(\"/sys/kbd/p\", func(ui.Event) {\n\t\tstate, err := client.PlayerState()\n\t\tif err != nil {\n\t\t\tquitAndFatal(err)\n\t\t}\n\t\tif state.Playing {\n\t\t\tif err := pause(pauseCmd, []string{}); err != nil {\n\t\t\t\tquitAndFatal(err)\n\t\t\t}\n\t\t} else {\n\t\t\tif err := play(playCmd, []string{}); err != nil {\n\t\t\t\tquitAndFatal(err)\n\t\t\t}\n\t\t}\n\t})\n\n\tui.Handle(\"/sys/kbd/l\", func(ui.Event) {\n\t\tif err := next(nextCmd, []string{}); err != nil {\n\t\t\tquitAndFatal(err)\n\t\t}\n\t})\n\n\tui.Handle(\"/sys/kbd/h\", func(ui.Event) {\n\t\tif err := prev(prevCmd, []string{}); err != nil {\n\t\t\tquitAndFatal(err)\n\t\t}\n\t})\n\n\tui.Handle(\"/sys/kbd/j\", func(ui.Event) {\n\t\tif err := vol(volCmd, []string{\"up\"}); err != nil {\n\t\t\tquitAndFatal(err)\n\t\t}\n\t})\n\n\tui.Handle(\"/sys/kbd/k\", func(ui.Event) {\n\t\tif err := vol(volCmd, []string{\"down\"}); err != nil {\n\t\t\tquitAndFatal(err)\n\t\t}\n\t})\n\n\tui.Handle(\"/sys/kbd/s\", func(ui.Event) {\n\t\tif err := shuffle(shuffleCmd, []string{}); err != nil {\n\t\t\tquitAndFatal(err)\n\t\t}\n\t})\n\n\tui.Handle(\"/sys/kbd/r\", func(ui.Event) {\n\t\tif err := repeat(repeatCmd, []string{}); err != nil {\n\t\t\tquitAndFatal(err)\n\t\t}\n\t})\n\n\tui.Handle(\"/timer/1s\", func(e ui.Event) {\n\t\tstate, err := client.PlayerState()\n\t\tif err != nil {\n\t\t\tquitAndFatal(err)\n\t\t}\n\n\t\tvolGauge.Percent = state.Device.Volume\n\t\tvolGauge.Label = \"Volume {{percent}}%\"\n\n\t\tshuffleState := \"off\"\n\t\tif state.ShuffleState {\n\t\t\tshuffleState = \"on\"\n\t\t}\n\n\t\tctlList.Items = []string{\n\t\t\t\"Shuffle \" + shuffleState,\n\t\t\t\"Repeat \" + state.RepeatState,\n\t\t}\n\n\t\tif state.Playing {\n\t\t\tprogressGauge.Label = \"Playing\"\n\t\t\tprogressGauge.BarColor = ui.ColorGreen\n\t\t} else {\n\t\t\tprogressGauge.Label = \"Paused\"\n\t\t\tprogressGauge.BarColor = ui.ColorRed\n\t\t}\n\n\t\tif state.Item != nil {\n\t\t\tvar artists []string\n\t\t\tfor _, a := range state.Item.Artists {\n\t\t\t\tartists = append(artists, a.Name)\n\t\t\t}\n\t\t\tsongList.Items = []string{\n\t\t\t\tstate.Item.Name,\n\t\t\t\tfmt.Sprintf(\"%s - %s\", strings.Join(artists, \", \"), state.Item.Album.Name),\n\t\t\t}\n\n\t\t\tcurrPosLabel.Text = durationToStr(state.Progress)\n\t\t\ttotalSecLabel.Text = durationToStr(state.Item.Duration)\n\n\t\t\tprogressGauge.Percent = progressPercent(state.Progress, state.Item.Duration)\n\t\t}\n\n\t\tdraw()\n\t})\n\n\tui.Loop()\n\n\treturn nil\n}\n\nfunc quitAndFatal(err error) {\n\tui.StopLoop()\n\tui.Close()\n\tlog.Fatal(err)\n}\n\nfunc durationToStr(d int) string {\n\tsec := roundToSec(d)\n\tminInt := int(sec / 60)\n\tsecInt := int(sec - float64(minInt*60))\n\treturn fmt.Sprintf(\"%d:%02d\", minInt, secInt)\n}\n\nfunc roundToSec(d int) float64 {\n\tdur := (time.Duration(d) * time.Millisecond).Round(time.Second)\n\treturn dur.Seconds()\n}\n\nfunc progressPercent(progress, total int) int {\n\treturn int(roundToSec(progress) / roundToSec(total) * 100.0)\n}\n"
  },
  {
    "path": "cmd/spotctl/version.go",
    "content": "package main\n\nvar (\n\tversion = \"1.0.1\"\n)\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/.gitignore",
    "content": ".DS_Store\n*.[568ao]\n*.ao\n*.so\n*.pyc\n._*\n.nfs.*\n[568a].out\n*~\n*.orig\ncore\n_obj\n_test\n_testmain.go\nprotoc-gen-go/testdata/multi/*.pb.go\n_conformance/_conformance\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/.travis.yml",
    "content": "sudo: false\nlanguage: go\ngo:\n- 1.6.x\n- 1.7.x\n- 1.8.x\n- 1.9.x\n\ninstall:\n  - go get -v -d -t github.com/golang/protobuf/...\n  - curl -L https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip -o /tmp/protoc.zip\n  - unzip /tmp/protoc.zip -d $HOME/protoc\n\nenv:\n  - PATH=$HOME/protoc/bin:$PATH\n\nscript:\n  - make all test\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/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/github.com/golang/protobuf/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/github.com/golang/protobuf/LICENSE",
    "content": "Go support for Protocol Buffers - Google's data interchange format\n\nCopyright 2010 The Go Authors.  All rights reserved.\nhttps://github.com/golang/protobuf\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\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/Make.protobuf",
    "content": "# Go support for Protocol Buffers - Google's data interchange format\n#\n# Copyright 2010 The Go Authors.  All rights reserved.\n# https://github.com/golang/protobuf\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n# Includable Makefile to add a rule for generating .pb.go files from .proto files\n# (Google protocol buffer descriptions).\n# Typical use if myproto.proto is a file in package mypackage in this directory:\n#\n#\tinclude $(GOROOT)/src/pkg/github.com/golang/protobuf/Make.protobuf\n\n%.pb.go:\t%.proto\n\tprotoc --go_out=. $<\n\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/Makefile",
    "content": "# Go support for Protocol Buffers - Google's data interchange format\n#\n# Copyright 2010 The Go Authors.  All rights reserved.\n# https://github.com/golang/protobuf\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\nall:\tinstall\n\ninstall:\n\tgo install ./proto ./jsonpb ./ptypes\n\tgo install ./protoc-gen-go\n\ntest:\n\tgo test ./proto ./jsonpb ./ptypes\n\tmake -C protoc-gen-go/testdata test\n\nclean:\n\tgo clean ./...\n\nnuke:\n\tgo clean -i ./...\n\nregenerate:\n\tmake -C protoc-gen-go/descriptor regenerate\n\tmake -C protoc-gen-go/plugin regenerate\n\tmake -C protoc-gen-go/testdata regenerate\n\tmake -C proto/testdata regenerate\n\tmake -C jsonpb/jsonpb_test_proto regenerate\n\tmake -C _conformance regenerate\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/README.md",
    "content": "# Go support for Protocol Buffers\n\n[![Build Status](https://travis-ci.org/golang/protobuf.svg?branch=master)](https://travis-ci.org/golang/protobuf)\n[![GoDoc](https://godoc.org/github.com/golang/protobuf?status.svg)](https://godoc.org/github.com/golang/protobuf)\n\nGoogle's data interchange format.\nCopyright 2010 The Go Authors.\nhttps://github.com/golang/protobuf\n\nThis package and the code it generates requires at least Go 1.4.\n\nThis software implements Go bindings for protocol buffers.  For\ninformation about protocol buffers themselves, see\n\thttps://developers.google.com/protocol-buffers/\n\n## Installation ##\n\nTo use this software, you must:\n- Install the standard C++ implementation of protocol buffers from\n\thttps://developers.google.com/protocol-buffers/\n- Of course, install the Go compiler and tools from\n\thttps://golang.org/\n  See\n\thttps://golang.org/doc/install\n  for details or, if you are using gccgo, follow the instructions at\n\thttps://golang.org/doc/install/gccgo\n- Grab the code from the repository and install the proto package.\n  The simplest way is to run `go get -u github.com/golang/protobuf/protoc-gen-go`.\n  The compiler plugin, protoc-gen-go, will be installed in $GOBIN,\n  defaulting to $GOPATH/bin.  It must be in your $PATH for the protocol\n  compiler, protoc, to find it.\n\nThis software has two parts: a 'protocol compiler plugin' that\ngenerates Go source files that, once compiled, can access and manage\nprotocol buffers; and a library that implements run-time support for\nencoding (marshaling), decoding (unmarshaling), and accessing protocol\nbuffers.\n\nThere is support for gRPC in Go using protocol buffers.\nSee the note at the bottom of this file for details.\n\nThere are no insertion points in the plugin.\n\n\n## Using protocol buffers with Go ##\n\nOnce the software is installed, there are two steps to using it.\nFirst you must compile the protocol buffer definitions and then import\nthem, with the support library, into your program.\n\nTo compile the protocol buffer definition, run protoc with the --go_out\nparameter set to the directory you want to output the Go code to.\n\n\tprotoc --go_out=. *.proto\n\nThe generated files will be suffixed .pb.go.  See the Test code below\nfor an example using such a file.\n\n\nThe package comment for the proto library contains text describing\nthe interface provided in Go for protocol buffers. Here is an edited\nversion.\n\n==========\n\nThe proto package converts data structures to and from the\nwire format of protocol buffers.  It works in concert with the\nGo source code generated for .proto files by the protocol compiler.\n\nA summary of the properties of the protocol buffer interface\nfor a protocol buffer variable v:\n\n  - Names are turned from camel_case to CamelCase for export.\n  - There are no methods on v to set fields; just treat\n  \tthem as structure fields.\n  - There are getters that return a field's value if set,\n\tand return the field's default value if unset.\n\tThe getters work even if the receiver is a nil message.\n  - The zero value for a struct is its correct initialization state.\n\tAll desired fields must be set before marshaling.\n  - A Reset() method will restore a protobuf struct to its zero state.\n  - Non-repeated fields are pointers to the values; nil means unset.\n\tThat is, optional or required field int32 f becomes F *int32.\n  - Repeated fields are slices.\n  - Helper functions are available to aid the setting of fields.\n\tHelpers for getting values are superseded by the\n\tGetFoo methods and their use is deprecated.\n\t\tmsg.Foo = proto.String(\"hello\") // set field\n  - Constants are defined to hold the default values of all fields that\n\thave them.  They have the form Default_StructName_FieldName.\n\tBecause the getter methods handle defaulted values,\n\tdirect use of these constants should be rare.\n  - Enums are given type names and maps from names to values.\n\tEnum values are prefixed with the enum's type name. Enum types have\n\ta String method, and a Enum method to assist in message construction.\n  - Nested groups and enums have type names prefixed with the name of\n  \tthe surrounding message type.\n  - Extensions are given descriptor names that start with E_,\n\tfollowed by an underscore-delimited list of the nested messages\n\tthat contain it (if any) followed by the CamelCased name of the\n\textension field itself.  HasExtension, ClearExtension, GetExtension\n\tand SetExtension are functions for manipulating extensions.\n  - Oneof field sets are given a single field in their message,\n\twith distinguished wrapper types for each possible field value.\n  - Marshal and Unmarshal are functions to encode and decode the wire format.\n\nWhen the .proto file specifies `syntax=\"proto3\"`, there are some differences:\n\n  - Non-repeated fields of non-message type are values instead of pointers.\n  - Enum types do not get an Enum method.\n\nConsider file test.proto, containing\n\n```proto\n\tsyntax = \"proto2\";\n\tpackage example;\n\t\n\tenum FOO { X = 17; };\n\t\n\tmessage Test {\n\t  required string label = 1;\n\t  optional int32 type = 2 [default=77];\n\t  repeated int64 reps = 3;\n\t  optional group OptionalGroup = 4 {\n\t    required string RequiredField = 5;\n\t  }\n\t}\n```\n\nTo create and play with a Test object from the example package,\n\n```go\n\tpackage main\n\n\timport (\n\t\t\"log\"\n\n\t\t\"github.com/golang/protobuf/proto\"\n\t\t\"path/to/example\"\n\t)\n\n\tfunc main() {\n\t\ttest := &example.Test {\n\t\t\tLabel: proto.String(\"hello\"),\n\t\t\tType:  proto.Int32(17),\n\t\t\tReps:  []int64{1, 2, 3},\n\t\t\tOptionalgroup: &example.Test_OptionalGroup {\n\t\t\t\tRequiredField: proto.String(\"good bye\"),\n\t\t\t},\n\t\t}\n\t\tdata, err := proto.Marshal(test)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"marshaling error: \", err)\n\t\t}\n\t\tnewTest := &example.Test{}\n\t\terr = proto.Unmarshal(data, newTest)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"unmarshaling error: \", err)\n\t\t}\n\t\t// Now test and newTest contain the same data.\n\t\tif test.GetLabel() != newTest.GetLabel() {\n\t\t\tlog.Fatalf(\"data mismatch %q != %q\", test.GetLabel(), newTest.GetLabel())\n\t\t}\n\t\t// etc.\n\t}\n```\n\n## Parameters ##\n\nTo pass extra parameters to the plugin, use a comma-separated\nparameter list separated from the output directory by a colon:\n\n\n\tprotoc --go_out=plugins=grpc,import_path=mypackage:. *.proto\n\n\n- `import_prefix=xxx` - a prefix that is added onto the beginning of\n  all imports. Useful for things like generating protos in a\n  subdirectory, or regenerating vendored protobufs in-place.\n- `import_path=foo/bar` - used as the package if no input files\n  declare `go_package`. If it contains slashes, everything up to the\n  rightmost slash is ignored.\n- `plugins=plugin1+plugin2` - specifies the list of sub-plugins to\n  load. The only plugin in this repo is `grpc`.\n- `Mfoo/bar.proto=quux/shme` - declares that foo/bar.proto is\n  associated with Go package quux/shme.  This is subject to the\n  import_prefix parameter.\n\n## gRPC Support ##\n\nIf a proto file specifies RPC services, protoc-gen-go can be instructed to\ngenerate code compatible with gRPC (http://www.grpc.io/). To do this, pass\nthe `plugins` parameter to protoc-gen-go; the usual way is to insert it into\nthe --go_out argument to protoc:\n\n\tprotoc --go_out=plugins=grpc:. *.proto\n\n## Compatibility ##\n\nThe library and the generated code are expected to be stable over time.\nHowever, we reserve the right to make breaking changes without notice for the\nfollowing reasons:\n\n- Security. A security issue in the specification or implementation may come to\n  light whose resolution requires breaking compatibility. We reserve the right\n  to address such security issues.\n- Unspecified behavior.  There are some aspects of the Protocol Buffers\n  specification that are undefined.  Programs that depend on such unspecified\n  behavior may break in future releases.\n- Specification errors or changes. If it becomes necessary to address an\n  inconsistency, incompleteness, or change in the Protocol Buffers\n  specification, resolving the issue could affect the meaning or legality of\n  existing programs.  We reserve the right to address such issues, including\n  updating the implementations.\n- Bugs.  If the library has a bug that violates the specification, a program\n  that depends on the buggy behavior may break if the bug is fixed.  We reserve\n  the right to fix such bugs.\n- Adding methods or fields to generated structs.  These may conflict with field\n  names that already exist in a schema, causing applications to break.  When the\n  code generator encounters a field in the schema that would collide with a\n  generated field or method name, the code generator will append an underscore\n  to the generated field or method name.\n- Adding, removing, or changing methods or fields in generated structs that\n  start with `XXX`.  These parts of the generated code are exported out of\n  necessity, but should not be considered part of the public API.\n- Adding, removing, or changing unexported symbols in generated code.\n\nAny breaking changes outside of these will be announced 6 months in advance to\nprotobuf@googlegroups.com.\n\nYou should, whenever possible, use generated code created by the `protoc-gen-go`\ntool built at the same commit as the `proto` package.  The `proto` package\ndeclares package-level constants in the form `ProtoPackageIsVersionX`.\nApplication code and generated code may depend on one of these constants to\nensure that compilation will fail if the available version of the proto library\nis too old.  Whenever we make a change to the generated code that requires newer\nlibrary support, in the same commit we will increment the version number of the\ngenerated code and declare a new package-level constant whose name incorporates\nthe latest version number.  Removing a compatibility constant is considered a\nbreaking change and would be subject to the announcement policy stated above.\n\nThe `protoc-gen-go/generator` package exposes a plugin interface,\nwhich is used by the gRPC code generation. This interface is not\nsupported and is subject to incompatible changes without notice.\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/Makefile",
    "content": "# Go support for Protocol Buffers - Google's data interchange format\n#\n# Copyright 2010 The Go Authors.  All rights reserved.\n# https://github.com/golang/protobuf\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\ninstall:\n\tgo install\n\ntest: install generate-test-pbs\n\tgo test\n\n\ngenerate-test-pbs:\n\tmake install\n\tmake -C testdata\n\tprotoc --go_out=Mtestdata/test.proto=github.com/golang/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any:. proto3_proto/proto3.proto\n\tmake\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/all_test.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2010 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto_test\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"math\"\n\t\"math/rand\"\n\t\"reflect\"\n\t\"runtime/debug\"\n\t\"strings\"\n\t\"testing\"\n\t\"time\"\n\n\t. \"github.com/golang/protobuf/proto\"\n\t. \"github.com/golang/protobuf/proto/testdata\"\n)\n\nvar globalO *Buffer\n\nfunc old() *Buffer {\n\tif globalO == nil {\n\t\tglobalO = NewBuffer(nil)\n\t}\n\tglobalO.Reset()\n\treturn globalO\n}\n\nfunc equalbytes(b1, b2 []byte, t *testing.T) {\n\tif len(b1) != len(b2) {\n\t\tt.Errorf(\"wrong lengths: 2*%d != %d\", len(b1), len(b2))\n\t\treturn\n\t}\n\tfor i := 0; i < len(b1); i++ {\n\t\tif b1[i] != b2[i] {\n\t\t\tt.Errorf(\"bad byte[%d]:%x %x: %s %s\", i, b1[i], b2[i], b1, b2)\n\t\t}\n\t}\n}\n\nfunc initGoTestField() *GoTestField {\n\tf := new(GoTestField)\n\tf.Label = String(\"label\")\n\tf.Type = String(\"type\")\n\treturn f\n}\n\n// These are all structurally equivalent but the tag numbers differ.\n// (It's remarkable that required, optional, and repeated all have\n// 8 letters.)\nfunc initGoTest_RequiredGroup() *GoTest_RequiredGroup {\n\treturn &GoTest_RequiredGroup{\n\t\tRequiredField: String(\"required\"),\n\t}\n}\n\nfunc initGoTest_OptionalGroup() *GoTest_OptionalGroup {\n\treturn &GoTest_OptionalGroup{\n\t\tRequiredField: String(\"optional\"),\n\t}\n}\n\nfunc initGoTest_RepeatedGroup() *GoTest_RepeatedGroup {\n\treturn &GoTest_RepeatedGroup{\n\t\tRequiredField: String(\"repeated\"),\n\t}\n}\n\nfunc initGoTest(setdefaults bool) *GoTest {\n\tpb := new(GoTest)\n\tif setdefaults {\n\t\tpb.F_BoolDefaulted = Bool(Default_GoTest_F_BoolDefaulted)\n\t\tpb.F_Int32Defaulted = Int32(Default_GoTest_F_Int32Defaulted)\n\t\tpb.F_Int64Defaulted = Int64(Default_GoTest_F_Int64Defaulted)\n\t\tpb.F_Fixed32Defaulted = Uint32(Default_GoTest_F_Fixed32Defaulted)\n\t\tpb.F_Fixed64Defaulted = Uint64(Default_GoTest_F_Fixed64Defaulted)\n\t\tpb.F_Uint32Defaulted = Uint32(Default_GoTest_F_Uint32Defaulted)\n\t\tpb.F_Uint64Defaulted = Uint64(Default_GoTest_F_Uint64Defaulted)\n\t\tpb.F_FloatDefaulted = Float32(Default_GoTest_F_FloatDefaulted)\n\t\tpb.F_DoubleDefaulted = Float64(Default_GoTest_F_DoubleDefaulted)\n\t\tpb.F_StringDefaulted = String(Default_GoTest_F_StringDefaulted)\n\t\tpb.F_BytesDefaulted = Default_GoTest_F_BytesDefaulted\n\t\tpb.F_Sint32Defaulted = Int32(Default_GoTest_F_Sint32Defaulted)\n\t\tpb.F_Sint64Defaulted = Int64(Default_GoTest_F_Sint64Defaulted)\n\t}\n\n\tpb.Kind = GoTest_TIME.Enum()\n\tpb.RequiredField = initGoTestField()\n\tpb.F_BoolRequired = Bool(true)\n\tpb.F_Int32Required = Int32(3)\n\tpb.F_Int64Required = Int64(6)\n\tpb.F_Fixed32Required = Uint32(32)\n\tpb.F_Fixed64Required = Uint64(64)\n\tpb.F_Uint32Required = Uint32(3232)\n\tpb.F_Uint64Required = Uint64(6464)\n\tpb.F_FloatRequired = Float32(3232)\n\tpb.F_DoubleRequired = Float64(6464)\n\tpb.F_StringRequired = String(\"string\")\n\tpb.F_BytesRequired = []byte(\"bytes\")\n\tpb.F_Sint32Required = Int32(-32)\n\tpb.F_Sint64Required = Int64(-64)\n\tpb.Requiredgroup = initGoTest_RequiredGroup()\n\n\treturn pb\n}\n\nfunc fail(msg string, b *bytes.Buffer, s string, t *testing.T) {\n\tdata := b.Bytes()\n\tld := len(data)\n\tls := len(s) / 2\n\n\tfmt.Printf(\"fail %s ld=%d ls=%d\\n\", msg, ld, ls)\n\n\t// find the interesting spot - n\n\tn := ls\n\tif ld < ls {\n\t\tn = ld\n\t}\n\tj := 0\n\tfor i := 0; i < n; i++ {\n\t\tbs := hex(s[j])*16 + hex(s[j+1])\n\t\tj += 2\n\t\tif data[i] == bs {\n\t\t\tcontinue\n\t\t}\n\t\tn = i\n\t\tbreak\n\t}\n\tl := n - 10\n\tif l < 0 {\n\t\tl = 0\n\t}\n\th := n + 10\n\n\t// find the interesting spot - n\n\tfmt.Printf(\"is[%d]:\", l)\n\tfor i := l; i < h; i++ {\n\t\tif i >= ld {\n\t\t\tfmt.Printf(\" --\")\n\t\t\tcontinue\n\t\t}\n\t\tfmt.Printf(\" %.2x\", data[i])\n\t}\n\tfmt.Printf(\"\\n\")\n\n\tfmt.Printf(\"sb[%d]:\", l)\n\tfor i := l; i < h; i++ {\n\t\tif i >= ls {\n\t\t\tfmt.Printf(\" --\")\n\t\t\tcontinue\n\t\t}\n\t\tbs := hex(s[j])*16 + hex(s[j+1])\n\t\tj += 2\n\t\tfmt.Printf(\" %.2x\", bs)\n\t}\n\tfmt.Printf(\"\\n\")\n\n\tt.Fail()\n\n\t//\tt.Errorf(\"%s: \\ngood: %s\\nbad: %x\", msg, s, b.Bytes())\n\t// Print the output in a partially-decoded format; can\n\t// be helpful when updating the test.  It produces the output\n\t// that is pasted, with minor edits, into the argument to verify().\n\t//\tdata := b.Bytes()\n\t//\tnesting := 0\n\t//\tfor b.Len() > 0 {\n\t//\t\tstart := len(data) - b.Len()\n\t//\t\tvar u uint64\n\t//\t\tu, err := DecodeVarint(b)\n\t//\t\tif err != nil {\n\t//\t\t\tfmt.Printf(\"decode error on varint:\", err)\n\t//\t\t\treturn\n\t//\t\t}\n\t//\t\twire := u & 0x7\n\t//\t\ttag := u >> 3\n\t//\t\tswitch wire {\n\t//\t\tcase WireVarint:\n\t//\t\t\tv, err := DecodeVarint(b)\n\t//\t\t\tif err != nil {\n\t//\t\t\t\tfmt.Printf(\"decode error on varint:\", err)\n\t//\t\t\t\treturn\n\t//\t\t\t}\n\t//\t\t\tfmt.Printf(\"\\t\\t\\\"%x\\\"  // field %d, encoding %d, value %d\\n\",\n\t//\t\t\t\tdata[start:len(data)-b.Len()], tag, wire, v)\n\t//\t\tcase WireFixed32:\n\t//\t\t\tv, err := DecodeFixed32(b)\n\t//\t\t\tif err != nil {\n\t//\t\t\t\tfmt.Printf(\"decode error on fixed32:\", err)\n\t//\t\t\t\treturn\n\t//\t\t\t}\n\t//\t\t\tfmt.Printf(\"\\t\\t\\\"%x\\\"  // field %d, encoding %d, value %d\\n\",\n\t//\t\t\t\tdata[start:len(data)-b.Len()], tag, wire, v)\n\t//\t\tcase WireFixed64:\n\t//\t\t\tv, err := DecodeFixed64(b)\n\t//\t\t\tif err != nil {\n\t//\t\t\t\tfmt.Printf(\"decode error on fixed64:\", err)\n\t//\t\t\t\treturn\n\t//\t\t\t}\n\t//\t\t\tfmt.Printf(\"\\t\\t\\\"%x\\\"  // field %d, encoding %d, value %d\\n\",\n\t//\t\t\t\tdata[start:len(data)-b.Len()], tag, wire, v)\n\t//\t\tcase WireBytes:\n\t//\t\t\tnb, err := DecodeVarint(b)\n\t//\t\t\tif err != nil {\n\t//\t\t\t\tfmt.Printf(\"decode error on bytes:\", err)\n\t//\t\t\t\treturn\n\t//\t\t\t}\n\t//\t\t\tafter_tag := len(data) - b.Len()\n\t//\t\t\tstr := make([]byte, nb)\n\t//\t\t\t_, err = b.Read(str)\n\t//\t\t\tif err != nil {\n\t//\t\t\t\tfmt.Printf(\"decode error on bytes:\", err)\n\t//\t\t\t\treturn\n\t//\t\t\t}\n\t//\t\t\tfmt.Printf(\"\\t\\t\\\"%x\\\" \\\"%x\\\"  // field %d, encoding %d (FIELD)\\n\",\n\t//\t\t\t\tdata[start:after_tag], str, tag, wire)\n\t//\t\tcase WireStartGroup:\n\t//\t\t\tnesting++\n\t//\t\t\tfmt.Printf(\"\\t\\t\\\"%x\\\"\\t\\t// start group field %d level %d\\n\",\n\t//\t\t\t\tdata[start:len(data)-b.Len()], tag, nesting)\n\t//\t\tcase WireEndGroup:\n\t//\t\t\tfmt.Printf(\"\\t\\t\\\"%x\\\"\\t\\t// end group field %d level %d\\n\",\n\t//\t\t\t\tdata[start:len(data)-b.Len()], tag, nesting)\n\t//\t\t\tnesting--\n\t//\t\tdefault:\n\t//\t\t\tfmt.Printf(\"unrecognized wire type %d\\n\", wire)\n\t//\t\t\treturn\n\t//\t\t}\n\t//\t}\n}\n\nfunc hex(c uint8) uint8 {\n\tif '0' <= c && c <= '9' {\n\t\treturn c - '0'\n\t}\n\tif 'a' <= c && c <= 'f' {\n\t\treturn 10 + c - 'a'\n\t}\n\tif 'A' <= c && c <= 'F' {\n\t\treturn 10 + c - 'A'\n\t}\n\treturn 0\n}\n\nfunc equal(b []byte, s string, t *testing.T) bool {\n\tif 2*len(b) != len(s) {\n\t\t//\t\tfail(fmt.Sprintf(\"wrong lengths: 2*%d != %d\", len(b), len(s)), b, s, t)\n\t\tfmt.Printf(\"wrong lengths: 2*%d != %d\\n\", len(b), len(s))\n\t\treturn false\n\t}\n\tfor i, j := 0, 0; i < len(b); i, j = i+1, j+2 {\n\t\tx := hex(s[j])*16 + hex(s[j+1])\n\t\tif b[i] != x {\n\t\t\t//\t\t\tfail(fmt.Sprintf(\"bad byte[%d]:%x %x\", i, b[i], x), b, s, t)\n\t\t\tfmt.Printf(\"bad byte[%d]:%x %x\", i, b[i], x)\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc overify(t *testing.T, pb *GoTest, expected string) {\n\to := old()\n\terr := o.Marshal(pb)\n\tif err != nil {\n\t\tfmt.Printf(\"overify marshal-1 err = %v\", err)\n\t\to.DebugPrint(\"\", o.Bytes())\n\t\tt.Fatalf(\"expected = %s\", expected)\n\t}\n\tif !equal(o.Bytes(), expected, t) {\n\t\to.DebugPrint(\"overify neq 1\", o.Bytes())\n\t\tt.Fatalf(\"expected = %s\", expected)\n\t}\n\n\t// Now test Unmarshal by recreating the original buffer.\n\tpbd := new(GoTest)\n\terr = o.Unmarshal(pbd)\n\tif err != nil {\n\t\tt.Fatalf(\"overify unmarshal err = %v\", err)\n\t\to.DebugPrint(\"\", o.Bytes())\n\t\tt.Fatalf(\"string = %s\", expected)\n\t}\n\to.Reset()\n\terr = o.Marshal(pbd)\n\tif err != nil {\n\t\tt.Errorf(\"overify marshal-2 err = %v\", err)\n\t\to.DebugPrint(\"\", o.Bytes())\n\t\tt.Fatalf(\"string = %s\", expected)\n\t}\n\tif !equal(o.Bytes(), expected, t) {\n\t\to.DebugPrint(\"overify neq 2\", o.Bytes())\n\t\tt.Fatalf(\"string = %s\", expected)\n\t}\n}\n\n// Simple tests for numeric encode/decode primitives (varint, etc.)\nfunc TestNumericPrimitives(t *testing.T) {\n\tfor i := uint64(0); i < 1e6; i += 111 {\n\t\to := old()\n\t\tif o.EncodeVarint(i) != nil {\n\t\t\tt.Error(\"EncodeVarint\")\n\t\t\tbreak\n\t\t}\n\t\tx, e := o.DecodeVarint()\n\t\tif e != nil {\n\t\t\tt.Fatal(\"DecodeVarint\")\n\t\t}\n\t\tif x != i {\n\t\t\tt.Fatal(\"varint decode fail:\", i, x)\n\t\t}\n\n\t\to = old()\n\t\tif o.EncodeFixed32(i) != nil {\n\t\t\tt.Fatal(\"encFixed32\")\n\t\t}\n\t\tx, e = o.DecodeFixed32()\n\t\tif e != nil {\n\t\t\tt.Fatal(\"decFixed32\")\n\t\t}\n\t\tif x != i {\n\t\t\tt.Fatal(\"fixed32 decode fail:\", i, x)\n\t\t}\n\n\t\to = old()\n\t\tif o.EncodeFixed64(i*1234567) != nil {\n\t\t\tt.Error(\"encFixed64\")\n\t\t\tbreak\n\t\t}\n\t\tx, e = o.DecodeFixed64()\n\t\tif e != nil {\n\t\t\tt.Error(\"decFixed64\")\n\t\t\tbreak\n\t\t}\n\t\tif x != i*1234567 {\n\t\t\tt.Error(\"fixed64 decode fail:\", i*1234567, x)\n\t\t\tbreak\n\t\t}\n\n\t\to = old()\n\t\ti32 := int32(i - 12345)\n\t\tif o.EncodeZigzag32(uint64(i32)) != nil {\n\t\t\tt.Fatal(\"EncodeZigzag32\")\n\t\t}\n\t\tx, e = o.DecodeZigzag32()\n\t\tif e != nil {\n\t\t\tt.Fatal(\"DecodeZigzag32\")\n\t\t}\n\t\tif x != uint64(uint32(i32)) {\n\t\t\tt.Fatal(\"zigzag32 decode fail:\", i32, x)\n\t\t}\n\n\t\to = old()\n\t\ti64 := int64(i - 12345)\n\t\tif o.EncodeZigzag64(uint64(i64)) != nil {\n\t\t\tt.Fatal(\"EncodeZigzag64\")\n\t\t}\n\t\tx, e = o.DecodeZigzag64()\n\t\tif e != nil {\n\t\t\tt.Fatal(\"DecodeZigzag64\")\n\t\t}\n\t\tif x != uint64(i64) {\n\t\t\tt.Fatal(\"zigzag64 decode fail:\", i64, x)\n\t\t}\n\t}\n}\n\n// fakeMarshaler is a simple struct implementing Marshaler and Message interfaces.\ntype fakeMarshaler struct {\n\tb   []byte\n\terr error\n}\n\nfunc (f *fakeMarshaler) Marshal() ([]byte, error) { return f.b, f.err }\nfunc (f *fakeMarshaler) String() string           { return fmt.Sprintf(\"Bytes: %v Error: %v\", f.b, f.err) }\nfunc (f *fakeMarshaler) ProtoMessage()            {}\nfunc (f *fakeMarshaler) Reset()                   {}\n\ntype msgWithFakeMarshaler struct {\n\tM *fakeMarshaler `protobuf:\"bytes,1,opt,name=fake\"`\n}\n\nfunc (m *msgWithFakeMarshaler) String() string { return CompactTextString(m) }\nfunc (m *msgWithFakeMarshaler) ProtoMessage()  {}\nfunc (m *msgWithFakeMarshaler) Reset()         {}\n\n// Simple tests for proto messages that implement the Marshaler interface.\nfunc TestMarshalerEncoding(t *testing.T) {\n\ttests := []struct {\n\t\tname    string\n\t\tm       Message\n\t\twant    []byte\n\t\terrType reflect.Type\n\t}{\n\t\t{\n\t\t\tname: \"Marshaler that fails\",\n\t\t\tm: &fakeMarshaler{\n\t\t\t\terr: errors.New(\"some marshal err\"),\n\t\t\t\tb:   []byte{5, 6, 7},\n\t\t\t},\n\t\t\t// Since the Marshal method returned bytes, they should be written to the\n\t\t\t// buffer.  (For efficiency, we assume that Marshal implementations are\n\t\t\t// always correct w.r.t. RequiredNotSetError and output.)\n\t\t\twant:    []byte{5, 6, 7},\n\t\t\terrType: reflect.TypeOf(errors.New(\"some marshal err\")),\n\t\t},\n\t\t{\n\t\t\tname: \"Marshaler that fails with RequiredNotSetError\",\n\t\t\tm: &msgWithFakeMarshaler{\n\t\t\t\tM: &fakeMarshaler{\n\t\t\t\t\terr: &RequiredNotSetError{},\n\t\t\t\t\tb:   []byte{5, 6, 7},\n\t\t\t\t},\n\t\t\t},\n\t\t\t// Since there's an error that can be continued after,\n\t\t\t// the buffer should be written.\n\t\t\twant: []byte{\n\t\t\t\t10, 3, // for &msgWithFakeMarshaler\n\t\t\t\t5, 6, 7, // for &fakeMarshaler\n\t\t\t},\n\t\t\terrType: reflect.TypeOf(&RequiredNotSetError{}),\n\t\t},\n\t\t{\n\t\t\tname: \"Marshaler that succeeds\",\n\t\t\tm: &fakeMarshaler{\n\t\t\t\tb: []byte{0, 1, 2, 3, 4, 127, 255},\n\t\t\t},\n\t\t\twant: []byte{0, 1, 2, 3, 4, 127, 255},\n\t\t},\n\t}\n\tfor _, test := range tests {\n\t\tb := NewBuffer(nil)\n\t\terr := b.Marshal(test.m)\n\t\tif reflect.TypeOf(err) != test.errType {\n\t\t\tt.Errorf(\"%s: got err %T(%v) wanted %T\", test.name, err, err, test.errType)\n\t\t}\n\t\tif !reflect.DeepEqual(test.want, b.Bytes()) {\n\t\t\tt.Errorf(\"%s: got bytes %v wanted %v\", test.name, b.Bytes(), test.want)\n\t\t}\n\t\tif size := Size(test.m); size != len(b.Bytes()) {\n\t\t\tt.Errorf(\"%s: Size(_) = %v, but marshaled to %v bytes\", test.name, size, len(b.Bytes()))\n\t\t}\n\n\t\tm, mErr := Marshal(test.m)\n\t\tif !bytes.Equal(b.Bytes(), m) {\n\t\t\tt.Errorf(\"%s: Marshal returned %v, but (*Buffer).Marshal wrote %v\", test.name, m, b.Bytes())\n\t\t}\n\t\tif !reflect.DeepEqual(err, mErr) {\n\t\t\tt.Errorf(\"%s: Marshal err = %q, but (*Buffer).Marshal returned %q\",\n\t\t\t\ttest.name, fmt.Sprint(mErr), fmt.Sprint(err))\n\t\t}\n\t}\n}\n\n// Simple tests for bytes\nfunc TestBytesPrimitives(t *testing.T) {\n\to := old()\n\tbytes := []byte{'n', 'o', 'w', ' ', 'i', 's', ' ', 't', 'h', 'e', ' ', 't', 'i', 'm', 'e'}\n\tif o.EncodeRawBytes(bytes) != nil {\n\t\tt.Error(\"EncodeRawBytes\")\n\t}\n\tdecb, e := o.DecodeRawBytes(false)\n\tif e != nil {\n\t\tt.Error(\"DecodeRawBytes\")\n\t}\n\tequalbytes(bytes, decb, t)\n}\n\n// Simple tests for strings\nfunc TestStringPrimitives(t *testing.T) {\n\to := old()\n\ts := \"now is the time\"\n\tif o.EncodeStringBytes(s) != nil {\n\t\tt.Error(\"enc_string\")\n\t}\n\tdecs, e := o.DecodeStringBytes()\n\tif e != nil {\n\t\tt.Error(\"dec_string\")\n\t}\n\tif s != decs {\n\t\tt.Error(\"string encode/decode fail:\", s, decs)\n\t}\n}\n\n// Do we catch the \"required bit not set\" case?\nfunc TestRequiredBit(t *testing.T) {\n\to := old()\n\tpb := new(GoTest)\n\terr := o.Marshal(pb)\n\tif err == nil {\n\t\tt.Error(\"did not catch missing required fields\")\n\t} else if strings.Index(err.Error(), \"Kind\") < 0 {\n\t\tt.Error(\"wrong error type:\", err)\n\t}\n}\n\n// Check that all fields are nil.\n// Clearly silly, and a residue from a more interesting test with an earlier,\n// different initialization property, but it once caught a compiler bug so\n// it lives.\nfunc checkInitialized(pb *GoTest, t *testing.T) {\n\tif pb.F_BoolDefaulted != nil {\n\t\tt.Error(\"New or Reset did not set boolean:\", *pb.F_BoolDefaulted)\n\t}\n\tif pb.F_Int32Defaulted != nil {\n\t\tt.Error(\"New or Reset did not set int32:\", *pb.F_Int32Defaulted)\n\t}\n\tif pb.F_Int64Defaulted != nil {\n\t\tt.Error(\"New or Reset did not set int64:\", *pb.F_Int64Defaulted)\n\t}\n\tif pb.F_Fixed32Defaulted != nil {\n\t\tt.Error(\"New or Reset did not set fixed32:\", *pb.F_Fixed32Defaulted)\n\t}\n\tif pb.F_Fixed64Defaulted != nil {\n\t\tt.Error(\"New or Reset did not set fixed64:\", *pb.F_Fixed64Defaulted)\n\t}\n\tif pb.F_Uint32Defaulted != nil {\n\t\tt.Error(\"New or Reset did not set uint32:\", *pb.F_Uint32Defaulted)\n\t}\n\tif pb.F_Uint64Defaulted != nil {\n\t\tt.Error(\"New or Reset did not set uint64:\", *pb.F_Uint64Defaulted)\n\t}\n\tif pb.F_FloatDefaulted != nil {\n\t\tt.Error(\"New or Reset did not set float:\", *pb.F_FloatDefaulted)\n\t}\n\tif pb.F_DoubleDefaulted != nil {\n\t\tt.Error(\"New or Reset did not set double:\", *pb.F_DoubleDefaulted)\n\t}\n\tif pb.F_StringDefaulted != nil {\n\t\tt.Error(\"New or Reset did not set string:\", *pb.F_StringDefaulted)\n\t}\n\tif pb.F_BytesDefaulted != nil {\n\t\tt.Error(\"New or Reset did not set bytes:\", string(pb.F_BytesDefaulted))\n\t}\n\tif pb.F_Sint32Defaulted != nil {\n\t\tt.Error(\"New or Reset did not set int32:\", *pb.F_Sint32Defaulted)\n\t}\n\tif pb.F_Sint64Defaulted != nil {\n\t\tt.Error(\"New or Reset did not set int64:\", *pb.F_Sint64Defaulted)\n\t}\n}\n\n// Does Reset() reset?\nfunc TestReset(t *testing.T) {\n\tpb := initGoTest(true)\n\t// muck with some values\n\tpb.F_BoolDefaulted = Bool(false)\n\tpb.F_Int32Defaulted = Int32(237)\n\tpb.F_Int64Defaulted = Int64(12346)\n\tpb.F_Fixed32Defaulted = Uint32(32000)\n\tpb.F_Fixed64Defaulted = Uint64(666)\n\tpb.F_Uint32Defaulted = Uint32(323232)\n\tpb.F_Uint64Defaulted = nil\n\tpb.F_FloatDefaulted = nil\n\tpb.F_DoubleDefaulted = Float64(0)\n\tpb.F_StringDefaulted = String(\"gotcha\")\n\tpb.F_BytesDefaulted = []byte(\"asdfasdf\")\n\tpb.F_Sint32Defaulted = Int32(123)\n\tpb.F_Sint64Defaulted = Int64(789)\n\tpb.Reset()\n\tcheckInitialized(pb, t)\n}\n\n// All required fields set, no defaults provided.\nfunc TestEncodeDecode1(t *testing.T) {\n\tpb := initGoTest(false)\n\toverify(t, pb,\n\t\t\"0807\"+ // field 1, encoding 0, value 7\n\t\t\t\"220d\"+\"0a056c6162656c120474797065\"+ // field 4, encoding 2 (GoTestField)\n\t\t\t\"5001\"+ // field 10, encoding 0, value 1\n\t\t\t\"5803\"+ // field 11, encoding 0, value 3\n\t\t\t\"6006\"+ // field 12, encoding 0, value 6\n\t\t\t\"6d20000000\"+ // field 13, encoding 5, value 0x20\n\t\t\t\"714000000000000000\"+ // field 14, encoding 1, value 0x40\n\t\t\t\"78a019\"+ // field 15, encoding 0, value 0xca0 = 3232\n\t\t\t\"8001c032\"+ // field 16, encoding 0, value 0x1940 = 6464\n\t\t\t\"8d0100004a45\"+ // field 17, encoding 5, value 3232.0\n\t\t\t\"9101000000000040b940\"+ // field 18, encoding 1, value 6464.0\n\t\t\t\"9a0106\"+\"737472696e67\"+ // field 19, encoding 2, string \"string\"\n\t\t\t\"b304\"+ // field 70, encoding 3, start group\n\t\t\t\"ba0408\"+\"7265717569726564\"+ // field 71, encoding 2, string \"required\"\n\t\t\t\"b404\"+ // field 70, encoding 4, end group\n\t\t\t\"aa0605\"+\"6279746573\"+ // field 101, encoding 2, string \"bytes\"\n\t\t\t\"b0063f\"+ // field 102, encoding 0, 0x3f zigzag32\n\t\t\t\"b8067f\") // field 103, encoding 0, 0x7f zigzag64\n}\n\n// All required fields set, defaults provided.\nfunc TestEncodeDecode2(t *testing.T) {\n\tpb := initGoTest(true)\n\toverify(t, pb,\n\t\t\"0807\"+ // field 1, encoding 0, value 7\n\t\t\t\"220d\"+\"0a056c6162656c120474797065\"+ // field 4, encoding 2 (GoTestField)\n\t\t\t\"5001\"+ // field 10, encoding 0, value 1\n\t\t\t\"5803\"+ // field 11, encoding 0, value 3\n\t\t\t\"6006\"+ // field 12, encoding 0, value 6\n\t\t\t\"6d20000000\"+ // field 13, encoding 5, value 32\n\t\t\t\"714000000000000000\"+ // field 14, encoding 1, value 64\n\t\t\t\"78a019\"+ // field 15, encoding 0, value 3232\n\t\t\t\"8001c032\"+ // field 16, encoding 0, value 6464\n\t\t\t\"8d0100004a45\"+ // field 17, encoding 5, value 3232.0\n\t\t\t\"9101000000000040b940\"+ // field 18, encoding 1, value 6464.0\n\t\t\t\"9a0106\"+\"737472696e67\"+ // field 19, encoding 2 string \"string\"\n\t\t\t\"c00201\"+ // field 40, encoding 0, value 1\n\t\t\t\"c80220\"+ // field 41, encoding 0, value 32\n\t\t\t\"d00240\"+ // field 42, encoding 0, value 64\n\t\t\t\"dd0240010000\"+ // field 43, encoding 5, value 320\n\t\t\t\"e1028002000000000000\"+ // field 44, encoding 1, value 640\n\t\t\t\"e8028019\"+ // field 45, encoding 0, value 3200\n\t\t\t\"f0028032\"+ // field 46, encoding 0, value 6400\n\t\t\t\"fd02e0659948\"+ // field 47, encoding 5, value 314159.0\n\t\t\t\"81030000000050971041\"+ // field 48, encoding 1, value 271828.0\n\t\t\t\"8a0310\"+\"68656c6c6f2c2022776f726c6421220a\"+ // field 49, encoding 2 string \"hello, \\\"world!\\\"\\n\"\n\t\t\t\"b304\"+ // start group field 70 level 1\n\t\t\t\"ba0408\"+\"7265717569726564\"+ // field 71, encoding 2, string \"required\"\n\t\t\t\"b404\"+ // end group field 70 level 1\n\t\t\t\"aa0605\"+\"6279746573\"+ // field 101, encoding 2 string \"bytes\"\n\t\t\t\"b0063f\"+ // field 102, encoding 0, 0x3f zigzag32\n\t\t\t\"b8067f\"+ // field 103, encoding 0, 0x7f zigzag64\n\t\t\t\"8a1907\"+\"4269676e6f7365\"+ // field 401, encoding 2, string \"Bignose\"\n\t\t\t\"90193f\"+ // field 402, encoding 0, value 63\n\t\t\t\"98197f\") // field 403, encoding 0, value 127\n\n}\n\n// All default fields set to their default value by hand\nfunc TestEncodeDecode3(t *testing.T) {\n\tpb := initGoTest(false)\n\tpb.F_BoolDefaulted = Bool(true)\n\tpb.F_Int32Defaulted = Int32(32)\n\tpb.F_Int64Defaulted = Int64(64)\n\tpb.F_Fixed32Defaulted = Uint32(320)\n\tpb.F_Fixed64Defaulted = Uint64(640)\n\tpb.F_Uint32Defaulted = Uint32(3200)\n\tpb.F_Uint64Defaulted = Uint64(6400)\n\tpb.F_FloatDefaulted = Float32(314159)\n\tpb.F_DoubleDefaulted = Float64(271828)\n\tpb.F_StringDefaulted = String(\"hello, \\\"world!\\\"\\n\")\n\tpb.F_BytesDefaulted = []byte(\"Bignose\")\n\tpb.F_Sint32Defaulted = Int32(-32)\n\tpb.F_Sint64Defaulted = Int64(-64)\n\n\toverify(t, pb,\n\t\t\"0807\"+ // field 1, encoding 0, value 7\n\t\t\t\"220d\"+\"0a056c6162656c120474797065\"+ // field 4, encoding 2 (GoTestField)\n\t\t\t\"5001\"+ // field 10, encoding 0, value 1\n\t\t\t\"5803\"+ // field 11, encoding 0, value 3\n\t\t\t\"6006\"+ // field 12, encoding 0, value 6\n\t\t\t\"6d20000000\"+ // field 13, encoding 5, value 32\n\t\t\t\"714000000000000000\"+ // field 14, encoding 1, value 64\n\t\t\t\"78a019\"+ // field 15, encoding 0, value 3232\n\t\t\t\"8001c032\"+ // field 16, encoding 0, value 6464\n\t\t\t\"8d0100004a45\"+ // field 17, encoding 5, value 3232.0\n\t\t\t\"9101000000000040b940\"+ // field 18, encoding 1, value 6464.0\n\t\t\t\"9a0106\"+\"737472696e67\"+ // field 19, encoding 2 string \"string\"\n\t\t\t\"c00201\"+ // field 40, encoding 0, value 1\n\t\t\t\"c80220\"+ // field 41, encoding 0, value 32\n\t\t\t\"d00240\"+ // field 42, encoding 0, value 64\n\t\t\t\"dd0240010000\"+ // field 43, encoding 5, value 320\n\t\t\t\"e1028002000000000000\"+ // field 44, encoding 1, value 640\n\t\t\t\"e8028019\"+ // field 45, encoding 0, value 3200\n\t\t\t\"f0028032\"+ // field 46, encoding 0, value 6400\n\t\t\t\"fd02e0659948\"+ // field 47, encoding 5, value 314159.0\n\t\t\t\"81030000000050971041\"+ // field 48, encoding 1, value 271828.0\n\t\t\t\"8a0310\"+\"68656c6c6f2c2022776f726c6421220a\"+ // field 49, encoding 2 string \"hello, \\\"world!\\\"\\n\"\n\t\t\t\"b304\"+ // start group field 70 level 1\n\t\t\t\"ba0408\"+\"7265717569726564\"+ // field 71, encoding 2, string \"required\"\n\t\t\t\"b404\"+ // end group field 70 level 1\n\t\t\t\"aa0605\"+\"6279746573\"+ // field 101, encoding 2 string \"bytes\"\n\t\t\t\"b0063f\"+ // field 102, encoding 0, 0x3f zigzag32\n\t\t\t\"b8067f\"+ // field 103, encoding 0, 0x7f zigzag64\n\t\t\t\"8a1907\"+\"4269676e6f7365\"+ // field 401, encoding 2, string \"Bignose\"\n\t\t\t\"90193f\"+ // field 402, encoding 0, value 63\n\t\t\t\"98197f\") // field 403, encoding 0, value 127\n\n}\n\n// All required fields set, defaults provided, all non-defaulted optional fields have values.\nfunc TestEncodeDecode4(t *testing.T) {\n\tpb := initGoTest(true)\n\tpb.Table = String(\"hello\")\n\tpb.Param = Int32(7)\n\tpb.OptionalField = initGoTestField()\n\tpb.F_BoolOptional = Bool(true)\n\tpb.F_Int32Optional = Int32(32)\n\tpb.F_Int64Optional = Int64(64)\n\tpb.F_Fixed32Optional = Uint32(3232)\n\tpb.F_Fixed64Optional = Uint64(6464)\n\tpb.F_Uint32Optional = Uint32(323232)\n\tpb.F_Uint64Optional = Uint64(646464)\n\tpb.F_FloatOptional = Float32(32.)\n\tpb.F_DoubleOptional = Float64(64.)\n\tpb.F_StringOptional = String(\"hello\")\n\tpb.F_BytesOptional = []byte(\"Bignose\")\n\tpb.F_Sint32Optional = Int32(-32)\n\tpb.F_Sint64Optional = Int64(-64)\n\tpb.Optionalgroup = initGoTest_OptionalGroup()\n\n\toverify(t, pb,\n\t\t\"0807\"+ // field 1, encoding 0, value 7\n\t\t\t\"1205\"+\"68656c6c6f\"+ // field 2, encoding 2, string \"hello\"\n\t\t\t\"1807\"+ // field 3, encoding 0, value 7\n\t\t\t\"220d\"+\"0a056c6162656c120474797065\"+ // field 4, encoding 2 (GoTestField)\n\t\t\t\"320d\"+\"0a056c6162656c120474797065\"+ // field 6, encoding 2 (GoTestField)\n\t\t\t\"5001\"+ // field 10, encoding 0, value 1\n\t\t\t\"5803\"+ // field 11, encoding 0, value 3\n\t\t\t\"6006\"+ // field 12, encoding 0, value 6\n\t\t\t\"6d20000000\"+ // field 13, encoding 5, value 32\n\t\t\t\"714000000000000000\"+ // field 14, encoding 1, value 64\n\t\t\t\"78a019\"+ // field 15, encoding 0, value 3232\n\t\t\t\"8001c032\"+ // field 16, encoding 0, value 6464\n\t\t\t\"8d0100004a45\"+ // field 17, encoding 5, value 3232.0\n\t\t\t\"9101000000000040b940\"+ // field 18, encoding 1, value 6464.0\n\t\t\t\"9a0106\"+\"737472696e67\"+ // field 19, encoding 2 string \"string\"\n\t\t\t\"f00101\"+ // field 30, encoding 0, value 1\n\t\t\t\"f80120\"+ // field 31, encoding 0, value 32\n\t\t\t\"800240\"+ // field 32, encoding 0, value 64\n\t\t\t\"8d02a00c0000\"+ // field 33, encoding 5, value 3232\n\t\t\t\"91024019000000000000\"+ // field 34, encoding 1, value 6464\n\t\t\t\"9802a0dd13\"+ // field 35, encoding 0, value 323232\n\t\t\t\"a002c0ba27\"+ // field 36, encoding 0, value 646464\n\t\t\t\"ad0200000042\"+ // field 37, encoding 5, value 32.0\n\t\t\t\"b1020000000000005040\"+ // field 38, encoding 1, value 64.0\n\t\t\t\"ba0205\"+\"68656c6c6f\"+ // field 39, encoding 2, string \"hello\"\n\t\t\t\"c00201\"+ // field 40, encoding 0, value 1\n\t\t\t\"c80220\"+ // field 41, encoding 0, value 32\n\t\t\t\"d00240\"+ // field 42, encoding 0, value 64\n\t\t\t\"dd0240010000\"+ // field 43, encoding 5, value 320\n\t\t\t\"e1028002000000000000\"+ // field 44, encoding 1, value 640\n\t\t\t\"e8028019\"+ // field 45, encoding 0, value 3200\n\t\t\t\"f0028032\"+ // field 46, encoding 0, value 6400\n\t\t\t\"fd02e0659948\"+ // field 47, encoding 5, value 314159.0\n\t\t\t\"81030000000050971041\"+ // field 48, encoding 1, value 271828.0\n\t\t\t\"8a0310\"+\"68656c6c6f2c2022776f726c6421220a\"+ // field 49, encoding 2 string \"hello, \\\"world!\\\"\\n\"\n\t\t\t\"b304\"+ // start group field 70 level 1\n\t\t\t\"ba0408\"+\"7265717569726564\"+ // field 71, encoding 2, string \"required\"\n\t\t\t\"b404\"+ // end group field 70 level 1\n\t\t\t\"d305\"+ // start group field 90 level 1\n\t\t\t\"da0508\"+\"6f7074696f6e616c\"+ // field 91, encoding 2, string \"optional\"\n\t\t\t\"d405\"+ // end group field 90 level 1\n\t\t\t\"aa0605\"+\"6279746573\"+ // field 101, encoding 2 string \"bytes\"\n\t\t\t\"b0063f\"+ // field 102, encoding 0, 0x3f zigzag32\n\t\t\t\"b8067f\"+ // field 103, encoding 0, 0x7f zigzag64\n\t\t\t\"ea1207\"+\"4269676e6f7365\"+ // field 301, encoding 2, string \"Bignose\"\n\t\t\t\"f0123f\"+ // field 302, encoding 0, value 63\n\t\t\t\"f8127f\"+ // field 303, encoding 0, value 127\n\t\t\t\"8a1907\"+\"4269676e6f7365\"+ // field 401, encoding 2, string \"Bignose\"\n\t\t\t\"90193f\"+ // field 402, encoding 0, value 63\n\t\t\t\"98197f\") // field 403, encoding 0, value 127\n\n}\n\n// All required fields set, defaults provided, all repeated fields given two values.\nfunc TestEncodeDecode5(t *testing.T) {\n\tpb := initGoTest(true)\n\tpb.RepeatedField = []*GoTestField{initGoTestField(), initGoTestField()}\n\tpb.F_BoolRepeated = []bool{false, true}\n\tpb.F_Int32Repeated = []int32{32, 33}\n\tpb.F_Int64Repeated = []int64{64, 65}\n\tpb.F_Fixed32Repeated = []uint32{3232, 3333}\n\tpb.F_Fixed64Repeated = []uint64{6464, 6565}\n\tpb.F_Uint32Repeated = []uint32{323232, 333333}\n\tpb.F_Uint64Repeated = []uint64{646464, 656565}\n\tpb.F_FloatRepeated = []float32{32., 33.}\n\tpb.F_DoubleRepeated = []float64{64., 65.}\n\tpb.F_StringRepeated = []string{\"hello\", \"sailor\"}\n\tpb.F_BytesRepeated = [][]byte{[]byte(\"big\"), []byte(\"nose\")}\n\tpb.F_Sint32Repeated = []int32{32, -32}\n\tpb.F_Sint64Repeated = []int64{64, -64}\n\tpb.Repeatedgroup = []*GoTest_RepeatedGroup{initGoTest_RepeatedGroup(), initGoTest_RepeatedGroup()}\n\n\toverify(t, pb,\n\t\t\"0807\"+ // field 1, encoding 0, value 7\n\t\t\t\"220d\"+\"0a056c6162656c120474797065\"+ // field 4, encoding 2 (GoTestField)\n\t\t\t\"2a0d\"+\"0a056c6162656c120474797065\"+ // field 5, encoding 2 (GoTestField)\n\t\t\t\"2a0d\"+\"0a056c6162656c120474797065\"+ // field 5, encoding 2 (GoTestField)\n\t\t\t\"5001\"+ // field 10, encoding 0, value 1\n\t\t\t\"5803\"+ // field 11, encoding 0, value 3\n\t\t\t\"6006\"+ // field 12, encoding 0, value 6\n\t\t\t\"6d20000000\"+ // field 13, encoding 5, value 32\n\t\t\t\"714000000000000000\"+ // field 14, encoding 1, value 64\n\t\t\t\"78a019\"+ // field 15, encoding 0, value 3232\n\t\t\t\"8001c032\"+ // field 16, encoding 0, value 6464\n\t\t\t\"8d0100004a45\"+ // field 17, encoding 5, value 3232.0\n\t\t\t\"9101000000000040b940\"+ // field 18, encoding 1, value 6464.0\n\t\t\t\"9a0106\"+\"737472696e67\"+ // field 19, encoding 2 string \"string\"\n\t\t\t\"a00100\"+ // field 20, encoding 0, value 0\n\t\t\t\"a00101\"+ // field 20, encoding 0, value 1\n\t\t\t\"a80120\"+ // field 21, encoding 0, value 32\n\t\t\t\"a80121\"+ // field 21, encoding 0, value 33\n\t\t\t\"b00140\"+ // field 22, encoding 0, value 64\n\t\t\t\"b00141\"+ // field 22, encoding 0, value 65\n\t\t\t\"bd01a00c0000\"+ // field 23, encoding 5, value 3232\n\t\t\t\"bd01050d0000\"+ // field 23, encoding 5, value 3333\n\t\t\t\"c1014019000000000000\"+ // field 24, encoding 1, value 6464\n\t\t\t\"c101a519000000000000\"+ // field 24, encoding 1, value 6565\n\t\t\t\"c801a0dd13\"+ // field 25, encoding 0, value 323232\n\t\t\t\"c80195ac14\"+ // field 25, encoding 0, value 333333\n\t\t\t\"d001c0ba27\"+ // field 26, encoding 0, value 646464\n\t\t\t\"d001b58928\"+ // field 26, encoding 0, value 656565\n\t\t\t\"dd0100000042\"+ // field 27, encoding 5, value 32.0\n\t\t\t\"dd0100000442\"+ // field 27, encoding 5, value 33.0\n\t\t\t\"e1010000000000005040\"+ // field 28, encoding 1, value 64.0\n\t\t\t\"e1010000000000405040\"+ // field 28, encoding 1, value 65.0\n\t\t\t\"ea0105\"+\"68656c6c6f\"+ // field 29, encoding 2, string \"hello\"\n\t\t\t\"ea0106\"+\"7361696c6f72\"+ // field 29, encoding 2, string \"sailor\"\n\t\t\t\"c00201\"+ // field 40, encoding 0, value 1\n\t\t\t\"c80220\"+ // field 41, encoding 0, value 32\n\t\t\t\"d00240\"+ // field 42, encoding 0, value 64\n\t\t\t\"dd0240010000\"+ // field 43, encoding 5, value 320\n\t\t\t\"e1028002000000000000\"+ // field 44, encoding 1, value 640\n\t\t\t\"e8028019\"+ // field 45, encoding 0, value 3200\n\t\t\t\"f0028032\"+ // field 46, encoding 0, value 6400\n\t\t\t\"fd02e0659948\"+ // field 47, encoding 5, value 314159.0\n\t\t\t\"81030000000050971041\"+ // field 48, encoding 1, value 271828.0\n\t\t\t\"8a0310\"+\"68656c6c6f2c2022776f726c6421220a\"+ // field 49, encoding 2 string \"hello, \\\"world!\\\"\\n\"\n\t\t\t\"b304\"+ // start group field 70 level 1\n\t\t\t\"ba0408\"+\"7265717569726564\"+ // field 71, encoding 2, string \"required\"\n\t\t\t\"b404\"+ // end group field 70 level 1\n\t\t\t\"8305\"+ // start group field 80 level 1\n\t\t\t\"8a0508\"+\"7265706561746564\"+ // field 81, encoding 2, string \"repeated\"\n\t\t\t\"8405\"+ // end group field 80 level 1\n\t\t\t\"8305\"+ // start group field 80 level 1\n\t\t\t\"8a0508\"+\"7265706561746564\"+ // field 81, encoding 2, string \"repeated\"\n\t\t\t\"8405\"+ // end group field 80 level 1\n\t\t\t\"aa0605\"+\"6279746573\"+ // field 101, encoding 2 string \"bytes\"\n\t\t\t\"b0063f\"+ // field 102, encoding 0, 0x3f zigzag32\n\t\t\t\"b8067f\"+ // field 103, encoding 0, 0x7f zigzag64\n\t\t\t\"ca0c03\"+\"626967\"+ // field 201, encoding 2, string \"big\"\n\t\t\t\"ca0c04\"+\"6e6f7365\"+ // field 201, encoding 2, string \"nose\"\n\t\t\t\"d00c40\"+ // field 202, encoding 0, value 32\n\t\t\t\"d00c3f\"+ // field 202, encoding 0, value -32\n\t\t\t\"d80c8001\"+ // field 203, encoding 0, value 64\n\t\t\t\"d80c7f\"+ // field 203, encoding 0, value -64\n\t\t\t\"8a1907\"+\"4269676e6f7365\"+ // field 401, encoding 2, string \"Bignose\"\n\t\t\t\"90193f\"+ // field 402, encoding 0, value 63\n\t\t\t\"98197f\") // field 403, encoding 0, value 127\n\n}\n\n// All required fields set, all packed repeated fields given two values.\nfunc TestEncodeDecode6(t *testing.T) {\n\tpb := initGoTest(false)\n\tpb.F_BoolRepeatedPacked = []bool{false, true}\n\tpb.F_Int32RepeatedPacked = []int32{32, 33}\n\tpb.F_Int64RepeatedPacked = []int64{64, 65}\n\tpb.F_Fixed32RepeatedPacked = []uint32{3232, 3333}\n\tpb.F_Fixed64RepeatedPacked = []uint64{6464, 6565}\n\tpb.F_Uint32RepeatedPacked = []uint32{323232, 333333}\n\tpb.F_Uint64RepeatedPacked = []uint64{646464, 656565}\n\tpb.F_FloatRepeatedPacked = []float32{32., 33.}\n\tpb.F_DoubleRepeatedPacked = []float64{64., 65.}\n\tpb.F_Sint32RepeatedPacked = []int32{32, -32}\n\tpb.F_Sint64RepeatedPacked = []int64{64, -64}\n\n\toverify(t, pb,\n\t\t\"0807\"+ // field 1, encoding 0, value 7\n\t\t\t\"220d\"+\"0a056c6162656c120474797065\"+ // field 4, encoding 2 (GoTestField)\n\t\t\t\"5001\"+ // field 10, encoding 0, value 1\n\t\t\t\"5803\"+ // field 11, encoding 0, value 3\n\t\t\t\"6006\"+ // field 12, encoding 0, value 6\n\t\t\t\"6d20000000\"+ // field 13, encoding 5, value 32\n\t\t\t\"714000000000000000\"+ // field 14, encoding 1, value 64\n\t\t\t\"78a019\"+ // field 15, encoding 0, value 3232\n\t\t\t\"8001c032\"+ // field 16, encoding 0, value 6464\n\t\t\t\"8d0100004a45\"+ // field 17, encoding 5, value 3232.0\n\t\t\t\"9101000000000040b940\"+ // field 18, encoding 1, value 6464.0\n\t\t\t\"9a0106\"+\"737472696e67\"+ // field 19, encoding 2 string \"string\"\n\t\t\t\"9203020001\"+ // field 50, encoding 2, 2 bytes, value 0, value 1\n\t\t\t\"9a03022021\"+ // field 51, encoding 2, 2 bytes, value 32, value 33\n\t\t\t\"a203024041\"+ // field 52, encoding 2, 2 bytes, value 64, value 65\n\t\t\t\"aa0308\"+ // field 53, encoding 2, 8 bytes\n\t\t\t\"a00c0000050d0000\"+ // value 3232, value 3333\n\t\t\t\"b20310\"+ // field 54, encoding 2, 16 bytes\n\t\t\t\"4019000000000000a519000000000000\"+ // value 6464, value 6565\n\t\t\t\"ba0306\"+ // field 55, encoding 2, 6 bytes\n\t\t\t\"a0dd1395ac14\"+ // value 323232, value 333333\n\t\t\t\"c20306\"+ // field 56, encoding 2, 6 bytes\n\t\t\t\"c0ba27b58928\"+ // value 646464, value 656565\n\t\t\t\"ca0308\"+ // field 57, encoding 2, 8 bytes\n\t\t\t\"0000004200000442\"+ // value 32.0, value 33.0\n\t\t\t\"d20310\"+ // field 58, encoding 2, 16 bytes\n\t\t\t\"00000000000050400000000000405040\"+ // value 64.0, value 65.0\n\t\t\t\"b304\"+ // start group field 70 level 1\n\t\t\t\"ba0408\"+\"7265717569726564\"+ // field 71, encoding 2, string \"required\"\n\t\t\t\"b404\"+ // end group field 70 level 1\n\t\t\t\"aa0605\"+\"6279746573\"+ // field 101, encoding 2 string \"bytes\"\n\t\t\t\"b0063f\"+ // field 102, encoding 0, 0x3f zigzag32\n\t\t\t\"b8067f\"+ // field 103, encoding 0, 0x7f zigzag64\n\t\t\t\"b21f02\"+ // field 502, encoding 2, 2 bytes\n\t\t\t\"403f\"+ // value 32, value -32\n\t\t\t\"ba1f03\"+ // field 503, encoding 2, 3 bytes\n\t\t\t\"80017f\") // value 64, value -64\n}\n\n// Test that we can encode empty bytes fields.\nfunc TestEncodeDecodeBytes1(t *testing.T) {\n\tpb := initGoTest(false)\n\n\t// Create our bytes\n\tpb.F_BytesRequired = []byte{}\n\tpb.F_BytesRepeated = [][]byte{{}}\n\tpb.F_BytesOptional = []byte{}\n\n\td, err := Marshal(pb)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tpbd := new(GoTest)\n\tif err := Unmarshal(d, pbd); err != nil {\n\t\tt.Error(err)\n\t}\n\n\tif pbd.F_BytesRequired == nil || len(pbd.F_BytesRequired) != 0 {\n\t\tt.Error(\"required empty bytes field is incorrect\")\n\t}\n\tif pbd.F_BytesRepeated == nil || len(pbd.F_BytesRepeated) == 1 && pbd.F_BytesRepeated[0] == nil {\n\t\tt.Error(\"repeated empty bytes field is incorrect\")\n\t}\n\tif pbd.F_BytesOptional == nil || len(pbd.F_BytesOptional) != 0 {\n\t\tt.Error(\"optional empty bytes field is incorrect\")\n\t}\n}\n\n// Test that we encode nil-valued fields of a repeated bytes field correctly.\n// Since entries in a repeated field cannot be nil, nil must mean empty value.\nfunc TestEncodeDecodeBytes2(t *testing.T) {\n\tpb := initGoTest(false)\n\n\t// Create our bytes\n\tpb.F_BytesRepeated = [][]byte{nil}\n\n\td, err := Marshal(pb)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tpbd := new(GoTest)\n\tif err := Unmarshal(d, pbd); err != nil {\n\t\tt.Error(err)\n\t}\n\n\tif len(pbd.F_BytesRepeated) != 1 || pbd.F_BytesRepeated[0] == nil {\n\t\tt.Error(\"Unexpected value for repeated bytes field\")\n\t}\n}\n\n// All required fields set, defaults provided, all repeated fields given two values.\nfunc TestSkippingUnrecognizedFields(t *testing.T) {\n\to := old()\n\tpb := initGoTestField()\n\n\t// Marshal it normally.\n\to.Marshal(pb)\n\n\t// Now new a GoSkipTest record.\n\tskip := &GoSkipTest{\n\t\tSkipInt32:   Int32(32),\n\t\tSkipFixed32: Uint32(3232),\n\t\tSkipFixed64: Uint64(6464),\n\t\tSkipString:  String(\"skipper\"),\n\t\tSkipgroup: &GoSkipTest_SkipGroup{\n\t\t\tGroupInt32:  Int32(75),\n\t\t\tGroupString: String(\"wxyz\"),\n\t\t},\n\t}\n\n\t// Marshal it into same buffer.\n\to.Marshal(skip)\n\n\tpbd := new(GoTestField)\n\to.Unmarshal(pbd)\n\n\t// The __unrecognized field should be a marshaling of GoSkipTest\n\tskipd := new(GoSkipTest)\n\n\to.SetBuf(pbd.XXX_unrecognized)\n\to.Unmarshal(skipd)\n\n\tif *skipd.SkipInt32 != *skip.SkipInt32 {\n\t\tt.Error(\"skip int32\", skipd.SkipInt32)\n\t}\n\tif *skipd.SkipFixed32 != *skip.SkipFixed32 {\n\t\tt.Error(\"skip fixed32\", skipd.SkipFixed32)\n\t}\n\tif *skipd.SkipFixed64 != *skip.SkipFixed64 {\n\t\tt.Error(\"skip fixed64\", skipd.SkipFixed64)\n\t}\n\tif *skipd.SkipString != *skip.SkipString {\n\t\tt.Error(\"skip string\", *skipd.SkipString)\n\t}\n\tif *skipd.Skipgroup.GroupInt32 != *skip.Skipgroup.GroupInt32 {\n\t\tt.Error(\"skip group int32\", skipd.Skipgroup.GroupInt32)\n\t}\n\tif *skipd.Skipgroup.GroupString != *skip.Skipgroup.GroupString {\n\t\tt.Error(\"skip group string\", *skipd.Skipgroup.GroupString)\n\t}\n}\n\n// Check that unrecognized fields of a submessage are preserved.\nfunc TestSubmessageUnrecognizedFields(t *testing.T) {\n\tnm := &NewMessage{\n\t\tNested: &NewMessage_Nested{\n\t\t\tName:      String(\"Nigel\"),\n\t\t\tFoodGroup: String(\"carbs\"),\n\t\t},\n\t}\n\tb, err := Marshal(nm)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal of NewMessage: %v\", err)\n\t}\n\n\t// Unmarshal into an OldMessage.\n\tom := new(OldMessage)\n\tif err := Unmarshal(b, om); err != nil {\n\t\tt.Fatalf(\"Unmarshal to OldMessage: %v\", err)\n\t}\n\texp := &OldMessage{\n\t\tNested: &OldMessage_Nested{\n\t\t\tName: String(\"Nigel\"),\n\t\t\t// normal protocol buffer users should not do this\n\t\t\tXXX_unrecognized: []byte(\"\\x12\\x05carbs\"),\n\t\t},\n\t}\n\tif !Equal(om, exp) {\n\t\tt.Errorf(\"om = %v, want %v\", om, exp)\n\t}\n\n\t// Clone the OldMessage.\n\tom = Clone(om).(*OldMessage)\n\tif !Equal(om, exp) {\n\t\tt.Errorf(\"Clone(om) = %v, want %v\", om, exp)\n\t}\n\n\t// Marshal the OldMessage, then unmarshal it into an empty NewMessage.\n\tif b, err = Marshal(om); err != nil {\n\t\tt.Fatalf(\"Marshal of OldMessage: %v\", err)\n\t}\n\tt.Logf(\"Marshal(%v) -> %q\", om, b)\n\tnm2 := new(NewMessage)\n\tif err := Unmarshal(b, nm2); err != nil {\n\t\tt.Fatalf(\"Unmarshal to NewMessage: %v\", err)\n\t}\n\tif !Equal(nm, nm2) {\n\t\tt.Errorf(\"NewMessage round-trip: %v => %v\", nm, nm2)\n\t}\n}\n\n// Check that an int32 field can be upgraded to an int64 field.\nfunc TestNegativeInt32(t *testing.T) {\n\tom := &OldMessage{\n\t\tNum: Int32(-1),\n\t}\n\tb, err := Marshal(om)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal of OldMessage: %v\", err)\n\t}\n\n\t// Check the size. It should be 11 bytes;\n\t// 1 for the field/wire type, and 10 for the negative number.\n\tif len(b) != 11 {\n\t\tt.Errorf(\"%v marshaled as %q, wanted 11 bytes\", om, b)\n\t}\n\n\t// Unmarshal into a NewMessage.\n\tnm := new(NewMessage)\n\tif err := Unmarshal(b, nm); err != nil {\n\t\tt.Fatalf(\"Unmarshal to NewMessage: %v\", err)\n\t}\n\twant := &NewMessage{\n\t\tNum: Int64(-1),\n\t}\n\tif !Equal(nm, want) {\n\t\tt.Errorf(\"nm = %v, want %v\", nm, want)\n\t}\n}\n\n// Check that we can grow an array (repeated field) to have many elements.\n// This test doesn't depend only on our encoding; for variety, it makes sure\n// we create, encode, and decode the correct contents explicitly.  It's therefore\n// a bit messier.\n// This test also uses (and hence tests) the Marshal/Unmarshal functions\n// instead of the methods.\nfunc TestBigRepeated(t *testing.T) {\n\tpb := initGoTest(true)\n\n\t// Create the arrays\n\tconst N = 50 // Internally the library starts much smaller.\n\tpb.Repeatedgroup = make([]*GoTest_RepeatedGroup, N)\n\tpb.F_Sint64Repeated = make([]int64, N)\n\tpb.F_Sint32Repeated = make([]int32, N)\n\tpb.F_BytesRepeated = make([][]byte, N)\n\tpb.F_StringRepeated = make([]string, N)\n\tpb.F_DoubleRepeated = make([]float64, N)\n\tpb.F_FloatRepeated = make([]float32, N)\n\tpb.F_Uint64Repeated = make([]uint64, N)\n\tpb.F_Uint32Repeated = make([]uint32, N)\n\tpb.F_Fixed64Repeated = make([]uint64, N)\n\tpb.F_Fixed32Repeated = make([]uint32, N)\n\tpb.F_Int64Repeated = make([]int64, N)\n\tpb.F_Int32Repeated = make([]int32, N)\n\tpb.F_BoolRepeated = make([]bool, N)\n\tpb.RepeatedField = make([]*GoTestField, N)\n\n\t// Fill in the arrays with checkable values.\n\tigtf := initGoTestField()\n\tigtrg := initGoTest_RepeatedGroup()\n\tfor i := 0; i < N; i++ {\n\t\tpb.Repeatedgroup[i] = igtrg\n\t\tpb.F_Sint64Repeated[i] = int64(i)\n\t\tpb.F_Sint32Repeated[i] = int32(i)\n\t\ts := fmt.Sprint(i)\n\t\tpb.F_BytesRepeated[i] = []byte(s)\n\t\tpb.F_StringRepeated[i] = s\n\t\tpb.F_DoubleRepeated[i] = float64(i)\n\t\tpb.F_FloatRepeated[i] = float32(i)\n\t\tpb.F_Uint64Repeated[i] = uint64(i)\n\t\tpb.F_Uint32Repeated[i] = uint32(i)\n\t\tpb.F_Fixed64Repeated[i] = uint64(i)\n\t\tpb.F_Fixed32Repeated[i] = uint32(i)\n\t\tpb.F_Int64Repeated[i] = int64(i)\n\t\tpb.F_Int32Repeated[i] = int32(i)\n\t\tpb.F_BoolRepeated[i] = i%2 == 0\n\t\tpb.RepeatedField[i] = igtf\n\t}\n\n\t// Marshal.\n\tbuf, _ := Marshal(pb)\n\n\t// Now test Unmarshal by recreating the original buffer.\n\tpbd := new(GoTest)\n\tUnmarshal(buf, pbd)\n\n\t// Check the checkable values\n\tfor i := uint64(0); i < N; i++ {\n\t\tif pbd.Repeatedgroup[i] == nil { // TODO: more checking?\n\t\t\tt.Error(\"pbd.Repeatedgroup bad\")\n\t\t}\n\t\tvar x uint64\n\t\tx = uint64(pbd.F_Sint64Repeated[i])\n\t\tif x != i {\n\t\t\tt.Error(\"pbd.F_Sint64Repeated bad\", x, i)\n\t\t}\n\t\tx = uint64(pbd.F_Sint32Repeated[i])\n\t\tif x != i {\n\t\t\tt.Error(\"pbd.F_Sint32Repeated bad\", x, i)\n\t\t}\n\t\ts := fmt.Sprint(i)\n\t\tequalbytes(pbd.F_BytesRepeated[i], []byte(s), t)\n\t\tif pbd.F_StringRepeated[i] != s {\n\t\t\tt.Error(\"pbd.F_Sint32Repeated bad\", pbd.F_StringRepeated[i], i)\n\t\t}\n\t\tx = uint64(pbd.F_DoubleRepeated[i])\n\t\tif x != i {\n\t\t\tt.Error(\"pbd.F_DoubleRepeated bad\", x, i)\n\t\t}\n\t\tx = uint64(pbd.F_FloatRepeated[i])\n\t\tif x != i {\n\t\t\tt.Error(\"pbd.F_FloatRepeated bad\", x, i)\n\t\t}\n\t\tx = pbd.F_Uint64Repeated[i]\n\t\tif x != i {\n\t\t\tt.Error(\"pbd.F_Uint64Repeated bad\", x, i)\n\t\t}\n\t\tx = uint64(pbd.F_Uint32Repeated[i])\n\t\tif x != i {\n\t\t\tt.Error(\"pbd.F_Uint32Repeated bad\", x, i)\n\t\t}\n\t\tx = pbd.F_Fixed64Repeated[i]\n\t\tif x != i {\n\t\t\tt.Error(\"pbd.F_Fixed64Repeated bad\", x, i)\n\t\t}\n\t\tx = uint64(pbd.F_Fixed32Repeated[i])\n\t\tif x != i {\n\t\t\tt.Error(\"pbd.F_Fixed32Repeated bad\", x, i)\n\t\t}\n\t\tx = uint64(pbd.F_Int64Repeated[i])\n\t\tif x != i {\n\t\t\tt.Error(\"pbd.F_Int64Repeated bad\", x, i)\n\t\t}\n\t\tx = uint64(pbd.F_Int32Repeated[i])\n\t\tif x != i {\n\t\t\tt.Error(\"pbd.F_Int32Repeated bad\", x, i)\n\t\t}\n\t\tif pbd.F_BoolRepeated[i] != (i%2 == 0) {\n\t\t\tt.Error(\"pbd.F_BoolRepeated bad\", x, i)\n\t\t}\n\t\tif pbd.RepeatedField[i] == nil { // TODO: more checking?\n\t\t\tt.Error(\"pbd.RepeatedField bad\")\n\t\t}\n\t}\n}\n\n// Verify we give a useful message when decoding to the wrong structure type.\nfunc TestTypeMismatch(t *testing.T) {\n\tpb1 := initGoTest(true)\n\n\t// Marshal\n\to := old()\n\to.Marshal(pb1)\n\n\t// Now Unmarshal it to the wrong type.\n\tpb2 := initGoTestField()\n\terr := o.Unmarshal(pb2)\n\tif err == nil {\n\t\tt.Error(\"expected error, got no error\")\n\t} else if !strings.Contains(err.Error(), \"bad wiretype\") {\n\t\tt.Error(\"expected bad wiretype error, got\", err)\n\t}\n}\n\nfunc encodeDecode(t *testing.T, in, out Message, msg string) {\n\tbuf, err := Marshal(in)\n\tif err != nil {\n\t\tt.Fatalf(\"failed marshaling %v: %v\", msg, err)\n\t}\n\tif err := Unmarshal(buf, out); err != nil {\n\t\tt.Fatalf(\"failed unmarshaling %v: %v\", msg, err)\n\t}\n}\n\nfunc TestPackedNonPackedDecoderSwitching(t *testing.T) {\n\tnp, p := new(NonPackedTest), new(PackedTest)\n\n\t// non-packed -> packed\n\tnp.A = []int32{0, 1, 1, 2, 3, 5}\n\tencodeDecode(t, np, p, \"non-packed -> packed\")\n\tif !reflect.DeepEqual(np.A, p.B) {\n\t\tt.Errorf(\"failed non-packed -> packed; np.A=%+v, p.B=%+v\", np.A, p.B)\n\t}\n\n\t// packed -> non-packed\n\tnp.Reset()\n\tp.B = []int32{3, 1, 4, 1, 5, 9}\n\tencodeDecode(t, p, np, \"packed -> non-packed\")\n\tif !reflect.DeepEqual(p.B, np.A) {\n\t\tt.Errorf(\"failed packed -> non-packed; p.B=%+v, np.A=%+v\", p.B, np.A)\n\t}\n}\n\nfunc TestProto1RepeatedGroup(t *testing.T) {\n\tpb := &MessageList{\n\t\tMessage: []*MessageList_Message{\n\t\t\t{\n\t\t\t\tName:  String(\"blah\"),\n\t\t\t\tCount: Int32(7),\n\t\t\t},\n\t\t\t// NOTE: pb.Message[1] is a nil\n\t\t\tnil,\n\t\t},\n\t}\n\n\to := old()\n\terr := o.Marshal(pb)\n\tif err == nil || !strings.Contains(err.Error(), \"repeated field Message has nil\") {\n\t\tt.Fatalf(\"unexpected or no error when marshaling: %v\", err)\n\t}\n}\n\n// Test that enums work.  Checks for a bug introduced by making enums\n// named types instead of int32: newInt32FromUint64 would crash with\n// a type mismatch in reflect.PointTo.\nfunc TestEnum(t *testing.T) {\n\tpb := new(GoEnum)\n\tpb.Foo = FOO_FOO1.Enum()\n\to := old()\n\tif err := o.Marshal(pb); err != nil {\n\t\tt.Fatal(\"error encoding enum:\", err)\n\t}\n\tpb1 := new(GoEnum)\n\tif err := o.Unmarshal(pb1); err != nil {\n\t\tt.Fatal(\"error decoding enum:\", err)\n\t}\n\tif *pb1.Foo != FOO_FOO1 {\n\t\tt.Error(\"expected 7 but got \", *pb1.Foo)\n\t}\n}\n\n// Enum types have String methods. Check that enum fields can be printed.\n// We don't care what the value actually is, just as long as it doesn't crash.\nfunc TestPrintingNilEnumFields(t *testing.T) {\n\tpb := new(GoEnum)\n\t_ = fmt.Sprintf(\"%+v\", pb)\n}\n\n// Verify that absent required fields cause Marshal/Unmarshal to return errors.\nfunc TestRequiredFieldEnforcement(t *testing.T) {\n\tpb := new(GoTestField)\n\t_, err := Marshal(pb)\n\tif err == nil {\n\t\tt.Error(\"marshal: expected error, got nil\")\n\t} else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), \"Label\") {\n\t\tt.Errorf(\"marshal: bad error type: %v\", err)\n\t}\n\n\t// A slightly sneaky, yet valid, proto. It encodes the same required field twice,\n\t// so simply counting the required fields is insufficient.\n\t// field 1, encoding 2, value \"hi\"\n\tbuf := []byte(\"\\x0A\\x02hi\\x0A\\x02hi\")\n\terr = Unmarshal(buf, pb)\n\tif err == nil {\n\t\tt.Error(\"unmarshal: expected error, got nil\")\n\t} else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), \"{Unknown}\") {\n\t\tt.Errorf(\"unmarshal: bad error type: %v\", err)\n\t}\n}\n\n// Verify that absent required fields in groups cause Marshal/Unmarshal to return errors.\nfunc TestRequiredFieldEnforcementGroups(t *testing.T) {\n\tpb := &GoTestRequiredGroupField{Group: &GoTestRequiredGroupField_Group{}}\n\tif _, err := Marshal(pb); err == nil {\n\t\tt.Error(\"marshal: expected error, got nil\")\n\t} else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), \"Group.Field\") {\n\t\tt.Errorf(\"marshal: bad error type: %v\", err)\n\t}\n\n\tbuf := []byte{11, 12}\n\tif err := Unmarshal(buf, pb); err == nil {\n\t\tt.Error(\"unmarshal: expected error, got nil\")\n\t} else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), \"Group.{Unknown}\") {\n\t\tt.Errorf(\"unmarshal: bad error type: %v\", err)\n\t}\n}\n\nfunc TestTypedNilMarshal(t *testing.T) {\n\t// A typed nil should return ErrNil and not crash.\n\t{\n\t\tvar m *GoEnum\n\t\tif _, err := Marshal(m); err != ErrNil {\n\t\t\tt.Errorf(\"Marshal(%#v): got %v, want ErrNil\", m, err)\n\t\t}\n\t}\n\n\t{\n\t\tm := &Communique{Union: &Communique_Msg{nil}}\n\t\tif _, err := Marshal(m); err == nil || err == ErrNil {\n\t\t\tt.Errorf(\"Marshal(%#v): got %v, want errOneofHasNil\", m, err)\n\t\t}\n\t}\n}\n\n// A type that implements the Marshaler interface, but is not nillable.\ntype nonNillableInt uint64\n\nfunc (nni nonNillableInt) Marshal() ([]byte, error) {\n\treturn EncodeVarint(uint64(nni)), nil\n}\n\ntype NNIMessage struct {\n\tnni nonNillableInt\n}\n\nfunc (*NNIMessage) Reset()         {}\nfunc (*NNIMessage) String() string { return \"\" }\nfunc (*NNIMessage) ProtoMessage()  {}\n\n// A type that implements the Marshaler interface and is nillable.\ntype nillableMessage struct {\n\tx uint64\n}\n\nfunc (nm *nillableMessage) Marshal() ([]byte, error) {\n\treturn EncodeVarint(nm.x), nil\n}\n\ntype NMMessage struct {\n\tnm *nillableMessage\n}\n\nfunc (*NMMessage) Reset()         {}\nfunc (*NMMessage) String() string { return \"\" }\nfunc (*NMMessage) ProtoMessage()  {}\n\n// Verify a type that uses the Marshaler interface, but has a nil pointer.\nfunc TestNilMarshaler(t *testing.T) {\n\t// Try a struct with a Marshaler field that is nil.\n\t// It should be directly marshable.\n\tnmm := new(NMMessage)\n\tif _, err := Marshal(nmm); err != nil {\n\t\tt.Error(\"unexpected error marshaling nmm: \", err)\n\t}\n\n\t// Try a struct with a Marshaler field that is not nillable.\n\tnnim := new(NNIMessage)\n\tnnim.nni = 7\n\tvar _ Marshaler = nnim.nni // verify it is truly a Marshaler\n\tif _, err := Marshal(nnim); err != nil {\n\t\tt.Error(\"unexpected error marshaling nnim: \", err)\n\t}\n}\n\nfunc TestAllSetDefaults(t *testing.T) {\n\t// Exercise SetDefaults with all scalar field types.\n\tm := &Defaults{\n\t\t// NaN != NaN, so override that here.\n\t\tF_Nan: Float32(1.7),\n\t}\n\texpected := &Defaults{\n\t\tF_Bool:    Bool(true),\n\t\tF_Int32:   Int32(32),\n\t\tF_Int64:   Int64(64),\n\t\tF_Fixed32: Uint32(320),\n\t\tF_Fixed64: Uint64(640),\n\t\tF_Uint32:  Uint32(3200),\n\t\tF_Uint64:  Uint64(6400),\n\t\tF_Float:   Float32(314159),\n\t\tF_Double:  Float64(271828),\n\t\tF_String:  String(`hello, \"world!\"` + \"\\n\"),\n\t\tF_Bytes:   []byte(\"Bignose\"),\n\t\tF_Sint32:  Int32(-32),\n\t\tF_Sint64:  Int64(-64),\n\t\tF_Enum:    Defaults_GREEN.Enum(),\n\t\tF_Pinf:    Float32(float32(math.Inf(1))),\n\t\tF_Ninf:    Float32(float32(math.Inf(-1))),\n\t\tF_Nan:     Float32(1.7),\n\t\tStrZero:   String(\"\"),\n\t}\n\tSetDefaults(m)\n\tif !Equal(m, expected) {\n\t\tt.Errorf(\"SetDefaults failed\\n got %v\\nwant %v\", m, expected)\n\t}\n}\n\nfunc TestSetDefaultsWithSetField(t *testing.T) {\n\t// Check that a set value is not overridden.\n\tm := &Defaults{\n\t\tF_Int32: Int32(12),\n\t}\n\tSetDefaults(m)\n\tif v := m.GetF_Int32(); v != 12 {\n\t\tt.Errorf(\"m.FInt32 = %v, want 12\", v)\n\t}\n}\n\nfunc TestSetDefaultsWithSubMessage(t *testing.T) {\n\tm := &OtherMessage{\n\t\tKey: Int64(123),\n\t\tInner: &InnerMessage{\n\t\t\tHost: String(\"gopher\"),\n\t\t},\n\t}\n\texpected := &OtherMessage{\n\t\tKey: Int64(123),\n\t\tInner: &InnerMessage{\n\t\t\tHost: String(\"gopher\"),\n\t\t\tPort: Int32(4000),\n\t\t},\n\t}\n\tSetDefaults(m)\n\tif !Equal(m, expected) {\n\t\tt.Errorf(\"\\n got %v\\nwant %v\", m, expected)\n\t}\n}\n\nfunc TestSetDefaultsWithRepeatedSubMessage(t *testing.T) {\n\tm := &MyMessage{\n\t\tRepInner: []*InnerMessage{{}},\n\t}\n\texpected := &MyMessage{\n\t\tRepInner: []*InnerMessage{{\n\t\t\tPort: Int32(4000),\n\t\t}},\n\t}\n\tSetDefaults(m)\n\tif !Equal(m, expected) {\n\t\tt.Errorf(\"\\n got %v\\nwant %v\", m, expected)\n\t}\n}\n\nfunc TestSetDefaultWithRepeatedNonMessage(t *testing.T) {\n\tm := &MyMessage{\n\t\tPet: []string{\"turtle\", \"wombat\"},\n\t}\n\texpected := Clone(m)\n\tSetDefaults(m)\n\tif !Equal(m, expected) {\n\t\tt.Errorf(\"\\n got %v\\nwant %v\", m, expected)\n\t}\n}\n\nfunc TestMaximumTagNumber(t *testing.T) {\n\tm := &MaxTag{\n\t\tLastField: String(\"natural goat essence\"),\n\t}\n\tbuf, err := Marshal(m)\n\tif err != nil {\n\t\tt.Fatalf(\"proto.Marshal failed: %v\", err)\n\t}\n\tm2 := new(MaxTag)\n\tif err := Unmarshal(buf, m2); err != nil {\n\t\tt.Fatalf(\"proto.Unmarshal failed: %v\", err)\n\t}\n\tif got, want := m2.GetLastField(), *m.LastField; got != want {\n\t\tt.Errorf(\"got %q, want %q\", got, want)\n\t}\n}\n\nfunc TestJSON(t *testing.T) {\n\tm := &MyMessage{\n\t\tCount: Int32(4),\n\t\tPet:   []string{\"bunny\", \"kitty\"},\n\t\tInner: &InnerMessage{\n\t\t\tHost: String(\"cauchy\"),\n\t\t},\n\t\tBikeshed: MyMessage_GREEN.Enum(),\n\t}\n\tconst expected = `{\"count\":4,\"pet\":[\"bunny\",\"kitty\"],\"inner\":{\"host\":\"cauchy\"},\"bikeshed\":1}`\n\n\tb, err := json.Marshal(m)\n\tif err != nil {\n\t\tt.Fatalf(\"json.Marshal failed: %v\", err)\n\t}\n\ts := string(b)\n\tif s != expected {\n\t\tt.Errorf(\"got  %s\\nwant %s\", s, expected)\n\t}\n\n\treceived := new(MyMessage)\n\tif err := json.Unmarshal(b, received); err != nil {\n\t\tt.Fatalf(\"json.Unmarshal failed: %v\", err)\n\t}\n\tif !Equal(received, m) {\n\t\tt.Fatalf(\"got %s, want %s\", received, m)\n\t}\n\n\t// Test unmarshalling of JSON with symbolic enum name.\n\tconst old = `{\"count\":4,\"pet\":[\"bunny\",\"kitty\"],\"inner\":{\"host\":\"cauchy\"},\"bikeshed\":\"GREEN\"}`\n\treceived.Reset()\n\tif err := json.Unmarshal([]byte(old), received); err != nil {\n\t\tt.Fatalf(\"json.Unmarshal failed: %v\", err)\n\t}\n\tif !Equal(received, m) {\n\t\tt.Fatalf(\"got %s, want %s\", received, m)\n\t}\n}\n\nfunc TestBadWireType(t *testing.T) {\n\tb := []byte{7<<3 | 6} // field 7, wire type 6\n\tpb := new(OtherMessage)\n\tif err := Unmarshal(b, pb); err == nil {\n\t\tt.Errorf(\"Unmarshal did not fail\")\n\t} else if !strings.Contains(err.Error(), \"unknown wire type\") {\n\t\tt.Errorf(\"wrong error: %v\", err)\n\t}\n}\n\nfunc TestBytesWithInvalidLength(t *testing.T) {\n\t// If a byte sequence has an invalid (negative) length, Unmarshal should not panic.\n\tb := []byte{2<<3 | WireBytes, 0xff, 0xff, 0xff, 0xff, 0xff, 0}\n\tUnmarshal(b, new(MyMessage))\n}\n\nfunc TestLengthOverflow(t *testing.T) {\n\t// Overflowing a length should not panic.\n\tb := []byte{2<<3 | WireBytes, 1, 1, 3<<3 | WireBytes, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x01}\n\tUnmarshal(b, new(MyMessage))\n}\n\nfunc TestVarintOverflow(t *testing.T) {\n\t// Overflowing a 64-bit length should not be allowed.\n\tb := []byte{1<<3 | WireVarint, 0x01, 3<<3 | WireBytes, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01}\n\tif err := Unmarshal(b, new(MyMessage)); err == nil {\n\t\tt.Fatalf(\"Overflowed uint64 length without error\")\n\t}\n}\n\nfunc TestUnmarshalFuzz(t *testing.T) {\n\tconst N = 1000\n\tseed := time.Now().UnixNano()\n\tt.Logf(\"RNG seed is %d\", seed)\n\trng := rand.New(rand.NewSource(seed))\n\tbuf := make([]byte, 20)\n\tfor i := 0; i < N; i++ {\n\t\tfor j := range buf {\n\t\t\tbuf[j] = byte(rng.Intn(256))\n\t\t}\n\t\tfuzzUnmarshal(t, buf)\n\t}\n}\n\nfunc TestMergeMessages(t *testing.T) {\n\tpb := &MessageList{Message: []*MessageList_Message{{Name: String(\"x\"), Count: Int32(1)}}}\n\tdata, err := Marshal(pb)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal: %v\", err)\n\t}\n\n\tpb1 := new(MessageList)\n\tif err := Unmarshal(data, pb1); err != nil {\n\t\tt.Fatalf(\"first Unmarshal: %v\", err)\n\t}\n\tif err := Unmarshal(data, pb1); err != nil {\n\t\tt.Fatalf(\"second Unmarshal: %v\", err)\n\t}\n\tif len(pb1.Message) != 1 {\n\t\tt.Errorf(\"two Unmarshals produced %d Messages, want 1\", len(pb1.Message))\n\t}\n\n\tpb2 := new(MessageList)\n\tif err := UnmarshalMerge(data, pb2); err != nil {\n\t\tt.Fatalf(\"first UnmarshalMerge: %v\", err)\n\t}\n\tif err := UnmarshalMerge(data, pb2); err != nil {\n\t\tt.Fatalf(\"second UnmarshalMerge: %v\", err)\n\t}\n\tif len(pb2.Message) != 2 {\n\t\tt.Errorf(\"two UnmarshalMerges produced %d Messages, want 2\", len(pb2.Message))\n\t}\n}\n\nfunc TestExtensionMarshalOrder(t *testing.T) {\n\tm := &MyMessage{Count: Int(123)}\n\tif err := SetExtension(m, E_Ext_More, &Ext{Data: String(\"alpha\")}); err != nil {\n\t\tt.Fatalf(\"SetExtension: %v\", err)\n\t}\n\tif err := SetExtension(m, E_Ext_Text, String(\"aleph\")); err != nil {\n\t\tt.Fatalf(\"SetExtension: %v\", err)\n\t}\n\tif err := SetExtension(m, E_Ext_Number, Int32(1)); err != nil {\n\t\tt.Fatalf(\"SetExtension: %v\", err)\n\t}\n\n\t// Serialize m several times, and check we get the same bytes each time.\n\tvar orig []byte\n\tfor i := 0; i < 100; i++ {\n\t\tb, err := Marshal(m)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Marshal: %v\", err)\n\t\t}\n\t\tif i == 0 {\n\t\t\torig = b\n\t\t\tcontinue\n\t\t}\n\t\tif !bytes.Equal(b, orig) {\n\t\t\tt.Errorf(\"Bytes differ on attempt #%d\", i)\n\t\t}\n\t}\n}\n\n// Many extensions, because small maps might not iterate differently on each iteration.\nvar exts = []*ExtensionDesc{\n\tE_X201,\n\tE_X202,\n\tE_X203,\n\tE_X204,\n\tE_X205,\n\tE_X206,\n\tE_X207,\n\tE_X208,\n\tE_X209,\n\tE_X210,\n\tE_X211,\n\tE_X212,\n\tE_X213,\n\tE_X214,\n\tE_X215,\n\tE_X216,\n\tE_X217,\n\tE_X218,\n\tE_X219,\n\tE_X220,\n\tE_X221,\n\tE_X222,\n\tE_X223,\n\tE_X224,\n\tE_X225,\n\tE_X226,\n\tE_X227,\n\tE_X228,\n\tE_X229,\n\tE_X230,\n\tE_X231,\n\tE_X232,\n\tE_X233,\n\tE_X234,\n\tE_X235,\n\tE_X236,\n\tE_X237,\n\tE_X238,\n\tE_X239,\n\tE_X240,\n\tE_X241,\n\tE_X242,\n\tE_X243,\n\tE_X244,\n\tE_X245,\n\tE_X246,\n\tE_X247,\n\tE_X248,\n\tE_X249,\n\tE_X250,\n}\n\nfunc TestMessageSetMarshalOrder(t *testing.T) {\n\tm := &MyMessageSet{}\n\tfor _, x := range exts {\n\t\tif err := SetExtension(m, x, &Empty{}); err != nil {\n\t\t\tt.Fatalf(\"SetExtension: %v\", err)\n\t\t}\n\t}\n\n\tbuf, err := Marshal(m)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal: %v\", err)\n\t}\n\n\t// Serialize m several times, and check we get the same bytes each time.\n\tfor i := 0; i < 10; i++ {\n\t\tb1, err := Marshal(m)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Marshal: %v\", err)\n\t\t}\n\t\tif !bytes.Equal(b1, buf) {\n\t\t\tt.Errorf(\"Bytes differ on re-Marshal #%d\", i)\n\t\t}\n\n\t\tm2 := &MyMessageSet{}\n\t\tif err := Unmarshal(buf, m2); err != nil {\n\t\t\tt.Errorf(\"Unmarshal: %v\", err)\n\t\t}\n\t\tb2, err := Marshal(m2)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"re-Marshal: %v\", err)\n\t\t}\n\t\tif !bytes.Equal(b2, buf) {\n\t\t\tt.Errorf(\"Bytes differ on round-trip #%d\", i)\n\t\t}\n\t}\n}\n\nfunc TestUnmarshalMergesMessages(t *testing.T) {\n\t// If a nested message occurs twice in the input,\n\t// the fields should be merged when decoding.\n\ta := &OtherMessage{\n\t\tKey: Int64(123),\n\t\tInner: &InnerMessage{\n\t\t\tHost: String(\"polhode\"),\n\t\t\tPort: Int32(1234),\n\t\t},\n\t}\n\taData, err := Marshal(a)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal(a): %v\", err)\n\t}\n\tb := &OtherMessage{\n\t\tWeight: Float32(1.2),\n\t\tInner: &InnerMessage{\n\t\t\tHost:      String(\"herpolhode\"),\n\t\t\tConnected: Bool(true),\n\t\t},\n\t}\n\tbData, err := Marshal(b)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal(b): %v\", err)\n\t}\n\twant := &OtherMessage{\n\t\tKey:    Int64(123),\n\t\tWeight: Float32(1.2),\n\t\tInner: &InnerMessage{\n\t\t\tHost:      String(\"herpolhode\"),\n\t\t\tPort:      Int32(1234),\n\t\t\tConnected: Bool(true),\n\t\t},\n\t}\n\tgot := new(OtherMessage)\n\tif err := Unmarshal(append(aData, bData...), got); err != nil {\n\t\tt.Fatalf(\"Unmarshal: %v\", err)\n\t}\n\tif !Equal(got, want) {\n\t\tt.Errorf(\"\\n got %v\\nwant %v\", got, want)\n\t}\n}\n\nfunc TestEncodingSizes(t *testing.T) {\n\ttests := []struct {\n\t\tm Message\n\t\tn int\n\t}{\n\t\t{&Defaults{F_Int32: Int32(math.MaxInt32)}, 6},\n\t\t{&Defaults{F_Int32: Int32(math.MinInt32)}, 11},\n\t\t{&Defaults{F_Uint32: Uint32(uint32(math.MaxInt32) + 1)}, 6},\n\t\t{&Defaults{F_Uint32: Uint32(math.MaxUint32)}, 6},\n\t}\n\tfor _, test := range tests {\n\t\tb, err := Marshal(test.m)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Marshal(%v): %v\", test.m, err)\n\t\t\tcontinue\n\t\t}\n\t\tif len(b) != test.n {\n\t\t\tt.Errorf(\"Marshal(%v) yielded %d bytes, want %d bytes\", test.m, len(b), test.n)\n\t\t}\n\t}\n}\n\nfunc TestRequiredNotSetError(t *testing.T) {\n\tpb := initGoTest(false)\n\tpb.RequiredField.Label = nil\n\tpb.F_Int32Required = nil\n\tpb.F_Int64Required = nil\n\n\texpected := \"0807\" + // field 1, encoding 0, value 7\n\t\t\"2206\" + \"120474797065\" + // field 4, encoding 2 (GoTestField)\n\t\t\"5001\" + // field 10, encoding 0, value 1\n\t\t\"6d20000000\" + // field 13, encoding 5, value 0x20\n\t\t\"714000000000000000\" + // field 14, encoding 1, value 0x40\n\t\t\"78a019\" + // field 15, encoding 0, value 0xca0 = 3232\n\t\t\"8001c032\" + // field 16, encoding 0, value 0x1940 = 6464\n\t\t\"8d0100004a45\" + // field 17, encoding 5, value 3232.0\n\t\t\"9101000000000040b940\" + // field 18, encoding 1, value 6464.0\n\t\t\"9a0106\" + \"737472696e67\" + // field 19, encoding 2, string \"string\"\n\t\t\"b304\" + // field 70, encoding 3, start group\n\t\t\"ba0408\" + \"7265717569726564\" + // field 71, encoding 2, string \"required\"\n\t\t\"b404\" + // field 70, encoding 4, end group\n\t\t\"aa0605\" + \"6279746573\" + // field 101, encoding 2, string \"bytes\"\n\t\t\"b0063f\" + // field 102, encoding 0, 0x3f zigzag32\n\t\t\"b8067f\" // field 103, encoding 0, 0x7f zigzag64\n\n\to := old()\n\tbytes, err := Marshal(pb)\n\tif _, ok := err.(*RequiredNotSetError); !ok {\n\t\tfmt.Printf(\"marshal-1 err = %v, want *RequiredNotSetError\", err)\n\t\to.DebugPrint(\"\", bytes)\n\t\tt.Fatalf(\"expected = %s\", expected)\n\t}\n\tif strings.Index(err.Error(), \"RequiredField.Label\") < 0 {\n\t\tt.Errorf(\"marshal-1 wrong err msg: %v\", err)\n\t}\n\tif !equal(bytes, expected, t) {\n\t\to.DebugPrint(\"neq 1\", bytes)\n\t\tt.Fatalf(\"expected = %s\", expected)\n\t}\n\n\t// Now test Unmarshal by recreating the original buffer.\n\tpbd := new(GoTest)\n\terr = Unmarshal(bytes, pbd)\n\tif _, ok := err.(*RequiredNotSetError); !ok {\n\t\tt.Fatalf(\"unmarshal err = %v, want *RequiredNotSetError\", err)\n\t\to.DebugPrint(\"\", bytes)\n\t\tt.Fatalf(\"string = %s\", expected)\n\t}\n\tif strings.Index(err.Error(), \"RequiredField.{Unknown}\") < 0 {\n\t\tt.Errorf(\"unmarshal wrong err msg: %v\", err)\n\t}\n\tbytes, err = Marshal(pbd)\n\tif _, ok := err.(*RequiredNotSetError); !ok {\n\t\tt.Errorf(\"marshal-2 err = %v, want *RequiredNotSetError\", err)\n\t\to.DebugPrint(\"\", bytes)\n\t\tt.Fatalf(\"string = %s\", expected)\n\t}\n\tif strings.Index(err.Error(), \"RequiredField.Label\") < 0 {\n\t\tt.Errorf(\"marshal-2 wrong err msg: %v\", err)\n\t}\n\tif !equal(bytes, expected, t) {\n\t\to.DebugPrint(\"neq 2\", bytes)\n\t\tt.Fatalf(\"string = %s\", expected)\n\t}\n}\n\nfunc fuzzUnmarshal(t *testing.T, data []byte) {\n\tdefer func() {\n\t\tif e := recover(); e != nil {\n\t\t\tt.Errorf(\"These bytes caused a panic: %+v\", data)\n\t\t\tt.Logf(\"Stack:\\n%s\", debug.Stack())\n\t\t\tt.FailNow()\n\t\t}\n\t}()\n\n\tpb := new(MyMessage)\n\tUnmarshal(data, pb)\n}\n\nfunc TestMapFieldMarshal(t *testing.T) {\n\tm := &MessageWithMap{\n\t\tNameMapping: map[int32]string{\n\t\t\t1: \"Rob\",\n\t\t\t4: \"Ian\",\n\t\t\t8: \"Dave\",\n\t\t},\n\t}\n\tb, err := Marshal(m)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal: %v\", err)\n\t}\n\n\t// b should be the concatenation of these three byte sequences in some order.\n\tparts := []string{\n\t\t\"\\n\\a\\b\\x01\\x12\\x03Rob\",\n\t\t\"\\n\\a\\b\\x04\\x12\\x03Ian\",\n\t\t\"\\n\\b\\b\\x08\\x12\\x04Dave\",\n\t}\n\tok := false\n\tfor i := range parts {\n\t\tfor j := range parts {\n\t\t\tif j == i {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor k := range parts {\n\t\t\t\tif k == i || k == j {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\ttry := parts[i] + parts[j] + parts[k]\n\t\t\t\tif bytes.Equal(b, []byte(try)) {\n\t\t\t\t\tok = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif !ok {\n\t\tt.Fatalf(\"Incorrect Marshal output.\\n got %q\\nwant %q (or a permutation of that)\", b, parts[0]+parts[1]+parts[2])\n\t}\n\tt.Logf(\"FYI b: %q\", b)\n\n\t(new(Buffer)).DebugPrint(\"Dump of b\", b)\n}\n\nfunc TestMapFieldRoundTrips(t *testing.T) {\n\tm := &MessageWithMap{\n\t\tNameMapping: map[int32]string{\n\t\t\t1: \"Rob\",\n\t\t\t4: \"Ian\",\n\t\t\t8: \"Dave\",\n\t\t},\n\t\tMsgMapping: map[int64]*FloatingPoint{\n\t\t\t0x7001: &FloatingPoint{F: Float64(2.0)},\n\t\t},\n\t\tByteMapping: map[bool][]byte{\n\t\t\tfalse: []byte(\"that's not right!\"),\n\t\t\ttrue:  []byte(\"aye, 'tis true!\"),\n\t\t},\n\t}\n\tb, err := Marshal(m)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal: %v\", err)\n\t}\n\tt.Logf(\"FYI b: %q\", b)\n\tm2 := new(MessageWithMap)\n\tif err := Unmarshal(b, m2); err != nil {\n\t\tt.Fatalf(\"Unmarshal: %v\", err)\n\t}\n\tfor _, pair := range [][2]interface{}{\n\t\t{m.NameMapping, m2.NameMapping},\n\t\t{m.MsgMapping, m2.MsgMapping},\n\t\t{m.ByteMapping, m2.ByteMapping},\n\t} {\n\t\tif !reflect.DeepEqual(pair[0], pair[1]) {\n\t\t\tt.Errorf(\"Map did not survive a round trip.\\ninitial: %v\\n  final: %v\", pair[0], pair[1])\n\t\t}\n\t}\n}\n\nfunc TestMapFieldWithNil(t *testing.T) {\n\tm1 := &MessageWithMap{\n\t\tMsgMapping: map[int64]*FloatingPoint{\n\t\t\t1: nil,\n\t\t},\n\t}\n\tb, err := Marshal(m1)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal: %v\", err)\n\t}\n\tm2 := new(MessageWithMap)\n\tif err := Unmarshal(b, m2); err != nil {\n\t\tt.Fatalf(\"Unmarshal: %v, got these bytes: %v\", err, b)\n\t}\n\tif v, ok := m2.MsgMapping[1]; !ok {\n\t\tt.Error(\"msg_mapping[1] not present\")\n\t} else if v != nil {\n\t\tt.Errorf(\"msg_mapping[1] not nil: %v\", v)\n\t}\n}\n\nfunc TestMapFieldWithNilBytes(t *testing.T) {\n\tm1 := &MessageWithMap{\n\t\tByteMapping: map[bool][]byte{\n\t\t\tfalse: []byte{},\n\t\t\ttrue:  nil,\n\t\t},\n\t}\n\tn := Size(m1)\n\tb, err := Marshal(m1)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal: %v\", err)\n\t}\n\tif n != len(b) {\n\t\tt.Errorf(\"Size(m1) = %d; want len(Marshal(m1)) = %d\", n, len(b))\n\t}\n\tm2 := new(MessageWithMap)\n\tif err := Unmarshal(b, m2); err != nil {\n\t\tt.Fatalf(\"Unmarshal: %v, got these bytes: %v\", err, b)\n\t}\n\tif v, ok := m2.ByteMapping[false]; !ok {\n\t\tt.Error(\"byte_mapping[false] not present\")\n\t} else if len(v) != 0 {\n\t\tt.Errorf(\"byte_mapping[false] not empty: %#v\", v)\n\t}\n\tif v, ok := m2.ByteMapping[true]; !ok {\n\t\tt.Error(\"byte_mapping[true] not present\")\n\t} else if len(v) != 0 {\n\t\tt.Errorf(\"byte_mapping[true] not empty: %#v\", v)\n\t}\n}\n\nfunc TestDecodeMapFieldMissingKey(t *testing.T) {\n\tb := []byte{\n\t\t0x0A, 0x03, // message, tag 1 (name_mapping), of length 3 bytes\n\t\t// no key\n\t\t0x12, 0x01, 0x6D, // string value of length 1 byte, value \"m\"\n\t}\n\tgot := &MessageWithMap{}\n\terr := Unmarshal(b, got)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to marshal map with missing key: %v\", err)\n\t}\n\twant := &MessageWithMap{NameMapping: map[int32]string{0: \"m\"}}\n\tif !Equal(got, want) {\n\t\tt.Errorf(\"Unmarshaled map with no key was not as expected. got: %v, want %v\", got, want)\n\t}\n}\n\nfunc TestDecodeMapFieldMissingValue(t *testing.T) {\n\tb := []byte{\n\t\t0x0A, 0x02, // message, tag 1 (name_mapping), of length 2 bytes\n\t\t0x08, 0x01, // varint key, value 1\n\t\t// no value\n\t}\n\tgot := &MessageWithMap{}\n\terr := Unmarshal(b, got)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to marshal map with missing value: %v\", err)\n\t}\n\twant := &MessageWithMap{NameMapping: map[int32]string{1: \"\"}}\n\tif !Equal(got, want) {\n\t\tt.Errorf(\"Unmarshaled map with no value was not as expected. got: %v, want %v\", got, want)\n\t}\n}\n\nfunc TestOneof(t *testing.T) {\n\tm := &Communique{}\n\tb, err := Marshal(m)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal of empty message with oneof: %v\", err)\n\t}\n\tif len(b) != 0 {\n\t\tt.Errorf(\"Marshal of empty message yielded too many bytes: %v\", b)\n\t}\n\n\tm = &Communique{\n\t\tUnion: &Communique_Name{\"Barry\"},\n\t}\n\n\t// Round-trip.\n\tb, err = Marshal(m)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal of message with oneof: %v\", err)\n\t}\n\tif len(b) != 7 { // name tag/wire (1) + name len (1) + name (5)\n\t\tt.Errorf(\"Incorrect marshal of message with oneof: %v\", b)\n\t}\n\tm.Reset()\n\tif err := Unmarshal(b, m); err != nil {\n\t\tt.Fatalf(\"Unmarshal of message with oneof: %v\", err)\n\t}\n\tif x, ok := m.Union.(*Communique_Name); !ok || x.Name != \"Barry\" {\n\t\tt.Errorf(\"After round trip, Union = %+v\", m.Union)\n\t}\n\tif name := m.GetName(); name != \"Barry\" {\n\t\tt.Errorf(\"After round trip, GetName = %q, want %q\", name, \"Barry\")\n\t}\n\n\t// Let's try with a message in the oneof.\n\tm.Union = &Communique_Msg{&Strings{StringField: String(\"deep deep string\")}}\n\tb, err = Marshal(m)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal of message with oneof set to message: %v\", err)\n\t}\n\tif len(b) != 20 { // msg tag/wire (1) + msg len (1) + msg (1 + 1 + 16)\n\t\tt.Errorf(\"Incorrect marshal of message with oneof set to message: %v\", b)\n\t}\n\tm.Reset()\n\tif err := Unmarshal(b, m); err != nil {\n\t\tt.Fatalf(\"Unmarshal of message with oneof set to message: %v\", err)\n\t}\n\tss, ok := m.Union.(*Communique_Msg)\n\tif !ok || ss.Msg.GetStringField() != \"deep deep string\" {\n\t\tt.Errorf(\"After round trip with oneof set to message, Union = %+v\", m.Union)\n\t}\n}\n\nfunc TestInefficientPackedBool(t *testing.T) {\n\t// https://github.com/golang/protobuf/issues/76\n\tinp := []byte{\n\t\t0x12, 0x02, // 0x12 = 2<<3|2; 2 bytes\n\t\t// Usually a bool should take a single byte,\n\t\t// but it is permitted to be any varint.\n\t\t0xb9, 0x30,\n\t}\n\tif err := Unmarshal(inp, new(MoreRepeated)); err != nil {\n\t\tt.Error(err)\n\t}\n}\n\n// Benchmarks\n\nfunc testMsg() *GoTest {\n\tpb := initGoTest(true)\n\tconst N = 1000 // Internally the library starts much smaller.\n\tpb.F_Int32Repeated = make([]int32, N)\n\tpb.F_DoubleRepeated = make([]float64, N)\n\tfor i := 0; i < N; i++ {\n\t\tpb.F_Int32Repeated[i] = int32(i)\n\t\tpb.F_DoubleRepeated[i] = float64(i)\n\t}\n\treturn pb\n}\n\nfunc bytesMsg() *GoTest {\n\tpb := initGoTest(true)\n\tbuf := make([]byte, 4000)\n\tfor i := range buf {\n\t\tbuf[i] = byte(i)\n\t}\n\tpb.F_BytesDefaulted = buf\n\treturn pb\n}\n\nfunc benchmarkMarshal(b *testing.B, pb Message, marshal func(Message) ([]byte, error)) {\n\td, _ := marshal(pb)\n\tb.SetBytes(int64(len(d)))\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tmarshal(pb)\n\t}\n}\n\nfunc benchmarkBufferMarshal(b *testing.B, pb Message) {\n\tp := NewBuffer(nil)\n\tbenchmarkMarshal(b, pb, func(pb0 Message) ([]byte, error) {\n\t\tp.Reset()\n\t\terr := p.Marshal(pb0)\n\t\treturn p.Bytes(), err\n\t})\n}\n\nfunc benchmarkSize(b *testing.B, pb Message) {\n\tbenchmarkMarshal(b, pb, func(pb0 Message) ([]byte, error) {\n\t\tSize(pb)\n\t\treturn nil, nil\n\t})\n}\n\nfunc newOf(pb Message) Message {\n\tin := reflect.ValueOf(pb)\n\tif in.IsNil() {\n\t\treturn pb\n\t}\n\treturn reflect.New(in.Type().Elem()).Interface().(Message)\n}\n\nfunc benchmarkUnmarshal(b *testing.B, pb Message, unmarshal func([]byte, Message) error) {\n\td, _ := Marshal(pb)\n\tb.SetBytes(int64(len(d)))\n\tpbd := newOf(pb)\n\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tunmarshal(d, pbd)\n\t}\n}\n\nfunc benchmarkBufferUnmarshal(b *testing.B, pb Message) {\n\tp := NewBuffer(nil)\n\tbenchmarkUnmarshal(b, pb, func(d []byte, pb0 Message) error {\n\t\tp.SetBuf(d)\n\t\treturn p.Unmarshal(pb0)\n\t})\n}\n\n// Benchmark{Marshal,BufferMarshal,Size,Unmarshal,BufferUnmarshal}{,Bytes}\n\nfunc BenchmarkMarshal(b *testing.B) {\n\tbenchmarkMarshal(b, testMsg(), Marshal)\n}\n\nfunc BenchmarkBufferMarshal(b *testing.B) {\n\tbenchmarkBufferMarshal(b, testMsg())\n}\n\nfunc BenchmarkSize(b *testing.B) {\n\tbenchmarkSize(b, testMsg())\n}\n\nfunc BenchmarkUnmarshal(b *testing.B) {\n\tbenchmarkUnmarshal(b, testMsg(), Unmarshal)\n}\n\nfunc BenchmarkBufferUnmarshal(b *testing.B) {\n\tbenchmarkBufferUnmarshal(b, testMsg())\n}\n\nfunc BenchmarkMarshalBytes(b *testing.B) {\n\tbenchmarkMarshal(b, bytesMsg(), Marshal)\n}\n\nfunc BenchmarkBufferMarshalBytes(b *testing.B) {\n\tbenchmarkBufferMarshal(b, bytesMsg())\n}\n\nfunc BenchmarkSizeBytes(b *testing.B) {\n\tbenchmarkSize(b, bytesMsg())\n}\n\nfunc BenchmarkUnmarshalBytes(b *testing.B) {\n\tbenchmarkUnmarshal(b, bytesMsg(), Unmarshal)\n}\n\nfunc BenchmarkBufferUnmarshalBytes(b *testing.B) {\n\tbenchmarkBufferUnmarshal(b, bytesMsg())\n}\n\nfunc BenchmarkUnmarshalUnrecognizedFields(b *testing.B) {\n\tb.StopTimer()\n\tpb := initGoTestField()\n\tskip := &GoSkipTest{\n\t\tSkipInt32:   Int32(32),\n\t\tSkipFixed32: Uint32(3232),\n\t\tSkipFixed64: Uint64(6464),\n\t\tSkipString:  String(\"skipper\"),\n\t\tSkipgroup: &GoSkipTest_SkipGroup{\n\t\t\tGroupInt32:  Int32(75),\n\t\t\tGroupString: String(\"wxyz\"),\n\t\t},\n\t}\n\n\tpbd := new(GoTestField)\n\tp := NewBuffer(nil)\n\tp.Marshal(pb)\n\tp.Marshal(skip)\n\tp2 := NewBuffer(nil)\n\n\tb.StartTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tp2.SetBuf(p.Bytes())\n\t\tp2.Unmarshal(pbd)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/any_test.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2016 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto_test\n\nimport (\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/golang/protobuf/proto\"\n\n\tpb \"github.com/golang/protobuf/proto/proto3_proto\"\n\ttestpb \"github.com/golang/protobuf/proto/testdata\"\n\tanypb \"github.com/golang/protobuf/ptypes/any\"\n)\n\nvar (\n\texpandedMarshaler        = proto.TextMarshaler{ExpandAny: true}\n\texpandedCompactMarshaler = proto.TextMarshaler{Compact: true, ExpandAny: true}\n)\n\n// anyEqual reports whether two messages which may be google.protobuf.Any or may\n// contain google.protobuf.Any fields are equal. We can't use proto.Equal for\n// comparison, because semantically equivalent messages may be marshaled to\n// binary in different tag order. Instead, trust that TextMarshaler with\n// ExpandAny option works and compare the text marshaling results.\nfunc anyEqual(got, want proto.Message) bool {\n\t// if messages are proto.Equal, no need to marshal.\n\tif proto.Equal(got, want) {\n\t\treturn true\n\t}\n\tg := expandedMarshaler.Text(got)\n\tw := expandedMarshaler.Text(want)\n\treturn g == w\n}\n\ntype golden struct {\n\tm    proto.Message\n\tt, c string\n}\n\nvar goldenMessages = makeGolden()\n\nfunc makeGolden() []golden {\n\tnested := &pb.Nested{Bunny: \"Monty\"}\n\tnb, err := proto.Marshal(nested)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tm1 := &pb.Message{\n\t\tName:        \"David\",\n\t\tResultCount: 47,\n\t\tAnything:    &anypb.Any{TypeUrl: \"type.googleapis.com/\" + proto.MessageName(nested), Value: nb},\n\t}\n\tm2 := &pb.Message{\n\t\tName:        \"David\",\n\t\tResultCount: 47,\n\t\tAnything:    &anypb.Any{TypeUrl: \"http://[::1]/type.googleapis.com/\" + proto.MessageName(nested), Value: nb},\n\t}\n\tm3 := &pb.Message{\n\t\tName:        \"David\",\n\t\tResultCount: 47,\n\t\tAnything:    &anypb.Any{TypeUrl: `type.googleapis.com/\"/` + proto.MessageName(nested), Value: nb},\n\t}\n\tm4 := &pb.Message{\n\t\tName:        \"David\",\n\t\tResultCount: 47,\n\t\tAnything:    &anypb.Any{TypeUrl: \"type.googleapis.com/a/path/\" + proto.MessageName(nested), Value: nb},\n\t}\n\tm5 := &anypb.Any{TypeUrl: \"type.googleapis.com/\" + proto.MessageName(nested), Value: nb}\n\n\tany1 := &testpb.MyMessage{Count: proto.Int32(47), Name: proto.String(\"David\")}\n\tproto.SetExtension(any1, testpb.E_Ext_More, &testpb.Ext{Data: proto.String(\"foo\")})\n\tproto.SetExtension(any1, testpb.E_Ext_Text, proto.String(\"bar\"))\n\tany1b, err := proto.Marshal(any1)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tany2 := &testpb.MyMessage{Count: proto.Int32(42), Bikeshed: testpb.MyMessage_GREEN.Enum(), RepBytes: [][]byte{[]byte(\"roboto\")}}\n\tproto.SetExtension(any2, testpb.E_Ext_More, &testpb.Ext{Data: proto.String(\"baz\")})\n\tany2b, err := proto.Marshal(any2)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tm6 := &pb.Message{\n\t\tName:        \"David\",\n\t\tResultCount: 47,\n\t\tAnything:    &anypb.Any{TypeUrl: \"type.googleapis.com/\" + proto.MessageName(any1), Value: any1b},\n\t\tManyThings: []*anypb.Any{\n\t\t\t&anypb.Any{TypeUrl: \"type.googleapis.com/\" + proto.MessageName(any2), Value: any2b},\n\t\t\t&anypb.Any{TypeUrl: \"type.googleapis.com/\" + proto.MessageName(any1), Value: any1b},\n\t\t},\n\t}\n\n\tconst (\n\t\tm1Golden = `\nname: \"David\"\nresult_count: 47\nanything: <\n  [type.googleapis.com/proto3_proto.Nested]: <\n    bunny: \"Monty\"\n  >\n>\n`\n\t\tm2Golden = `\nname: \"David\"\nresult_count: 47\nanything: <\n  [\"http://[::1]/type.googleapis.com/proto3_proto.Nested\"]: <\n    bunny: \"Monty\"\n  >\n>\n`\n\t\tm3Golden = `\nname: \"David\"\nresult_count: 47\nanything: <\n  [\"type.googleapis.com/\\\"/proto3_proto.Nested\"]: <\n    bunny: \"Monty\"\n  >\n>\n`\n\t\tm4Golden = `\nname: \"David\"\nresult_count: 47\nanything: <\n  [type.googleapis.com/a/path/proto3_proto.Nested]: <\n    bunny: \"Monty\"\n  >\n>\n`\n\t\tm5Golden = `\n[type.googleapis.com/proto3_proto.Nested]: <\n  bunny: \"Monty\"\n>\n`\n\t\tm6Golden = `\nname: \"David\"\nresult_count: 47\nanything: <\n  [type.googleapis.com/testdata.MyMessage]: <\n    count: 47\n    name: \"David\"\n    [testdata.Ext.more]: <\n      data: \"foo\"\n    >\n    [testdata.Ext.text]: \"bar\"\n  >\n>\nmany_things: <\n  [type.googleapis.com/testdata.MyMessage]: <\n    count: 42\n    bikeshed: GREEN\n    rep_bytes: \"roboto\"\n    [testdata.Ext.more]: <\n      data: \"baz\"\n    >\n  >\n>\nmany_things: <\n  [type.googleapis.com/testdata.MyMessage]: <\n    count: 47\n    name: \"David\"\n    [testdata.Ext.more]: <\n      data: \"foo\"\n    >\n    [testdata.Ext.text]: \"bar\"\n  >\n>\n`\n\t)\n\treturn []golden{\n\t\t{m1, strings.TrimSpace(m1Golden) + \"\\n\", strings.TrimSpace(compact(m1Golden)) + \" \"},\n\t\t{m2, strings.TrimSpace(m2Golden) + \"\\n\", strings.TrimSpace(compact(m2Golden)) + \" \"},\n\t\t{m3, strings.TrimSpace(m3Golden) + \"\\n\", strings.TrimSpace(compact(m3Golden)) + \" \"},\n\t\t{m4, strings.TrimSpace(m4Golden) + \"\\n\", strings.TrimSpace(compact(m4Golden)) + \" \"},\n\t\t{m5, strings.TrimSpace(m5Golden) + \"\\n\", strings.TrimSpace(compact(m5Golden)) + \" \"},\n\t\t{m6, strings.TrimSpace(m6Golden) + \"\\n\", strings.TrimSpace(compact(m6Golden)) + \" \"},\n\t}\n}\n\nfunc TestMarshalGolden(t *testing.T) {\n\tfor _, tt := range goldenMessages {\n\t\tif got, want := expandedMarshaler.Text(tt.m), tt.t; got != want {\n\t\t\tt.Errorf(\"message %v: got:\\n%s\\nwant:\\n%s\", tt.m, got, want)\n\t\t}\n\t\tif got, want := expandedCompactMarshaler.Text(tt.m), tt.c; got != want {\n\t\t\tt.Errorf(\"message %v: got:\\n`%s`\\nwant:\\n`%s`\", tt.m, got, want)\n\t\t}\n\t}\n}\n\nfunc TestUnmarshalGolden(t *testing.T) {\n\tfor _, tt := range goldenMessages {\n\t\twant := tt.m\n\t\tgot := proto.Clone(tt.m)\n\t\tgot.Reset()\n\t\tif err := proto.UnmarshalText(tt.t, got); err != nil {\n\t\t\tt.Errorf(\"failed to unmarshal\\n%s\\nerror: %v\", tt.t, err)\n\t\t}\n\t\tif !anyEqual(got, want) {\n\t\t\tt.Errorf(\"message:\\n%s\\ngot:\\n%s\\nwant:\\n%s\", tt.t, got, want)\n\t\t}\n\t\tgot.Reset()\n\t\tif err := proto.UnmarshalText(tt.c, got); err != nil {\n\t\t\tt.Errorf(\"failed to unmarshal\\n%s\\nerror: %v\", tt.c, err)\n\t\t}\n\t\tif !anyEqual(got, want) {\n\t\t\tt.Errorf(\"message:\\n%s\\ngot:\\n%s\\nwant:\\n%s\", tt.c, got, want)\n\t\t}\n\t}\n}\n\nfunc TestMarshalUnknownAny(t *testing.T) {\n\tm := &pb.Message{\n\t\tAnything: &anypb.Any{\n\t\t\tTypeUrl: \"foo\",\n\t\t\tValue:   []byte(\"bar\"),\n\t\t},\n\t}\n\twant := `anything: <\n  type_url: \"foo\"\n  value: \"bar\"\n>\n`\n\tgot := expandedMarshaler.Text(m)\n\tif got != want {\n\t\tt.Errorf(\"got\\n`%s`\\nwant\\n`%s`\", got, want)\n\t}\n}\n\nfunc TestAmbiguousAny(t *testing.T) {\n\tpb := &anypb.Any{}\n\terr := proto.UnmarshalText(`\n\ttype_url: \"ttt/proto3_proto.Nested\"\n\tvalue: \"\\n\\x05Monty\"\n\t`, pb)\n\tt.Logf(\"result: %v (error: %v)\", expandedMarshaler.Text(pb), err)\n\tif err != nil {\n\t\tt.Errorf(\"failed to parse ambiguous Any message: %v\", err)\n\t}\n}\n\nfunc TestUnmarshalOverwriteAny(t *testing.T) {\n\tpb := &anypb.Any{}\n\terr := proto.UnmarshalText(`\n  [type.googleapis.com/a/path/proto3_proto.Nested]: <\n    bunny: \"Monty\"\n  >\n  [type.googleapis.com/a/path/proto3_proto.Nested]: <\n    bunny: \"Rabbit of Caerbannog\"\n  >\n\t`, pb)\n\twant := `line 7: Any message unpacked multiple times, or \"type_url\" already set`\n\tif err.Error() != want {\n\t\tt.Errorf(\"incorrect error.\\nHave: %v\\nWant: %v\", err.Error(), want)\n\t}\n}\n\nfunc TestUnmarshalAnyMixAndMatch(t *testing.T) {\n\tpb := &anypb.Any{}\n\terr := proto.UnmarshalText(`\n\tvalue: \"\\n\\x05Monty\"\n  [type.googleapis.com/a/path/proto3_proto.Nested]: <\n    bunny: \"Rabbit of Caerbannog\"\n  >\n\t`, pb)\n\twant := `line 5: Any message unpacked multiple times, or \"value\" already set`\n\tif err.Error() != want {\n\t\tt.Errorf(\"incorrect error.\\nHave: %v\\nWant: %v\", err.Error(), want)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/clone.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2011 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Protocol buffer deep copy and merge.\n// TODO: RawMessage.\n\npackage proto\n\nimport (\n\t\"log\"\n\t\"reflect\"\n\t\"strings\"\n)\n\n// Clone returns a deep copy of a protocol buffer.\nfunc Clone(pb Message) Message {\n\tin := reflect.ValueOf(pb)\n\tif in.IsNil() {\n\t\treturn pb\n\t}\n\n\tout := reflect.New(in.Type().Elem())\n\t// out is empty so a merge is a deep copy.\n\tmergeStruct(out.Elem(), in.Elem())\n\treturn out.Interface().(Message)\n}\n\n// Merge merges src into dst.\n// Required and optional fields that are set in src will be set to that value in dst.\n// Elements of repeated fields will be appended.\n// Merge panics if src and dst are not the same type, or if dst is nil.\nfunc Merge(dst, src Message) {\n\tin := reflect.ValueOf(src)\n\tout := reflect.ValueOf(dst)\n\tif out.IsNil() {\n\t\tpanic(\"proto: nil destination\")\n\t}\n\tif in.Type() != out.Type() {\n\t\t// Explicit test prior to mergeStruct so that mistyped nils will fail\n\t\tpanic(\"proto: type mismatch\")\n\t}\n\tif in.IsNil() {\n\t\t// Merging nil into non-nil is a quiet no-op\n\t\treturn\n\t}\n\tmergeStruct(out.Elem(), in.Elem())\n}\n\nfunc mergeStruct(out, in reflect.Value) {\n\tsprop := GetProperties(in.Type())\n\tfor i := 0; i < in.NumField(); i++ {\n\t\tf := in.Type().Field(i)\n\t\tif strings.HasPrefix(f.Name, \"XXX_\") {\n\t\t\tcontinue\n\t\t}\n\t\tmergeAny(out.Field(i), in.Field(i), false, sprop.Prop[i])\n\t}\n\n\tif emIn, ok := extendable(in.Addr().Interface()); ok {\n\t\temOut, _ := extendable(out.Addr().Interface())\n\t\tmIn, muIn := emIn.extensionsRead()\n\t\tif mIn != nil {\n\t\t\tmOut := emOut.extensionsWrite()\n\t\t\tmuIn.Lock()\n\t\t\tmergeExtension(mOut, mIn)\n\t\t\tmuIn.Unlock()\n\t\t}\n\t}\n\n\tuf := in.FieldByName(\"XXX_unrecognized\")\n\tif !uf.IsValid() {\n\t\treturn\n\t}\n\tuin := uf.Bytes()\n\tif len(uin) > 0 {\n\t\tout.FieldByName(\"XXX_unrecognized\").SetBytes(append([]byte(nil), uin...))\n\t}\n}\n\n// mergeAny performs a merge between two values of the same type.\n// viaPtr indicates whether the values were indirected through a pointer (implying proto2).\n// prop is set if this is a struct field (it may be nil).\nfunc mergeAny(out, in reflect.Value, viaPtr bool, prop *Properties) {\n\tif in.Type() == protoMessageType {\n\t\tif !in.IsNil() {\n\t\t\tif out.IsNil() {\n\t\t\t\tout.Set(reflect.ValueOf(Clone(in.Interface().(Message))))\n\t\t\t} else {\n\t\t\t\tMerge(out.Interface().(Message), in.Interface().(Message))\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tswitch in.Kind() {\n\tcase reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64,\n\t\treflect.String, reflect.Uint32, reflect.Uint64:\n\t\tif !viaPtr && isProto3Zero(in) {\n\t\t\treturn\n\t\t}\n\t\tout.Set(in)\n\tcase reflect.Interface:\n\t\t// Probably a oneof field; copy non-nil values.\n\t\tif in.IsNil() {\n\t\t\treturn\n\t\t}\n\t\t// Allocate destination if it is not set, or set to a different type.\n\t\t// Otherwise we will merge as normal.\n\t\tif out.IsNil() || out.Elem().Type() != in.Elem().Type() {\n\t\t\tout.Set(reflect.New(in.Elem().Elem().Type())) // interface -> *T -> T -> new(T)\n\t\t}\n\t\tmergeAny(out.Elem(), in.Elem(), false, nil)\n\tcase reflect.Map:\n\t\tif in.Len() == 0 {\n\t\t\treturn\n\t\t}\n\t\tif out.IsNil() {\n\t\t\tout.Set(reflect.MakeMap(in.Type()))\n\t\t}\n\t\t// For maps with value types of *T or []byte we need to deep copy each value.\n\t\telemKind := in.Type().Elem().Kind()\n\t\tfor _, key := range in.MapKeys() {\n\t\t\tvar val reflect.Value\n\t\t\tswitch elemKind {\n\t\t\tcase reflect.Ptr:\n\t\t\t\tval = reflect.New(in.Type().Elem().Elem())\n\t\t\t\tmergeAny(val, in.MapIndex(key), false, nil)\n\t\t\tcase reflect.Slice:\n\t\t\t\tval = in.MapIndex(key)\n\t\t\t\tval = reflect.ValueOf(append([]byte{}, val.Bytes()...))\n\t\t\tdefault:\n\t\t\t\tval = in.MapIndex(key)\n\t\t\t}\n\t\t\tout.SetMapIndex(key, val)\n\t\t}\n\tcase reflect.Ptr:\n\t\tif in.IsNil() {\n\t\t\treturn\n\t\t}\n\t\tif out.IsNil() {\n\t\t\tout.Set(reflect.New(in.Elem().Type()))\n\t\t}\n\t\tmergeAny(out.Elem(), in.Elem(), true, nil)\n\tcase reflect.Slice:\n\t\tif in.IsNil() {\n\t\t\treturn\n\t\t}\n\t\tif in.Type().Elem().Kind() == reflect.Uint8 {\n\t\t\t// []byte is a scalar bytes field, not a repeated field.\n\n\t\t\t// Edge case: if this is in a proto3 message, a zero length\n\t\t\t// bytes field is considered the zero value, and should not\n\t\t\t// be merged.\n\t\t\tif prop != nil && prop.proto3 && in.Len() == 0 {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Make a deep copy.\n\t\t\t// Append to []byte{} instead of []byte(nil) so that we never end up\n\t\t\t// with a nil result.\n\t\t\tout.SetBytes(append([]byte{}, in.Bytes()...))\n\t\t\treturn\n\t\t}\n\t\tn := in.Len()\n\t\tif out.IsNil() {\n\t\t\tout.Set(reflect.MakeSlice(in.Type(), 0, n))\n\t\t}\n\t\tswitch in.Type().Elem().Kind() {\n\t\tcase reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64,\n\t\t\treflect.String, reflect.Uint32, reflect.Uint64:\n\t\t\tout.Set(reflect.AppendSlice(out, in))\n\t\tdefault:\n\t\t\tfor i := 0; i < n; i++ {\n\t\t\t\tx := reflect.Indirect(reflect.New(in.Type().Elem()))\n\t\t\t\tmergeAny(x, in.Index(i), false, nil)\n\t\t\t\tout.Set(reflect.Append(out, x))\n\t\t\t}\n\t\t}\n\tcase reflect.Struct:\n\t\tmergeStruct(out, in)\n\tdefault:\n\t\t// unknown type, so not a protocol buffer\n\t\tlog.Printf(\"proto: don't know how to copy %v\", in)\n\t}\n}\n\nfunc mergeExtension(out, in map[int32]Extension) {\n\tfor extNum, eIn := range in {\n\t\teOut := Extension{desc: eIn.desc}\n\t\tif eIn.value != nil {\n\t\t\tv := reflect.New(reflect.TypeOf(eIn.value)).Elem()\n\t\t\tmergeAny(v, reflect.ValueOf(eIn.value), false, nil)\n\t\t\teOut.value = v.Interface()\n\t\t}\n\t\tif eIn.enc != nil {\n\t\t\teOut.enc = make([]byte, len(eIn.enc))\n\t\t\tcopy(eOut.enc, eIn.enc)\n\t\t}\n\n\t\tout[extNum] = eOut\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/clone_test.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2011 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto_test\n\nimport (\n\t\"testing\"\n\n\t\"github.com/golang/protobuf/proto\"\n\n\tproto3pb \"github.com/golang/protobuf/proto/proto3_proto\"\n\tpb \"github.com/golang/protobuf/proto/testdata\"\n)\n\nvar cloneTestMessage = &pb.MyMessage{\n\tCount: proto.Int32(42),\n\tName:  proto.String(\"Dave\"),\n\tPet:   []string{\"bunny\", \"kitty\", \"horsey\"},\n\tInner: &pb.InnerMessage{\n\t\tHost:      proto.String(\"niles\"),\n\t\tPort:      proto.Int32(9099),\n\t\tConnected: proto.Bool(true),\n\t},\n\tOthers: []*pb.OtherMessage{\n\t\t{\n\t\t\tValue: []byte(\"some bytes\"),\n\t\t},\n\t},\n\tSomegroup: &pb.MyMessage_SomeGroup{\n\t\tGroupField: proto.Int32(6),\n\t},\n\tRepBytes: [][]byte{[]byte(\"sham\"), []byte(\"wow\")},\n}\n\nfunc init() {\n\text := &pb.Ext{\n\t\tData: proto.String(\"extension\"),\n\t}\n\tif err := proto.SetExtension(cloneTestMessage, pb.E_Ext_More, ext); err != nil {\n\t\tpanic(\"SetExtension: \" + err.Error())\n\t}\n}\n\nfunc TestClone(t *testing.T) {\n\tm := proto.Clone(cloneTestMessage).(*pb.MyMessage)\n\tif !proto.Equal(m, cloneTestMessage) {\n\t\tt.Errorf(\"Clone(%v) = %v\", cloneTestMessage, m)\n\t}\n\n\t// Verify it was a deep copy.\n\t*m.Inner.Port++\n\tif proto.Equal(m, cloneTestMessage) {\n\t\tt.Error(\"Mutating clone changed the original\")\n\t}\n\t// Byte fields and repeated fields should be copied.\n\tif &m.Pet[0] == &cloneTestMessage.Pet[0] {\n\t\tt.Error(\"Pet: repeated field not copied\")\n\t}\n\tif &m.Others[0] == &cloneTestMessage.Others[0] {\n\t\tt.Error(\"Others: repeated field not copied\")\n\t}\n\tif &m.Others[0].Value[0] == &cloneTestMessage.Others[0].Value[0] {\n\t\tt.Error(\"Others[0].Value: bytes field not copied\")\n\t}\n\tif &m.RepBytes[0] == &cloneTestMessage.RepBytes[0] {\n\t\tt.Error(\"RepBytes: repeated field not copied\")\n\t}\n\tif &m.RepBytes[0][0] == &cloneTestMessage.RepBytes[0][0] {\n\t\tt.Error(\"RepBytes[0]: bytes field not copied\")\n\t}\n}\n\nfunc TestCloneNil(t *testing.T) {\n\tvar m *pb.MyMessage\n\tif c := proto.Clone(m); !proto.Equal(m, c) {\n\t\tt.Errorf(\"Clone(%v) = %v\", m, c)\n\t}\n}\n\nvar mergeTests = []struct {\n\tsrc, dst, want proto.Message\n}{\n\t{\n\t\tsrc: &pb.MyMessage{\n\t\t\tCount: proto.Int32(42),\n\t\t},\n\t\tdst: &pb.MyMessage{\n\t\t\tName: proto.String(\"Dave\"),\n\t\t},\n\t\twant: &pb.MyMessage{\n\t\t\tCount: proto.Int32(42),\n\t\t\tName:  proto.String(\"Dave\"),\n\t\t},\n\t},\n\t{\n\t\tsrc: &pb.MyMessage{\n\t\t\tInner: &pb.InnerMessage{\n\t\t\t\tHost:      proto.String(\"hey\"),\n\t\t\t\tConnected: proto.Bool(true),\n\t\t\t},\n\t\t\tPet: []string{\"horsey\"},\n\t\t\tOthers: []*pb.OtherMessage{\n\t\t\t\t{\n\t\t\t\t\tValue: []byte(\"some bytes\"),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tdst: &pb.MyMessage{\n\t\t\tInner: &pb.InnerMessage{\n\t\t\t\tHost: proto.String(\"niles\"),\n\t\t\t\tPort: proto.Int32(9099),\n\t\t\t},\n\t\t\tPet: []string{\"bunny\", \"kitty\"},\n\t\t\tOthers: []*pb.OtherMessage{\n\t\t\t\t{\n\t\t\t\t\tKey: proto.Int64(31415926535),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t// Explicitly test a src=nil field\n\t\t\t\t\tInner: nil,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\twant: &pb.MyMessage{\n\t\t\tInner: &pb.InnerMessage{\n\t\t\t\tHost:      proto.String(\"hey\"),\n\t\t\t\tConnected: proto.Bool(true),\n\t\t\t\tPort:      proto.Int32(9099),\n\t\t\t},\n\t\t\tPet: []string{\"bunny\", \"kitty\", \"horsey\"},\n\t\t\tOthers: []*pb.OtherMessage{\n\t\t\t\t{\n\t\t\t\t\tKey: proto.Int64(31415926535),\n\t\t\t\t},\n\t\t\t\t{},\n\t\t\t\t{\n\t\t\t\t\tValue: []byte(\"some bytes\"),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tsrc: &pb.MyMessage{\n\t\t\tRepBytes: [][]byte{[]byte(\"wow\")},\n\t\t},\n\t\tdst: &pb.MyMessage{\n\t\t\tSomegroup: &pb.MyMessage_SomeGroup{\n\t\t\t\tGroupField: proto.Int32(6),\n\t\t\t},\n\t\t\tRepBytes: [][]byte{[]byte(\"sham\")},\n\t\t},\n\t\twant: &pb.MyMessage{\n\t\t\tSomegroup: &pb.MyMessage_SomeGroup{\n\t\t\t\tGroupField: proto.Int32(6),\n\t\t\t},\n\t\t\tRepBytes: [][]byte{[]byte(\"sham\"), []byte(\"wow\")},\n\t\t},\n\t},\n\t// Check that a scalar bytes field replaces rather than appends.\n\t{\n\t\tsrc:  &pb.OtherMessage{Value: []byte(\"foo\")},\n\t\tdst:  &pb.OtherMessage{Value: []byte(\"bar\")},\n\t\twant: &pb.OtherMessage{Value: []byte(\"foo\")},\n\t},\n\t{\n\t\tsrc: &pb.MessageWithMap{\n\t\t\tNameMapping: map[int32]string{6: \"Nigel\"},\n\t\t\tMsgMapping: map[int64]*pb.FloatingPoint{\n\t\t\t\t0x4001: &pb.FloatingPoint{F: proto.Float64(2.0)},\n\t\t\t\t0x4002: &pb.FloatingPoint{\n\t\t\t\t\tF: proto.Float64(2.0),\n\t\t\t\t},\n\t\t\t},\n\t\t\tByteMapping: map[bool][]byte{true: []byte(\"wowsa\")},\n\t\t},\n\t\tdst: &pb.MessageWithMap{\n\t\t\tNameMapping: map[int32]string{\n\t\t\t\t6: \"Bruce\", // should be overwritten\n\t\t\t\t7: \"Andrew\",\n\t\t\t},\n\t\t\tMsgMapping: map[int64]*pb.FloatingPoint{\n\t\t\t\t0x4002: &pb.FloatingPoint{\n\t\t\t\t\tF:     proto.Float64(3.0),\n\t\t\t\t\tExact: proto.Bool(true),\n\t\t\t\t}, // the entire message should be overwritten\n\t\t\t},\n\t\t},\n\t\twant: &pb.MessageWithMap{\n\t\t\tNameMapping: map[int32]string{\n\t\t\t\t6: \"Nigel\",\n\t\t\t\t7: \"Andrew\",\n\t\t\t},\n\t\t\tMsgMapping: map[int64]*pb.FloatingPoint{\n\t\t\t\t0x4001: &pb.FloatingPoint{F: proto.Float64(2.0)},\n\t\t\t\t0x4002: &pb.FloatingPoint{\n\t\t\t\t\tF: proto.Float64(2.0),\n\t\t\t\t},\n\t\t\t},\n\t\t\tByteMapping: map[bool][]byte{true: []byte(\"wowsa\")},\n\t\t},\n\t},\n\t// proto3 shouldn't merge zero values,\n\t// in the same way that proto2 shouldn't merge nils.\n\t{\n\t\tsrc: &proto3pb.Message{\n\t\t\tName: \"Aaron\",\n\t\t\tData: []byte(\"\"), // zero value, but not nil\n\t\t},\n\t\tdst: &proto3pb.Message{\n\t\t\tHeightInCm: 176,\n\t\t\tData:       []byte(\"texas!\"),\n\t\t},\n\t\twant: &proto3pb.Message{\n\t\t\tName:       \"Aaron\",\n\t\t\tHeightInCm: 176,\n\t\t\tData:       []byte(\"texas!\"),\n\t\t},\n\t},\n\t// Oneof fields should merge by assignment.\n\t{\n\t\tsrc: &pb.Communique{\n\t\t\tUnion: &pb.Communique_Number{41},\n\t\t},\n\t\tdst: &pb.Communique{\n\t\t\tUnion: &pb.Communique_Name{\"Bobby Tables\"},\n\t\t},\n\t\twant: &pb.Communique{\n\t\t\tUnion: &pb.Communique_Number{41},\n\t\t},\n\t},\n\t// Oneof nil is the same as not set.\n\t{\n\t\tsrc: &pb.Communique{},\n\t\tdst: &pb.Communique{\n\t\t\tUnion: &pb.Communique_Name{\"Bobby Tables\"},\n\t\t},\n\t\twant: &pb.Communique{\n\t\t\tUnion: &pb.Communique_Name{\"Bobby Tables\"},\n\t\t},\n\t},\n\t{\n\t\tsrc: &proto3pb.Message{\n\t\t\tTerrain: map[string]*proto3pb.Nested{\n\t\t\t\t\"kay_a\": &proto3pb.Nested{Cute: true},      // replace\n\t\t\t\t\"kay_b\": &proto3pb.Nested{Bunny: \"rabbit\"}, // insert\n\t\t\t},\n\t\t},\n\t\tdst: &proto3pb.Message{\n\t\t\tTerrain: map[string]*proto3pb.Nested{\n\t\t\t\t\"kay_a\": &proto3pb.Nested{Bunny: \"lost\"},  // replaced\n\t\t\t\t\"kay_c\": &proto3pb.Nested{Bunny: \"bunny\"}, // keep\n\t\t\t},\n\t\t},\n\t\twant: &proto3pb.Message{\n\t\t\tTerrain: map[string]*proto3pb.Nested{\n\t\t\t\t\"kay_a\": &proto3pb.Nested{Cute: true},\n\t\t\t\t\"kay_b\": &proto3pb.Nested{Bunny: \"rabbit\"},\n\t\t\t\t\"kay_c\": &proto3pb.Nested{Bunny: \"bunny\"},\n\t\t\t},\n\t\t},\n\t},\n}\n\nfunc TestMerge(t *testing.T) {\n\tfor _, m := range mergeTests {\n\t\tgot := proto.Clone(m.dst)\n\t\tproto.Merge(got, m.src)\n\t\tif !proto.Equal(got, m.want) {\n\t\t\tt.Errorf(\"Merge(%v, %v)\\n got %v\\nwant %v\\n\", m.dst, m.src, got, m.want)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/decode.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2010 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto\n\n/*\n * Routines for decoding protocol buffer data to construct in-memory representations.\n */\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"reflect\"\n)\n\n// errOverflow is returned when an integer is too large to be represented.\nvar errOverflow = errors.New(\"proto: integer overflow\")\n\n// ErrInternalBadWireType is returned by generated code when an incorrect\n// wire type is encountered. It does not get returned to user code.\nvar ErrInternalBadWireType = errors.New(\"proto: internal error: bad wiretype for oneof\")\n\n// The fundamental decoders that interpret bytes on the wire.\n// Those that take integer types all return uint64 and are\n// therefore of type valueDecoder.\n\n// DecodeVarint reads a varint-encoded integer from the slice.\n// It returns the integer and the number of bytes consumed, or\n// zero if there is not enough.\n// This is the format for the\n// int32, int64, uint32, uint64, bool, and enum\n// protocol buffer types.\nfunc DecodeVarint(buf []byte) (x uint64, n int) {\n\tfor shift := uint(0); shift < 64; shift += 7 {\n\t\tif n >= len(buf) {\n\t\t\treturn 0, 0\n\t\t}\n\t\tb := uint64(buf[n])\n\t\tn++\n\t\tx |= (b & 0x7F) << shift\n\t\tif (b & 0x80) == 0 {\n\t\t\treturn x, n\n\t\t}\n\t}\n\n\t// The number is too large to represent in a 64-bit value.\n\treturn 0, 0\n}\n\nfunc (p *Buffer) decodeVarintSlow() (x uint64, err error) {\n\ti := p.index\n\tl := len(p.buf)\n\n\tfor shift := uint(0); shift < 64; shift += 7 {\n\t\tif i >= l {\n\t\t\terr = io.ErrUnexpectedEOF\n\t\t\treturn\n\t\t}\n\t\tb := p.buf[i]\n\t\ti++\n\t\tx |= (uint64(b) & 0x7F) << shift\n\t\tif b < 0x80 {\n\t\t\tp.index = i\n\t\t\treturn\n\t\t}\n\t}\n\n\t// The number is too large to represent in a 64-bit value.\n\terr = errOverflow\n\treturn\n}\n\n// DecodeVarint reads a varint-encoded integer from the Buffer.\n// This is the format for the\n// int32, int64, uint32, uint64, bool, and enum\n// protocol buffer types.\nfunc (p *Buffer) DecodeVarint() (x uint64, err error) {\n\ti := p.index\n\tbuf := p.buf\n\n\tif i >= len(buf) {\n\t\treturn 0, io.ErrUnexpectedEOF\n\t} else if buf[i] < 0x80 {\n\t\tp.index++\n\t\treturn uint64(buf[i]), nil\n\t} else if len(buf)-i < 10 {\n\t\treturn p.decodeVarintSlow()\n\t}\n\n\tvar b uint64\n\t// we already checked the first byte\n\tx = uint64(buf[i]) - 0x80\n\ti++\n\n\tb = uint64(buf[i])\n\ti++\n\tx += b << 7\n\tif b&0x80 == 0 {\n\t\tgoto done\n\t}\n\tx -= 0x80 << 7\n\n\tb = uint64(buf[i])\n\ti++\n\tx += b << 14\n\tif b&0x80 == 0 {\n\t\tgoto done\n\t}\n\tx -= 0x80 << 14\n\n\tb = uint64(buf[i])\n\ti++\n\tx += b << 21\n\tif b&0x80 == 0 {\n\t\tgoto done\n\t}\n\tx -= 0x80 << 21\n\n\tb = uint64(buf[i])\n\ti++\n\tx += b << 28\n\tif b&0x80 == 0 {\n\t\tgoto done\n\t}\n\tx -= 0x80 << 28\n\n\tb = uint64(buf[i])\n\ti++\n\tx += b << 35\n\tif b&0x80 == 0 {\n\t\tgoto done\n\t}\n\tx -= 0x80 << 35\n\n\tb = uint64(buf[i])\n\ti++\n\tx += b << 42\n\tif b&0x80 == 0 {\n\t\tgoto done\n\t}\n\tx -= 0x80 << 42\n\n\tb = uint64(buf[i])\n\ti++\n\tx += b << 49\n\tif b&0x80 == 0 {\n\t\tgoto done\n\t}\n\tx -= 0x80 << 49\n\n\tb = uint64(buf[i])\n\ti++\n\tx += b << 56\n\tif b&0x80 == 0 {\n\t\tgoto done\n\t}\n\tx -= 0x80 << 56\n\n\tb = uint64(buf[i])\n\ti++\n\tx += b << 63\n\tif b&0x80 == 0 {\n\t\tgoto done\n\t}\n\t// x -= 0x80 << 63 // Always zero.\n\n\treturn 0, errOverflow\n\ndone:\n\tp.index = i\n\treturn x, nil\n}\n\n// DecodeFixed64 reads a 64-bit integer from the Buffer.\n// This is the format for the\n// fixed64, sfixed64, and double protocol buffer types.\nfunc (p *Buffer) DecodeFixed64() (x uint64, err error) {\n\t// x, err already 0\n\ti := p.index + 8\n\tif i < 0 || i > len(p.buf) {\n\t\terr = io.ErrUnexpectedEOF\n\t\treturn\n\t}\n\tp.index = i\n\n\tx = uint64(p.buf[i-8])\n\tx |= uint64(p.buf[i-7]) << 8\n\tx |= uint64(p.buf[i-6]) << 16\n\tx |= uint64(p.buf[i-5]) << 24\n\tx |= uint64(p.buf[i-4]) << 32\n\tx |= uint64(p.buf[i-3]) << 40\n\tx |= uint64(p.buf[i-2]) << 48\n\tx |= uint64(p.buf[i-1]) << 56\n\treturn\n}\n\n// DecodeFixed32 reads a 32-bit integer from the Buffer.\n// This is the format for the\n// fixed32, sfixed32, and float protocol buffer types.\nfunc (p *Buffer) DecodeFixed32() (x uint64, err error) {\n\t// x, err already 0\n\ti := p.index + 4\n\tif i < 0 || i > len(p.buf) {\n\t\terr = io.ErrUnexpectedEOF\n\t\treturn\n\t}\n\tp.index = i\n\n\tx = uint64(p.buf[i-4])\n\tx |= uint64(p.buf[i-3]) << 8\n\tx |= uint64(p.buf[i-2]) << 16\n\tx |= uint64(p.buf[i-1]) << 24\n\treturn\n}\n\n// DecodeZigzag64 reads a zigzag-encoded 64-bit integer\n// from the Buffer.\n// This is the format used for the sint64 protocol buffer type.\nfunc (p *Buffer) DecodeZigzag64() (x uint64, err error) {\n\tx, err = p.DecodeVarint()\n\tif err != nil {\n\t\treturn\n\t}\n\tx = (x >> 1) ^ uint64((int64(x&1)<<63)>>63)\n\treturn\n}\n\n// DecodeZigzag32 reads a zigzag-encoded 32-bit integer\n// from  the Buffer.\n// This is the format used for the sint32 protocol buffer type.\nfunc (p *Buffer) DecodeZigzag32() (x uint64, err error) {\n\tx, err = p.DecodeVarint()\n\tif err != nil {\n\t\treturn\n\t}\n\tx = uint64((uint32(x) >> 1) ^ uint32((int32(x&1)<<31)>>31))\n\treturn\n}\n\n// These are not ValueDecoders: they produce an array of bytes or a string.\n// bytes, embedded messages\n\n// DecodeRawBytes reads a count-delimited byte buffer from the Buffer.\n// This is the format used for the bytes protocol buffer\n// type and for embedded messages.\nfunc (p *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error) {\n\tn, err := p.DecodeVarint()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tnb := int(n)\n\tif nb < 0 {\n\t\treturn nil, fmt.Errorf(\"proto: bad byte length %d\", nb)\n\t}\n\tend := p.index + nb\n\tif end < p.index || end > len(p.buf) {\n\t\treturn nil, io.ErrUnexpectedEOF\n\t}\n\n\tif !alloc {\n\t\t// todo: check if can get more uses of alloc=false\n\t\tbuf = p.buf[p.index:end]\n\t\tp.index += nb\n\t\treturn\n\t}\n\n\tbuf = make([]byte, nb)\n\tcopy(buf, p.buf[p.index:])\n\tp.index += nb\n\treturn\n}\n\n// DecodeStringBytes reads an encoded string from the Buffer.\n// This is the format used for the proto2 string type.\nfunc (p *Buffer) DecodeStringBytes() (s string, err error) {\n\tbuf, err := p.DecodeRawBytes(false)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn string(buf), nil\n}\n\n// Skip the next item in the buffer. Its wire type is decoded and presented as an argument.\n// If the protocol buffer has extensions, and the field matches, add it as an extension.\n// Otherwise, if the XXX_unrecognized field exists, append the skipped data there.\nfunc (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer, unrecField field) error {\n\toi := o.index\n\n\terr := o.skip(t, tag, wire)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !unrecField.IsValid() {\n\t\treturn nil\n\t}\n\n\tptr := structPointer_Bytes(base, unrecField)\n\n\t// Add the skipped field to struct field\n\tobuf := o.buf\n\n\to.buf = *ptr\n\to.EncodeVarint(uint64(tag<<3 | wire))\n\t*ptr = append(o.buf, obuf[oi:o.index]...)\n\n\to.buf = obuf\n\n\treturn nil\n}\n\n// Skip the next item in the buffer. Its wire type is decoded and presented as an argument.\nfunc (o *Buffer) skip(t reflect.Type, tag, wire int) error {\n\n\tvar u uint64\n\tvar err error\n\n\tswitch wire {\n\tcase WireVarint:\n\t\t_, err = o.DecodeVarint()\n\tcase WireFixed64:\n\t\t_, err = o.DecodeFixed64()\n\tcase WireBytes:\n\t\t_, err = o.DecodeRawBytes(false)\n\tcase WireFixed32:\n\t\t_, err = o.DecodeFixed32()\n\tcase WireStartGroup:\n\t\tfor {\n\t\t\tu, err = o.DecodeVarint()\n\t\t\tif err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tfwire := int(u & 0x7)\n\t\t\tif fwire == WireEndGroup {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tftag := int(u >> 3)\n\t\t\terr = o.skip(t, ftag, fwire)\n\t\t\tif err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\tdefault:\n\t\terr = fmt.Errorf(\"proto: can't skip unknown wire type %d for %s\", wire, t)\n\t}\n\treturn err\n}\n\n// Unmarshaler is the interface representing objects that can\n// unmarshal themselves.  The method should reset the receiver before\n// decoding starts.  The argument points to data that may be\n// overwritten, so implementations should not keep references to the\n// buffer.\ntype Unmarshaler interface {\n\tUnmarshal([]byte) error\n}\n\n// Unmarshal parses the protocol buffer representation in buf and places the\n// decoded result in pb.  If the struct underlying pb does not match\n// the data in buf, the results can be unpredictable.\n//\n// Unmarshal resets pb before starting to unmarshal, so any\n// existing data in pb is always removed. Use UnmarshalMerge\n// to preserve and append to existing data.\nfunc Unmarshal(buf []byte, pb Message) error {\n\tpb.Reset()\n\treturn UnmarshalMerge(buf, pb)\n}\n\n// UnmarshalMerge parses the protocol buffer representation in buf and\n// writes the decoded result to pb.  If the struct underlying pb does not match\n// the data in buf, the results can be unpredictable.\n//\n// UnmarshalMerge merges into existing data in pb.\n// Most code should use Unmarshal instead.\nfunc UnmarshalMerge(buf []byte, pb Message) error {\n\t// If the object can unmarshal itself, let it.\n\tif u, ok := pb.(Unmarshaler); ok {\n\t\treturn u.Unmarshal(buf)\n\t}\n\treturn NewBuffer(buf).Unmarshal(pb)\n}\n\n// DecodeMessage reads a count-delimited message from the Buffer.\nfunc (p *Buffer) DecodeMessage(pb Message) error {\n\tenc, err := p.DecodeRawBytes(false)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn NewBuffer(enc).Unmarshal(pb)\n}\n\n// DecodeGroup reads a tag-delimited group from the Buffer.\nfunc (p *Buffer) DecodeGroup(pb Message) error {\n\ttyp, base, err := getbase(pb)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), true, base)\n}\n\n// Unmarshal parses the protocol buffer representation in the\n// Buffer and places the decoded result in pb.  If the struct\n// underlying pb does not match the data in the buffer, the results can be\n// unpredictable.\n//\n// Unlike proto.Unmarshal, this does not reset pb before starting to unmarshal.\nfunc (p *Buffer) Unmarshal(pb Message) error {\n\t// If the object can unmarshal itself, let it.\n\tif u, ok := pb.(Unmarshaler); ok {\n\t\terr := u.Unmarshal(p.buf[p.index:])\n\t\tp.index = len(p.buf)\n\t\treturn err\n\t}\n\n\ttyp, base, err := getbase(pb)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), false, base)\n\n\tif collectStats {\n\t\tstats.Decode++\n\t}\n\n\treturn err\n}\n\n// unmarshalType does the work of unmarshaling a structure.\nfunc (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group bool, base structPointer) error {\n\tvar state errorState\n\trequired, reqFields := prop.reqCount, uint64(0)\n\n\tvar err error\n\tfor err == nil && o.index < len(o.buf) {\n\t\toi := o.index\n\t\tvar u uint64\n\t\tu, err = o.DecodeVarint()\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\twire := int(u & 0x7)\n\t\tif wire == WireEndGroup {\n\t\t\tif is_group {\n\t\t\t\tif required > 0 {\n\t\t\t\t\t// Not enough information to determine the exact field.\n\t\t\t\t\t// (See below.)\n\t\t\t\t\treturn &RequiredNotSetError{\"{Unknown}\"}\n\t\t\t\t}\n\t\t\t\treturn nil // input is satisfied\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"proto: %s: wiretype end group for non-group\", st)\n\t\t}\n\t\ttag := int(u >> 3)\n\t\tif tag <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: %s: illegal tag %d (wire type %d)\", st, tag, wire)\n\t\t}\n\t\tfieldnum, ok := prop.decoderTags.get(tag)\n\t\tif !ok {\n\t\t\t// Maybe it's an extension?\n\t\t\tif prop.extendable {\n\t\t\t\tif e, _ := extendable(structPointer_Interface(base, st)); isExtensionField(e, int32(tag)) {\n\t\t\t\t\tif err = o.skip(st, tag, wire); err == nil {\n\t\t\t\t\t\textmap := e.extensionsWrite()\n\t\t\t\t\t\text := extmap[int32(tag)] // may be missing\n\t\t\t\t\t\text.enc = append(ext.enc, o.buf[oi:o.index]...)\n\t\t\t\t\t\textmap[int32(tag)] = ext\n\t\t\t\t\t}\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Maybe it's a oneof?\n\t\t\tif prop.oneofUnmarshaler != nil {\n\t\t\t\tm := structPointer_Interface(base, st).(Message)\n\t\t\t\t// First return value indicates whether tag is a oneof field.\n\t\t\t\tok, err = prop.oneofUnmarshaler(m, tag, wire, o)\n\t\t\t\tif err == ErrInternalBadWireType {\n\t\t\t\t\t// Map the error to something more descriptive.\n\t\t\t\t\t// Do the formatting here to save generated code space.\n\t\t\t\t\terr = fmt.Errorf(\"bad wiretype for oneof field in %T\", m)\n\t\t\t\t}\n\t\t\t\tif ok {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\terr = o.skipAndSave(st, tag, wire, base, prop.unrecField)\n\t\t\tcontinue\n\t\t}\n\t\tp := prop.Prop[fieldnum]\n\n\t\tif p.dec == nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"proto: no protobuf decoder for %s.%s\\n\", st, st.Field(fieldnum).Name)\n\t\t\tcontinue\n\t\t}\n\t\tdec := p.dec\n\t\tif wire != WireStartGroup && wire != p.WireType {\n\t\t\tif wire == WireBytes && p.packedDec != nil {\n\t\t\t\t// a packable field\n\t\t\t\tdec = p.packedDec\n\t\t\t} else {\n\t\t\t\terr = fmt.Errorf(\"proto: bad wiretype for field %s.%s: got wiretype %d, want %d\", st, st.Field(fieldnum).Name, wire, p.WireType)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tdecErr := dec(o, p, base)\n\t\tif decErr != nil && !state.shouldContinue(decErr, p) {\n\t\t\terr = decErr\n\t\t}\n\t\tif err == nil && p.Required {\n\t\t\t// Successfully decoded a required field.\n\t\t\tif tag <= 64 {\n\t\t\t\t// use bitmap for fields 1-64 to catch field reuse.\n\t\t\t\tvar mask uint64 = 1 << uint64(tag-1)\n\t\t\t\tif reqFields&mask == 0 {\n\t\t\t\t\t// new required field\n\t\t\t\t\treqFields |= mask\n\t\t\t\t\trequired--\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// This is imprecise. It can be fooled by a required field\n\t\t\t\t// with a tag > 64 that is encoded twice; that's very rare.\n\t\t\t\t// A fully correct implementation would require allocating\n\t\t\t\t// a data structure, which we would like to avoid.\n\t\t\t\trequired--\n\t\t\t}\n\t\t}\n\t}\n\tif err == nil {\n\t\tif is_group {\n\t\t\treturn io.ErrUnexpectedEOF\n\t\t}\n\t\tif state.err != nil {\n\t\t\treturn state.err\n\t\t}\n\t\tif required > 0 {\n\t\t\t// Not enough information to determine the exact field. If we use extra\n\t\t\t// CPU, we could determine the field only if the missing required field\n\t\t\t// has a tag <= 64 and we check reqFields.\n\t\t\treturn &RequiredNotSetError{\"{Unknown}\"}\n\t\t}\n\t}\n\treturn err\n}\n\n// Individual type decoders\n// For each,\n//\tu is the decoded value,\n//\tv is a pointer to the field (pointer) in the struct\n\n// Sizes of the pools to allocate inside the Buffer.\n// The goal is modest amortization and allocation\n// on at least 16-byte boundaries.\nconst (\n\tboolPoolSize   = 16\n\tuint32PoolSize = 8\n\tuint64PoolSize = 4\n)\n\n// Decode a bool.\nfunc (o *Buffer) dec_bool(p *Properties, base structPointer) error {\n\tu, err := p.valDec(o)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(o.bools) == 0 {\n\t\to.bools = make([]bool, boolPoolSize)\n\t}\n\to.bools[0] = u != 0\n\t*structPointer_Bool(base, p.field) = &o.bools[0]\n\to.bools = o.bools[1:]\n\treturn nil\n}\n\nfunc (o *Buffer) dec_proto3_bool(p *Properties, base structPointer) error {\n\tu, err := p.valDec(o)\n\tif err != nil {\n\t\treturn err\n\t}\n\t*structPointer_BoolVal(base, p.field) = u != 0\n\treturn nil\n}\n\n// Decode an int32.\nfunc (o *Buffer) dec_int32(p *Properties, base structPointer) error {\n\tu, err := p.valDec(o)\n\tif err != nil {\n\t\treturn err\n\t}\n\tword32_Set(structPointer_Word32(base, p.field), o, uint32(u))\n\treturn nil\n}\n\nfunc (o *Buffer) dec_proto3_int32(p *Properties, base structPointer) error {\n\tu, err := p.valDec(o)\n\tif err != nil {\n\t\treturn err\n\t}\n\tword32Val_Set(structPointer_Word32Val(base, p.field), uint32(u))\n\treturn nil\n}\n\n// Decode an int64.\nfunc (o *Buffer) dec_int64(p *Properties, base structPointer) error {\n\tu, err := p.valDec(o)\n\tif err != nil {\n\t\treturn err\n\t}\n\tword64_Set(structPointer_Word64(base, p.field), o, u)\n\treturn nil\n}\n\nfunc (o *Buffer) dec_proto3_int64(p *Properties, base structPointer) error {\n\tu, err := p.valDec(o)\n\tif err != nil {\n\t\treturn err\n\t}\n\tword64Val_Set(structPointer_Word64Val(base, p.field), o, u)\n\treturn nil\n}\n\n// Decode a string.\nfunc (o *Buffer) dec_string(p *Properties, base structPointer) error {\n\ts, err := o.DecodeStringBytes()\n\tif err != nil {\n\t\treturn err\n\t}\n\t*structPointer_String(base, p.field) = &s\n\treturn nil\n}\n\nfunc (o *Buffer) dec_proto3_string(p *Properties, base structPointer) error {\n\ts, err := o.DecodeStringBytes()\n\tif err != nil {\n\t\treturn err\n\t}\n\t*structPointer_StringVal(base, p.field) = s\n\treturn nil\n}\n\n// Decode a slice of bytes ([]byte).\nfunc (o *Buffer) dec_slice_byte(p *Properties, base structPointer) error {\n\tb, err := o.DecodeRawBytes(true)\n\tif err != nil {\n\t\treturn err\n\t}\n\t*structPointer_Bytes(base, p.field) = b\n\treturn nil\n}\n\n// Decode a slice of bools ([]bool).\nfunc (o *Buffer) dec_slice_bool(p *Properties, base structPointer) error {\n\tu, err := p.valDec(o)\n\tif err != nil {\n\t\treturn err\n\t}\n\tv := structPointer_BoolSlice(base, p.field)\n\t*v = append(*v, u != 0)\n\treturn nil\n}\n\n// Decode a slice of bools ([]bool) in packed format.\nfunc (o *Buffer) dec_slice_packed_bool(p *Properties, base structPointer) error {\n\tv := structPointer_BoolSlice(base, p.field)\n\n\tnn, err := o.DecodeVarint()\n\tif err != nil {\n\t\treturn err\n\t}\n\tnb := int(nn) // number of bytes of encoded bools\n\tfin := o.index + nb\n\tif fin < o.index {\n\t\treturn errOverflow\n\t}\n\n\ty := *v\n\tfor o.index < fin {\n\t\tu, err := p.valDec(o)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ty = append(y, u != 0)\n\t}\n\n\t*v = y\n\treturn nil\n}\n\n// Decode a slice of int32s ([]int32).\nfunc (o *Buffer) dec_slice_int32(p *Properties, base structPointer) error {\n\tu, err := p.valDec(o)\n\tif err != nil {\n\t\treturn err\n\t}\n\tstructPointer_Word32Slice(base, p.field).Append(uint32(u))\n\treturn nil\n}\n\n// Decode a slice of int32s ([]int32) in packed format.\nfunc (o *Buffer) dec_slice_packed_int32(p *Properties, base structPointer) error {\n\tv := structPointer_Word32Slice(base, p.field)\n\n\tnn, err := o.DecodeVarint()\n\tif err != nil {\n\t\treturn err\n\t}\n\tnb := int(nn) // number of bytes of encoded int32s\n\n\tfin := o.index + nb\n\tif fin < o.index {\n\t\treturn errOverflow\n\t}\n\tfor o.index < fin {\n\t\tu, err := p.valDec(o)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tv.Append(uint32(u))\n\t}\n\treturn nil\n}\n\n// Decode a slice of int64s ([]int64).\nfunc (o *Buffer) dec_slice_int64(p *Properties, base structPointer) error {\n\tu, err := p.valDec(o)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstructPointer_Word64Slice(base, p.field).Append(u)\n\treturn nil\n}\n\n// Decode a slice of int64s ([]int64) in packed format.\nfunc (o *Buffer) dec_slice_packed_int64(p *Properties, base structPointer) error {\n\tv := structPointer_Word64Slice(base, p.field)\n\n\tnn, err := o.DecodeVarint()\n\tif err != nil {\n\t\treturn err\n\t}\n\tnb := int(nn) // number of bytes of encoded int64s\n\n\tfin := o.index + nb\n\tif fin < o.index {\n\t\treturn errOverflow\n\t}\n\tfor o.index < fin {\n\t\tu, err := p.valDec(o)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tv.Append(u)\n\t}\n\treturn nil\n}\n\n// Decode a slice of strings ([]string).\nfunc (o *Buffer) dec_slice_string(p *Properties, base structPointer) error {\n\ts, err := o.DecodeStringBytes()\n\tif err != nil {\n\t\treturn err\n\t}\n\tv := structPointer_StringSlice(base, p.field)\n\t*v = append(*v, s)\n\treturn nil\n}\n\n// Decode a slice of slice of bytes ([][]byte).\nfunc (o *Buffer) dec_slice_slice_byte(p *Properties, base structPointer) error {\n\tb, err := o.DecodeRawBytes(true)\n\tif err != nil {\n\t\treturn err\n\t}\n\tv := structPointer_BytesSlice(base, p.field)\n\t*v = append(*v, b)\n\treturn nil\n}\n\n// Decode a map field.\nfunc (o *Buffer) dec_new_map(p *Properties, base structPointer) error {\n\traw, err := o.DecodeRawBytes(false)\n\tif err != nil {\n\t\treturn err\n\t}\n\toi := o.index       // index at the end of this map entry\n\to.index -= len(raw) // move buffer back to start of map entry\n\n\tmptr := structPointer_NewAt(base, p.field, p.mtype) // *map[K]V\n\tif mptr.Elem().IsNil() {\n\t\tmptr.Elem().Set(reflect.MakeMap(mptr.Type().Elem()))\n\t}\n\tv := mptr.Elem() // map[K]V\n\n\t// Prepare addressable doubly-indirect placeholders for the key and value types.\n\t// See enc_new_map for why.\n\tkeyptr := reflect.New(reflect.PtrTo(p.mtype.Key())).Elem() // addressable *K\n\tkeybase := toStructPointer(keyptr.Addr())                  // **K\n\n\tvar valbase structPointer\n\tvar valptr reflect.Value\n\tswitch p.mtype.Elem().Kind() {\n\tcase reflect.Slice:\n\t\t// []byte\n\t\tvar dummy []byte\n\t\tvalptr = reflect.ValueOf(&dummy)  // *[]byte\n\t\tvalbase = toStructPointer(valptr) // *[]byte\n\tcase reflect.Ptr:\n\t\t// message; valptr is **Msg; need to allocate the intermediate pointer\n\t\tvalptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V\n\t\tvalptr.Set(reflect.New(valptr.Type().Elem()))\n\t\tvalbase = toStructPointer(valptr)\n\tdefault:\n\t\t// everything else\n\t\tvalptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V\n\t\tvalbase = toStructPointer(valptr.Addr())                   // **V\n\t}\n\n\t// Decode.\n\t// This parses a restricted wire format, namely the encoding of a message\n\t// with two fields. See enc_new_map for the format.\n\tfor o.index < oi {\n\t\t// tagcode for key and value properties are always a single byte\n\t\t// because they have tags 1 and 2.\n\t\ttagcode := o.buf[o.index]\n\t\to.index++\n\t\tswitch tagcode {\n\t\tcase p.mkeyprop.tagcode[0]:\n\t\t\tif err := p.mkeyprop.dec(o, p.mkeyprop, keybase); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase p.mvalprop.tagcode[0]:\n\t\t\tif err := p.mvalprop.dec(o, p.mvalprop, valbase); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tdefault:\n\t\t\t// TODO: Should we silently skip this instead?\n\t\t\treturn fmt.Errorf(\"proto: bad map data tag %d\", raw[0])\n\t\t}\n\t}\n\tkeyelem, valelem := keyptr.Elem(), valptr.Elem()\n\tif !keyelem.IsValid() {\n\t\tkeyelem = reflect.Zero(p.mtype.Key())\n\t}\n\tif !valelem.IsValid() {\n\t\tvalelem = reflect.Zero(p.mtype.Elem())\n\t}\n\n\tv.SetMapIndex(keyelem, valelem)\n\treturn nil\n}\n\n// Decode a group.\nfunc (o *Buffer) dec_struct_group(p *Properties, base structPointer) error {\n\tbas := structPointer_GetStructPointer(base, p.field)\n\tif structPointer_IsNil(bas) {\n\t\t// allocate new nested message\n\t\tbas = toStructPointer(reflect.New(p.stype))\n\t\tstructPointer_SetStructPointer(base, p.field, bas)\n\t}\n\treturn o.unmarshalType(p.stype, p.sprop, true, bas)\n}\n\n// Decode an embedded message.\nfunc (o *Buffer) dec_struct_message(p *Properties, base structPointer) (err error) {\n\traw, e := o.DecodeRawBytes(false)\n\tif e != nil {\n\t\treturn e\n\t}\n\n\tbas := structPointer_GetStructPointer(base, p.field)\n\tif structPointer_IsNil(bas) {\n\t\t// allocate new nested message\n\t\tbas = toStructPointer(reflect.New(p.stype))\n\t\tstructPointer_SetStructPointer(base, p.field, bas)\n\t}\n\n\t// If the object can unmarshal itself, let it.\n\tif p.isUnmarshaler {\n\t\tiv := structPointer_Interface(bas, p.stype)\n\t\treturn iv.(Unmarshaler).Unmarshal(raw)\n\t}\n\n\tobuf := o.buf\n\toi := o.index\n\to.buf = raw\n\to.index = 0\n\n\terr = o.unmarshalType(p.stype, p.sprop, false, bas)\n\to.buf = obuf\n\to.index = oi\n\n\treturn err\n}\n\n// Decode a slice of embedded messages.\nfunc (o *Buffer) dec_slice_struct_message(p *Properties, base structPointer) error {\n\treturn o.dec_slice_struct(p, false, base)\n}\n\n// Decode a slice of embedded groups.\nfunc (o *Buffer) dec_slice_struct_group(p *Properties, base structPointer) error {\n\treturn o.dec_slice_struct(p, true, base)\n}\n\n// Decode a slice of structs ([]*struct).\nfunc (o *Buffer) dec_slice_struct(p *Properties, is_group bool, base structPointer) error {\n\tv := reflect.New(p.stype)\n\tbas := toStructPointer(v)\n\tstructPointer_StructPointerSlice(base, p.field).Append(bas)\n\n\tif is_group {\n\t\terr := o.unmarshalType(p.stype, p.sprop, is_group, bas)\n\t\treturn err\n\t}\n\n\traw, err := o.DecodeRawBytes(false)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// If the object can unmarshal itself, let it.\n\tif p.isUnmarshaler {\n\t\tiv := v.Interface()\n\t\treturn iv.(Unmarshaler).Unmarshal(raw)\n\t}\n\n\tobuf := o.buf\n\toi := o.index\n\to.buf = raw\n\to.index = 0\n\n\terr = o.unmarshalType(p.stype, p.sprop, is_group, bas)\n\n\to.buf = obuf\n\to.index = oi\n\n\treturn err\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/decode_test.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2010 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// +build go1.7\n\npackage proto_test\n\nimport (\n\t\"fmt\"\n\t\"testing\"\n\n\t\"github.com/golang/protobuf/proto\"\n\ttpb \"github.com/golang/protobuf/proto/proto3_proto\"\n)\n\nvar (\n\tbytesBlackhole []byte\n\tmsgBlackhole   = new(tpb.Message)\n)\n\n// BenchmarkVarint32ArraySmall shows the performance on an array of small int32 fields (1 and\n// 2 bytes long).\nfunc BenchmarkVarint32ArraySmall(b *testing.B) {\n\tfor i := uint(1); i <= 10; i++ {\n\t\tdist := genInt32Dist([7]int{0, 3, 1}, 1<<i)\n\t\traw, err := proto.Marshal(&tpb.Message{\n\t\t\tShortKey: dist,\n\t\t})\n\t\tif err != nil {\n\t\t\tb.Error(\"wrong encode\", err)\n\t\t}\n\t\tb.Run(fmt.Sprintf(\"Len%v\", len(dist)), func(b *testing.B) {\n\t\t\tscratchBuf := proto.NewBuffer(nil)\n\t\t\tb.ResetTimer()\n\t\t\tfor k := 0; k < b.N; k++ {\n\t\t\t\tscratchBuf.SetBuf(raw)\n\t\t\t\tmsgBlackhole.Reset()\n\t\t\t\tif err := scratchBuf.Unmarshal(msgBlackhole); err != nil {\n\t\t\t\t\tb.Error(\"wrong decode\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}\n\n// BenchmarkVarint32ArrayLarge shows the performance on an array of large int32 fields (3 and\n// 4 bytes long, with a small number of 1, 2, 5 and 10 byte long versions).\nfunc BenchmarkVarint32ArrayLarge(b *testing.B) {\n\tfor i := uint(1); i <= 10; i++ {\n\t\tdist := genInt32Dist([7]int{0, 1, 2, 4, 8, 1, 1}, 1<<i)\n\t\traw, err := proto.Marshal(&tpb.Message{\n\t\t\tShortKey: dist,\n\t\t})\n\t\tif err != nil {\n\t\t\tb.Error(\"wrong encode\", err)\n\t\t}\n\t\tb.Run(fmt.Sprintf(\"Len%v\", len(dist)), func(b *testing.B) {\n\t\t\tscratchBuf := proto.NewBuffer(nil)\n\t\t\tb.ResetTimer()\n\t\t\tfor k := 0; k < b.N; k++ {\n\t\t\t\tscratchBuf.SetBuf(raw)\n\t\t\t\tmsgBlackhole.Reset()\n\t\t\t\tif err := scratchBuf.Unmarshal(msgBlackhole); err != nil {\n\t\t\t\t\tb.Error(\"wrong decode\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}\n\n// BenchmarkVarint64ArraySmall shows the performance on an array of small int64 fields (1 and\n// 2 bytes long).\nfunc BenchmarkVarint64ArraySmall(b *testing.B) {\n\tfor i := uint(1); i <= 10; i++ {\n\t\tdist := genUint64Dist([11]int{0, 3, 1}, 1<<i)\n\t\traw, err := proto.Marshal(&tpb.Message{\n\t\t\tKey: dist,\n\t\t})\n\t\tif err != nil {\n\t\t\tb.Error(\"wrong encode\", err)\n\t\t}\n\t\tb.Run(fmt.Sprintf(\"Len%v\", len(dist)), func(b *testing.B) {\n\t\t\tscratchBuf := proto.NewBuffer(nil)\n\t\t\tb.ResetTimer()\n\t\t\tfor k := 0; k < b.N; k++ {\n\t\t\t\tscratchBuf.SetBuf(raw)\n\t\t\t\tmsgBlackhole.Reset()\n\t\t\t\tif err := scratchBuf.Unmarshal(msgBlackhole); err != nil {\n\t\t\t\t\tb.Error(\"wrong decode\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}\n\n// BenchmarkVarint64ArrayLarge shows the performance on an array of large int64 fields (6, 7,\n// and 8 bytes long with a small number of the other sizes).\nfunc BenchmarkVarint64ArrayLarge(b *testing.B) {\n\tfor i := uint(1); i <= 10; i++ {\n\t\tdist := genUint64Dist([11]int{0, 1, 1, 2, 4, 8, 16, 32, 16, 1, 1}, 1<<i)\n\t\traw, err := proto.Marshal(&tpb.Message{\n\t\t\tKey: dist,\n\t\t})\n\t\tif err != nil {\n\t\t\tb.Error(\"wrong encode\", err)\n\t\t}\n\t\tb.Run(fmt.Sprintf(\"Len%v\", len(dist)), func(b *testing.B) {\n\t\t\tscratchBuf := proto.NewBuffer(nil)\n\t\t\tb.ResetTimer()\n\t\t\tfor k := 0; k < b.N; k++ {\n\t\t\t\tscratchBuf.SetBuf(raw)\n\t\t\t\tmsgBlackhole.Reset()\n\t\t\t\tif err := scratchBuf.Unmarshal(msgBlackhole); err != nil {\n\t\t\t\t\tb.Error(\"wrong decode\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}\n\n// BenchmarkVarint64ArrayMixed shows the performance of lots of small messages, each\n// containing a small number of large (3, 4, and 5 byte) repeated int64s.\nfunc BenchmarkVarint64ArrayMixed(b *testing.B) {\n\tfor i := uint(1); i <= 1<<5; i <<= 1 {\n\t\tdist := genUint64Dist([11]int{0, 0, 0, 4, 6, 4, 0, 0, 0, 0, 0}, int(i))\n\t\t// number of sub fields\n\t\tfor k := uint(1); k <= 1<<10; k <<= 2 {\n\t\t\tmsg := &tpb.Message{}\n\t\t\tfor m := uint(0); m < k; m++ {\n\t\t\t\tmsg.Children = append(msg.Children, &tpb.Message{\n\t\t\t\t\tKey: dist,\n\t\t\t\t})\n\t\t\t}\n\t\t\traw, err := proto.Marshal(msg)\n\t\t\tif err != nil {\n\t\t\t\tb.Error(\"wrong encode\", err)\n\t\t\t}\n\t\t\tb.Run(fmt.Sprintf(\"Fields%vLen%v\", k, i), func(b *testing.B) {\n\t\t\t\tscratchBuf := proto.NewBuffer(nil)\n\t\t\t\tb.ResetTimer()\n\t\t\t\tfor k := 0; k < b.N; k++ {\n\t\t\t\t\tscratchBuf.SetBuf(raw)\n\t\t\t\t\tmsgBlackhole.Reset()\n\t\t\t\t\tif err := scratchBuf.Unmarshal(msgBlackhole); err != nil {\n\t\t\t\t\t\tb.Error(\"wrong decode\", err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n}\n\n// genInt32Dist generates a slice of ints that will match the size distribution of dist.\n// A size of 6 corresponds to a max length varint32, which is 10 bytes.  The distribution\n// is 1-indexed. (i.e. the value at index 1 is how many 1 byte ints to create).\nfunc genInt32Dist(dist [7]int, count int) (dest []int32) {\n\tfor i := 0; i < count; i++ {\n\t\tfor k := 0; k < len(dist); k++ {\n\t\t\tvar num int32\n\t\t\tswitch k {\n\t\t\tcase 1:\n\t\t\t\tnum = 1<<7 - 1\n\t\t\tcase 2:\n\t\t\t\tnum = 1<<14 - 1\n\t\t\tcase 3:\n\t\t\t\tnum = 1<<21 - 1\n\t\t\tcase 4:\n\t\t\t\tnum = 1<<28 - 1\n\t\t\tcase 5:\n\t\t\t\tnum = 1<<29 - 1\n\t\t\tcase 6:\n\t\t\t\tnum = -1\n\t\t\t}\n\t\t\tfor m := 0; m < dist[k]; m++ {\n\t\t\t\tdest = append(dest, num)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}\n\n// genUint64Dist generates a slice of ints that will match the size distribution of dist.\n// The distribution is 1-indexed. (i.e. the value at index 1 is how many 1 byte ints to create).\nfunc genUint64Dist(dist [11]int, count int) (dest []uint64) {\n\tfor i := 0; i < count; i++ {\n\t\tfor k := 0; k < len(dist); k++ {\n\t\t\tvar num uint64\n\t\t\tswitch k {\n\t\t\tcase 1:\n\t\t\t\tnum = 1<<7 - 1\n\t\t\tcase 2:\n\t\t\t\tnum = 1<<14 - 1\n\t\t\tcase 3:\n\t\t\t\tnum = 1<<21 - 1\n\t\t\tcase 4:\n\t\t\t\tnum = 1<<28 - 1\n\t\t\tcase 5:\n\t\t\t\tnum = 1<<35 - 1\n\t\t\tcase 6:\n\t\t\t\tnum = 1<<42 - 1\n\t\t\tcase 7:\n\t\t\t\tnum = 1<<49 - 1\n\t\t\tcase 8:\n\t\t\t\tnum = 1<<56 - 1\n\t\t\tcase 9:\n\t\t\t\tnum = 1<<63 - 1\n\t\t\tcase 10:\n\t\t\t\tnum = 1<<64 - 1\n\t\t\t}\n\t\t\tfor m := 0; m < dist[k]; m++ {\n\t\t\t\tdest = append(dest, num)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}\n\n// BenchmarkDecodeEmpty measures the overhead of doing the minimal possible decode.\nfunc BenchmarkDecodeEmpty(b *testing.B) {\n\traw, err := proto.Marshal(&tpb.Message{})\n\tif err != nil {\n\t\tb.Error(\"wrong encode\", err)\n\t}\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tif err := proto.Unmarshal(raw, msgBlackhole); err != nil {\n\t\t\tb.Error(\"wrong decode\", err)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/encode.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2010 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto\n\n/*\n * Routines for encoding data into the wire format for protocol buffers.\n */\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"sort\"\n)\n\n// RequiredNotSetError is the error returned if Marshal is called with\n// a protocol buffer struct whose required fields have not\n// all been initialized. It is also the error returned if Unmarshal is\n// called with an encoded protocol buffer that does not include all the\n// required fields.\n//\n// When printed, RequiredNotSetError reports the first unset required field in a\n// message. If the field cannot be precisely determined, it is reported as\n// \"{Unknown}\".\ntype RequiredNotSetError struct {\n\tfield string\n}\n\nfunc (e *RequiredNotSetError) Error() string {\n\treturn fmt.Sprintf(\"proto: required field %q not set\", e.field)\n}\n\nvar (\n\t// errRepeatedHasNil is the error returned if Marshal is called with\n\t// a struct with a repeated field containing a nil element.\n\terrRepeatedHasNil = errors.New(\"proto: repeated field has nil element\")\n\n\t// errOneofHasNil is the error returned if Marshal is called with\n\t// a struct with a oneof field containing a nil element.\n\terrOneofHasNil = errors.New(\"proto: oneof field has nil value\")\n\n\t// ErrNil is the error returned if Marshal is called with nil.\n\tErrNil = errors.New(\"proto: Marshal called with nil\")\n\n\t// ErrTooLarge is the error returned if Marshal is called with a\n\t// message that encodes to >2GB.\n\tErrTooLarge = errors.New(\"proto: message encodes to over 2 GB\")\n)\n\n// The fundamental encoders that put bytes on the wire.\n// Those that take integer types all accept uint64 and are\n// therefore of type valueEncoder.\n\nconst maxVarintBytes = 10 // maximum length of a varint\n\n// maxMarshalSize is the largest allowed size of an encoded protobuf,\n// since C++ and Java use signed int32s for the size.\nconst maxMarshalSize = 1<<31 - 1\n\n// EncodeVarint returns the varint encoding of x.\n// This is the format for the\n// int32, int64, uint32, uint64, bool, and enum\n// protocol buffer types.\n// Not used by the package itself, but helpful to clients\n// wishing to use the same encoding.\nfunc EncodeVarint(x uint64) []byte {\n\tvar buf [maxVarintBytes]byte\n\tvar n int\n\tfor n = 0; x > 127; n++ {\n\t\tbuf[n] = 0x80 | uint8(x&0x7F)\n\t\tx >>= 7\n\t}\n\tbuf[n] = uint8(x)\n\tn++\n\treturn buf[0:n]\n}\n\n// EncodeVarint writes a varint-encoded integer to the Buffer.\n// This is the format for the\n// int32, int64, uint32, uint64, bool, and enum\n// protocol buffer types.\nfunc (p *Buffer) EncodeVarint(x uint64) error {\n\tfor x >= 1<<7 {\n\t\tp.buf = append(p.buf, uint8(x&0x7f|0x80))\n\t\tx >>= 7\n\t}\n\tp.buf = append(p.buf, uint8(x))\n\treturn nil\n}\n\n// SizeVarint returns the varint encoding size of an integer.\nfunc SizeVarint(x uint64) int {\n\treturn sizeVarint(x)\n}\n\nfunc sizeVarint(x uint64) (n int) {\n\tfor {\n\t\tn++\n\t\tx >>= 7\n\t\tif x == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn n\n}\n\n// EncodeFixed64 writes a 64-bit integer to the Buffer.\n// This is the format for the\n// fixed64, sfixed64, and double protocol buffer types.\nfunc (p *Buffer) EncodeFixed64(x uint64) error {\n\tp.buf = append(p.buf,\n\t\tuint8(x),\n\t\tuint8(x>>8),\n\t\tuint8(x>>16),\n\t\tuint8(x>>24),\n\t\tuint8(x>>32),\n\t\tuint8(x>>40),\n\t\tuint8(x>>48),\n\t\tuint8(x>>56))\n\treturn nil\n}\n\nfunc sizeFixed64(x uint64) int {\n\treturn 8\n}\n\n// EncodeFixed32 writes a 32-bit integer to the Buffer.\n// This is the format for the\n// fixed32, sfixed32, and float protocol buffer types.\nfunc (p *Buffer) EncodeFixed32(x uint64) error {\n\tp.buf = append(p.buf,\n\t\tuint8(x),\n\t\tuint8(x>>8),\n\t\tuint8(x>>16),\n\t\tuint8(x>>24))\n\treturn nil\n}\n\nfunc sizeFixed32(x uint64) int {\n\treturn 4\n}\n\n// EncodeZigzag64 writes a zigzag-encoded 64-bit integer\n// to the Buffer.\n// This is the format used for the sint64 protocol buffer type.\nfunc (p *Buffer) EncodeZigzag64(x uint64) error {\n\t// use signed number to get arithmetic right shift.\n\treturn p.EncodeVarint((x << 1) ^ uint64((int64(x) >> 63)))\n}\n\nfunc sizeZigzag64(x uint64) int {\n\treturn sizeVarint((x << 1) ^ uint64((int64(x) >> 63)))\n}\n\n// EncodeZigzag32 writes a zigzag-encoded 32-bit integer\n// to the Buffer.\n// This is the format used for the sint32 protocol buffer type.\nfunc (p *Buffer) EncodeZigzag32(x uint64) error {\n\t// use signed number to get arithmetic right shift.\n\treturn p.EncodeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31))))\n}\n\nfunc sizeZigzag32(x uint64) int {\n\treturn sizeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31))))\n}\n\n// EncodeRawBytes writes a count-delimited byte buffer to the Buffer.\n// This is the format used for the bytes protocol buffer\n// type and for embedded messages.\nfunc (p *Buffer) EncodeRawBytes(b []byte) error {\n\tp.EncodeVarint(uint64(len(b)))\n\tp.buf = append(p.buf, b...)\n\treturn nil\n}\n\nfunc sizeRawBytes(b []byte) int {\n\treturn sizeVarint(uint64(len(b))) +\n\t\tlen(b)\n}\n\n// EncodeStringBytes writes an encoded string to the Buffer.\n// This is the format used for the proto2 string type.\nfunc (p *Buffer) EncodeStringBytes(s string) error {\n\tp.EncodeVarint(uint64(len(s)))\n\tp.buf = append(p.buf, s...)\n\treturn nil\n}\n\nfunc sizeStringBytes(s string) int {\n\treturn sizeVarint(uint64(len(s))) +\n\t\tlen(s)\n}\n\n// Marshaler is the interface representing objects that can marshal themselves.\ntype Marshaler interface {\n\tMarshal() ([]byte, error)\n}\n\n// Marshal takes the protocol buffer\n// and encodes it into the wire format, returning the data.\nfunc Marshal(pb Message) ([]byte, error) {\n\t// Can the object marshal itself?\n\tif m, ok := pb.(Marshaler); ok {\n\t\treturn m.Marshal()\n\t}\n\tp := NewBuffer(nil)\n\terr := p.Marshal(pb)\n\tif p.buf == nil && err == nil {\n\t\t// Return a non-nil slice on success.\n\t\treturn []byte{}, nil\n\t}\n\treturn p.buf, err\n}\n\n// EncodeMessage writes the protocol buffer to the Buffer,\n// prefixed by a varint-encoded length.\nfunc (p *Buffer) EncodeMessage(pb Message) error {\n\tt, base, err := getbase(pb)\n\tif structPointer_IsNil(base) {\n\t\treturn ErrNil\n\t}\n\tif err == nil {\n\t\tvar state errorState\n\t\terr = p.enc_len_struct(GetProperties(t.Elem()), base, &state)\n\t}\n\treturn err\n}\n\n// Marshal takes the protocol buffer\n// and encodes it into the wire format, writing the result to the\n// Buffer.\nfunc (p *Buffer) Marshal(pb Message) error {\n\t// Can the object marshal itself?\n\tif m, ok := pb.(Marshaler); ok {\n\t\tdata, err := m.Marshal()\n\t\tp.buf = append(p.buf, data...)\n\t\treturn err\n\t}\n\n\tt, base, err := getbase(pb)\n\tif structPointer_IsNil(base) {\n\t\treturn ErrNil\n\t}\n\tif err == nil {\n\t\terr = p.enc_struct(GetProperties(t.Elem()), base)\n\t}\n\n\tif collectStats {\n\t\t(stats).Encode++ // Parens are to work around a goimports bug.\n\t}\n\n\tif len(p.buf) > maxMarshalSize {\n\t\treturn ErrTooLarge\n\t}\n\treturn err\n}\n\n// Size returns the encoded size of a protocol buffer.\nfunc Size(pb Message) (n int) {\n\t// Can the object marshal itself?  If so, Size is slow.\n\t// TODO: add Size to Marshaler, or add a Sizer interface.\n\tif m, ok := pb.(Marshaler); ok {\n\t\tb, _ := m.Marshal()\n\t\treturn len(b)\n\t}\n\n\tt, base, err := getbase(pb)\n\tif structPointer_IsNil(base) {\n\t\treturn 0\n\t}\n\tif err == nil {\n\t\tn = size_struct(GetProperties(t.Elem()), base)\n\t}\n\n\tif collectStats {\n\t\t(stats).Size++ // Parens are to work around a goimports bug.\n\t}\n\n\treturn\n}\n\n// Individual type encoders.\n\n// Encode a bool.\nfunc (o *Buffer) enc_bool(p *Properties, base structPointer) error {\n\tv := *structPointer_Bool(base, p.field)\n\tif v == nil {\n\t\treturn ErrNil\n\t}\n\tx := 0\n\tif *v {\n\t\tx = 1\n\t}\n\to.buf = append(o.buf, p.tagcode...)\n\tp.valEnc(o, uint64(x))\n\treturn nil\n}\n\nfunc (o *Buffer) enc_proto3_bool(p *Properties, base structPointer) error {\n\tv := *structPointer_BoolVal(base, p.field)\n\tif !v {\n\t\treturn ErrNil\n\t}\n\to.buf = append(o.buf, p.tagcode...)\n\tp.valEnc(o, 1)\n\treturn nil\n}\n\nfunc size_bool(p *Properties, base structPointer) int {\n\tv := *structPointer_Bool(base, p.field)\n\tif v == nil {\n\t\treturn 0\n\t}\n\treturn len(p.tagcode) + 1 // each bool takes exactly one byte\n}\n\nfunc size_proto3_bool(p *Properties, base structPointer) int {\n\tv := *structPointer_BoolVal(base, p.field)\n\tif !v && !p.oneof {\n\t\treturn 0\n\t}\n\treturn len(p.tagcode) + 1 // each bool takes exactly one byte\n}\n\n// Encode an int32.\nfunc (o *Buffer) enc_int32(p *Properties, base structPointer) error {\n\tv := structPointer_Word32(base, p.field)\n\tif word32_IsNil(v) {\n\t\treturn ErrNil\n\t}\n\tx := int32(word32_Get(v)) // permit sign extension to use full 64-bit range\n\to.buf = append(o.buf, p.tagcode...)\n\tp.valEnc(o, uint64(x))\n\treturn nil\n}\n\nfunc (o *Buffer) enc_proto3_int32(p *Properties, base structPointer) error {\n\tv := structPointer_Word32Val(base, p.field)\n\tx := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range\n\tif x == 0 {\n\t\treturn ErrNil\n\t}\n\to.buf = append(o.buf, p.tagcode...)\n\tp.valEnc(o, uint64(x))\n\treturn nil\n}\n\nfunc size_int32(p *Properties, base structPointer) (n int) {\n\tv := structPointer_Word32(base, p.field)\n\tif word32_IsNil(v) {\n\t\treturn 0\n\t}\n\tx := int32(word32_Get(v)) // permit sign extension to use full 64-bit range\n\tn += len(p.tagcode)\n\tn += p.valSize(uint64(x))\n\treturn\n}\n\nfunc size_proto3_int32(p *Properties, base structPointer) (n int) {\n\tv := structPointer_Word32Val(base, p.field)\n\tx := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range\n\tif x == 0 && !p.oneof {\n\t\treturn 0\n\t}\n\tn += len(p.tagcode)\n\tn += p.valSize(uint64(x))\n\treturn\n}\n\n// Encode a uint32.\n// Exactly the same as int32, except for no sign extension.\nfunc (o *Buffer) enc_uint32(p *Properties, base structPointer) error {\n\tv := structPointer_Word32(base, p.field)\n\tif word32_IsNil(v) {\n\t\treturn ErrNil\n\t}\n\tx := word32_Get(v)\n\to.buf = append(o.buf, p.tagcode...)\n\tp.valEnc(o, uint64(x))\n\treturn nil\n}\n\nfunc (o *Buffer) enc_proto3_uint32(p *Properties, base structPointer) error {\n\tv := structPointer_Word32Val(base, p.field)\n\tx := word32Val_Get(v)\n\tif x == 0 {\n\t\treturn ErrNil\n\t}\n\to.buf = append(o.buf, p.tagcode...)\n\tp.valEnc(o, uint64(x))\n\treturn nil\n}\n\nfunc size_uint32(p *Properties, base structPointer) (n int) {\n\tv := structPointer_Word32(base, p.field)\n\tif word32_IsNil(v) {\n\t\treturn 0\n\t}\n\tx := word32_Get(v)\n\tn += len(p.tagcode)\n\tn += p.valSize(uint64(x))\n\treturn\n}\n\nfunc size_proto3_uint32(p *Properties, base structPointer) (n int) {\n\tv := structPointer_Word32Val(base, p.field)\n\tx := word32Val_Get(v)\n\tif x == 0 && !p.oneof {\n\t\treturn 0\n\t}\n\tn += len(p.tagcode)\n\tn += p.valSize(uint64(x))\n\treturn\n}\n\n// Encode an int64.\nfunc (o *Buffer) enc_int64(p *Properties, base structPointer) error {\n\tv := structPointer_Word64(base, p.field)\n\tif word64_IsNil(v) {\n\t\treturn ErrNil\n\t}\n\tx := word64_Get(v)\n\to.buf = append(o.buf, p.tagcode...)\n\tp.valEnc(o, x)\n\treturn nil\n}\n\nfunc (o *Buffer) enc_proto3_int64(p *Properties, base structPointer) error {\n\tv := structPointer_Word64Val(base, p.field)\n\tx := word64Val_Get(v)\n\tif x == 0 {\n\t\treturn ErrNil\n\t}\n\to.buf = append(o.buf, p.tagcode...)\n\tp.valEnc(o, x)\n\treturn nil\n}\n\nfunc size_int64(p *Properties, base structPointer) (n int) {\n\tv := structPointer_Word64(base, p.field)\n\tif word64_IsNil(v) {\n\t\treturn 0\n\t}\n\tx := word64_Get(v)\n\tn += len(p.tagcode)\n\tn += p.valSize(x)\n\treturn\n}\n\nfunc size_proto3_int64(p *Properties, base structPointer) (n int) {\n\tv := structPointer_Word64Val(base, p.field)\n\tx := word64Val_Get(v)\n\tif x == 0 && !p.oneof {\n\t\treturn 0\n\t}\n\tn += len(p.tagcode)\n\tn += p.valSize(x)\n\treturn\n}\n\n// Encode a string.\nfunc (o *Buffer) enc_string(p *Properties, base structPointer) error {\n\tv := *structPointer_String(base, p.field)\n\tif v == nil {\n\t\treturn ErrNil\n\t}\n\tx := *v\n\to.buf = append(o.buf, p.tagcode...)\n\to.EncodeStringBytes(x)\n\treturn nil\n}\n\nfunc (o *Buffer) enc_proto3_string(p *Properties, base structPointer) error {\n\tv := *structPointer_StringVal(base, p.field)\n\tif v == \"\" {\n\t\treturn ErrNil\n\t}\n\to.buf = append(o.buf, p.tagcode...)\n\to.EncodeStringBytes(v)\n\treturn nil\n}\n\nfunc size_string(p *Properties, base structPointer) (n int) {\n\tv := *structPointer_String(base, p.field)\n\tif v == nil {\n\t\treturn 0\n\t}\n\tx := *v\n\tn += len(p.tagcode)\n\tn += sizeStringBytes(x)\n\treturn\n}\n\nfunc size_proto3_string(p *Properties, base structPointer) (n int) {\n\tv := *structPointer_StringVal(base, p.field)\n\tif v == \"\" && !p.oneof {\n\t\treturn 0\n\t}\n\tn += len(p.tagcode)\n\tn += sizeStringBytes(v)\n\treturn\n}\n\n// All protocol buffer fields are nillable, but be careful.\nfunc isNil(v reflect.Value) bool {\n\tswitch v.Kind() {\n\tcase reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:\n\t\treturn v.IsNil()\n\t}\n\treturn false\n}\n\n// Encode a message struct.\nfunc (o *Buffer) enc_struct_message(p *Properties, base structPointer) error {\n\tvar state errorState\n\tstructp := structPointer_GetStructPointer(base, p.field)\n\tif structPointer_IsNil(structp) {\n\t\treturn ErrNil\n\t}\n\n\t// Can the object marshal itself?\n\tif p.isMarshaler {\n\t\tm := structPointer_Interface(structp, p.stype).(Marshaler)\n\t\tdata, err := m.Marshal()\n\t\tif err != nil && !state.shouldContinue(err, nil) {\n\t\t\treturn err\n\t\t}\n\t\to.buf = append(o.buf, p.tagcode...)\n\t\to.EncodeRawBytes(data)\n\t\treturn state.err\n\t}\n\n\to.buf = append(o.buf, p.tagcode...)\n\treturn o.enc_len_struct(p.sprop, structp, &state)\n}\n\nfunc size_struct_message(p *Properties, base structPointer) int {\n\tstructp := structPointer_GetStructPointer(base, p.field)\n\tif structPointer_IsNil(structp) {\n\t\treturn 0\n\t}\n\n\t// Can the object marshal itself?\n\tif p.isMarshaler {\n\t\tm := structPointer_Interface(structp, p.stype).(Marshaler)\n\t\tdata, _ := m.Marshal()\n\t\tn0 := len(p.tagcode)\n\t\tn1 := sizeRawBytes(data)\n\t\treturn n0 + n1\n\t}\n\n\tn0 := len(p.tagcode)\n\tn1 := size_struct(p.sprop, structp)\n\tn2 := sizeVarint(uint64(n1)) // size of encoded length\n\treturn n0 + n1 + n2\n}\n\n// Encode a group struct.\nfunc (o *Buffer) enc_struct_group(p *Properties, base structPointer) error {\n\tvar state errorState\n\tb := structPointer_GetStructPointer(base, p.field)\n\tif structPointer_IsNil(b) {\n\t\treturn ErrNil\n\t}\n\n\to.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup))\n\terr := o.enc_struct(p.sprop, b)\n\tif err != nil && !state.shouldContinue(err, nil) {\n\t\treturn err\n\t}\n\to.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup))\n\treturn state.err\n}\n\nfunc size_struct_group(p *Properties, base structPointer) (n int) {\n\tb := structPointer_GetStructPointer(base, p.field)\n\tif structPointer_IsNil(b) {\n\t\treturn 0\n\t}\n\n\tn += sizeVarint(uint64((p.Tag << 3) | WireStartGroup))\n\tn += size_struct(p.sprop, b)\n\tn += sizeVarint(uint64((p.Tag << 3) | WireEndGroup))\n\treturn\n}\n\n// Encode a slice of bools ([]bool).\nfunc (o *Buffer) enc_slice_bool(p *Properties, base structPointer) error {\n\ts := *structPointer_BoolSlice(base, p.field)\n\tl := len(s)\n\tif l == 0 {\n\t\treturn ErrNil\n\t}\n\tfor _, x := range s {\n\t\to.buf = append(o.buf, p.tagcode...)\n\t\tv := uint64(0)\n\t\tif x {\n\t\t\tv = 1\n\t\t}\n\t\tp.valEnc(o, v)\n\t}\n\treturn nil\n}\n\nfunc size_slice_bool(p *Properties, base structPointer) int {\n\ts := *structPointer_BoolSlice(base, p.field)\n\tl := len(s)\n\tif l == 0 {\n\t\treturn 0\n\t}\n\treturn l * (len(p.tagcode) + 1) // each bool takes exactly one byte\n}\n\n// Encode a slice of bools ([]bool) in packed format.\nfunc (o *Buffer) enc_slice_packed_bool(p *Properties, base structPointer) error {\n\ts := *structPointer_BoolSlice(base, p.field)\n\tl := len(s)\n\tif l == 0 {\n\t\treturn ErrNil\n\t}\n\to.buf = append(o.buf, p.tagcode...)\n\to.EncodeVarint(uint64(l)) // each bool takes exactly one byte\n\tfor _, x := range s {\n\t\tv := uint64(0)\n\t\tif x {\n\t\t\tv = 1\n\t\t}\n\t\tp.valEnc(o, v)\n\t}\n\treturn nil\n}\n\nfunc size_slice_packed_bool(p *Properties, base structPointer) (n int) {\n\ts := *structPointer_BoolSlice(base, p.field)\n\tl := len(s)\n\tif l == 0 {\n\t\treturn 0\n\t}\n\tn += len(p.tagcode)\n\tn += sizeVarint(uint64(l))\n\tn += l // each bool takes exactly one byte\n\treturn\n}\n\n// Encode a slice of bytes ([]byte).\nfunc (o *Buffer) enc_slice_byte(p *Properties, base structPointer) error {\n\ts := *structPointer_Bytes(base, p.field)\n\tif s == nil {\n\t\treturn ErrNil\n\t}\n\to.buf = append(o.buf, p.tagcode...)\n\to.EncodeRawBytes(s)\n\treturn nil\n}\n\nfunc (o *Buffer) enc_proto3_slice_byte(p *Properties, base structPointer) error {\n\ts := *structPointer_Bytes(base, p.field)\n\tif len(s) == 0 {\n\t\treturn ErrNil\n\t}\n\to.buf = append(o.buf, p.tagcode...)\n\to.EncodeRawBytes(s)\n\treturn nil\n}\n\nfunc size_slice_byte(p *Properties, base structPointer) (n int) {\n\ts := *structPointer_Bytes(base, p.field)\n\tif s == nil && !p.oneof {\n\t\treturn 0\n\t}\n\tn += len(p.tagcode)\n\tn += sizeRawBytes(s)\n\treturn\n}\n\nfunc size_proto3_slice_byte(p *Properties, base structPointer) (n int) {\n\ts := *structPointer_Bytes(base, p.field)\n\tif len(s) == 0 && !p.oneof {\n\t\treturn 0\n\t}\n\tn += len(p.tagcode)\n\tn += sizeRawBytes(s)\n\treturn\n}\n\n// Encode a slice of int32s ([]int32).\nfunc (o *Buffer) enc_slice_int32(p *Properties, base structPointer) error {\n\ts := structPointer_Word32Slice(base, p.field)\n\tl := s.Len()\n\tif l == 0 {\n\t\treturn ErrNil\n\t}\n\tfor i := 0; i < l; i++ {\n\t\to.buf = append(o.buf, p.tagcode...)\n\t\tx := int32(s.Index(i)) // permit sign extension to use full 64-bit range\n\t\tp.valEnc(o, uint64(x))\n\t}\n\treturn nil\n}\n\nfunc size_slice_int32(p *Properties, base structPointer) (n int) {\n\ts := structPointer_Word32Slice(base, p.field)\n\tl := s.Len()\n\tif l == 0 {\n\t\treturn 0\n\t}\n\tfor i := 0; i < l; i++ {\n\t\tn += len(p.tagcode)\n\t\tx := int32(s.Index(i)) // permit sign extension to use full 64-bit range\n\t\tn += p.valSize(uint64(x))\n\t}\n\treturn\n}\n\n// Encode a slice of int32s ([]int32) in packed format.\nfunc (o *Buffer) enc_slice_packed_int32(p *Properties, base structPointer) error {\n\ts := structPointer_Word32Slice(base, p.field)\n\tl := s.Len()\n\tif l == 0 {\n\t\treturn ErrNil\n\t}\n\t// TODO: Reuse a Buffer.\n\tbuf := NewBuffer(nil)\n\tfor i := 0; i < l; i++ {\n\t\tx := int32(s.Index(i)) // permit sign extension to use full 64-bit range\n\t\tp.valEnc(buf, uint64(x))\n\t}\n\n\to.buf = append(o.buf, p.tagcode...)\n\to.EncodeVarint(uint64(len(buf.buf)))\n\to.buf = append(o.buf, buf.buf...)\n\treturn nil\n}\n\nfunc size_slice_packed_int32(p *Properties, base structPointer) (n int) {\n\ts := structPointer_Word32Slice(base, p.field)\n\tl := s.Len()\n\tif l == 0 {\n\t\treturn 0\n\t}\n\tvar bufSize int\n\tfor i := 0; i < l; i++ {\n\t\tx := int32(s.Index(i)) // permit sign extension to use full 64-bit range\n\t\tbufSize += p.valSize(uint64(x))\n\t}\n\n\tn += len(p.tagcode)\n\tn += sizeVarint(uint64(bufSize))\n\tn += bufSize\n\treturn\n}\n\n// Encode a slice of uint32s ([]uint32).\n// Exactly the same as int32, except for no sign extension.\nfunc (o *Buffer) enc_slice_uint32(p *Properties, base structPointer) error {\n\ts := structPointer_Word32Slice(base, p.field)\n\tl := s.Len()\n\tif l == 0 {\n\t\treturn ErrNil\n\t}\n\tfor i := 0; i < l; i++ {\n\t\to.buf = append(o.buf, p.tagcode...)\n\t\tx := s.Index(i)\n\t\tp.valEnc(o, uint64(x))\n\t}\n\treturn nil\n}\n\nfunc size_slice_uint32(p *Properties, base structPointer) (n int) {\n\ts := structPointer_Word32Slice(base, p.field)\n\tl := s.Len()\n\tif l == 0 {\n\t\treturn 0\n\t}\n\tfor i := 0; i < l; i++ {\n\t\tn += len(p.tagcode)\n\t\tx := s.Index(i)\n\t\tn += p.valSize(uint64(x))\n\t}\n\treturn\n}\n\n// Encode a slice of uint32s ([]uint32) in packed format.\n// Exactly the same as int32, except for no sign extension.\nfunc (o *Buffer) enc_slice_packed_uint32(p *Properties, base structPointer) error {\n\ts := structPointer_Word32Slice(base, p.field)\n\tl := s.Len()\n\tif l == 0 {\n\t\treturn ErrNil\n\t}\n\t// TODO: Reuse a Buffer.\n\tbuf := NewBuffer(nil)\n\tfor i := 0; i < l; i++ {\n\t\tp.valEnc(buf, uint64(s.Index(i)))\n\t}\n\n\to.buf = append(o.buf, p.tagcode...)\n\to.EncodeVarint(uint64(len(buf.buf)))\n\to.buf = append(o.buf, buf.buf...)\n\treturn nil\n}\n\nfunc size_slice_packed_uint32(p *Properties, base structPointer) (n int) {\n\ts := structPointer_Word32Slice(base, p.field)\n\tl := s.Len()\n\tif l == 0 {\n\t\treturn 0\n\t}\n\tvar bufSize int\n\tfor i := 0; i < l; i++ {\n\t\tbufSize += p.valSize(uint64(s.Index(i)))\n\t}\n\n\tn += len(p.tagcode)\n\tn += sizeVarint(uint64(bufSize))\n\tn += bufSize\n\treturn\n}\n\n// Encode a slice of int64s ([]int64).\nfunc (o *Buffer) enc_slice_int64(p *Properties, base structPointer) error {\n\ts := structPointer_Word64Slice(base, p.field)\n\tl := s.Len()\n\tif l == 0 {\n\t\treturn ErrNil\n\t}\n\tfor i := 0; i < l; i++ {\n\t\to.buf = append(o.buf, p.tagcode...)\n\t\tp.valEnc(o, s.Index(i))\n\t}\n\treturn nil\n}\n\nfunc size_slice_int64(p *Properties, base structPointer) (n int) {\n\ts := structPointer_Word64Slice(base, p.field)\n\tl := s.Len()\n\tif l == 0 {\n\t\treturn 0\n\t}\n\tfor i := 0; i < l; i++ {\n\t\tn += len(p.tagcode)\n\t\tn += p.valSize(s.Index(i))\n\t}\n\treturn\n}\n\n// Encode a slice of int64s ([]int64) in packed format.\nfunc (o *Buffer) enc_slice_packed_int64(p *Properties, base structPointer) error {\n\ts := structPointer_Word64Slice(base, p.field)\n\tl := s.Len()\n\tif l == 0 {\n\t\treturn ErrNil\n\t}\n\t// TODO: Reuse a Buffer.\n\tbuf := NewBuffer(nil)\n\tfor i := 0; i < l; i++ {\n\t\tp.valEnc(buf, s.Index(i))\n\t}\n\n\to.buf = append(o.buf, p.tagcode...)\n\to.EncodeVarint(uint64(len(buf.buf)))\n\to.buf = append(o.buf, buf.buf...)\n\treturn nil\n}\n\nfunc size_slice_packed_int64(p *Properties, base structPointer) (n int) {\n\ts := structPointer_Word64Slice(base, p.field)\n\tl := s.Len()\n\tif l == 0 {\n\t\treturn 0\n\t}\n\tvar bufSize int\n\tfor i := 0; i < l; i++ {\n\t\tbufSize += p.valSize(s.Index(i))\n\t}\n\n\tn += len(p.tagcode)\n\tn += sizeVarint(uint64(bufSize))\n\tn += bufSize\n\treturn\n}\n\n// Encode a slice of slice of bytes ([][]byte).\nfunc (o *Buffer) enc_slice_slice_byte(p *Properties, base structPointer) error {\n\tss := *structPointer_BytesSlice(base, p.field)\n\tl := len(ss)\n\tif l == 0 {\n\t\treturn ErrNil\n\t}\n\tfor i := 0; i < l; i++ {\n\t\to.buf = append(o.buf, p.tagcode...)\n\t\to.EncodeRawBytes(ss[i])\n\t}\n\treturn nil\n}\n\nfunc size_slice_slice_byte(p *Properties, base structPointer) (n int) {\n\tss := *structPointer_BytesSlice(base, p.field)\n\tl := len(ss)\n\tif l == 0 {\n\t\treturn 0\n\t}\n\tn += l * len(p.tagcode)\n\tfor i := 0; i < l; i++ {\n\t\tn += sizeRawBytes(ss[i])\n\t}\n\treturn\n}\n\n// Encode a slice of strings ([]string).\nfunc (o *Buffer) enc_slice_string(p *Properties, base structPointer) error {\n\tss := *structPointer_StringSlice(base, p.field)\n\tl := len(ss)\n\tfor i := 0; i < l; i++ {\n\t\to.buf = append(o.buf, p.tagcode...)\n\t\to.EncodeStringBytes(ss[i])\n\t}\n\treturn nil\n}\n\nfunc size_slice_string(p *Properties, base structPointer) (n int) {\n\tss := *structPointer_StringSlice(base, p.field)\n\tl := len(ss)\n\tn += l * len(p.tagcode)\n\tfor i := 0; i < l; i++ {\n\t\tn += sizeStringBytes(ss[i])\n\t}\n\treturn\n}\n\n// Encode a slice of message structs ([]*struct).\nfunc (o *Buffer) enc_slice_struct_message(p *Properties, base structPointer) error {\n\tvar state errorState\n\ts := structPointer_StructPointerSlice(base, p.field)\n\tl := s.Len()\n\n\tfor i := 0; i < l; i++ {\n\t\tstructp := s.Index(i)\n\t\tif structPointer_IsNil(structp) {\n\t\t\treturn errRepeatedHasNil\n\t\t}\n\n\t\t// Can the object marshal itself?\n\t\tif p.isMarshaler {\n\t\t\tm := structPointer_Interface(structp, p.stype).(Marshaler)\n\t\t\tdata, err := m.Marshal()\n\t\t\tif err != nil && !state.shouldContinue(err, nil) {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\to.buf = append(o.buf, p.tagcode...)\n\t\t\to.EncodeRawBytes(data)\n\t\t\tcontinue\n\t\t}\n\n\t\to.buf = append(o.buf, p.tagcode...)\n\t\terr := o.enc_len_struct(p.sprop, structp, &state)\n\t\tif err != nil && !state.shouldContinue(err, nil) {\n\t\t\tif err == ErrNil {\n\t\t\t\treturn errRepeatedHasNil\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t}\n\treturn state.err\n}\n\nfunc size_slice_struct_message(p *Properties, base structPointer) (n int) {\n\ts := structPointer_StructPointerSlice(base, p.field)\n\tl := s.Len()\n\tn += l * len(p.tagcode)\n\tfor i := 0; i < l; i++ {\n\t\tstructp := s.Index(i)\n\t\tif structPointer_IsNil(structp) {\n\t\t\treturn // return the size up to this point\n\t\t}\n\n\t\t// Can the object marshal itself?\n\t\tif p.isMarshaler {\n\t\t\tm := structPointer_Interface(structp, p.stype).(Marshaler)\n\t\t\tdata, _ := m.Marshal()\n\t\t\tn += sizeRawBytes(data)\n\t\t\tcontinue\n\t\t}\n\n\t\tn0 := size_struct(p.sprop, structp)\n\t\tn1 := sizeVarint(uint64(n0)) // size of encoded length\n\t\tn += n0 + n1\n\t}\n\treturn\n}\n\n// Encode a slice of group structs ([]*struct).\nfunc (o *Buffer) enc_slice_struct_group(p *Properties, base structPointer) error {\n\tvar state errorState\n\ts := structPointer_StructPointerSlice(base, p.field)\n\tl := s.Len()\n\n\tfor i := 0; i < l; i++ {\n\t\tb := s.Index(i)\n\t\tif structPointer_IsNil(b) {\n\t\t\treturn errRepeatedHasNil\n\t\t}\n\n\t\to.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup))\n\n\t\terr := o.enc_struct(p.sprop, b)\n\n\t\tif err != nil && !state.shouldContinue(err, nil) {\n\t\t\tif err == ErrNil {\n\t\t\t\treturn errRepeatedHasNil\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\n\t\to.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup))\n\t}\n\treturn state.err\n}\n\nfunc size_slice_struct_group(p *Properties, base structPointer) (n int) {\n\ts := structPointer_StructPointerSlice(base, p.field)\n\tl := s.Len()\n\n\tn += l * sizeVarint(uint64((p.Tag<<3)|WireStartGroup))\n\tn += l * sizeVarint(uint64((p.Tag<<3)|WireEndGroup))\n\tfor i := 0; i < l; i++ {\n\t\tb := s.Index(i)\n\t\tif structPointer_IsNil(b) {\n\t\t\treturn // return size up to this point\n\t\t}\n\n\t\tn += size_struct(p.sprop, b)\n\t}\n\treturn\n}\n\n// Encode an extension map.\nfunc (o *Buffer) enc_map(p *Properties, base structPointer) error {\n\texts := structPointer_ExtMap(base, p.field)\n\tif err := encodeExtensionsMap(*exts); err != nil {\n\t\treturn err\n\t}\n\n\treturn o.enc_map_body(*exts)\n}\n\nfunc (o *Buffer) enc_exts(p *Properties, base structPointer) error {\n\texts := structPointer_Extensions(base, p.field)\n\n\tv, mu := exts.extensionsRead()\n\tif v == nil {\n\t\treturn nil\n\t}\n\n\tmu.Lock()\n\tdefer mu.Unlock()\n\tif err := encodeExtensionsMap(v); err != nil {\n\t\treturn err\n\t}\n\n\treturn o.enc_map_body(v)\n}\n\nfunc (o *Buffer) enc_map_body(v map[int32]Extension) error {\n\t// Fast-path for common cases: zero or one extensions.\n\tif len(v) <= 1 {\n\t\tfor _, e := range v {\n\t\t\to.buf = append(o.buf, e.enc...)\n\t\t}\n\t\treturn nil\n\t}\n\n\t// Sort keys to provide a deterministic encoding.\n\tkeys := make([]int, 0, len(v))\n\tfor k := range v {\n\t\tkeys = append(keys, int(k))\n\t}\n\tsort.Ints(keys)\n\n\tfor _, k := range keys {\n\t\to.buf = append(o.buf, v[int32(k)].enc...)\n\t}\n\treturn nil\n}\n\nfunc size_map(p *Properties, base structPointer) int {\n\tv := structPointer_ExtMap(base, p.field)\n\treturn extensionsMapSize(*v)\n}\n\nfunc size_exts(p *Properties, base structPointer) int {\n\tv := structPointer_Extensions(base, p.field)\n\treturn extensionsSize(v)\n}\n\n// Encode a map field.\nfunc (o *Buffer) enc_new_map(p *Properties, base structPointer) error {\n\tvar state errorState // XXX: or do we need to plumb this through?\n\n\t/*\n\t\tA map defined as\n\t\t\tmap<key_type, value_type> map_field = N;\n\t\tis encoded in the same way as\n\t\t\tmessage MapFieldEntry {\n\t\t\t\tkey_type key = 1;\n\t\t\t\tvalue_type value = 2;\n\t\t\t}\n\t\t\trepeated MapFieldEntry map_field = N;\n\t*/\n\n\tv := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V\n\tif v.Len() == 0 {\n\t\treturn nil\n\t}\n\n\tkeycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype)\n\n\tenc := func() error {\n\t\tif err := p.mkeyprop.enc(o, p.mkeyprop, keybase); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := p.mvalprop.enc(o, p.mvalprop, valbase); err != nil && err != ErrNil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\n\t// Don't sort map keys. It is not required by the spec, and C++ doesn't do it.\n\tfor _, key := range v.MapKeys() {\n\t\tval := v.MapIndex(key)\n\n\t\tkeycopy.Set(key)\n\t\tvalcopy.Set(val)\n\n\t\to.buf = append(o.buf, p.tagcode...)\n\t\tif err := o.enc_len_thing(enc, &state); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc size_new_map(p *Properties, base structPointer) int {\n\tv := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V\n\n\tkeycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype)\n\n\tn := 0\n\tfor _, key := range v.MapKeys() {\n\t\tval := v.MapIndex(key)\n\t\tkeycopy.Set(key)\n\t\tvalcopy.Set(val)\n\n\t\t// Tag codes for key and val are the responsibility of the sub-sizer.\n\t\tkeysize := p.mkeyprop.size(p.mkeyprop, keybase)\n\t\tvalsize := p.mvalprop.size(p.mvalprop, valbase)\n\t\tentry := keysize + valsize\n\t\t// Add on tag code and length of map entry itself.\n\t\tn += len(p.tagcode) + sizeVarint(uint64(entry)) + entry\n\t}\n\treturn n\n}\n\n// mapEncodeScratch returns a new reflect.Value matching the map's value type,\n// and a structPointer suitable for passing to an encoder or sizer.\nfunc mapEncodeScratch(mapType reflect.Type) (keycopy, valcopy reflect.Value, keybase, valbase structPointer) {\n\t// Prepare addressable doubly-indirect placeholders for the key and value types.\n\t// This is needed because the element-type encoders expect **T, but the map iteration produces T.\n\n\tkeycopy = reflect.New(mapType.Key()).Elem()                 // addressable K\n\tkeyptr := reflect.New(reflect.PtrTo(keycopy.Type())).Elem() // addressable *K\n\tkeyptr.Set(keycopy.Addr())                                  //\n\tkeybase = toStructPointer(keyptr.Addr())                    // **K\n\n\t// Value types are more varied and require special handling.\n\tswitch mapType.Elem().Kind() {\n\tcase reflect.Slice:\n\t\t// []byte\n\t\tvar dummy []byte\n\t\tvalcopy = reflect.ValueOf(&dummy).Elem() // addressable []byte\n\t\tvalbase = toStructPointer(valcopy.Addr())\n\tcase reflect.Ptr:\n\t\t// message; the generated field type is map[K]*Msg (so V is *Msg),\n\t\t// so we only need one level of indirection.\n\t\tvalcopy = reflect.New(mapType.Elem()).Elem() // addressable V\n\t\tvalbase = toStructPointer(valcopy.Addr())\n\tdefault:\n\t\t// everything else\n\t\tvalcopy = reflect.New(mapType.Elem()).Elem()                // addressable V\n\t\tvalptr := reflect.New(reflect.PtrTo(valcopy.Type())).Elem() // addressable *V\n\t\tvalptr.Set(valcopy.Addr())                                  //\n\t\tvalbase = toStructPointer(valptr.Addr())                    // **V\n\t}\n\treturn\n}\n\n// Encode a struct.\nfunc (o *Buffer) enc_struct(prop *StructProperties, base structPointer) error {\n\tvar state errorState\n\t// Encode fields in tag order so that decoders may use optimizations\n\t// that depend on the ordering.\n\t// https://developers.google.com/protocol-buffers/docs/encoding#order\n\tfor _, i := range prop.order {\n\t\tp := prop.Prop[i]\n\t\tif p.enc != nil {\n\t\t\terr := p.enc(o, p, base)\n\t\t\tif err != nil {\n\t\t\t\tif err == ErrNil {\n\t\t\t\t\tif p.Required && state.err == nil {\n\t\t\t\t\t\tstate.err = &RequiredNotSetError{p.Name}\n\t\t\t\t\t}\n\t\t\t\t} else if err == errRepeatedHasNil {\n\t\t\t\t\t// Give more context to nil values in repeated fields.\n\t\t\t\t\treturn errors.New(\"repeated field \" + p.OrigName + \" has nil element\")\n\t\t\t\t} else if !state.shouldContinue(err, p) {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\tif len(o.buf) > maxMarshalSize {\n\t\t\t\treturn ErrTooLarge\n\t\t\t}\n\t\t}\n\t}\n\n\t// Do oneof fields.\n\tif prop.oneofMarshaler != nil {\n\t\tm := structPointer_Interface(base, prop.stype).(Message)\n\t\tif err := prop.oneofMarshaler(m, o); err == ErrNil {\n\t\t\treturn errOneofHasNil\n\t\t} else if err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Add unrecognized fields at the end.\n\tif prop.unrecField.IsValid() {\n\t\tv := *structPointer_Bytes(base, prop.unrecField)\n\t\tif len(o.buf)+len(v) > maxMarshalSize {\n\t\t\treturn ErrTooLarge\n\t\t}\n\t\tif len(v) > 0 {\n\t\t\to.buf = append(o.buf, v...)\n\t\t}\n\t}\n\n\treturn state.err\n}\n\nfunc size_struct(prop *StructProperties, base structPointer) (n int) {\n\tfor _, i := range prop.order {\n\t\tp := prop.Prop[i]\n\t\tif p.size != nil {\n\t\t\tn += p.size(p, base)\n\t\t}\n\t}\n\n\t// Add unrecognized fields at the end.\n\tif prop.unrecField.IsValid() {\n\t\tv := *structPointer_Bytes(base, prop.unrecField)\n\t\tn += len(v)\n\t}\n\n\t// Factor in any oneof fields.\n\tif prop.oneofSizer != nil {\n\t\tm := structPointer_Interface(base, prop.stype).(Message)\n\t\tn += prop.oneofSizer(m)\n\t}\n\n\treturn\n}\n\nvar zeroes [20]byte // longer than any conceivable sizeVarint\n\n// Encode a struct, preceded by its encoded length (as a varint).\nfunc (o *Buffer) enc_len_struct(prop *StructProperties, base structPointer, state *errorState) error {\n\treturn o.enc_len_thing(func() error { return o.enc_struct(prop, base) }, state)\n}\n\n// Encode something, preceded by its encoded length (as a varint).\nfunc (o *Buffer) enc_len_thing(enc func() error, state *errorState) error {\n\tiLen := len(o.buf)\n\to.buf = append(o.buf, 0, 0, 0, 0) // reserve four bytes for length\n\tiMsg := len(o.buf)\n\terr := enc()\n\tif err != nil && !state.shouldContinue(err, nil) {\n\t\treturn err\n\t}\n\tlMsg := len(o.buf) - iMsg\n\tlLen := sizeVarint(uint64(lMsg))\n\tswitch x := lLen - (iMsg - iLen); {\n\tcase x > 0: // actual length is x bytes larger than the space we reserved\n\t\t// Move msg x bytes right.\n\t\to.buf = append(o.buf, zeroes[:x]...)\n\t\tcopy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg])\n\tcase x < 0: // actual length is x bytes smaller than the space we reserved\n\t\t// Move msg x bytes left.\n\t\tcopy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg])\n\t\to.buf = o.buf[:len(o.buf)+x] // x is negative\n\t}\n\t// Encode the length in the reserved space.\n\to.buf = o.buf[:iLen]\n\to.EncodeVarint(uint64(lMsg))\n\to.buf = o.buf[:len(o.buf)+lMsg]\n\treturn state.err\n}\n\n// errorState maintains the first error that occurs and updates that error\n// with additional context.\ntype errorState struct {\n\terr error\n}\n\n// shouldContinue reports whether encoding should continue upon encountering the\n// given error. If the error is RequiredNotSetError, shouldContinue returns true\n// and, if this is the first appearance of that error, remembers it for future\n// reporting.\n//\n// If prop is not nil, it may update any error with additional context about the\n// field with the error.\nfunc (s *errorState) shouldContinue(err error, prop *Properties) bool {\n\t// Ignore unset required fields.\n\treqNotSet, ok := err.(*RequiredNotSetError)\n\tif !ok {\n\t\treturn false\n\t}\n\tif s.err == nil {\n\t\tif prop != nil {\n\t\t\terr = &RequiredNotSetError{prop.Name + \".\" + reqNotSet.field}\n\t\t}\n\t\ts.err = err\n\t}\n\treturn true\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/encode_test.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2010 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// +build go1.7\n\npackage proto_test\n\nimport (\n\t\"strconv\"\n\t\"testing\"\n\n\t\"github.com/golang/protobuf/proto\"\n\ttpb \"github.com/golang/protobuf/proto/proto3_proto\"\n\t\"github.com/golang/protobuf/ptypes\"\n)\n\nvar (\n\tblackhole []byte\n)\n\n// BenchmarkAny creates increasingly large arbitrary Any messages.  The type is always the\n// same.\nfunc BenchmarkAny(b *testing.B) {\n\tdata := make([]byte, 1<<20)\n\tquantum := 1 << 10\n\tfor i := uint(0); i <= 10; i++ {\n\t\tb.Run(strconv.Itoa(quantum<<i), func(b *testing.B) {\n\t\t\tfor k := 0; k < b.N; k++ {\n\t\t\t\tinner := &tpb.Message{\n\t\t\t\t\tData: data[:quantum<<i],\n\t\t\t\t}\n\t\t\t\touter, err := ptypes.MarshalAny(inner)\n\t\t\t\tif err != nil {\n\t\t\t\t\tb.Error(\"wrong encode\", err)\n\t\t\t\t}\n\t\t\t\traw, err := proto.Marshal(&tpb.Message{\n\t\t\t\t\tAnything: outer,\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\tb.Error(\"wrong encode\", err)\n\t\t\t\t}\n\t\t\t\tblackhole = raw\n\t\t\t}\n\t\t})\n\t}\n}\n\n// BenchmarkEmpy measures the overhead of doing the minimal possible encode.\nfunc BenchmarkEmpy(b *testing.B) {\n\tfor i := 0; i < b.N; i++ {\n\t\traw, err := proto.Marshal(&tpb.Message{})\n\t\tif err != nil {\n\t\t\tb.Error(\"wrong encode\", err)\n\t\t}\n\t\tblackhole = raw\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/equal.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2011 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Protocol buffer comparison.\n\npackage proto\n\nimport (\n\t\"bytes\"\n\t\"log\"\n\t\"reflect\"\n\t\"strings\"\n)\n\n/*\nEqual returns true iff protocol buffers a and b are equal.\nThe arguments must both be pointers to protocol buffer structs.\n\nEquality is defined in this way:\n  - Two messages are equal iff they are the same type,\n    corresponding fields are equal, unknown field sets\n    are equal, and extensions sets are equal.\n  - Two set scalar fields are equal iff their values are equal.\n    If the fields are of a floating-point type, remember that\n    NaN != x for all x, including NaN. If the message is defined\n    in a proto3 .proto file, fields are not \"set\"; specifically,\n    zero length proto3 \"bytes\" fields are equal (nil == {}).\n  - Two repeated fields are equal iff their lengths are the same,\n    and their corresponding elements are equal. Note a \"bytes\" field,\n    although represented by []byte, is not a repeated field and the\n    rule for the scalar fields described above applies.\n  - Two unset fields are equal.\n  - Two unknown field sets are equal if their current\n    encoded state is equal.\n  - Two extension sets are equal iff they have corresponding\n    elements that are pairwise equal.\n  - Two map fields are equal iff their lengths are the same,\n    and they contain the same set of elements. Zero-length map\n    fields are equal.\n  - Every other combination of things are not equal.\n\nThe return value is undefined if a and b are not protocol buffers.\n*/\nfunc Equal(a, b Message) bool {\n\tif a == nil || b == nil {\n\t\treturn a == b\n\t}\n\tv1, v2 := reflect.ValueOf(a), reflect.ValueOf(b)\n\tif v1.Type() != v2.Type() {\n\t\treturn false\n\t}\n\tif v1.Kind() == reflect.Ptr {\n\t\tif v1.IsNil() {\n\t\t\treturn v2.IsNil()\n\t\t}\n\t\tif v2.IsNil() {\n\t\t\treturn false\n\t\t}\n\t\tv1, v2 = v1.Elem(), v2.Elem()\n\t}\n\tif v1.Kind() != reflect.Struct {\n\t\treturn false\n\t}\n\treturn equalStruct(v1, v2)\n}\n\n// v1 and v2 are known to have the same type.\nfunc equalStruct(v1, v2 reflect.Value) bool {\n\tsprop := GetProperties(v1.Type())\n\tfor i := 0; i < v1.NumField(); i++ {\n\t\tf := v1.Type().Field(i)\n\t\tif strings.HasPrefix(f.Name, \"XXX_\") {\n\t\t\tcontinue\n\t\t}\n\t\tf1, f2 := v1.Field(i), v2.Field(i)\n\t\tif f.Type.Kind() == reflect.Ptr {\n\t\t\tif n1, n2 := f1.IsNil(), f2.IsNil(); n1 && n2 {\n\t\t\t\t// both unset\n\t\t\t\tcontinue\n\t\t\t} else if n1 != n2 {\n\t\t\t\t// set/unset mismatch\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tb1, ok := f1.Interface().(raw)\n\t\t\tif ok {\n\t\t\t\tb2 := f2.Interface().(raw)\n\t\t\t\t// RawMessage\n\t\t\t\tif !bytes.Equal(b1.Bytes(), b2.Bytes()) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tf1, f2 = f1.Elem(), f2.Elem()\n\t\t}\n\t\tif !equalAny(f1, f2, sprop.Prop[i]) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tif em1 := v1.FieldByName(\"XXX_InternalExtensions\"); em1.IsValid() {\n\t\tem2 := v2.FieldByName(\"XXX_InternalExtensions\")\n\t\tif !equalExtensions(v1.Type(), em1.Interface().(XXX_InternalExtensions), em2.Interface().(XXX_InternalExtensions)) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tif em1 := v1.FieldByName(\"XXX_extensions\"); em1.IsValid() {\n\t\tem2 := v2.FieldByName(\"XXX_extensions\")\n\t\tif !equalExtMap(v1.Type(), em1.Interface().(map[int32]Extension), em2.Interface().(map[int32]Extension)) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tuf := v1.FieldByName(\"XXX_unrecognized\")\n\tif !uf.IsValid() {\n\t\treturn true\n\t}\n\n\tu1 := uf.Bytes()\n\tu2 := v2.FieldByName(\"XXX_unrecognized\").Bytes()\n\tif !bytes.Equal(u1, u2) {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n// v1 and v2 are known to have the same type.\n// prop may be nil.\nfunc equalAny(v1, v2 reflect.Value, prop *Properties) bool {\n\tif v1.Type() == protoMessageType {\n\t\tm1, _ := v1.Interface().(Message)\n\t\tm2, _ := v2.Interface().(Message)\n\t\treturn Equal(m1, m2)\n\t}\n\tswitch v1.Kind() {\n\tcase reflect.Bool:\n\t\treturn v1.Bool() == v2.Bool()\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn v1.Float() == v2.Float()\n\tcase reflect.Int32, reflect.Int64:\n\t\treturn v1.Int() == v2.Int()\n\tcase reflect.Interface:\n\t\t// Probably a oneof field; compare the inner values.\n\t\tn1, n2 := v1.IsNil(), v2.IsNil()\n\t\tif n1 || n2 {\n\t\t\treturn n1 == n2\n\t\t}\n\t\te1, e2 := v1.Elem(), v2.Elem()\n\t\tif e1.Type() != e2.Type() {\n\t\t\treturn false\n\t\t}\n\t\treturn equalAny(e1, e2, nil)\n\tcase reflect.Map:\n\t\tif v1.Len() != v2.Len() {\n\t\t\treturn false\n\t\t}\n\t\tfor _, key := range v1.MapKeys() {\n\t\t\tval2 := v2.MapIndex(key)\n\t\t\tif !val2.IsValid() {\n\t\t\t\t// This key was not found in the second map.\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif !equalAny(v1.MapIndex(key), val2, nil) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\tcase reflect.Ptr:\n\t\t// Maps may have nil values in them, so check for nil.\n\t\tif v1.IsNil() && v2.IsNil() {\n\t\t\treturn true\n\t\t}\n\t\tif v1.IsNil() != v2.IsNil() {\n\t\t\treturn false\n\t\t}\n\t\treturn equalAny(v1.Elem(), v2.Elem(), prop)\n\tcase reflect.Slice:\n\t\tif v1.Type().Elem().Kind() == reflect.Uint8 {\n\t\t\t// short circuit: []byte\n\n\t\t\t// Edge case: if this is in a proto3 message, a zero length\n\t\t\t// bytes field is considered the zero value.\n\t\t\tif prop != nil && prop.proto3 && v1.Len() == 0 && v2.Len() == 0 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif v1.IsNil() != v2.IsNil() {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn bytes.Equal(v1.Interface().([]byte), v2.Interface().([]byte))\n\t\t}\n\n\t\tif v1.Len() != v2.Len() {\n\t\t\treturn false\n\t\t}\n\t\tfor i := 0; i < v1.Len(); i++ {\n\t\t\tif !equalAny(v1.Index(i), v2.Index(i), prop) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\tcase reflect.String:\n\t\treturn v1.Interface().(string) == v2.Interface().(string)\n\tcase reflect.Struct:\n\t\treturn equalStruct(v1, v2)\n\tcase reflect.Uint32, reflect.Uint64:\n\t\treturn v1.Uint() == v2.Uint()\n\t}\n\n\t// unknown type, so not a protocol buffer\n\tlog.Printf(\"proto: don't know how to compare %v\", v1)\n\treturn false\n}\n\n// base is the struct type that the extensions are based on.\n// x1 and x2 are InternalExtensions.\nfunc equalExtensions(base reflect.Type, x1, x2 XXX_InternalExtensions) bool {\n\tem1, _ := x1.extensionsRead()\n\tem2, _ := x2.extensionsRead()\n\treturn equalExtMap(base, em1, em2)\n}\n\nfunc equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool {\n\tif len(em1) != len(em2) {\n\t\treturn false\n\t}\n\n\tfor extNum, e1 := range em1 {\n\t\te2, ok := em2[extNum]\n\t\tif !ok {\n\t\t\treturn false\n\t\t}\n\n\t\tm1, m2 := e1.value, e2.value\n\n\t\tif m1 != nil && m2 != nil {\n\t\t\t// Both are unencoded.\n\t\t\tif !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\t// At least one is encoded. To do a semantically correct comparison\n\t\t// we need to unmarshal them first.\n\t\tvar desc *ExtensionDesc\n\t\tif m := extensionMaps[base]; m != nil {\n\t\t\tdesc = m[extNum]\n\t\t}\n\t\tif desc == nil {\n\t\t\tlog.Printf(\"proto: don't know how to compare extension %d of %v\", extNum, base)\n\t\t\tcontinue\n\t\t}\n\t\tvar err error\n\t\tif m1 == nil {\n\t\t\tm1, err = decodeExtension(e1.enc, desc)\n\t\t}\n\t\tif m2 == nil && err == nil {\n\t\t\tm2, err = decodeExtension(e2.enc, desc)\n\t\t}\n\t\tif err != nil {\n\t\t\t// The encoded form is invalid.\n\t\t\tlog.Printf(\"proto: badly encoded extension %d of %v: %v\", extNum, base, err)\n\t\t\treturn false\n\t\t}\n\t\tif !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/equal_test.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2011 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto_test\n\nimport (\n\t\"testing\"\n\n\t. \"github.com/golang/protobuf/proto\"\n\tproto3pb \"github.com/golang/protobuf/proto/proto3_proto\"\n\tpb \"github.com/golang/protobuf/proto/testdata\"\n)\n\n// Four identical base messages.\n// The init function adds extensions to some of them.\nvar messageWithoutExtension = &pb.MyMessage{Count: Int32(7)}\nvar messageWithExtension1a = &pb.MyMessage{Count: Int32(7)}\nvar messageWithExtension1b = &pb.MyMessage{Count: Int32(7)}\nvar messageWithExtension2 = &pb.MyMessage{Count: Int32(7)}\n\n// Two messages with non-message extensions.\nvar messageWithInt32Extension1 = &pb.MyMessage{Count: Int32(8)}\nvar messageWithInt32Extension2 = &pb.MyMessage{Count: Int32(8)}\n\nfunc init() {\n\text1 := &pb.Ext{Data: String(\"Kirk\")}\n\text2 := &pb.Ext{Data: String(\"Picard\")}\n\n\t// messageWithExtension1a has ext1, but never marshals it.\n\tif err := SetExtension(messageWithExtension1a, pb.E_Ext_More, ext1); err != nil {\n\t\tpanic(\"SetExtension on 1a failed: \" + err.Error())\n\t}\n\n\t// messageWithExtension1b is the unmarshaled form of messageWithExtension1a.\n\tif err := SetExtension(messageWithExtension1b, pb.E_Ext_More, ext1); err != nil {\n\t\tpanic(\"SetExtension on 1b failed: \" + err.Error())\n\t}\n\tbuf, err := Marshal(messageWithExtension1b)\n\tif err != nil {\n\t\tpanic(\"Marshal of 1b failed: \" + err.Error())\n\t}\n\tmessageWithExtension1b.Reset()\n\tif err := Unmarshal(buf, messageWithExtension1b); err != nil {\n\t\tpanic(\"Unmarshal of 1b failed: \" + err.Error())\n\t}\n\n\t// messageWithExtension2 has ext2.\n\tif err := SetExtension(messageWithExtension2, pb.E_Ext_More, ext2); err != nil {\n\t\tpanic(\"SetExtension on 2 failed: \" + err.Error())\n\t}\n\n\tif err := SetExtension(messageWithInt32Extension1, pb.E_Ext_Number, Int32(23)); err != nil {\n\t\tpanic(\"SetExtension on Int32-1 failed: \" + err.Error())\n\t}\n\tif err := SetExtension(messageWithInt32Extension1, pb.E_Ext_Number, Int32(24)); err != nil {\n\t\tpanic(\"SetExtension on Int32-2 failed: \" + err.Error())\n\t}\n}\n\nvar EqualTests = []struct {\n\tdesc string\n\ta, b Message\n\texp  bool\n}{\n\t{\"different types\", &pb.GoEnum{}, &pb.GoTestField{}, false},\n\t{\"equal empty\", &pb.GoEnum{}, &pb.GoEnum{}, true},\n\t{\"nil vs nil\", nil, nil, true},\n\t{\"typed nil vs typed nil\", (*pb.GoEnum)(nil), (*pb.GoEnum)(nil), true},\n\t{\"typed nil vs empty\", (*pb.GoEnum)(nil), &pb.GoEnum{}, false},\n\t{\"different typed nil\", (*pb.GoEnum)(nil), (*pb.GoTestField)(nil), false},\n\n\t{\"one set field, one unset field\", &pb.GoTestField{Label: String(\"foo\")}, &pb.GoTestField{}, false},\n\t{\"one set field zero, one unset field\", &pb.GoTest{Param: Int32(0)}, &pb.GoTest{}, false},\n\t{\"different set fields\", &pb.GoTestField{Label: String(\"foo\")}, &pb.GoTestField{Label: String(\"bar\")}, false},\n\t{\"equal set\", &pb.GoTestField{Label: String(\"foo\")}, &pb.GoTestField{Label: String(\"foo\")}, true},\n\n\t{\"repeated, one set\", &pb.GoTest{F_Int32Repeated: []int32{2, 3}}, &pb.GoTest{}, false},\n\t{\"repeated, different length\", &pb.GoTest{F_Int32Repeated: []int32{2, 3}}, &pb.GoTest{F_Int32Repeated: []int32{2}}, false},\n\t{\"repeated, different value\", &pb.GoTest{F_Int32Repeated: []int32{2}}, &pb.GoTest{F_Int32Repeated: []int32{3}}, false},\n\t{\"repeated, equal\", &pb.GoTest{F_Int32Repeated: []int32{2, 4}}, &pb.GoTest{F_Int32Repeated: []int32{2, 4}}, true},\n\t{\"repeated, nil equal nil\", &pb.GoTest{F_Int32Repeated: nil}, &pb.GoTest{F_Int32Repeated: nil}, true},\n\t{\"repeated, nil equal empty\", &pb.GoTest{F_Int32Repeated: nil}, &pb.GoTest{F_Int32Repeated: []int32{}}, true},\n\t{\"repeated, empty equal nil\", &pb.GoTest{F_Int32Repeated: []int32{}}, &pb.GoTest{F_Int32Repeated: nil}, true},\n\n\t{\n\t\t\"nested, different\",\n\t\t&pb.GoTest{RequiredField: &pb.GoTestField{Label: String(\"foo\")}},\n\t\t&pb.GoTest{RequiredField: &pb.GoTestField{Label: String(\"bar\")}},\n\t\tfalse,\n\t},\n\t{\n\t\t\"nested, equal\",\n\t\t&pb.GoTest{RequiredField: &pb.GoTestField{Label: String(\"wow\")}},\n\t\t&pb.GoTest{RequiredField: &pb.GoTestField{Label: String(\"wow\")}},\n\t\ttrue,\n\t},\n\n\t{\"bytes\", &pb.OtherMessage{Value: []byte(\"foo\")}, &pb.OtherMessage{Value: []byte(\"foo\")}, true},\n\t{\"bytes, empty\", &pb.OtherMessage{Value: []byte{}}, &pb.OtherMessage{Value: []byte{}}, true},\n\t{\"bytes, empty vs nil\", &pb.OtherMessage{Value: []byte{}}, &pb.OtherMessage{Value: nil}, false},\n\t{\n\t\t\"repeated bytes\",\n\t\t&pb.MyMessage{RepBytes: [][]byte{[]byte(\"sham\"), []byte(\"wow\")}},\n\t\t&pb.MyMessage{RepBytes: [][]byte{[]byte(\"sham\"), []byte(\"wow\")}},\n\t\ttrue,\n\t},\n\t// In proto3, []byte{} and []byte(nil) are equal.\n\t{\"proto3 bytes, empty vs nil\", &proto3pb.Message{Data: []byte{}}, &proto3pb.Message{Data: nil}, true},\n\n\t{\"extension vs. no extension\", messageWithoutExtension, messageWithExtension1a, false},\n\t{\"extension vs. same extension\", messageWithExtension1a, messageWithExtension1b, true},\n\t{\"extension vs. different extension\", messageWithExtension1a, messageWithExtension2, false},\n\n\t{\"int32 extension vs. itself\", messageWithInt32Extension1, messageWithInt32Extension1, true},\n\t{\"int32 extension vs. a different int32\", messageWithInt32Extension1, messageWithInt32Extension2, false},\n\n\t{\n\t\t\"message with group\",\n\t\t&pb.MyMessage{\n\t\t\tCount: Int32(1),\n\t\t\tSomegroup: &pb.MyMessage_SomeGroup{\n\t\t\t\tGroupField: Int32(5),\n\t\t\t},\n\t\t},\n\t\t&pb.MyMessage{\n\t\t\tCount: Int32(1),\n\t\t\tSomegroup: &pb.MyMessage_SomeGroup{\n\t\t\t\tGroupField: Int32(5),\n\t\t\t},\n\t\t},\n\t\ttrue,\n\t},\n\n\t{\n\t\t\"map same\",\n\t\t&pb.MessageWithMap{NameMapping: map[int32]string{1: \"Ken\"}},\n\t\t&pb.MessageWithMap{NameMapping: map[int32]string{1: \"Ken\"}},\n\t\ttrue,\n\t},\n\t{\n\t\t\"map different entry\",\n\t\t&pb.MessageWithMap{NameMapping: map[int32]string{1: \"Ken\"}},\n\t\t&pb.MessageWithMap{NameMapping: map[int32]string{2: \"Rob\"}},\n\t\tfalse,\n\t},\n\t{\n\t\t\"map different key only\",\n\t\t&pb.MessageWithMap{NameMapping: map[int32]string{1: \"Ken\"}},\n\t\t&pb.MessageWithMap{NameMapping: map[int32]string{2: \"Ken\"}},\n\t\tfalse,\n\t},\n\t{\n\t\t\"map different value only\",\n\t\t&pb.MessageWithMap{NameMapping: map[int32]string{1: \"Ken\"}},\n\t\t&pb.MessageWithMap{NameMapping: map[int32]string{1: \"Rob\"}},\n\t\tfalse,\n\t},\n\t{\n\t\t\"zero-length maps same\",\n\t\t&pb.MessageWithMap{NameMapping: map[int32]string{}},\n\t\t&pb.MessageWithMap{NameMapping: nil},\n\t\ttrue,\n\t},\n\t{\n\t\t\"orders in map don't matter\",\n\t\t&pb.MessageWithMap{NameMapping: map[int32]string{1: \"Ken\", 2: \"Rob\"}},\n\t\t&pb.MessageWithMap{NameMapping: map[int32]string{2: \"Rob\", 1: \"Ken\"}},\n\t\ttrue,\n\t},\n\t{\n\t\t\"oneof same\",\n\t\t&pb.Communique{Union: &pb.Communique_Number{41}},\n\t\t&pb.Communique{Union: &pb.Communique_Number{41}},\n\t\ttrue,\n\t},\n\t{\n\t\t\"oneof one nil\",\n\t\t&pb.Communique{Union: &pb.Communique_Number{41}},\n\t\t&pb.Communique{},\n\t\tfalse,\n\t},\n\t{\n\t\t\"oneof different\",\n\t\t&pb.Communique{Union: &pb.Communique_Number{41}},\n\t\t&pb.Communique{Union: &pb.Communique_Name{\"Bobby Tables\"}},\n\t\tfalse,\n\t},\n}\n\nfunc TestEqual(t *testing.T) {\n\tfor _, tc := range EqualTests {\n\t\tif res := Equal(tc.a, tc.b); res != tc.exp {\n\t\t\tt.Errorf(\"%v: Equal(%v, %v) = %v, want %v\", tc.desc, tc.a, tc.b, res, tc.exp)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/extensions.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2010 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto\n\n/*\n * Types and routines for supporting protocol buffer extensions.\n */\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"strconv\"\n\t\"sync\"\n)\n\n// ErrMissingExtension is the error returned by GetExtension if the named extension is not in the message.\nvar ErrMissingExtension = errors.New(\"proto: missing extension\")\n\n// ExtensionRange represents a range of message extensions for a protocol buffer.\n// Used in code generated by the protocol compiler.\ntype ExtensionRange struct {\n\tStart, End int32 // both inclusive\n}\n\n// extendableProto is an interface implemented by any protocol buffer generated by the current\n// proto compiler that may be extended.\ntype extendableProto interface {\n\tMessage\n\tExtensionRangeArray() []ExtensionRange\n\textensionsWrite() map[int32]Extension\n\textensionsRead() (map[int32]Extension, sync.Locker)\n}\n\n// extendableProtoV1 is an interface implemented by a protocol buffer generated by the previous\n// version of the proto compiler that may be extended.\ntype extendableProtoV1 interface {\n\tMessage\n\tExtensionRangeArray() []ExtensionRange\n\tExtensionMap() map[int32]Extension\n}\n\n// extensionAdapter is a wrapper around extendableProtoV1 that implements extendableProto.\ntype extensionAdapter struct {\n\textendableProtoV1\n}\n\nfunc (e extensionAdapter) extensionsWrite() map[int32]Extension {\n\treturn e.ExtensionMap()\n}\n\nfunc (e extensionAdapter) extensionsRead() (map[int32]Extension, sync.Locker) {\n\treturn e.ExtensionMap(), notLocker{}\n}\n\n// notLocker is a sync.Locker whose Lock and Unlock methods are nops.\ntype notLocker struct{}\n\nfunc (n notLocker) Lock()   {}\nfunc (n notLocker) Unlock() {}\n\n// extendable returns the extendableProto interface for the given generated proto message.\n// If the proto message has the old extension format, it returns a wrapper that implements\n// the extendableProto interface.\nfunc extendable(p interface{}) (extendableProto, bool) {\n\tif ep, ok := p.(extendableProto); ok {\n\t\treturn ep, ok\n\t}\n\tif ep, ok := p.(extendableProtoV1); ok {\n\t\treturn extensionAdapter{ep}, ok\n\t}\n\treturn nil, false\n}\n\n// XXX_InternalExtensions is an internal representation of proto extensions.\n//\n// Each generated message struct type embeds an anonymous XXX_InternalExtensions field,\n// thus gaining the unexported 'extensions' method, which can be called only from the proto package.\n//\n// The methods of XXX_InternalExtensions are not concurrency safe in general,\n// but calls to logically read-only methods such as has and get may be executed concurrently.\ntype XXX_InternalExtensions struct {\n\t// The struct must be indirect so that if a user inadvertently copies a\n\t// generated message and its embedded XXX_InternalExtensions, they\n\t// avoid the mayhem of a copied mutex.\n\t//\n\t// The mutex serializes all logically read-only operations to p.extensionMap.\n\t// It is up to the client to ensure that write operations to p.extensionMap are\n\t// mutually exclusive with other accesses.\n\tp *struct {\n\t\tmu           sync.Mutex\n\t\textensionMap map[int32]Extension\n\t}\n}\n\n// extensionsWrite returns the extension map, creating it on first use.\nfunc (e *XXX_InternalExtensions) extensionsWrite() map[int32]Extension {\n\tif e.p == nil {\n\t\te.p = new(struct {\n\t\t\tmu           sync.Mutex\n\t\t\textensionMap map[int32]Extension\n\t\t})\n\t\te.p.extensionMap = make(map[int32]Extension)\n\t}\n\treturn e.p.extensionMap\n}\n\n// extensionsRead returns the extensions map for read-only use.  It may be nil.\n// The caller must hold the returned mutex's lock when accessing Elements within the map.\nfunc (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Locker) {\n\tif e.p == nil {\n\t\treturn nil, nil\n\t}\n\treturn e.p.extensionMap, &e.p.mu\n}\n\nvar extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem()\nvar extendableProtoV1Type = reflect.TypeOf((*extendableProtoV1)(nil)).Elem()\n\n// ExtensionDesc represents an extension specification.\n// Used in generated code from the protocol compiler.\ntype ExtensionDesc struct {\n\tExtendedType  Message     // nil pointer to the type that is being extended\n\tExtensionType interface{} // nil pointer to the extension type\n\tField         int32       // field number\n\tName          string      // fully-qualified name of extension, for text formatting\n\tTag           string      // protobuf tag style\n\tFilename      string      // name of the file in which the extension is defined\n}\n\nfunc (ed *ExtensionDesc) repeated() bool {\n\tt := reflect.TypeOf(ed.ExtensionType)\n\treturn t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8\n}\n\n// Extension represents an extension in a message.\ntype Extension struct {\n\t// When an extension is stored in a message using SetExtension\n\t// only desc and value are set. When the message is marshaled\n\t// enc will be set to the encoded form of the message.\n\t//\n\t// When a message is unmarshaled and contains extensions, each\n\t// extension will have only enc set. When such an extension is\n\t// accessed using GetExtension (or GetExtensions) desc and value\n\t// will be set.\n\tdesc  *ExtensionDesc\n\tvalue interface{}\n\tenc   []byte\n}\n\n// SetRawExtension is for testing only.\nfunc SetRawExtension(base Message, id int32, b []byte) {\n\tepb, ok := extendable(base)\n\tif !ok {\n\t\treturn\n\t}\n\textmap := epb.extensionsWrite()\n\textmap[id] = Extension{enc: b}\n}\n\n// isExtensionField returns true iff the given field number is in an extension range.\nfunc isExtensionField(pb extendableProto, field int32) bool {\n\tfor _, er := range pb.ExtensionRangeArray() {\n\t\tif er.Start <= field && field <= er.End {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// checkExtensionTypes checks that the given extension is valid for pb.\nfunc checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error {\n\tvar pbi interface{} = pb\n\t// Check the extended type.\n\tif ea, ok := pbi.(extensionAdapter); ok {\n\t\tpbi = ea.extendableProtoV1\n\t}\n\tif a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b {\n\t\treturn errors.New(\"proto: bad extended type; \" + b.String() + \" does not extend \" + a.String())\n\t}\n\t// Check the range.\n\tif !isExtensionField(pb, extension.Field) {\n\t\treturn errors.New(\"proto: bad extension number; not in declared ranges\")\n\t}\n\treturn nil\n}\n\n// extPropKey is sufficient to uniquely identify an extension.\ntype extPropKey struct {\n\tbase  reflect.Type\n\tfield int32\n}\n\nvar extProp = struct {\n\tsync.RWMutex\n\tm map[extPropKey]*Properties\n}{\n\tm: make(map[extPropKey]*Properties),\n}\n\nfunc extensionProperties(ed *ExtensionDesc) *Properties {\n\tkey := extPropKey{base: reflect.TypeOf(ed.ExtendedType), field: ed.Field}\n\n\textProp.RLock()\n\tif prop, ok := extProp.m[key]; ok {\n\t\textProp.RUnlock()\n\t\treturn prop\n\t}\n\textProp.RUnlock()\n\n\textProp.Lock()\n\tdefer extProp.Unlock()\n\t// Check again.\n\tif prop, ok := extProp.m[key]; ok {\n\t\treturn prop\n\t}\n\n\tprop := new(Properties)\n\tprop.Init(reflect.TypeOf(ed.ExtensionType), \"unknown_name\", ed.Tag, nil)\n\textProp.m[key] = prop\n\treturn prop\n}\n\n// encode encodes any unmarshaled (unencoded) extensions in e.\nfunc encodeExtensions(e *XXX_InternalExtensions) error {\n\tm, mu := e.extensionsRead()\n\tif m == nil {\n\t\treturn nil // fast path\n\t}\n\tmu.Lock()\n\tdefer mu.Unlock()\n\treturn encodeExtensionsMap(m)\n}\n\n// encode encodes any unmarshaled (unencoded) extensions in e.\nfunc encodeExtensionsMap(m map[int32]Extension) error {\n\tfor k, e := range m {\n\t\tif e.value == nil || e.desc == nil {\n\t\t\t// Extension is only in its encoded form.\n\t\t\tcontinue\n\t\t}\n\n\t\t// We don't skip extensions that have an encoded form set,\n\t\t// because the extension value may have been mutated after\n\t\t// the last time this function was called.\n\n\t\tet := reflect.TypeOf(e.desc.ExtensionType)\n\t\tprops := extensionProperties(e.desc)\n\n\t\tp := NewBuffer(nil)\n\t\t// If e.value has type T, the encoder expects a *struct{ X T }.\n\t\t// Pass a *T with a zero field and hope it all works out.\n\t\tx := reflect.New(et)\n\t\tx.Elem().Set(reflect.ValueOf(e.value))\n\t\tif err := props.enc(p, props, toStructPointer(x)); err != nil {\n\t\t\treturn err\n\t\t}\n\t\te.enc = p.buf\n\t\tm[k] = e\n\t}\n\treturn nil\n}\n\nfunc extensionsSize(e *XXX_InternalExtensions) (n int) {\n\tm, mu := e.extensionsRead()\n\tif m == nil {\n\t\treturn 0\n\t}\n\tmu.Lock()\n\tdefer mu.Unlock()\n\treturn extensionsMapSize(m)\n}\n\nfunc extensionsMapSize(m map[int32]Extension) (n int) {\n\tfor _, e := range m {\n\t\tif e.value == nil || e.desc == nil {\n\t\t\t// Extension is only in its encoded form.\n\t\t\tn += len(e.enc)\n\t\t\tcontinue\n\t\t}\n\n\t\t// We don't skip extensions that have an encoded form set,\n\t\t// because the extension value may have been mutated after\n\t\t// the last time this function was called.\n\n\t\tet := reflect.TypeOf(e.desc.ExtensionType)\n\t\tprops := extensionProperties(e.desc)\n\n\t\t// If e.value has type T, the encoder expects a *struct{ X T }.\n\t\t// Pass a *T with a zero field and hope it all works out.\n\t\tx := reflect.New(et)\n\t\tx.Elem().Set(reflect.ValueOf(e.value))\n\t\tn += props.size(props, toStructPointer(x))\n\t}\n\treturn\n}\n\n// HasExtension returns whether the given extension is present in pb.\nfunc HasExtension(pb Message, extension *ExtensionDesc) bool {\n\t// TODO: Check types, field numbers, etc.?\n\tepb, ok := extendable(pb)\n\tif !ok {\n\t\treturn false\n\t}\n\textmap, mu := epb.extensionsRead()\n\tif extmap == nil {\n\t\treturn false\n\t}\n\tmu.Lock()\n\t_, ok = extmap[extension.Field]\n\tmu.Unlock()\n\treturn ok\n}\n\n// ClearExtension removes the given extension from pb.\nfunc ClearExtension(pb Message, extension *ExtensionDesc) {\n\tepb, ok := extendable(pb)\n\tif !ok {\n\t\treturn\n\t}\n\t// TODO: Check types, field numbers, etc.?\n\textmap := epb.extensionsWrite()\n\tdelete(extmap, extension.Field)\n}\n\n// GetExtension parses and returns the given extension of pb.\n// If the extension is not present and has no default value it returns ErrMissingExtension.\nfunc GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) {\n\tepb, ok := extendable(pb)\n\tif !ok {\n\t\treturn nil, errors.New(\"proto: not an extendable proto\")\n\t}\n\n\tif err := checkExtensionTypes(epb, extension); err != nil {\n\t\treturn nil, err\n\t}\n\n\temap, mu := epb.extensionsRead()\n\tif emap == nil {\n\t\treturn defaultExtensionValue(extension)\n\t}\n\tmu.Lock()\n\tdefer mu.Unlock()\n\te, ok := emap[extension.Field]\n\tif !ok {\n\t\t// defaultExtensionValue returns the default value or\n\t\t// ErrMissingExtension if there is no default.\n\t\treturn defaultExtensionValue(extension)\n\t}\n\n\tif e.value != nil {\n\t\t// Already decoded. Check the descriptor, though.\n\t\tif e.desc != extension {\n\t\t\t// This shouldn't happen. If it does, it means that\n\t\t\t// GetExtension was called twice with two different\n\t\t\t// descriptors with the same field number.\n\t\t\treturn nil, errors.New(\"proto: descriptor conflict\")\n\t\t}\n\t\treturn e.value, nil\n\t}\n\n\tv, err := decodeExtension(e.enc, extension)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Remember the decoded version and drop the encoded version.\n\t// That way it is safe to mutate what we return.\n\te.value = v\n\te.desc = extension\n\te.enc = nil\n\temap[extension.Field] = e\n\treturn e.value, nil\n}\n\n// defaultExtensionValue returns the default value for extension.\n// If no default for an extension is defined ErrMissingExtension is returned.\nfunc defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) {\n\tt := reflect.TypeOf(extension.ExtensionType)\n\tprops := extensionProperties(extension)\n\n\tsf, _, err := fieldDefault(t, props)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif sf == nil || sf.value == nil {\n\t\t// There is no default value.\n\t\treturn nil, ErrMissingExtension\n\t}\n\n\tif t.Kind() != reflect.Ptr {\n\t\t// We do not need to return a Ptr, we can directly return sf.value.\n\t\treturn sf.value, nil\n\t}\n\n\t// We need to return an interface{} that is a pointer to sf.value.\n\tvalue := reflect.New(t).Elem()\n\tvalue.Set(reflect.New(value.Type().Elem()))\n\tif sf.kind == reflect.Int32 {\n\t\t// We may have an int32 or an enum, but the underlying data is int32.\n\t\t// Since we can't set an int32 into a non int32 reflect.value directly\n\t\t// set it as a int32.\n\t\tvalue.Elem().SetInt(int64(sf.value.(int32)))\n\t} else {\n\t\tvalue.Elem().Set(reflect.ValueOf(sf.value))\n\t}\n\treturn value.Interface(), nil\n}\n\n// decodeExtension decodes an extension encoded in b.\nfunc decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) {\n\to := NewBuffer(b)\n\n\tt := reflect.TypeOf(extension.ExtensionType)\n\n\tprops := extensionProperties(extension)\n\n\t// t is a pointer to a struct, pointer to basic type or a slice.\n\t// Allocate a \"field\" to store the pointer/slice itself; the\n\t// pointer/slice will be stored here. We pass\n\t// the address of this field to props.dec.\n\t// This passes a zero field and a *t and lets props.dec\n\t// interpret it as a *struct{ x t }.\n\tvalue := reflect.New(t).Elem()\n\n\tfor {\n\t\t// Discard wire type and field number varint. It isn't needed.\n\t\tif _, err := o.DecodeVarint(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif err := props.dec(o, props, toStructPointer(value.Addr())); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif o.index >= len(o.buf) {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn value.Interface(), nil\n}\n\n// GetExtensions returns a slice of the extensions present in pb that are also listed in es.\n// The returned slice has the same length as es; missing extensions will appear as nil elements.\nfunc GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) {\n\tepb, ok := extendable(pb)\n\tif !ok {\n\t\treturn nil, errors.New(\"proto: not an extendable proto\")\n\t}\n\textensions = make([]interface{}, len(es))\n\tfor i, e := range es {\n\t\textensions[i], err = GetExtension(epb, e)\n\t\tif err == ErrMissingExtension {\n\t\t\terr = nil\n\t\t}\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}\n\n// ExtensionDescs returns a new slice containing pb's extension descriptors, in undefined order.\n// For non-registered extensions, ExtensionDescs returns an incomplete descriptor containing\n// just the Field field, which defines the extension's field number.\nfunc ExtensionDescs(pb Message) ([]*ExtensionDesc, error) {\n\tepb, ok := extendable(pb)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"proto: %T is not an extendable proto.Message\", pb)\n\t}\n\tregisteredExtensions := RegisteredExtensions(pb)\n\n\temap, mu := epb.extensionsRead()\n\tif emap == nil {\n\t\treturn nil, nil\n\t}\n\tmu.Lock()\n\tdefer mu.Unlock()\n\textensions := make([]*ExtensionDesc, 0, len(emap))\n\tfor extid, e := range emap {\n\t\tdesc := e.desc\n\t\tif desc == nil {\n\t\t\tdesc = registeredExtensions[extid]\n\t\t\tif desc == nil {\n\t\t\t\tdesc = &ExtensionDesc{Field: extid}\n\t\t\t}\n\t\t}\n\n\t\textensions = append(extensions, desc)\n\t}\n\treturn extensions, nil\n}\n\n// SetExtension sets the specified extension of pb to the specified value.\nfunc SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error {\n\tepb, ok := extendable(pb)\n\tif !ok {\n\t\treturn errors.New(\"proto: not an extendable proto\")\n\t}\n\tif err := checkExtensionTypes(epb, extension); err != nil {\n\t\treturn err\n\t}\n\ttyp := reflect.TypeOf(extension.ExtensionType)\n\tif typ != reflect.TypeOf(value) {\n\t\treturn errors.New(\"proto: bad extension value type\")\n\t}\n\t// nil extension values need to be caught early, because the\n\t// encoder can't distinguish an ErrNil due to a nil extension\n\t// from an ErrNil due to a missing field. Extensions are\n\t// always optional, so the encoder would just swallow the error\n\t// and drop all the extensions from the encoded message.\n\tif reflect.ValueOf(value).IsNil() {\n\t\treturn fmt.Errorf(\"proto: SetExtension called with nil value of type %T\", value)\n\t}\n\n\textmap := epb.extensionsWrite()\n\textmap[extension.Field] = Extension{desc: extension, value: value}\n\treturn nil\n}\n\n// ClearAllExtensions clears all extensions from pb.\nfunc ClearAllExtensions(pb Message) {\n\tepb, ok := extendable(pb)\n\tif !ok {\n\t\treturn\n\t}\n\tm := epb.extensionsWrite()\n\tfor k := range m {\n\t\tdelete(m, k)\n\t}\n}\n\n// A global registry of extensions.\n// The generated code will register the generated descriptors by calling RegisterExtension.\n\nvar extensionMaps = make(map[reflect.Type]map[int32]*ExtensionDesc)\n\n// RegisterExtension is called from the generated code.\nfunc RegisterExtension(desc *ExtensionDesc) {\n\tst := reflect.TypeOf(desc.ExtendedType).Elem()\n\tm := extensionMaps[st]\n\tif m == nil {\n\t\tm = make(map[int32]*ExtensionDesc)\n\t\textensionMaps[st] = m\n\t}\n\tif _, ok := m[desc.Field]; ok {\n\t\tpanic(\"proto: duplicate extension registered: \" + st.String() + \" \" + strconv.Itoa(int(desc.Field)))\n\t}\n\tm[desc.Field] = desc\n}\n\n// RegisteredExtensions returns a map of the registered extensions of a\n// protocol buffer struct, indexed by the extension number.\n// The argument pb should be a nil pointer to the struct type.\nfunc RegisteredExtensions(pb Message) map[int32]*ExtensionDesc {\n\treturn extensionMaps[reflect.TypeOf(pb).Elem()]\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/extensions_test.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2014 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto_test\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"sort\"\n\t\"testing\"\n\n\t\"github.com/golang/protobuf/proto\"\n\tpb \"github.com/golang/protobuf/proto/testdata\"\n\t\"golang.org/x/sync/errgroup\"\n)\n\nfunc TestGetExtensionsWithMissingExtensions(t *testing.T) {\n\tmsg := &pb.MyMessage{}\n\text1 := &pb.Ext{}\n\tif err := proto.SetExtension(msg, pb.E_Ext_More, ext1); err != nil {\n\t\tt.Fatalf(\"Could not set ext1: %s\", err)\n\t}\n\texts, err := proto.GetExtensions(msg, []*proto.ExtensionDesc{\n\t\tpb.E_Ext_More,\n\t\tpb.E_Ext_Text,\n\t})\n\tif err != nil {\n\t\tt.Fatalf(\"GetExtensions() failed: %s\", err)\n\t}\n\tif exts[0] != ext1 {\n\t\tt.Errorf(\"ext1 not in returned extensions: %T %v\", exts[0], exts[0])\n\t}\n\tif exts[1] != nil {\n\t\tt.Errorf(\"ext2 in returned extensions: %T %v\", exts[1], exts[1])\n\t}\n}\n\nfunc TestExtensionDescsWithMissingExtensions(t *testing.T) {\n\tmsg := &pb.MyMessage{Count: proto.Int32(0)}\n\textdesc1 := pb.E_Ext_More\n\tif descs, err := proto.ExtensionDescs(msg); len(descs) != 0 || err != nil {\n\t\tt.Errorf(\"proto.ExtensionDescs: got %d descs, error %v; want 0, nil\", len(descs), err)\n\t}\n\n\text1 := &pb.Ext{}\n\tif err := proto.SetExtension(msg, extdesc1, ext1); err != nil {\n\t\tt.Fatalf(\"Could not set ext1: %s\", err)\n\t}\n\textdesc2 := &proto.ExtensionDesc{\n\t\tExtendedType:  (*pb.MyMessage)(nil),\n\t\tExtensionType: (*bool)(nil),\n\t\tField:         123456789,\n\t\tName:          \"a.b\",\n\t\tTag:           \"varint,123456789,opt\",\n\t}\n\text2 := proto.Bool(false)\n\tif err := proto.SetExtension(msg, extdesc2, ext2); err != nil {\n\t\tt.Fatalf(\"Could not set ext2: %s\", err)\n\t}\n\n\tb, err := proto.Marshal(msg)\n\tif err != nil {\n\t\tt.Fatalf(\"Could not marshal msg: %v\", err)\n\t}\n\tif err := proto.Unmarshal(b, msg); err != nil {\n\t\tt.Fatalf(\"Could not unmarshal into msg: %v\", err)\n\t}\n\n\tdescs, err := proto.ExtensionDescs(msg)\n\tif err != nil {\n\t\tt.Fatalf(\"proto.ExtensionDescs: got error %v\", err)\n\t}\n\tsortExtDescs(descs)\n\twantDescs := []*proto.ExtensionDesc{extdesc1, &proto.ExtensionDesc{Field: extdesc2.Field}}\n\tif !reflect.DeepEqual(descs, wantDescs) {\n\t\tt.Errorf(\"proto.ExtensionDescs(msg) sorted extension ids: got %+v, want %+v\", descs, wantDescs)\n\t}\n}\n\ntype ExtensionDescSlice []*proto.ExtensionDesc\n\nfunc (s ExtensionDescSlice) Len() int           { return len(s) }\nfunc (s ExtensionDescSlice) Less(i, j int) bool { return s[i].Field < s[j].Field }\nfunc (s ExtensionDescSlice) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }\n\nfunc sortExtDescs(s []*proto.ExtensionDesc) {\n\tsort.Sort(ExtensionDescSlice(s))\n}\n\nfunc TestGetExtensionStability(t *testing.T) {\n\tcheck := func(m *pb.MyMessage) bool {\n\t\text1, err := proto.GetExtension(m, pb.E_Ext_More)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"GetExtension() failed: %s\", err)\n\t\t}\n\t\text2, err := proto.GetExtension(m, pb.E_Ext_More)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"GetExtension() failed: %s\", err)\n\t\t}\n\t\treturn ext1 == ext2\n\t}\n\tmsg := &pb.MyMessage{Count: proto.Int32(4)}\n\text0 := &pb.Ext{}\n\tif err := proto.SetExtension(msg, pb.E_Ext_More, ext0); err != nil {\n\t\tt.Fatalf(\"Could not set ext1: %s\", ext0)\n\t}\n\tif !check(msg) {\n\t\tt.Errorf(\"GetExtension() not stable before marshaling\")\n\t}\n\tbb, err := proto.Marshal(msg)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal() failed: %s\", err)\n\t}\n\tmsg1 := &pb.MyMessage{}\n\terr = proto.Unmarshal(bb, msg1)\n\tif err != nil {\n\t\tt.Fatalf(\"Unmarshal() failed: %s\", err)\n\t}\n\tif !check(msg1) {\n\t\tt.Errorf(\"GetExtension() not stable after unmarshaling\")\n\t}\n}\n\nfunc TestGetExtensionDefaults(t *testing.T) {\n\tvar setFloat64 float64 = 1\n\tvar setFloat32 float32 = 2\n\tvar setInt32 int32 = 3\n\tvar setInt64 int64 = 4\n\tvar setUint32 uint32 = 5\n\tvar setUint64 uint64 = 6\n\tvar setBool = true\n\tvar setBool2 = false\n\tvar setString = \"Goodnight string\"\n\tvar setBytes = []byte(\"Goodnight bytes\")\n\tvar setEnum = pb.DefaultsMessage_TWO\n\n\ttype testcase struct {\n\t\text  *proto.ExtensionDesc // Extension we are testing.\n\t\twant interface{}          // Expected value of extension, or nil (meaning that GetExtension will fail).\n\t\tdef  interface{}          // Expected value of extension after ClearExtension().\n\t}\n\ttests := []testcase{\n\t\t{pb.E_NoDefaultDouble, setFloat64, nil},\n\t\t{pb.E_NoDefaultFloat, setFloat32, nil},\n\t\t{pb.E_NoDefaultInt32, setInt32, nil},\n\t\t{pb.E_NoDefaultInt64, setInt64, nil},\n\t\t{pb.E_NoDefaultUint32, setUint32, nil},\n\t\t{pb.E_NoDefaultUint64, setUint64, nil},\n\t\t{pb.E_NoDefaultSint32, setInt32, nil},\n\t\t{pb.E_NoDefaultSint64, setInt64, nil},\n\t\t{pb.E_NoDefaultFixed32, setUint32, nil},\n\t\t{pb.E_NoDefaultFixed64, setUint64, nil},\n\t\t{pb.E_NoDefaultSfixed32, setInt32, nil},\n\t\t{pb.E_NoDefaultSfixed64, setInt64, nil},\n\t\t{pb.E_NoDefaultBool, setBool, nil},\n\t\t{pb.E_NoDefaultBool, setBool2, nil},\n\t\t{pb.E_NoDefaultString, setString, nil},\n\t\t{pb.E_NoDefaultBytes, setBytes, nil},\n\t\t{pb.E_NoDefaultEnum, setEnum, nil},\n\t\t{pb.E_DefaultDouble, setFloat64, float64(3.1415)},\n\t\t{pb.E_DefaultFloat, setFloat32, float32(3.14)},\n\t\t{pb.E_DefaultInt32, setInt32, int32(42)},\n\t\t{pb.E_DefaultInt64, setInt64, int64(43)},\n\t\t{pb.E_DefaultUint32, setUint32, uint32(44)},\n\t\t{pb.E_DefaultUint64, setUint64, uint64(45)},\n\t\t{pb.E_DefaultSint32, setInt32, int32(46)},\n\t\t{pb.E_DefaultSint64, setInt64, int64(47)},\n\t\t{pb.E_DefaultFixed32, setUint32, uint32(48)},\n\t\t{pb.E_DefaultFixed64, setUint64, uint64(49)},\n\t\t{pb.E_DefaultSfixed32, setInt32, int32(50)},\n\t\t{pb.E_DefaultSfixed64, setInt64, int64(51)},\n\t\t{pb.E_DefaultBool, setBool, true},\n\t\t{pb.E_DefaultBool, setBool2, true},\n\t\t{pb.E_DefaultString, setString, \"Hello, string\"},\n\t\t{pb.E_DefaultBytes, setBytes, []byte(\"Hello, bytes\")},\n\t\t{pb.E_DefaultEnum, setEnum, pb.DefaultsMessage_ONE},\n\t}\n\n\tcheckVal := func(test testcase, msg *pb.DefaultsMessage, valWant interface{}) error {\n\t\tval, err := proto.GetExtension(msg, test.ext)\n\t\tif err != nil {\n\t\t\tif valWant != nil {\n\t\t\t\treturn fmt.Errorf(\"GetExtension(): %s\", err)\n\t\t\t}\n\t\t\tif want := proto.ErrMissingExtension; err != want {\n\t\t\t\treturn fmt.Errorf(\"Unexpected error: got %v, want %v\", err, want)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t\t// All proto2 extension values are either a pointer to a value or a slice of values.\n\t\tty := reflect.TypeOf(val)\n\t\ttyWant := reflect.TypeOf(test.ext.ExtensionType)\n\t\tif got, want := ty, tyWant; got != want {\n\t\t\treturn fmt.Errorf(\"unexpected reflect.TypeOf(): got %v want %v\", got, want)\n\t\t}\n\t\ttye := ty.Elem()\n\t\ttyeWant := tyWant.Elem()\n\t\tif got, want := tye, tyeWant; got != want {\n\t\t\treturn fmt.Errorf(\"unexpected reflect.TypeOf().Elem(): got %v want %v\", got, want)\n\t\t}\n\n\t\t// Check the name of the type of the value.\n\t\t// If it is an enum it will be type int32 with the name of the enum.\n\t\tif got, want := tye.Name(), tye.Name(); got != want {\n\t\t\treturn fmt.Errorf(\"unexpected reflect.TypeOf().Elem().Name(): got %v want %v\", got, want)\n\t\t}\n\n\t\t// Check that value is what we expect.\n\t\t// If we have a pointer in val, get the value it points to.\n\t\tvalExp := val\n\t\tif ty.Kind() == reflect.Ptr {\n\t\t\tvalExp = reflect.ValueOf(val).Elem().Interface()\n\t\t}\n\t\tif got, want := valExp, valWant; !reflect.DeepEqual(got, want) {\n\t\t\treturn fmt.Errorf(\"unexpected reflect.DeepEqual(): got %v want %v\", got, want)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tsetTo := func(test testcase) interface{} {\n\t\tsetTo := reflect.ValueOf(test.want)\n\t\tif typ := reflect.TypeOf(test.ext.ExtensionType); typ.Kind() == reflect.Ptr {\n\t\t\tsetTo = reflect.New(typ).Elem()\n\t\t\tsetTo.Set(reflect.New(setTo.Type().Elem()))\n\t\t\tsetTo.Elem().Set(reflect.ValueOf(test.want))\n\t\t}\n\t\treturn setTo.Interface()\n\t}\n\n\tfor _, test := range tests {\n\t\tmsg := &pb.DefaultsMessage{}\n\t\tname := test.ext.Name\n\n\t\t// Check the initial value.\n\t\tif err := checkVal(test, msg, test.def); err != nil {\n\t\t\tt.Errorf(\"%s: %v\", name, err)\n\t\t}\n\n\t\t// Set the per-type value and check value.\n\t\tname = fmt.Sprintf(\"%s (set to %T %v)\", name, test.want, test.want)\n\t\tif err := proto.SetExtension(msg, test.ext, setTo(test)); err != nil {\n\t\t\tt.Errorf(\"%s: SetExtension(): %v\", name, err)\n\t\t\tcontinue\n\t\t}\n\t\tif err := checkVal(test, msg, test.want); err != nil {\n\t\t\tt.Errorf(\"%s: %v\", name, err)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Set and check the value.\n\t\tname += \" (cleared)\"\n\t\tproto.ClearExtension(msg, test.ext)\n\t\tif err := checkVal(test, msg, test.def); err != nil {\n\t\t\tt.Errorf(\"%s: %v\", name, err)\n\t\t}\n\t}\n}\n\nfunc TestExtensionsRoundTrip(t *testing.T) {\n\tmsg := &pb.MyMessage{}\n\text1 := &pb.Ext{\n\t\tData: proto.String(\"hi\"),\n\t}\n\text2 := &pb.Ext{\n\t\tData: proto.String(\"there\"),\n\t}\n\texists := proto.HasExtension(msg, pb.E_Ext_More)\n\tif exists {\n\t\tt.Error(\"Extension More present unexpectedly\")\n\t}\n\tif err := proto.SetExtension(msg, pb.E_Ext_More, ext1); err != nil {\n\t\tt.Error(err)\n\t}\n\tif err := proto.SetExtension(msg, pb.E_Ext_More, ext2); err != nil {\n\t\tt.Error(err)\n\t}\n\te, err := proto.GetExtension(msg, pb.E_Ext_More)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tx, ok := e.(*pb.Ext)\n\tif !ok {\n\t\tt.Errorf(\"e has type %T, expected testdata.Ext\", e)\n\t} else if *x.Data != \"there\" {\n\t\tt.Errorf(\"SetExtension failed to overwrite, got %+v, not 'there'\", x)\n\t}\n\tproto.ClearExtension(msg, pb.E_Ext_More)\n\tif _, err = proto.GetExtension(msg, pb.E_Ext_More); err != proto.ErrMissingExtension {\n\t\tt.Errorf(\"got %v, expected ErrMissingExtension\", e)\n\t}\n\tif _, err := proto.GetExtension(msg, pb.E_X215); err == nil {\n\t\tt.Error(\"expected bad extension error, got nil\")\n\t}\n\tif err := proto.SetExtension(msg, pb.E_X215, 12); err == nil {\n\t\tt.Error(\"expected extension err\")\n\t}\n\tif err := proto.SetExtension(msg, pb.E_Ext_More, 12); err == nil {\n\t\tt.Error(\"expected some sort of type mismatch error, got nil\")\n\t}\n}\n\nfunc TestNilExtension(t *testing.T) {\n\tmsg := &pb.MyMessage{\n\t\tCount: proto.Int32(1),\n\t}\n\tif err := proto.SetExtension(msg, pb.E_Ext_Text, proto.String(\"hello\")); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif err := proto.SetExtension(msg, pb.E_Ext_More, (*pb.Ext)(nil)); err == nil {\n\t\tt.Error(\"expected SetExtension to fail due to a nil extension\")\n\t} else if want := \"proto: SetExtension called with nil value of type *testdata.Ext\"; err.Error() != want {\n\t\tt.Errorf(\"expected error %v, got %v\", want, err)\n\t}\n\t// Note: if the behavior of Marshal is ever changed to ignore nil extensions, update\n\t// this test to verify that E_Ext_Text is properly propagated through marshal->unmarshal.\n}\n\nfunc TestMarshalUnmarshalRepeatedExtension(t *testing.T) {\n\t// Add a repeated extension to the result.\n\ttests := []struct {\n\t\tname string\n\t\text  []*pb.ComplexExtension\n\t}{\n\t\t{\n\t\t\t\"two fields\",\n\t\t\t[]*pb.ComplexExtension{\n\t\t\t\t{First: proto.Int32(7)},\n\t\t\t\t{Second: proto.Int32(11)},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"repeated field\",\n\t\t\t[]*pb.ComplexExtension{\n\t\t\t\t{Third: []int32{1000}},\n\t\t\t\t{Third: []int32{2000}},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"two fields and repeated field\",\n\t\t\t[]*pb.ComplexExtension{\n\t\t\t\t{Third: []int32{1000}},\n\t\t\t\t{First: proto.Int32(9)},\n\t\t\t\t{Second: proto.Int32(21)},\n\t\t\t\t{Third: []int32{2000}},\n\t\t\t},\n\t\t},\n\t}\n\tfor _, test := range tests {\n\t\t// Marshal message with a repeated extension.\n\t\tmsg1 := new(pb.OtherMessage)\n\t\terr := proto.SetExtension(msg1, pb.E_RComplex, test.ext)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"[%s] Error setting extension: %v\", test.name, err)\n\t\t}\n\t\tb, err := proto.Marshal(msg1)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"[%s] Error marshaling message: %v\", test.name, err)\n\t\t}\n\n\t\t// Unmarshal and read the merged proto.\n\t\tmsg2 := new(pb.OtherMessage)\n\t\terr = proto.Unmarshal(b, msg2)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"[%s] Error unmarshaling message: %v\", test.name, err)\n\t\t}\n\t\te, err := proto.GetExtension(msg2, pb.E_RComplex)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"[%s] Error getting extension: %v\", test.name, err)\n\t\t}\n\t\text := e.([]*pb.ComplexExtension)\n\t\tif ext == nil {\n\t\t\tt.Fatalf(\"[%s] Invalid extension\", test.name)\n\t\t}\n\t\tif !reflect.DeepEqual(ext, test.ext) {\n\t\t\tt.Errorf(\"[%s] Wrong value for ComplexExtension: got: %v want: %v\\n\", test.name, ext, test.ext)\n\t\t}\n\t}\n}\n\nfunc TestUnmarshalRepeatingNonRepeatedExtension(t *testing.T) {\n\t// We may see multiple instances of the same extension in the wire\n\t// format. For example, the proto compiler may encode custom options in\n\t// this way. Here, we verify that we merge the extensions together.\n\ttests := []struct {\n\t\tname string\n\t\text  []*pb.ComplexExtension\n\t}{\n\t\t{\n\t\t\t\"two fields\",\n\t\t\t[]*pb.ComplexExtension{\n\t\t\t\t{First: proto.Int32(7)},\n\t\t\t\t{Second: proto.Int32(11)},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"repeated field\",\n\t\t\t[]*pb.ComplexExtension{\n\t\t\t\t{Third: []int32{1000}},\n\t\t\t\t{Third: []int32{2000}},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"two fields and repeated field\",\n\t\t\t[]*pb.ComplexExtension{\n\t\t\t\t{Third: []int32{1000}},\n\t\t\t\t{First: proto.Int32(9)},\n\t\t\t\t{Second: proto.Int32(21)},\n\t\t\t\t{Third: []int32{2000}},\n\t\t\t},\n\t\t},\n\t}\n\tfor _, test := range tests {\n\t\tvar buf bytes.Buffer\n\t\tvar want pb.ComplexExtension\n\n\t\t// Generate a serialized representation of a repeated extension\n\t\t// by catenating bytes together.\n\t\tfor i, e := range test.ext {\n\t\t\t// Merge to create the wanted proto.\n\t\t\tproto.Merge(&want, e)\n\n\t\t\t// serialize the message\n\t\t\tmsg := new(pb.OtherMessage)\n\t\t\terr := proto.SetExtension(msg, pb.E_Complex, e)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"[%s] Error setting extension %d: %v\", test.name, i, err)\n\t\t\t}\n\t\t\tb, err := proto.Marshal(msg)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"[%s] Error marshaling message %d: %v\", test.name, i, err)\n\t\t\t}\n\t\t\tbuf.Write(b)\n\t\t}\n\n\t\t// Unmarshal and read the merged proto.\n\t\tmsg2 := new(pb.OtherMessage)\n\t\terr := proto.Unmarshal(buf.Bytes(), msg2)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"[%s] Error unmarshaling message: %v\", test.name, err)\n\t\t}\n\t\te, err := proto.GetExtension(msg2, pb.E_Complex)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"[%s] Error getting extension: %v\", test.name, err)\n\t\t}\n\t\text := e.(*pb.ComplexExtension)\n\t\tif ext == nil {\n\t\t\tt.Fatalf(\"[%s] Invalid extension\", test.name)\n\t\t}\n\t\tif !reflect.DeepEqual(*ext, want) {\n\t\t\tt.Errorf(\"[%s] Wrong value for ComplexExtension: got: %s want: %s\\n\", test.name, ext, want)\n\t\t}\n\t}\n}\n\nfunc TestClearAllExtensions(t *testing.T) {\n\t// unregistered extension\n\tdesc := &proto.ExtensionDesc{\n\t\tExtendedType:  (*pb.MyMessage)(nil),\n\t\tExtensionType: (*bool)(nil),\n\t\tField:         101010100,\n\t\tName:          \"emptyextension\",\n\t\tTag:           \"varint,0,opt\",\n\t}\n\tm := &pb.MyMessage{}\n\tif proto.HasExtension(m, desc) {\n\t\tt.Errorf(\"proto.HasExtension(%s): got true, want false\", proto.MarshalTextString(m))\n\t}\n\tif err := proto.SetExtension(m, desc, proto.Bool(true)); err != nil {\n\t\tt.Errorf(\"proto.SetExtension(m, desc, true): got error %q, want nil\", err)\n\t}\n\tif !proto.HasExtension(m, desc) {\n\t\tt.Errorf(\"proto.HasExtension(%s): got false, want true\", proto.MarshalTextString(m))\n\t}\n\tproto.ClearAllExtensions(m)\n\tif proto.HasExtension(m, desc) {\n\t\tt.Errorf(\"proto.HasExtension(%s): got true, want false\", proto.MarshalTextString(m))\n\t}\n}\n\nfunc TestMarshalRace(t *testing.T) {\n\t// unregistered extension\n\tdesc := &proto.ExtensionDesc{\n\t\tExtendedType:  (*pb.MyMessage)(nil),\n\t\tExtensionType: (*bool)(nil),\n\t\tField:         101010100,\n\t\tName:          \"emptyextension\",\n\t\tTag:           \"varint,0,opt\",\n\t}\n\n\tm := &pb.MyMessage{Count: proto.Int32(4)}\n\tif err := proto.SetExtension(m, desc, proto.Bool(true)); err != nil {\n\t\tt.Errorf(\"proto.SetExtension(m, desc, true): got error %q, want nil\", err)\n\t}\n\n\tvar g errgroup.Group\n\tfor n := 3; n > 0; n-- {\n\t\tg.Go(func() error {\n\t\t\t_, err := proto.Marshal(m)\n\t\t\treturn err\n\t\t})\n\t}\n\tif err := g.Wait(); err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/lib.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2010 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n/*\nPackage proto converts data structures to and from the wire format of\nprotocol buffers.  It works in concert with the Go source code generated\nfor .proto files by the protocol compiler.\n\nA summary of the properties of the protocol buffer interface\nfor a protocol buffer variable v:\n\n  - Names are turned from camel_case to CamelCase for export.\n  - There are no methods on v to set fields; just treat\n\tthem as structure fields.\n  - There are getters that return a field's value if set,\n\tand return the field's default value if unset.\n\tThe getters work even if the receiver is a nil message.\n  - The zero value for a struct is its correct initialization state.\n\tAll desired fields must be set before marshaling.\n  - A Reset() method will restore a protobuf struct to its zero state.\n  - Non-repeated fields are pointers to the values; nil means unset.\n\tThat is, optional or required field int32 f becomes F *int32.\n  - Repeated fields are slices.\n  - Helper functions are available to aid the setting of fields.\n\tmsg.Foo = proto.String(\"hello\") // set field\n  - Constants are defined to hold the default values of all fields that\n\thave them.  They have the form Default_StructName_FieldName.\n\tBecause the getter methods handle defaulted values,\n\tdirect use of these constants should be rare.\n  - Enums are given type names and maps from names to values.\n\tEnum values are prefixed by the enclosing message's name, or by the\n\tenum's type name if it is a top-level enum. Enum types have a String\n\tmethod, and a Enum method to assist in message construction.\n  - Nested messages, groups and enums have type names prefixed with the name of\n\tthe surrounding message type.\n  - Extensions are given descriptor names that start with E_,\n\tfollowed by an underscore-delimited list of the nested messages\n\tthat contain it (if any) followed by the CamelCased name of the\n\textension field itself.  HasExtension, ClearExtension, GetExtension\n\tand SetExtension are functions for manipulating extensions.\n  - Oneof field sets are given a single field in their message,\n\twith distinguished wrapper types for each possible field value.\n  - Marshal and Unmarshal are functions to encode and decode the wire format.\n\nWhen the .proto file specifies `syntax=\"proto3\"`, there are some differences:\n\n  - Non-repeated fields of non-message type are values instead of pointers.\n  - Enum types do not get an Enum method.\n\nThe simplest way to describe this is to see an example.\nGiven file test.proto, containing\n\n\tpackage example;\n\n\tenum FOO { X = 17; }\n\n\tmessage Test {\n\t  required string label = 1;\n\t  optional int32 type = 2 [default=77];\n\t  repeated int64 reps = 3;\n\t  optional group OptionalGroup = 4 {\n\t    required string RequiredField = 5;\n\t  }\n\t  oneof union {\n\t    int32 number = 6;\n\t    string name = 7;\n\t  }\n\t}\n\nThe resulting file, test.pb.go, is:\n\n\tpackage example\n\n\timport proto \"github.com/golang/protobuf/proto\"\n\timport math \"math\"\n\n\ttype FOO int32\n\tconst (\n\t\tFOO_X FOO = 17\n\t)\n\tvar FOO_name = map[int32]string{\n\t\t17: \"X\",\n\t}\n\tvar FOO_value = map[string]int32{\n\t\t\"X\": 17,\n\t}\n\n\tfunc (x FOO) Enum() *FOO {\n\t\tp := new(FOO)\n\t\t*p = x\n\t\treturn p\n\t}\n\tfunc (x FOO) String() string {\n\t\treturn proto.EnumName(FOO_name, int32(x))\n\t}\n\tfunc (x *FOO) UnmarshalJSON(data []byte) error {\n\t\tvalue, err := proto.UnmarshalJSONEnum(FOO_value, data)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t*x = FOO(value)\n\t\treturn nil\n\t}\n\n\ttype Test struct {\n\t\tLabel         *string             `protobuf:\"bytes,1,req,name=label\" json:\"label,omitempty\"`\n\t\tType          *int32              `protobuf:\"varint,2,opt,name=type,def=77\" json:\"type,omitempty\"`\n\t\tReps          []int64             `protobuf:\"varint,3,rep,name=reps\" json:\"reps,omitempty\"`\n\t\tOptionalgroup *Test_OptionalGroup `protobuf:\"group,4,opt,name=OptionalGroup\" json:\"optionalgroup,omitempty\"`\n\t\t// Types that are valid to be assigned to Union:\n\t\t//\t*Test_Number\n\t\t//\t*Test_Name\n\t\tUnion            isTest_Union `protobuf_oneof:\"union\"`\n\t\tXXX_unrecognized []byte       `json:\"-\"`\n\t}\n\tfunc (m *Test) Reset()         { *m = Test{} }\n\tfunc (m *Test) String() string { return proto.CompactTextString(m) }\n\tfunc (*Test) ProtoMessage() {}\n\n\ttype isTest_Union interface {\n\t\tisTest_Union()\n\t}\n\n\ttype Test_Number struct {\n\t\tNumber int32 `protobuf:\"varint,6,opt,name=number\"`\n\t}\n\ttype Test_Name struct {\n\t\tName string `protobuf:\"bytes,7,opt,name=name\"`\n\t}\n\n\tfunc (*Test_Number) isTest_Union() {}\n\tfunc (*Test_Name) isTest_Union()   {}\n\n\tfunc (m *Test) GetUnion() isTest_Union {\n\t\tif m != nil {\n\t\t\treturn m.Union\n\t\t}\n\t\treturn nil\n\t}\n\tconst Default_Test_Type int32 = 77\n\n\tfunc (m *Test) GetLabel() string {\n\t\tif m != nil && m.Label != nil {\n\t\t\treturn *m.Label\n\t\t}\n\t\treturn \"\"\n\t}\n\n\tfunc (m *Test) GetType() int32 {\n\t\tif m != nil && m.Type != nil {\n\t\t\treturn *m.Type\n\t\t}\n\t\treturn Default_Test_Type\n\t}\n\n\tfunc (m *Test) GetOptionalgroup() *Test_OptionalGroup {\n\t\tif m != nil {\n\t\t\treturn m.Optionalgroup\n\t\t}\n\t\treturn nil\n\t}\n\n\ttype Test_OptionalGroup struct {\n\t\tRequiredField *string `protobuf:\"bytes,5,req\" json:\"RequiredField,omitempty\"`\n\t}\n\tfunc (m *Test_OptionalGroup) Reset()         { *m = Test_OptionalGroup{} }\n\tfunc (m *Test_OptionalGroup) String() string { return proto.CompactTextString(m) }\n\n\tfunc (m *Test_OptionalGroup) GetRequiredField() string {\n\t\tif m != nil && m.RequiredField != nil {\n\t\t\treturn *m.RequiredField\n\t\t}\n\t\treturn \"\"\n\t}\n\n\tfunc (m *Test) GetNumber() int32 {\n\t\tif x, ok := m.GetUnion().(*Test_Number); ok {\n\t\t\treturn x.Number\n\t\t}\n\t\treturn 0\n\t}\n\n\tfunc (m *Test) GetName() string {\n\t\tif x, ok := m.GetUnion().(*Test_Name); ok {\n\t\t\treturn x.Name\n\t\t}\n\t\treturn \"\"\n\t}\n\n\tfunc init() {\n\t\tproto.RegisterEnum(\"example.FOO\", FOO_name, FOO_value)\n\t}\n\nTo create and play with a Test object:\n\n\tpackage main\n\n\timport (\n\t\t\"log\"\n\n\t\t\"github.com/golang/protobuf/proto\"\n\t\tpb \"./example.pb\"\n\t)\n\n\tfunc main() {\n\t\ttest := &pb.Test{\n\t\t\tLabel: proto.String(\"hello\"),\n\t\t\tType:  proto.Int32(17),\n\t\t\tReps:  []int64{1, 2, 3},\n\t\t\tOptionalgroup: &pb.Test_OptionalGroup{\n\t\t\t\tRequiredField: proto.String(\"good bye\"),\n\t\t\t},\n\t\t\tUnion: &pb.Test_Name{\"fred\"},\n\t\t}\n\t\tdata, err := proto.Marshal(test)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"marshaling error: \", err)\n\t\t}\n\t\tnewTest := &pb.Test{}\n\t\terr = proto.Unmarshal(data, newTest)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"unmarshaling error: \", err)\n\t\t}\n\t\t// Now test and newTest contain the same data.\n\t\tif test.GetLabel() != newTest.GetLabel() {\n\t\t\tlog.Fatalf(\"data mismatch %q != %q\", test.GetLabel(), newTest.GetLabel())\n\t\t}\n\t\t// Use a type switch to determine which oneof was set.\n\t\tswitch u := test.Union.(type) {\n\t\tcase *pb.Test_Number: // u.Number contains the number.\n\t\tcase *pb.Test_Name: // u.Name contains the string.\n\t\t}\n\t\t// etc.\n\t}\n*/\npackage proto\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"log\"\n\t\"reflect\"\n\t\"sort\"\n\t\"strconv\"\n\t\"sync\"\n)\n\n// Message is implemented by generated protocol buffer messages.\ntype Message interface {\n\tReset()\n\tString() string\n\tProtoMessage()\n}\n\n// Stats records allocation details about the protocol buffer encoders\n// and decoders.  Useful for tuning the library itself.\ntype Stats struct {\n\tEmalloc uint64 // mallocs in encode\n\tDmalloc uint64 // mallocs in decode\n\tEncode  uint64 // number of encodes\n\tDecode  uint64 // number of decodes\n\tChit    uint64 // number of cache hits\n\tCmiss   uint64 // number of cache misses\n\tSize    uint64 // number of sizes\n}\n\n// Set to true to enable stats collection.\nconst collectStats = false\n\nvar stats Stats\n\n// GetStats returns a copy of the global Stats structure.\nfunc GetStats() Stats { return stats }\n\n// A Buffer is a buffer manager for marshaling and unmarshaling\n// protocol buffers.  It may be reused between invocations to\n// reduce memory usage.  It is not necessary to use a Buffer;\n// the global functions Marshal and Unmarshal create a\n// temporary Buffer and are fine for most applications.\ntype Buffer struct {\n\tbuf   []byte // encode/decode byte stream\n\tindex int    // read point\n\n\t// pools of basic types to amortize allocation.\n\tbools   []bool\n\tuint32s []uint32\n\tuint64s []uint64\n\n\t// extra pools, only used with pointer_reflect.go\n\tint32s   []int32\n\tint64s   []int64\n\tfloat32s []float32\n\tfloat64s []float64\n}\n\n// NewBuffer allocates a new Buffer and initializes its internal data to\n// the contents of the argument slice.\nfunc NewBuffer(e []byte) *Buffer {\n\treturn &Buffer{buf: e}\n}\n\n// Reset resets the Buffer, ready for marshaling a new protocol buffer.\nfunc (p *Buffer) Reset() {\n\tp.buf = p.buf[0:0] // for reading/writing\n\tp.index = 0        // for reading\n}\n\n// SetBuf replaces the internal buffer with the slice,\n// ready for unmarshaling the contents of the slice.\nfunc (p *Buffer) SetBuf(s []byte) {\n\tp.buf = s\n\tp.index = 0\n}\n\n// Bytes returns the contents of the Buffer.\nfunc (p *Buffer) Bytes() []byte { return p.buf }\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 {\n\treturn &v\n}\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 {\n\treturn &v\n}\n\n// Int is a helper routine that allocates a new int32 value\n// to store v and returns a pointer to it, but unlike Int32\n// its argument value is an int.\nfunc Int(v int) *int32 {\n\tp := new(int32)\n\t*p = int32(v)\n\treturn p\n}\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 {\n\treturn &v\n}\n\n// Float32 is a helper routine that allocates a new float32 value\n// to store v and returns a pointer to it.\nfunc Float32(v float32) *float32 {\n\treturn &v\n}\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 {\n\treturn &v\n}\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 {\n\treturn &v\n}\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 {\n\treturn &v\n}\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 {\n\treturn &v\n}\n\n// EnumName is a helper function to simplify printing protocol buffer enums\n// by name.  Given an enum map and a value, it returns a useful string.\nfunc EnumName(m map[int32]string, v int32) string {\n\ts, ok := m[v]\n\tif ok {\n\t\treturn s\n\t}\n\treturn strconv.Itoa(int(v))\n}\n\n// UnmarshalJSONEnum is a helper function to simplify recovering enum int values\n// from their JSON-encoded representation. Given a map from the enum's symbolic\n// names to its int values, and a byte buffer containing the JSON-encoded\n// value, it returns an int32 that can be cast to the enum type by the caller.\n//\n// The function can deal with both JSON representations, numeric and symbolic.\nfunc UnmarshalJSONEnum(m map[string]int32, data []byte, enumName string) (int32, error) {\n\tif data[0] == '\"' {\n\t\t// New style: enums are strings.\n\t\tvar repr string\n\t\tif err := json.Unmarshal(data, &repr); err != nil {\n\t\t\treturn -1, err\n\t\t}\n\t\tval, ok := m[repr]\n\t\tif !ok {\n\t\t\treturn 0, fmt.Errorf(\"unrecognized enum %s value %q\", enumName, repr)\n\t\t}\n\t\treturn val, nil\n\t}\n\t// Old style: enums are ints.\n\tvar val int32\n\tif err := json.Unmarshal(data, &val); err != nil {\n\t\treturn 0, fmt.Errorf(\"cannot unmarshal %#q into enum %s\", data, enumName)\n\t}\n\treturn val, nil\n}\n\n// DebugPrint dumps the encoded data in b in a debugging format with a header\n// including the string s. Used in testing but made available for general debugging.\nfunc (p *Buffer) DebugPrint(s string, b []byte) {\n\tvar u uint64\n\n\tobuf := p.buf\n\tindex := p.index\n\tp.buf = b\n\tp.index = 0\n\tdepth := 0\n\n\tfmt.Printf(\"\\n--- %s ---\\n\", s)\n\nout:\n\tfor {\n\t\tfor i := 0; i < depth; i++ {\n\t\t\tfmt.Print(\"  \")\n\t\t}\n\n\t\tindex := p.index\n\t\tif index == len(p.buf) {\n\t\t\tbreak\n\t\t}\n\n\t\top, err := p.DecodeVarint()\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"%3d: fetching op err %v\\n\", index, err)\n\t\t\tbreak out\n\t\t}\n\t\ttag := op >> 3\n\t\twire := op & 7\n\n\t\tswitch wire {\n\t\tdefault:\n\t\t\tfmt.Printf(\"%3d: t=%3d unknown wire=%d\\n\",\n\t\t\t\tindex, tag, wire)\n\t\t\tbreak out\n\n\t\tcase WireBytes:\n\t\t\tvar r []byte\n\n\t\t\tr, err = p.DecodeRawBytes(false)\n\t\t\tif err != nil {\n\t\t\t\tbreak out\n\t\t\t}\n\t\t\tfmt.Printf(\"%3d: t=%3d bytes [%d]\", index, tag, len(r))\n\t\t\tif len(r) <= 6 {\n\t\t\t\tfor i := 0; i < len(r); i++ {\n\t\t\t\t\tfmt.Printf(\" %.2x\", r[i])\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor i := 0; i < 3; i++ {\n\t\t\t\t\tfmt.Printf(\" %.2x\", r[i])\n\t\t\t\t}\n\t\t\t\tfmt.Printf(\" ..\")\n\t\t\t\tfor i := len(r) - 3; i < len(r); i++ {\n\t\t\t\t\tfmt.Printf(\" %.2x\", r[i])\n\t\t\t\t}\n\t\t\t}\n\t\t\tfmt.Printf(\"\\n\")\n\n\t\tcase WireFixed32:\n\t\t\tu, err = p.DecodeFixed32()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"%3d: t=%3d fix32 err %v\\n\", index, tag, err)\n\t\t\t\tbreak out\n\t\t\t}\n\t\t\tfmt.Printf(\"%3d: t=%3d fix32 %d\\n\", index, tag, u)\n\n\t\tcase WireFixed64:\n\t\t\tu, err = p.DecodeFixed64()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"%3d: t=%3d fix64 err %v\\n\", index, tag, err)\n\t\t\t\tbreak out\n\t\t\t}\n\t\t\tfmt.Printf(\"%3d: t=%3d fix64 %d\\n\", index, tag, u)\n\n\t\tcase WireVarint:\n\t\t\tu, err = p.DecodeVarint()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"%3d: t=%3d varint err %v\\n\", index, tag, err)\n\t\t\t\tbreak out\n\t\t\t}\n\t\t\tfmt.Printf(\"%3d: t=%3d varint %d\\n\", index, tag, u)\n\n\t\tcase WireStartGroup:\n\t\t\tfmt.Printf(\"%3d: t=%3d start\\n\", index, tag)\n\t\t\tdepth++\n\n\t\tcase WireEndGroup:\n\t\t\tdepth--\n\t\t\tfmt.Printf(\"%3d: t=%3d end\\n\", index, tag)\n\t\t}\n\t}\n\n\tif depth != 0 {\n\t\tfmt.Printf(\"%3d: start-end not balanced %d\\n\", p.index, depth)\n\t}\n\tfmt.Printf(\"\\n\")\n\n\tp.buf = obuf\n\tp.index = index\n}\n\n// SetDefaults sets unset protocol buffer fields to their default values.\n// It only modifies fields that are both unset and have defined defaults.\n// It recursively sets default values in any non-nil sub-messages.\nfunc SetDefaults(pb Message) {\n\tsetDefaults(reflect.ValueOf(pb), true, false)\n}\n\n// v is a pointer to a struct.\nfunc setDefaults(v reflect.Value, recur, zeros bool) {\n\tv = v.Elem()\n\n\tdefaultMu.RLock()\n\tdm, ok := defaults[v.Type()]\n\tdefaultMu.RUnlock()\n\tif !ok {\n\t\tdm = buildDefaultMessage(v.Type())\n\t\tdefaultMu.Lock()\n\t\tdefaults[v.Type()] = dm\n\t\tdefaultMu.Unlock()\n\t}\n\n\tfor _, sf := range dm.scalars {\n\t\tf := v.Field(sf.index)\n\t\tif !f.IsNil() {\n\t\t\t// field already set\n\t\t\tcontinue\n\t\t}\n\t\tdv := sf.value\n\t\tif dv == nil && !zeros {\n\t\t\t// no explicit default, and don't want to set zeros\n\t\t\tcontinue\n\t\t}\n\t\tfptr := f.Addr().Interface() // **T\n\t\t// TODO: Consider batching the allocations we do here.\n\t\tswitch sf.kind {\n\t\tcase reflect.Bool:\n\t\t\tb := new(bool)\n\t\t\tif dv != nil {\n\t\t\t\t*b = dv.(bool)\n\t\t\t}\n\t\t\t*(fptr.(**bool)) = b\n\t\tcase reflect.Float32:\n\t\t\tf := new(float32)\n\t\t\tif dv != nil {\n\t\t\t\t*f = dv.(float32)\n\t\t\t}\n\t\t\t*(fptr.(**float32)) = f\n\t\tcase reflect.Float64:\n\t\t\tf := new(float64)\n\t\t\tif dv != nil {\n\t\t\t\t*f = dv.(float64)\n\t\t\t}\n\t\t\t*(fptr.(**float64)) = f\n\t\tcase reflect.Int32:\n\t\t\t// might be an enum\n\t\t\tif ft := f.Type(); ft != int32PtrType {\n\t\t\t\t// enum\n\t\t\t\tf.Set(reflect.New(ft.Elem()))\n\t\t\t\tif dv != nil {\n\t\t\t\t\tf.Elem().SetInt(int64(dv.(int32)))\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// int32 field\n\t\t\t\ti := new(int32)\n\t\t\t\tif dv != nil {\n\t\t\t\t\t*i = dv.(int32)\n\t\t\t\t}\n\t\t\t\t*(fptr.(**int32)) = i\n\t\t\t}\n\t\tcase reflect.Int64:\n\t\t\ti := new(int64)\n\t\t\tif dv != nil {\n\t\t\t\t*i = dv.(int64)\n\t\t\t}\n\t\t\t*(fptr.(**int64)) = i\n\t\tcase reflect.String:\n\t\t\ts := new(string)\n\t\t\tif dv != nil {\n\t\t\t\t*s = dv.(string)\n\t\t\t}\n\t\t\t*(fptr.(**string)) = s\n\t\tcase reflect.Uint8:\n\t\t\t// exceptional case: []byte\n\t\t\tvar b []byte\n\t\t\tif dv != nil {\n\t\t\t\tdb := dv.([]byte)\n\t\t\t\tb = make([]byte, len(db))\n\t\t\t\tcopy(b, db)\n\t\t\t} else {\n\t\t\t\tb = []byte{}\n\t\t\t}\n\t\t\t*(fptr.(*[]byte)) = b\n\t\tcase reflect.Uint32:\n\t\t\tu := new(uint32)\n\t\t\tif dv != nil {\n\t\t\t\t*u = dv.(uint32)\n\t\t\t}\n\t\t\t*(fptr.(**uint32)) = u\n\t\tcase reflect.Uint64:\n\t\t\tu := new(uint64)\n\t\t\tif dv != nil {\n\t\t\t\t*u = dv.(uint64)\n\t\t\t}\n\t\t\t*(fptr.(**uint64)) = u\n\t\tdefault:\n\t\t\tlog.Printf(\"proto: can't set default for field %v (sf.kind=%v)\", f, sf.kind)\n\t\t}\n\t}\n\n\tfor _, ni := range dm.nested {\n\t\tf := v.Field(ni)\n\t\t// f is *T or []*T or map[T]*T\n\t\tswitch f.Kind() {\n\t\tcase reflect.Ptr:\n\t\t\tif f.IsNil() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tsetDefaults(f, recur, zeros)\n\n\t\tcase reflect.Slice:\n\t\t\tfor i := 0; i < f.Len(); i++ {\n\t\t\t\te := f.Index(i)\n\t\t\t\tif e.IsNil() {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tsetDefaults(e, recur, zeros)\n\t\t\t}\n\n\t\tcase reflect.Map:\n\t\t\tfor _, k := range f.MapKeys() {\n\t\t\t\te := f.MapIndex(k)\n\t\t\t\tif e.IsNil() {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tsetDefaults(e, recur, zeros)\n\t\t\t}\n\t\t}\n\t}\n}\n\nvar (\n\t// defaults maps a protocol buffer struct type to a slice of the fields,\n\t// with its scalar fields set to their proto-declared non-zero default values.\n\tdefaultMu sync.RWMutex\n\tdefaults  = make(map[reflect.Type]defaultMessage)\n\n\tint32PtrType = reflect.TypeOf((*int32)(nil))\n)\n\n// defaultMessage represents information about the default values of a message.\ntype defaultMessage struct {\n\tscalars []scalarField\n\tnested  []int // struct field index of nested messages\n}\n\ntype scalarField struct {\n\tindex int          // struct field index\n\tkind  reflect.Kind // element type (the T in *T or []T)\n\tvalue interface{}  // the proto-declared default value, or nil\n}\n\n// t is a struct type.\nfunc buildDefaultMessage(t reflect.Type) (dm defaultMessage) {\n\tsprop := GetProperties(t)\n\tfor _, prop := range sprop.Prop {\n\t\tfi, ok := sprop.decoderTags.get(prop.Tag)\n\t\tif !ok {\n\t\t\t// XXX_unrecognized\n\t\t\tcontinue\n\t\t}\n\t\tft := t.Field(fi).Type\n\n\t\tsf, nested, err := fieldDefault(ft, prop)\n\t\tswitch {\n\t\tcase err != nil:\n\t\t\tlog.Print(err)\n\t\tcase nested:\n\t\t\tdm.nested = append(dm.nested, fi)\n\t\tcase sf != nil:\n\t\t\tsf.index = fi\n\t\t\tdm.scalars = append(dm.scalars, *sf)\n\t\t}\n\t}\n\n\treturn dm\n}\n\n// fieldDefault returns the scalarField for field type ft.\n// sf will be nil if the field can not have a default.\n// nestedMessage will be true if this is a nested message.\n// Note that sf.index is not set on return.\nfunc fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) {\n\tvar canHaveDefault bool\n\tswitch ft.Kind() {\n\tcase reflect.Ptr:\n\t\tif ft.Elem().Kind() == reflect.Struct {\n\t\t\tnestedMessage = true\n\t\t} else {\n\t\t\tcanHaveDefault = true // proto2 scalar field\n\t\t}\n\n\tcase reflect.Slice:\n\t\tswitch ft.Elem().Kind() {\n\t\tcase reflect.Ptr:\n\t\t\tnestedMessage = true // repeated message\n\t\tcase reflect.Uint8:\n\t\t\tcanHaveDefault = true // bytes field\n\t\t}\n\n\tcase reflect.Map:\n\t\tif ft.Elem().Kind() == reflect.Ptr {\n\t\t\tnestedMessage = true // map with message values\n\t\t}\n\t}\n\n\tif !canHaveDefault {\n\t\tif nestedMessage {\n\t\t\treturn nil, true, nil\n\t\t}\n\t\treturn nil, false, nil\n\t}\n\n\t// We now know that ft is a pointer or slice.\n\tsf = &scalarField{kind: ft.Elem().Kind()}\n\n\t// scalar fields without defaults\n\tif !prop.HasDefault {\n\t\treturn sf, false, nil\n\t}\n\n\t// a scalar field: either *T or []byte\n\tswitch ft.Elem().Kind() {\n\tcase reflect.Bool:\n\t\tx, err := strconv.ParseBool(prop.Default)\n\t\tif err != nil {\n\t\t\treturn nil, false, fmt.Errorf(\"proto: bad default bool %q: %v\", prop.Default, err)\n\t\t}\n\t\tsf.value = x\n\tcase reflect.Float32:\n\t\tx, err := strconv.ParseFloat(prop.Default, 32)\n\t\tif err != nil {\n\t\t\treturn nil, false, fmt.Errorf(\"proto: bad default float32 %q: %v\", prop.Default, err)\n\t\t}\n\t\tsf.value = float32(x)\n\tcase reflect.Float64:\n\t\tx, err := strconv.ParseFloat(prop.Default, 64)\n\t\tif err != nil {\n\t\t\treturn nil, false, fmt.Errorf(\"proto: bad default float64 %q: %v\", prop.Default, err)\n\t\t}\n\t\tsf.value = x\n\tcase reflect.Int32:\n\t\tx, err := strconv.ParseInt(prop.Default, 10, 32)\n\t\tif err != nil {\n\t\t\treturn nil, false, fmt.Errorf(\"proto: bad default int32 %q: %v\", prop.Default, err)\n\t\t}\n\t\tsf.value = int32(x)\n\tcase reflect.Int64:\n\t\tx, err := strconv.ParseInt(prop.Default, 10, 64)\n\t\tif err != nil {\n\t\t\treturn nil, false, fmt.Errorf(\"proto: bad default int64 %q: %v\", prop.Default, err)\n\t\t}\n\t\tsf.value = x\n\tcase reflect.String:\n\t\tsf.value = prop.Default\n\tcase reflect.Uint8:\n\t\t// []byte (not *uint8)\n\t\tsf.value = []byte(prop.Default)\n\tcase reflect.Uint32:\n\t\tx, err := strconv.ParseUint(prop.Default, 10, 32)\n\t\tif err != nil {\n\t\t\treturn nil, false, fmt.Errorf(\"proto: bad default uint32 %q: %v\", prop.Default, err)\n\t\t}\n\t\tsf.value = uint32(x)\n\tcase reflect.Uint64:\n\t\tx, err := strconv.ParseUint(prop.Default, 10, 64)\n\t\tif err != nil {\n\t\t\treturn nil, false, fmt.Errorf(\"proto: bad default uint64 %q: %v\", prop.Default, err)\n\t\t}\n\t\tsf.value = x\n\tdefault:\n\t\treturn nil, false, fmt.Errorf(\"proto: unhandled def kind %v\", ft.Elem().Kind())\n\t}\n\n\treturn sf, false, nil\n}\n\n// Map fields may have key types of non-float scalars, strings and enums.\n// The easiest way to sort them in some deterministic order is to use fmt.\n// If this turns out to be inefficient we can always consider other options,\n// such as doing a Schwartzian transform.\n\nfunc mapKeys(vs []reflect.Value) sort.Interface {\n\ts := mapKeySorter{\n\t\tvs: vs,\n\t\t// default Less function: textual comparison\n\t\tless: func(a, b reflect.Value) bool {\n\t\t\treturn fmt.Sprint(a.Interface()) < fmt.Sprint(b.Interface())\n\t\t},\n\t}\n\n\t// Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps;\n\t// numeric keys are sorted numerically.\n\tif len(vs) == 0 {\n\t\treturn s\n\t}\n\tswitch vs[0].Kind() {\n\tcase reflect.Int32, reflect.Int64:\n\t\ts.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() }\n\tcase reflect.Uint32, reflect.Uint64:\n\t\ts.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() }\n\t}\n\n\treturn s\n}\n\ntype mapKeySorter struct {\n\tvs   []reflect.Value\n\tless func(a, b reflect.Value) bool\n}\n\nfunc (s mapKeySorter) Len() int      { return len(s.vs) }\nfunc (s mapKeySorter) Swap(i, j int) { s.vs[i], s.vs[j] = s.vs[j], s.vs[i] }\nfunc (s mapKeySorter) Less(i, j int) bool {\n\treturn s.less(s.vs[i], s.vs[j])\n}\n\n// isProto3Zero reports whether v is a zero proto3 value.\nfunc isProto3Zero(v reflect.Value) bool {\n\tswitch v.Kind() {\n\tcase reflect.Bool:\n\t\treturn !v.Bool()\n\tcase reflect.Int32, reflect.Int64:\n\t\treturn v.Int() == 0\n\tcase reflect.Uint32, reflect.Uint64:\n\t\treturn v.Uint() == 0\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn v.Float() == 0\n\tcase reflect.String:\n\t\treturn v.String() == \"\"\n\t}\n\treturn false\n}\n\n// ProtoPackageIsVersion2 is referenced from generated protocol buffer files\n// to assert that that code is compatible with this version of the proto package.\nconst ProtoPackageIsVersion2 = true\n\n// ProtoPackageIsVersion1 is referenced from generated protocol buffer files\n// to assert that that code is compatible with this version of the proto package.\nconst ProtoPackageIsVersion1 = true\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/map_test.go",
    "content": "package proto_test\n\nimport (\n\t\"fmt\"\n\t\"testing\"\n\n\t\"github.com/golang/protobuf/proto\"\n\tppb \"github.com/golang/protobuf/proto/proto3_proto\"\n)\n\nfunc marshalled() []byte {\n\tm := &ppb.IntMaps{}\n\tfor i := 0; i < 1000; i++ {\n\t\tm.Maps = append(m.Maps, &ppb.IntMap{\n\t\t\tRtt: map[int32]int32{1: 2},\n\t\t})\n\t}\n\tb, err := proto.Marshal(m)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Can't marshal %+v: %v\", m, err))\n\t}\n\treturn b\n}\n\nfunc BenchmarkConcurrentMapUnmarshal(b *testing.B) {\n\tin := marshalled()\n\tb.RunParallel(func(pb *testing.PB) {\n\t\tfor pb.Next() {\n\t\t\tvar out ppb.IntMaps\n\t\t\tif err := proto.Unmarshal(in, &out); err != nil {\n\t\t\t\tb.Errorf(\"Can't unmarshal ppb.IntMaps: %v\", err)\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunc BenchmarkSequentialMapUnmarshal(b *testing.B) {\n\tin := marshalled()\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tvar out ppb.IntMaps\n\t\tif err := proto.Unmarshal(in, &out); err != nil {\n\t\t\tb.Errorf(\"Can't unmarshal ppb.IntMaps: %v\", err)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/message_set.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2010 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto\n\n/*\n * Support for message sets.\n */\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"sort\"\n)\n\n// errNoMessageTypeID occurs when a protocol buffer does not have a message type ID.\n// A message type ID is required for storing a protocol buffer in a message set.\nvar errNoMessageTypeID = errors.New(\"proto does not have a message type ID\")\n\n// The first two types (_MessageSet_Item and messageSet)\n// model what the protocol compiler produces for the following protocol message:\n//   message MessageSet {\n//     repeated group Item = 1 {\n//       required int32 type_id = 2;\n//       required string message = 3;\n//     };\n//   }\n// That is the MessageSet wire format. We can't use a proto to generate these\n// because that would introduce a circular dependency between it and this package.\n\ntype _MessageSet_Item struct {\n\tTypeId  *int32 `protobuf:\"varint,2,req,name=type_id\"`\n\tMessage []byte `protobuf:\"bytes,3,req,name=message\"`\n}\n\ntype messageSet struct {\n\tItem             []*_MessageSet_Item `protobuf:\"group,1,rep\"`\n\tXXX_unrecognized []byte\n\t// TODO: caching?\n}\n\n// Make sure messageSet is a Message.\nvar _ Message = (*messageSet)(nil)\n\n// messageTypeIder is an interface satisfied by a protocol buffer type\n// that may be stored in a MessageSet.\ntype messageTypeIder interface {\n\tMessageTypeId() int32\n}\n\nfunc (ms *messageSet) find(pb Message) *_MessageSet_Item {\n\tmti, ok := pb.(messageTypeIder)\n\tif !ok {\n\t\treturn nil\n\t}\n\tid := mti.MessageTypeId()\n\tfor _, item := range ms.Item {\n\t\tif *item.TypeId == id {\n\t\t\treturn item\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (ms *messageSet) Has(pb Message) bool {\n\tif ms.find(pb) != nil {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc (ms *messageSet) Unmarshal(pb Message) error {\n\tif item := ms.find(pb); item != nil {\n\t\treturn Unmarshal(item.Message, pb)\n\t}\n\tif _, ok := pb.(messageTypeIder); !ok {\n\t\treturn errNoMessageTypeID\n\t}\n\treturn nil // TODO: return error instead?\n}\n\nfunc (ms *messageSet) Marshal(pb Message) error {\n\tmsg, err := Marshal(pb)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif item := ms.find(pb); item != nil {\n\t\t// reuse existing item\n\t\titem.Message = msg\n\t\treturn nil\n\t}\n\n\tmti, ok := pb.(messageTypeIder)\n\tif !ok {\n\t\treturn errNoMessageTypeID\n\t}\n\n\tmtid := mti.MessageTypeId()\n\tms.Item = append(ms.Item, &_MessageSet_Item{\n\t\tTypeId:  &mtid,\n\t\tMessage: msg,\n\t})\n\treturn nil\n}\n\nfunc (ms *messageSet) Reset()         { *ms = messageSet{} }\nfunc (ms *messageSet) String() string { return CompactTextString(ms) }\nfunc (*messageSet) ProtoMessage()     {}\n\n// Support for the message_set_wire_format message option.\n\nfunc skipVarint(buf []byte) []byte {\n\ti := 0\n\tfor ; buf[i]&0x80 != 0; i++ {\n\t}\n\treturn buf[i+1:]\n}\n\n// MarshalMessageSet encodes the extension map represented by m in the message set wire format.\n// It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option.\nfunc MarshalMessageSet(exts interface{}) ([]byte, error) {\n\tvar m map[int32]Extension\n\tswitch exts := exts.(type) {\n\tcase *XXX_InternalExtensions:\n\t\tif err := encodeExtensions(exts); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tm, _ = exts.extensionsRead()\n\tcase map[int32]Extension:\n\t\tif err := encodeExtensionsMap(exts); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tm = exts\n\tdefault:\n\t\treturn nil, errors.New(\"proto: not an extension map\")\n\t}\n\n\t// Sort extension IDs to provide a deterministic encoding.\n\t// See also enc_map in encode.go.\n\tids := make([]int, 0, len(m))\n\tfor id := range m {\n\t\tids = append(ids, int(id))\n\t}\n\tsort.Ints(ids)\n\n\tms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))}\n\tfor _, id := range ids {\n\t\te := m[int32(id)]\n\t\t// Remove the wire type and field number varint, as well as the length varint.\n\t\tmsg := skipVarint(skipVarint(e.enc))\n\n\t\tms.Item = append(ms.Item, &_MessageSet_Item{\n\t\t\tTypeId:  Int32(int32(id)),\n\t\t\tMessage: msg,\n\t\t})\n\t}\n\treturn Marshal(ms)\n}\n\n// UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format.\n// It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option.\nfunc UnmarshalMessageSet(buf []byte, exts interface{}) error {\n\tvar m map[int32]Extension\n\tswitch exts := exts.(type) {\n\tcase *XXX_InternalExtensions:\n\t\tm = exts.extensionsWrite()\n\tcase map[int32]Extension:\n\t\tm = exts\n\tdefault:\n\t\treturn errors.New(\"proto: not an extension map\")\n\t}\n\n\tms := new(messageSet)\n\tif err := Unmarshal(buf, ms); err != nil {\n\t\treturn err\n\t}\n\tfor _, item := range ms.Item {\n\t\tid := *item.TypeId\n\t\tmsg := item.Message\n\n\t\t// Restore wire type and field number varint, plus length varint.\n\t\t// Be careful to preserve duplicate items.\n\t\tb := EncodeVarint(uint64(id)<<3 | WireBytes)\n\t\tif ext, ok := m[id]; ok {\n\t\t\t// Existing data; rip off the tag and length varint\n\t\t\t// so we join the new data correctly.\n\t\t\t// We can assume that ext.enc is set because we are unmarshaling.\n\t\t\to := ext.enc[len(b):]   // skip wire type and field number\n\t\t\t_, n := DecodeVarint(o) // calculate length of length varint\n\t\t\to = o[n:]               // skip length varint\n\t\t\tmsg = append(o, msg...) // join old data and new data\n\t\t}\n\t\tb = append(b, EncodeVarint(uint64(len(msg)))...)\n\t\tb = append(b, msg...)\n\n\t\tm[id] = Extension{enc: b}\n\t}\n\treturn nil\n}\n\n// MarshalMessageSetJSON encodes the extension map represented by m in JSON format.\n// It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option.\nfunc MarshalMessageSetJSON(exts interface{}) ([]byte, error) {\n\tvar m map[int32]Extension\n\tswitch exts := exts.(type) {\n\tcase *XXX_InternalExtensions:\n\t\tm, _ = exts.extensionsRead()\n\tcase map[int32]Extension:\n\t\tm = exts\n\tdefault:\n\t\treturn nil, errors.New(\"proto: not an extension map\")\n\t}\n\tvar b bytes.Buffer\n\tb.WriteByte('{')\n\n\t// Process the map in key order for deterministic output.\n\tids := make([]int32, 0, len(m))\n\tfor id := range m {\n\t\tids = append(ids, id)\n\t}\n\tsort.Sort(int32Slice(ids)) // int32Slice defined in text.go\n\n\tfor i, id := range ids {\n\t\text := m[id]\n\t\tif i > 0 {\n\t\t\tb.WriteByte(',')\n\t\t}\n\n\t\tmsd, ok := messageSetMap[id]\n\t\tif !ok {\n\t\t\t// Unknown type; we can't render it, so skip it.\n\t\t\tcontinue\n\t\t}\n\t\tfmt.Fprintf(&b, `\"[%s]\":`, msd.name)\n\n\t\tx := ext.value\n\t\tif x == nil {\n\t\t\tx = reflect.New(msd.t.Elem()).Interface()\n\t\t\tif err := Unmarshal(ext.enc, x.(Message)); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\td, err := json.Marshal(x)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tb.Write(d)\n\t}\n\tb.WriteByte('}')\n\treturn b.Bytes(), nil\n}\n\n// UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format.\n// It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option.\nfunc UnmarshalMessageSetJSON(buf []byte, exts interface{}) error {\n\t// Common-case fast path.\n\tif len(buf) == 0 || bytes.Equal(buf, []byte(\"{}\")) {\n\t\treturn nil\n\t}\n\n\t// This is fairly tricky, and it's not clear that it is needed.\n\treturn errors.New(\"TODO: UnmarshalMessageSetJSON not yet implemented\")\n}\n\n// A global registry of types that can be used in a MessageSet.\n\nvar messageSetMap = make(map[int32]messageSetDesc)\n\ntype messageSetDesc struct {\n\tt    reflect.Type // pointer to struct\n\tname string\n}\n\n// RegisterMessageSetType is called from the generated code.\nfunc RegisterMessageSetType(m Message, fieldNum int32, name string) {\n\tmessageSetMap[fieldNum] = messageSetDesc{\n\t\tt:    reflect.TypeOf(m),\n\t\tname: name,\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/message_set_test.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2014 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto\n\nimport (\n\t\"bytes\"\n\t\"testing\"\n)\n\nfunc TestUnmarshalMessageSetWithDuplicate(t *testing.T) {\n\t// Check that a repeated message set entry will be concatenated.\n\tin := &messageSet{\n\t\tItem: []*_MessageSet_Item{\n\t\t\t{TypeId: Int32(12345), Message: []byte(\"hoo\")},\n\t\t\t{TypeId: Int32(12345), Message: []byte(\"hah\")},\n\t\t},\n\t}\n\tb, err := Marshal(in)\n\tif err != nil {\n\t\tt.Fatalf(\"Marshal: %v\", err)\n\t}\n\tt.Logf(\"Marshaled bytes: %q\", b)\n\n\tvar extensions XXX_InternalExtensions\n\tif err := UnmarshalMessageSet(b, &extensions); err != nil {\n\t\tt.Fatalf(\"UnmarshalMessageSet: %v\", err)\n\t}\n\text, ok := extensions.p.extensionMap[12345]\n\tif !ok {\n\t\tt.Fatalf(\"Didn't retrieve extension 12345; map is %v\", extensions.p.extensionMap)\n\t}\n\t// Skip wire type/field number and length varints.\n\tgot := skipVarint(skipVarint(ext.enc))\n\tif want := []byte(\"hoohah\"); !bytes.Equal(got, want) {\n\t\tt.Errorf(\"Combined extension is %q, want %q\", got, want)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/pointer_reflect.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2012 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// +build appengine js\n\n// This file contains an implementation of proto field accesses using package reflect.\n// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can\n// be used on App Engine.\n\npackage proto\n\nimport (\n\t\"math\"\n\t\"reflect\"\n)\n\n// A structPointer is a pointer to a struct.\ntype structPointer struct {\n\tv reflect.Value\n}\n\n// toStructPointer returns a structPointer equivalent to the given reflect value.\n// The reflect value must itself be a pointer to a struct.\nfunc toStructPointer(v reflect.Value) structPointer {\n\treturn structPointer{v}\n}\n\n// IsNil reports whether p is nil.\nfunc structPointer_IsNil(p structPointer) bool {\n\treturn p.v.IsNil()\n}\n\n// Interface returns the struct pointer as an interface value.\nfunc structPointer_Interface(p structPointer, _ reflect.Type) interface{} {\n\treturn p.v.Interface()\n}\n\n// A field identifies a field in a struct, accessible from a structPointer.\n// In this implementation, a field is identified by the sequence of field indices\n// passed to reflect's FieldByIndex.\ntype field []int\n\n// toField returns a field equivalent to the given reflect field.\nfunc toField(f *reflect.StructField) field {\n\treturn f.Index\n}\n\n// invalidField is an invalid field identifier.\nvar invalidField = field(nil)\n\n// IsValid reports whether the field identifier is valid.\nfunc (f field) IsValid() bool { return f != nil }\n\n// field returns the given field in the struct as a reflect value.\nfunc structPointer_field(p structPointer, f field) reflect.Value {\n\t// Special case: an extension map entry with a value of type T\n\t// passes a *T to the struct-handling code with a zero field,\n\t// expecting that it will be treated as equivalent to *struct{ X T },\n\t// which has the same memory layout. We have to handle that case\n\t// specially, because reflect will panic if we call FieldByIndex on a\n\t// non-struct.\n\tif f == nil {\n\t\treturn p.v.Elem()\n\t}\n\n\treturn p.v.Elem().FieldByIndex(f)\n}\n\n// ifield returns the given field in the struct as an interface value.\nfunc structPointer_ifield(p structPointer, f field) interface{} {\n\treturn structPointer_field(p, f).Addr().Interface()\n}\n\n// Bytes returns the address of a []byte field in the struct.\nfunc structPointer_Bytes(p structPointer, f field) *[]byte {\n\treturn structPointer_ifield(p, f).(*[]byte)\n}\n\n// BytesSlice returns the address of a [][]byte field in the struct.\nfunc structPointer_BytesSlice(p structPointer, f field) *[][]byte {\n\treturn structPointer_ifield(p, f).(*[][]byte)\n}\n\n// Bool returns the address of a *bool field in the struct.\nfunc structPointer_Bool(p structPointer, f field) **bool {\n\treturn structPointer_ifield(p, f).(**bool)\n}\n\n// BoolVal returns the address of a bool field in the struct.\nfunc structPointer_BoolVal(p structPointer, f field) *bool {\n\treturn structPointer_ifield(p, f).(*bool)\n}\n\n// BoolSlice returns the address of a []bool field in the struct.\nfunc structPointer_BoolSlice(p structPointer, f field) *[]bool {\n\treturn structPointer_ifield(p, f).(*[]bool)\n}\n\n// String returns the address of a *string field in the struct.\nfunc structPointer_String(p structPointer, f field) **string {\n\treturn structPointer_ifield(p, f).(**string)\n}\n\n// StringVal returns the address of a string field in the struct.\nfunc structPointer_StringVal(p structPointer, f field) *string {\n\treturn structPointer_ifield(p, f).(*string)\n}\n\n// StringSlice returns the address of a []string field in the struct.\nfunc structPointer_StringSlice(p structPointer, f field) *[]string {\n\treturn structPointer_ifield(p, f).(*[]string)\n}\n\n// Extensions returns the address of an extension map field in the struct.\nfunc structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions {\n\treturn structPointer_ifield(p, f).(*XXX_InternalExtensions)\n}\n\n// ExtMap returns the address of an extension map field in the struct.\nfunc structPointer_ExtMap(p structPointer, f field) *map[int32]Extension {\n\treturn structPointer_ifield(p, f).(*map[int32]Extension)\n}\n\n// NewAt returns the reflect.Value for a pointer to a field in the struct.\nfunc structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value {\n\treturn structPointer_field(p, f).Addr()\n}\n\n// SetStructPointer writes a *struct field in the struct.\nfunc structPointer_SetStructPointer(p structPointer, f field, q structPointer) {\n\tstructPointer_field(p, f).Set(q.v)\n}\n\n// GetStructPointer reads a *struct field in the struct.\nfunc structPointer_GetStructPointer(p structPointer, f field) structPointer {\n\treturn structPointer{structPointer_field(p, f)}\n}\n\n// StructPointerSlice the address of a []*struct field in the struct.\nfunc structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice {\n\treturn structPointerSlice{structPointer_field(p, f)}\n}\n\n// A structPointerSlice represents the address of a slice of pointers to structs\n// (themselves messages or groups). That is, v.Type() is *[]*struct{...}.\ntype structPointerSlice struct {\n\tv reflect.Value\n}\n\nfunc (p structPointerSlice) Len() int                  { return p.v.Len() }\nfunc (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} }\nfunc (p structPointerSlice) Append(q structPointer) {\n\tp.v.Set(reflect.Append(p.v, q.v))\n}\n\nvar (\n\tint32Type   = reflect.TypeOf(int32(0))\n\tuint32Type  = reflect.TypeOf(uint32(0))\n\tfloat32Type = reflect.TypeOf(float32(0))\n\tint64Type   = reflect.TypeOf(int64(0))\n\tuint64Type  = reflect.TypeOf(uint64(0))\n\tfloat64Type = reflect.TypeOf(float64(0))\n)\n\n// A word32 represents a field of type *int32, *uint32, *float32, or *enum.\n// That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable.\ntype word32 struct {\n\tv reflect.Value\n}\n\n// IsNil reports whether p is nil.\nfunc word32_IsNil(p word32) bool {\n\treturn p.v.IsNil()\n}\n\n// Set sets p to point at a newly allocated word with bits set to x.\nfunc word32_Set(p word32, o *Buffer, x uint32) {\n\tt := p.v.Type().Elem()\n\tswitch t {\n\tcase int32Type:\n\t\tif len(o.int32s) == 0 {\n\t\t\to.int32s = make([]int32, uint32PoolSize)\n\t\t}\n\t\to.int32s[0] = int32(x)\n\t\tp.v.Set(reflect.ValueOf(&o.int32s[0]))\n\t\to.int32s = o.int32s[1:]\n\t\treturn\n\tcase uint32Type:\n\t\tif len(o.uint32s) == 0 {\n\t\t\to.uint32s = make([]uint32, uint32PoolSize)\n\t\t}\n\t\to.uint32s[0] = x\n\t\tp.v.Set(reflect.ValueOf(&o.uint32s[0]))\n\t\to.uint32s = o.uint32s[1:]\n\t\treturn\n\tcase float32Type:\n\t\tif len(o.float32s) == 0 {\n\t\t\to.float32s = make([]float32, uint32PoolSize)\n\t\t}\n\t\to.float32s[0] = math.Float32frombits(x)\n\t\tp.v.Set(reflect.ValueOf(&o.float32s[0]))\n\t\to.float32s = o.float32s[1:]\n\t\treturn\n\t}\n\n\t// must be enum\n\tp.v.Set(reflect.New(t))\n\tp.v.Elem().SetInt(int64(int32(x)))\n}\n\n// Get gets the bits pointed at by p, as a uint32.\nfunc word32_Get(p word32) uint32 {\n\telem := p.v.Elem()\n\tswitch elem.Kind() {\n\tcase reflect.Int32:\n\t\treturn uint32(elem.Int())\n\tcase reflect.Uint32:\n\t\treturn uint32(elem.Uint())\n\tcase reflect.Float32:\n\t\treturn math.Float32bits(float32(elem.Float()))\n\t}\n\tpanic(\"unreachable\")\n}\n\n// Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct.\nfunc structPointer_Word32(p structPointer, f field) word32 {\n\treturn word32{structPointer_field(p, f)}\n}\n\n// A word32Val represents a field of type int32, uint32, float32, or enum.\n// That is, v.Type() is int32, uint32, float32, or enum and v is assignable.\ntype word32Val struct {\n\tv reflect.Value\n}\n\n// Set sets *p to x.\nfunc word32Val_Set(p word32Val, x uint32) {\n\tswitch p.v.Type() {\n\tcase int32Type:\n\t\tp.v.SetInt(int64(x))\n\t\treturn\n\tcase uint32Type:\n\t\tp.v.SetUint(uint64(x))\n\t\treturn\n\tcase float32Type:\n\t\tp.v.SetFloat(float64(math.Float32frombits(x)))\n\t\treturn\n\t}\n\n\t// must be enum\n\tp.v.SetInt(int64(int32(x)))\n}\n\n// Get gets the bits pointed at by p, as a uint32.\nfunc word32Val_Get(p word32Val) uint32 {\n\telem := p.v\n\tswitch elem.Kind() {\n\tcase reflect.Int32:\n\t\treturn uint32(elem.Int())\n\tcase reflect.Uint32:\n\t\treturn uint32(elem.Uint())\n\tcase reflect.Float32:\n\t\treturn math.Float32bits(float32(elem.Float()))\n\t}\n\tpanic(\"unreachable\")\n}\n\n// Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct.\nfunc structPointer_Word32Val(p structPointer, f field) word32Val {\n\treturn word32Val{structPointer_field(p, f)}\n}\n\n// A word32Slice is a slice of 32-bit values.\n// That is, v.Type() is []int32, []uint32, []float32, or []enum.\ntype word32Slice struct {\n\tv reflect.Value\n}\n\nfunc (p word32Slice) Append(x uint32) {\n\tn, m := p.v.Len(), p.v.Cap()\n\tif n < m {\n\t\tp.v.SetLen(n + 1)\n\t} else {\n\t\tt := p.v.Type().Elem()\n\t\tp.v.Set(reflect.Append(p.v, reflect.Zero(t)))\n\t}\n\telem := p.v.Index(n)\n\tswitch elem.Kind() {\n\tcase reflect.Int32:\n\t\telem.SetInt(int64(int32(x)))\n\tcase reflect.Uint32:\n\t\telem.SetUint(uint64(x))\n\tcase reflect.Float32:\n\t\telem.SetFloat(float64(math.Float32frombits(x)))\n\t}\n}\n\nfunc (p word32Slice) Len() int {\n\treturn p.v.Len()\n}\n\nfunc (p word32Slice) Index(i int) uint32 {\n\telem := p.v.Index(i)\n\tswitch elem.Kind() {\n\tcase reflect.Int32:\n\t\treturn uint32(elem.Int())\n\tcase reflect.Uint32:\n\t\treturn uint32(elem.Uint())\n\tcase reflect.Float32:\n\t\treturn math.Float32bits(float32(elem.Float()))\n\t}\n\tpanic(\"unreachable\")\n}\n\n// Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct.\nfunc structPointer_Word32Slice(p structPointer, f field) word32Slice {\n\treturn word32Slice{structPointer_field(p, f)}\n}\n\n// word64 is like word32 but for 64-bit values.\ntype word64 struct {\n\tv reflect.Value\n}\n\nfunc word64_Set(p word64, o *Buffer, x uint64) {\n\tt := p.v.Type().Elem()\n\tswitch t {\n\tcase int64Type:\n\t\tif len(o.int64s) == 0 {\n\t\t\to.int64s = make([]int64, uint64PoolSize)\n\t\t}\n\t\to.int64s[0] = int64(x)\n\t\tp.v.Set(reflect.ValueOf(&o.int64s[0]))\n\t\to.int64s = o.int64s[1:]\n\t\treturn\n\tcase uint64Type:\n\t\tif len(o.uint64s) == 0 {\n\t\t\to.uint64s = make([]uint64, uint64PoolSize)\n\t\t}\n\t\to.uint64s[0] = x\n\t\tp.v.Set(reflect.ValueOf(&o.uint64s[0]))\n\t\to.uint64s = o.uint64s[1:]\n\t\treturn\n\tcase float64Type:\n\t\tif len(o.float64s) == 0 {\n\t\t\to.float64s = make([]float64, uint64PoolSize)\n\t\t}\n\t\to.float64s[0] = math.Float64frombits(x)\n\t\tp.v.Set(reflect.ValueOf(&o.float64s[0]))\n\t\to.float64s = o.float64s[1:]\n\t\treturn\n\t}\n\tpanic(\"unreachable\")\n}\n\nfunc word64_IsNil(p word64) bool {\n\treturn p.v.IsNil()\n}\n\nfunc word64_Get(p word64) uint64 {\n\telem := p.v.Elem()\n\tswitch elem.Kind() {\n\tcase reflect.Int64:\n\t\treturn uint64(elem.Int())\n\tcase reflect.Uint64:\n\t\treturn elem.Uint()\n\tcase reflect.Float64:\n\t\treturn math.Float64bits(elem.Float())\n\t}\n\tpanic(\"unreachable\")\n}\n\nfunc structPointer_Word64(p structPointer, f field) word64 {\n\treturn word64{structPointer_field(p, f)}\n}\n\n// word64Val is like word32Val but for 64-bit values.\ntype word64Val struct {\n\tv reflect.Value\n}\n\nfunc word64Val_Set(p word64Val, o *Buffer, x uint64) {\n\tswitch p.v.Type() {\n\tcase int64Type:\n\t\tp.v.SetInt(int64(x))\n\t\treturn\n\tcase uint64Type:\n\t\tp.v.SetUint(x)\n\t\treturn\n\tcase float64Type:\n\t\tp.v.SetFloat(math.Float64frombits(x))\n\t\treturn\n\t}\n\tpanic(\"unreachable\")\n}\n\nfunc word64Val_Get(p word64Val) uint64 {\n\telem := p.v\n\tswitch elem.Kind() {\n\tcase reflect.Int64:\n\t\treturn uint64(elem.Int())\n\tcase reflect.Uint64:\n\t\treturn elem.Uint()\n\tcase reflect.Float64:\n\t\treturn math.Float64bits(elem.Float())\n\t}\n\tpanic(\"unreachable\")\n}\n\nfunc structPointer_Word64Val(p structPointer, f field) word64Val {\n\treturn word64Val{structPointer_field(p, f)}\n}\n\ntype word64Slice struct {\n\tv reflect.Value\n}\n\nfunc (p word64Slice) Append(x uint64) {\n\tn, m := p.v.Len(), p.v.Cap()\n\tif n < m {\n\t\tp.v.SetLen(n + 1)\n\t} else {\n\t\tt := p.v.Type().Elem()\n\t\tp.v.Set(reflect.Append(p.v, reflect.Zero(t)))\n\t}\n\telem := p.v.Index(n)\n\tswitch elem.Kind() {\n\tcase reflect.Int64:\n\t\telem.SetInt(int64(int64(x)))\n\tcase reflect.Uint64:\n\t\telem.SetUint(uint64(x))\n\tcase reflect.Float64:\n\t\telem.SetFloat(float64(math.Float64frombits(x)))\n\t}\n}\n\nfunc (p word64Slice) Len() int {\n\treturn p.v.Len()\n}\n\nfunc (p word64Slice) Index(i int) uint64 {\n\telem := p.v.Index(i)\n\tswitch elem.Kind() {\n\tcase reflect.Int64:\n\t\treturn uint64(elem.Int())\n\tcase reflect.Uint64:\n\t\treturn uint64(elem.Uint())\n\tcase reflect.Float64:\n\t\treturn math.Float64bits(float64(elem.Float()))\n\t}\n\tpanic(\"unreachable\")\n}\n\nfunc structPointer_Word64Slice(p structPointer, f field) word64Slice {\n\treturn word64Slice{structPointer_field(p, f)}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/pointer_unsafe.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2012 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// +build !appengine,!js\n\n// This file contains the implementation of the proto field accesses using package unsafe.\n\npackage proto\n\nimport (\n\t\"reflect\"\n\t\"unsafe\"\n)\n\n// NOTE: These type_Foo functions would more idiomatically be methods,\n// but Go does not allow methods on pointer types, and we must preserve\n// some pointer type for the garbage collector. We use these\n// funcs with clunky names as our poor approximation to methods.\n//\n// An alternative would be\n//\ttype structPointer struct { p unsafe.Pointer }\n// but that does not registerize as well.\n\n// A structPointer is a pointer to a struct.\ntype structPointer unsafe.Pointer\n\n// toStructPointer returns a structPointer equivalent to the given reflect value.\nfunc toStructPointer(v reflect.Value) structPointer {\n\treturn structPointer(unsafe.Pointer(v.Pointer()))\n}\n\n// IsNil reports whether p is nil.\nfunc structPointer_IsNil(p structPointer) bool {\n\treturn p == nil\n}\n\n// Interface returns the struct pointer, assumed to have element type t,\n// as an interface value.\nfunc structPointer_Interface(p structPointer, t reflect.Type) interface{} {\n\treturn reflect.NewAt(t, unsafe.Pointer(p)).Interface()\n}\n\n// A field identifies a field in a struct, accessible from a structPointer.\n// In this implementation, a field is identified by its byte offset from the start of the struct.\ntype field uintptr\n\n// toField returns a field equivalent to the given reflect field.\nfunc toField(f *reflect.StructField) field {\n\treturn field(f.Offset)\n}\n\n// invalidField is an invalid field identifier.\nconst invalidField = ^field(0)\n\n// IsValid reports whether the field identifier is valid.\nfunc (f field) IsValid() bool {\n\treturn f != ^field(0)\n}\n\n// Bytes returns the address of a []byte field in the struct.\nfunc structPointer_Bytes(p structPointer, f field) *[]byte {\n\treturn (*[]byte)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n\n// BytesSlice returns the address of a [][]byte field in the struct.\nfunc structPointer_BytesSlice(p structPointer, f field) *[][]byte {\n\treturn (*[][]byte)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n\n// Bool returns the address of a *bool field in the struct.\nfunc structPointer_Bool(p structPointer, f field) **bool {\n\treturn (**bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n\n// BoolVal returns the address of a bool field in the struct.\nfunc structPointer_BoolVal(p structPointer, f field) *bool {\n\treturn (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n\n// BoolSlice returns the address of a []bool field in the struct.\nfunc structPointer_BoolSlice(p structPointer, f field) *[]bool {\n\treturn (*[]bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n\n// String returns the address of a *string field in the struct.\nfunc structPointer_String(p structPointer, f field) **string {\n\treturn (**string)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n\n// StringVal returns the address of a string field in the struct.\nfunc structPointer_StringVal(p structPointer, f field) *string {\n\treturn (*string)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n\n// StringSlice returns the address of a []string field in the struct.\nfunc structPointer_StringSlice(p structPointer, f field) *[]string {\n\treturn (*[]string)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n\n// ExtMap returns the address of an extension map field in the struct.\nfunc structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions {\n\treturn (*XXX_InternalExtensions)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n\nfunc structPointer_ExtMap(p structPointer, f field) *map[int32]Extension {\n\treturn (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n\n// NewAt returns the reflect.Value for a pointer to a field in the struct.\nfunc structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value {\n\treturn reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f)))\n}\n\n// SetStructPointer writes a *struct field in the struct.\nfunc structPointer_SetStructPointer(p structPointer, f field, q structPointer) {\n\t*(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) = q\n}\n\n// GetStructPointer reads a *struct field in the struct.\nfunc structPointer_GetStructPointer(p structPointer, f field) structPointer {\n\treturn *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n\n// StructPointerSlice the address of a []*struct field in the struct.\nfunc structPointer_StructPointerSlice(p structPointer, f field) *structPointerSlice {\n\treturn (*structPointerSlice)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n\n// A structPointerSlice represents a slice of pointers to structs (themselves submessages or groups).\ntype structPointerSlice []structPointer\n\nfunc (v *structPointerSlice) Len() int                  { return len(*v) }\nfunc (v *structPointerSlice) Index(i int) structPointer { return (*v)[i] }\nfunc (v *structPointerSlice) Append(p structPointer)    { *v = append(*v, p) }\n\n// A word32 is the address of a \"pointer to 32-bit value\" field.\ntype word32 **uint32\n\n// IsNil reports whether *v is nil.\nfunc word32_IsNil(p word32) bool {\n\treturn *p == nil\n}\n\n// Set sets *v to point at a newly allocated word set to x.\nfunc word32_Set(p word32, o *Buffer, x uint32) {\n\tif len(o.uint32s) == 0 {\n\t\to.uint32s = make([]uint32, uint32PoolSize)\n\t}\n\to.uint32s[0] = x\n\t*p = &o.uint32s[0]\n\to.uint32s = o.uint32s[1:]\n}\n\n// Get gets the value pointed at by *v.\nfunc word32_Get(p word32) uint32 {\n\treturn **p\n}\n\n// Word32 returns the address of a *int32, *uint32, *float32, or *enum field in the struct.\nfunc structPointer_Word32(p structPointer, f field) word32 {\n\treturn word32((**uint32)(unsafe.Pointer(uintptr(p) + uintptr(f))))\n}\n\n// A word32Val is the address of a 32-bit value field.\ntype word32Val *uint32\n\n// Set sets *p to x.\nfunc word32Val_Set(p word32Val, x uint32) {\n\t*p = x\n}\n\n// Get gets the value pointed at by p.\nfunc word32Val_Get(p word32Val) uint32 {\n\treturn *p\n}\n\n// Word32Val returns the address of a *int32, *uint32, *float32, or *enum field in the struct.\nfunc structPointer_Word32Val(p structPointer, f field) word32Val {\n\treturn word32Val((*uint32)(unsafe.Pointer(uintptr(p) + uintptr(f))))\n}\n\n// A word32Slice is a slice of 32-bit values.\ntype word32Slice []uint32\n\nfunc (v *word32Slice) Append(x uint32)    { *v = append(*v, x) }\nfunc (v *word32Slice) Len() int           { return len(*v) }\nfunc (v *word32Slice) Index(i int) uint32 { return (*v)[i] }\n\n// Word32Slice returns the address of a []int32, []uint32, []float32, or []enum field in the struct.\nfunc structPointer_Word32Slice(p structPointer, f field) *word32Slice {\n\treturn (*word32Slice)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n\n// word64 is like word32 but for 64-bit values.\ntype word64 **uint64\n\nfunc word64_Set(p word64, o *Buffer, x uint64) {\n\tif len(o.uint64s) == 0 {\n\t\to.uint64s = make([]uint64, uint64PoolSize)\n\t}\n\to.uint64s[0] = x\n\t*p = &o.uint64s[0]\n\to.uint64s = o.uint64s[1:]\n}\n\nfunc word64_IsNil(p word64) bool {\n\treturn *p == nil\n}\n\nfunc word64_Get(p word64) uint64 {\n\treturn **p\n}\n\nfunc structPointer_Word64(p structPointer, f field) word64 {\n\treturn word64((**uint64)(unsafe.Pointer(uintptr(p) + uintptr(f))))\n}\n\n// word64Val is like word32Val but for 64-bit values.\ntype word64Val *uint64\n\nfunc word64Val_Set(p word64Val, o *Buffer, x uint64) {\n\t*p = x\n}\n\nfunc word64Val_Get(p word64Val) uint64 {\n\treturn *p\n}\n\nfunc structPointer_Word64Val(p structPointer, f field) word64Val {\n\treturn word64Val((*uint64)(unsafe.Pointer(uintptr(p) + uintptr(f))))\n}\n\n// word64Slice is like word32Slice but for 64-bit values.\ntype word64Slice []uint64\n\nfunc (v *word64Slice) Append(x uint64)    { *v = append(*v, x) }\nfunc (v *word64Slice) Len() int           { return len(*v) }\nfunc (v *word64Slice) Index(i int) uint64 { return (*v)[i] }\n\nfunc structPointer_Word64Slice(p structPointer, f field) *word64Slice {\n\treturn (*word64Slice)(unsafe.Pointer(uintptr(p) + uintptr(f)))\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/properties.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2010 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto\n\n/*\n * Routines for encoding data into the wire format for protocol buffers.\n */\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"reflect\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync\"\n)\n\nconst debug bool = false\n\n// Constants that identify the encoding of a value on the wire.\nconst (\n\tWireVarint     = 0\n\tWireFixed64    = 1\n\tWireBytes      = 2\n\tWireStartGroup = 3\n\tWireEndGroup   = 4\n\tWireFixed32    = 5\n)\n\nconst startSize = 10 // initial slice/string sizes\n\n// Encoders are defined in encode.go\n// An encoder outputs the full representation of a field, including its\n// tag and encoder type.\ntype encoder func(p *Buffer, prop *Properties, base structPointer) error\n\n// A valueEncoder encodes a single integer in a particular encoding.\ntype valueEncoder func(o *Buffer, x uint64) error\n\n// Sizers are defined in encode.go\n// A sizer returns the encoded size of a field, including its tag and encoder\n// type.\ntype sizer func(prop *Properties, base structPointer) int\n\n// A valueSizer returns the encoded size of a single integer in a particular\n// encoding.\ntype valueSizer func(x uint64) int\n\n// Decoders are defined in decode.go\n// A decoder creates a value from its wire representation.\n// Unrecognized subelements are saved in unrec.\ntype decoder func(p *Buffer, prop *Properties, base structPointer) error\n\n// A valueDecoder decodes a single integer in a particular encoding.\ntype valueDecoder func(o *Buffer) (x uint64, err error)\n\n// A oneofMarshaler does the marshaling for all oneof fields in a message.\ntype oneofMarshaler func(Message, *Buffer) error\n\n// A oneofUnmarshaler does the unmarshaling for a oneof field in a message.\ntype oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error)\n\n// A oneofSizer does the sizing for all oneof fields in a message.\ntype oneofSizer func(Message) int\n\n// tagMap is an optimization over map[int]int for typical protocol buffer\n// use-cases. Encoded protocol buffers are often in tag order with small tag\n// numbers.\ntype tagMap struct {\n\tfastTags []int\n\tslowTags map[int]int\n}\n\n// tagMapFastLimit is the upper bound on the tag number that will be stored in\n// the tagMap slice rather than its map.\nconst tagMapFastLimit = 1024\n\nfunc (p *tagMap) get(t int) (int, bool) {\n\tif t > 0 && t < tagMapFastLimit {\n\t\tif t >= len(p.fastTags) {\n\t\t\treturn 0, false\n\t\t}\n\t\tfi := p.fastTags[t]\n\t\treturn fi, fi >= 0\n\t}\n\tfi, ok := p.slowTags[t]\n\treturn fi, ok\n}\n\nfunc (p *tagMap) put(t int, fi int) {\n\tif t > 0 && t < tagMapFastLimit {\n\t\tfor len(p.fastTags) < t+1 {\n\t\t\tp.fastTags = append(p.fastTags, -1)\n\t\t}\n\t\tp.fastTags[t] = fi\n\t\treturn\n\t}\n\tif p.slowTags == nil {\n\t\tp.slowTags = make(map[int]int)\n\t}\n\tp.slowTags[t] = fi\n}\n\n// StructProperties represents properties for all the fields of a struct.\n// decoderTags and decoderOrigNames should only be used by the decoder.\ntype StructProperties struct {\n\tProp             []*Properties  // properties for each field\n\treqCount         int            // required count\n\tdecoderTags      tagMap         // map from proto tag to struct field number\n\tdecoderOrigNames map[string]int // map from original name to struct field number\n\torder            []int          // list of struct field numbers in tag order\n\tunrecField       field          // field id of the XXX_unrecognized []byte field\n\textendable       bool           // is this an extendable proto\n\n\toneofMarshaler   oneofMarshaler\n\toneofUnmarshaler oneofUnmarshaler\n\toneofSizer       oneofSizer\n\tstype            reflect.Type\n\n\t// OneofTypes contains information about the oneof fields in this message.\n\t// It is keyed by the original name of a field.\n\tOneofTypes map[string]*OneofProperties\n}\n\n// OneofProperties represents information about a specific field in a oneof.\ntype OneofProperties struct {\n\tType  reflect.Type // pointer to generated struct type for this oneof field\n\tField int          // struct field number of the containing oneof in the message\n\tProp  *Properties\n}\n\n// Implement the sorting interface so we can sort the fields in tag order, as recommended by the spec.\n// See encode.go, (*Buffer).enc_struct.\n\nfunc (sp *StructProperties) Len() int { return len(sp.order) }\nfunc (sp *StructProperties) Less(i, j int) bool {\n\treturn sp.Prop[sp.order[i]].Tag < sp.Prop[sp.order[j]].Tag\n}\nfunc (sp *StructProperties) Swap(i, j int) { sp.order[i], sp.order[j] = sp.order[j], sp.order[i] }\n\n// Properties represents the protocol-specific behavior of a single struct field.\ntype Properties struct {\n\tName     string // name of the field, for error messages\n\tOrigName string // original name before protocol compiler (always set)\n\tJSONName string // name to use for JSON; determined by protoc\n\tWire     string\n\tWireType int\n\tTag      int\n\tRequired bool\n\tOptional bool\n\tRepeated bool\n\tPacked   bool   // relevant for repeated primitives only\n\tEnum     string // set for enum types only\n\tproto3   bool   // whether this is known to be a proto3 field; set for []byte only\n\toneof    bool   // whether this is a oneof field\n\n\tDefault    string // default value\n\tHasDefault bool   // whether an explicit default was provided\n\tdef_uint64 uint64\n\n\tenc           encoder\n\tvalEnc        valueEncoder // set for bool and numeric types only\n\tfield         field\n\ttagcode       []byte // encoding of EncodeVarint((Tag<<3)|WireType)\n\ttagbuf        [8]byte\n\tstype         reflect.Type      // set for struct types only\n\tsprop         *StructProperties // set for struct types only\n\tisMarshaler   bool\n\tisUnmarshaler bool\n\n\tmtype    reflect.Type // set for map types only\n\tmkeyprop *Properties  // set for map types only\n\tmvalprop *Properties  // set for map types only\n\n\tsize    sizer\n\tvalSize valueSizer // set for bool and numeric types only\n\n\tdec    decoder\n\tvalDec valueDecoder // set for bool and numeric types only\n\n\t// If this is a packable field, this will be the decoder for the packed version of the field.\n\tpackedDec decoder\n}\n\n// String formats the properties in the protobuf struct field tag style.\nfunc (p *Properties) String() string {\n\ts := p.Wire\n\ts = \",\"\n\ts += strconv.Itoa(p.Tag)\n\tif p.Required {\n\t\ts += \",req\"\n\t}\n\tif p.Optional {\n\t\ts += \",opt\"\n\t}\n\tif p.Repeated {\n\t\ts += \",rep\"\n\t}\n\tif p.Packed {\n\t\ts += \",packed\"\n\t}\n\ts += \",name=\" + p.OrigName\n\tif p.JSONName != p.OrigName {\n\t\ts += \",json=\" + p.JSONName\n\t}\n\tif p.proto3 {\n\t\ts += \",proto3\"\n\t}\n\tif p.oneof {\n\t\ts += \",oneof\"\n\t}\n\tif len(p.Enum) > 0 {\n\t\ts += \",enum=\" + p.Enum\n\t}\n\tif p.HasDefault {\n\t\ts += \",def=\" + p.Default\n\t}\n\treturn s\n}\n\n// Parse populates p by parsing a string in the protobuf struct field tag style.\nfunc (p *Properties) Parse(s string) {\n\t// \"bytes,49,opt,name=foo,def=hello!\"\n\tfields := strings.Split(s, \",\") // breaks def=, but handled below.\n\tif len(fields) < 2 {\n\t\tfmt.Fprintf(os.Stderr, \"proto: tag has too few fields: %q\\n\", s)\n\t\treturn\n\t}\n\n\tp.Wire = fields[0]\n\tswitch p.Wire {\n\tcase \"varint\":\n\t\tp.WireType = WireVarint\n\t\tp.valEnc = (*Buffer).EncodeVarint\n\t\tp.valDec = (*Buffer).DecodeVarint\n\t\tp.valSize = sizeVarint\n\tcase \"fixed32\":\n\t\tp.WireType = WireFixed32\n\t\tp.valEnc = (*Buffer).EncodeFixed32\n\t\tp.valDec = (*Buffer).DecodeFixed32\n\t\tp.valSize = sizeFixed32\n\tcase \"fixed64\":\n\t\tp.WireType = WireFixed64\n\t\tp.valEnc = (*Buffer).EncodeFixed64\n\t\tp.valDec = (*Buffer).DecodeFixed64\n\t\tp.valSize = sizeFixed64\n\tcase \"zigzag32\":\n\t\tp.WireType = WireVarint\n\t\tp.valEnc = (*Buffer).EncodeZigzag32\n\t\tp.valDec = (*Buffer).DecodeZigzag32\n\t\tp.valSize = sizeZigzag32\n\tcase \"zigzag64\":\n\t\tp.WireType = WireVarint\n\t\tp.valEnc = (*Buffer).EncodeZigzag64\n\t\tp.valDec = (*Buffer).DecodeZigzag64\n\t\tp.valSize = sizeZigzag64\n\tcase \"bytes\", \"group\":\n\t\tp.WireType = WireBytes\n\t\t// no numeric converter for non-numeric types\n\tdefault:\n\t\tfmt.Fprintf(os.Stderr, \"proto: tag has unknown wire type: %q\\n\", s)\n\t\treturn\n\t}\n\n\tvar err error\n\tp.Tag, err = strconv.Atoi(fields[1])\n\tif err != nil {\n\t\treturn\n\t}\n\n\tfor i := 2; i < len(fields); i++ {\n\t\tf := fields[i]\n\t\tswitch {\n\t\tcase f == \"req\":\n\t\t\tp.Required = true\n\t\tcase f == \"opt\":\n\t\t\tp.Optional = true\n\t\tcase f == \"rep\":\n\t\t\tp.Repeated = true\n\t\tcase f == \"packed\":\n\t\t\tp.Packed = true\n\t\tcase strings.HasPrefix(f, \"name=\"):\n\t\t\tp.OrigName = f[5:]\n\t\tcase strings.HasPrefix(f, \"json=\"):\n\t\t\tp.JSONName = f[5:]\n\t\tcase strings.HasPrefix(f, \"enum=\"):\n\t\t\tp.Enum = f[5:]\n\t\tcase f == \"proto3\":\n\t\t\tp.proto3 = true\n\t\tcase f == \"oneof\":\n\t\t\tp.oneof = true\n\t\tcase strings.HasPrefix(f, \"def=\"):\n\t\t\tp.HasDefault = true\n\t\t\tp.Default = f[4:] // rest of string\n\t\t\tif i+1 < len(fields) {\n\t\t\t\t// Commas aren't escaped, and def is always last.\n\t\t\t\tp.Default += \",\" + strings.Join(fields[i+1:], \",\")\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc logNoSliceEnc(t1, t2 reflect.Type) {\n\tfmt.Fprintf(os.Stderr, \"proto: no slice oenc for %T = []%T\\n\", t1, t2)\n}\n\nvar protoMessageType = reflect.TypeOf((*Message)(nil)).Elem()\n\n// Initialize the fields for encoding and decoding.\nfunc (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lockGetProp bool) {\n\tp.enc = nil\n\tp.dec = nil\n\tp.size = nil\n\n\tswitch t1 := typ; t1.Kind() {\n\tdefault:\n\t\tfmt.Fprintf(os.Stderr, \"proto: no coders for %v\\n\", t1)\n\n\t// proto3 scalar types\n\n\tcase reflect.Bool:\n\t\tp.enc = (*Buffer).enc_proto3_bool\n\t\tp.dec = (*Buffer).dec_proto3_bool\n\t\tp.size = size_proto3_bool\n\tcase reflect.Int32:\n\t\tp.enc = (*Buffer).enc_proto3_int32\n\t\tp.dec = (*Buffer).dec_proto3_int32\n\t\tp.size = size_proto3_int32\n\tcase reflect.Uint32:\n\t\tp.enc = (*Buffer).enc_proto3_uint32\n\t\tp.dec = (*Buffer).dec_proto3_int32 // can reuse\n\t\tp.size = size_proto3_uint32\n\tcase reflect.Int64, reflect.Uint64:\n\t\tp.enc = (*Buffer).enc_proto3_int64\n\t\tp.dec = (*Buffer).dec_proto3_int64\n\t\tp.size = size_proto3_int64\n\tcase reflect.Float32:\n\t\tp.enc = (*Buffer).enc_proto3_uint32 // can just treat them as bits\n\t\tp.dec = (*Buffer).dec_proto3_int32\n\t\tp.size = size_proto3_uint32\n\tcase reflect.Float64:\n\t\tp.enc = (*Buffer).enc_proto3_int64 // can just treat them as bits\n\t\tp.dec = (*Buffer).dec_proto3_int64\n\t\tp.size = size_proto3_int64\n\tcase reflect.String:\n\t\tp.enc = (*Buffer).enc_proto3_string\n\t\tp.dec = (*Buffer).dec_proto3_string\n\t\tp.size = size_proto3_string\n\n\tcase reflect.Ptr:\n\t\tswitch t2 := t1.Elem(); t2.Kind() {\n\t\tdefault:\n\t\t\tfmt.Fprintf(os.Stderr, \"proto: no encoder function for %v -> %v\\n\", t1, t2)\n\t\t\tbreak\n\t\tcase reflect.Bool:\n\t\t\tp.enc = (*Buffer).enc_bool\n\t\t\tp.dec = (*Buffer).dec_bool\n\t\t\tp.size = size_bool\n\t\tcase reflect.Int32:\n\t\t\tp.enc = (*Buffer).enc_int32\n\t\t\tp.dec = (*Buffer).dec_int32\n\t\t\tp.size = size_int32\n\t\tcase reflect.Uint32:\n\t\t\tp.enc = (*Buffer).enc_uint32\n\t\t\tp.dec = (*Buffer).dec_int32 // can reuse\n\t\t\tp.size = size_uint32\n\t\tcase reflect.Int64, reflect.Uint64:\n\t\t\tp.enc = (*Buffer).enc_int64\n\t\t\tp.dec = (*Buffer).dec_int64\n\t\t\tp.size = size_int64\n\t\tcase reflect.Float32:\n\t\t\tp.enc = (*Buffer).enc_uint32 // can just treat them as bits\n\t\t\tp.dec = (*Buffer).dec_int32\n\t\t\tp.size = size_uint32\n\t\tcase reflect.Float64:\n\t\t\tp.enc = (*Buffer).enc_int64 // can just treat them as bits\n\t\t\tp.dec = (*Buffer).dec_int64\n\t\t\tp.size = size_int64\n\t\tcase reflect.String:\n\t\t\tp.enc = (*Buffer).enc_string\n\t\t\tp.dec = (*Buffer).dec_string\n\t\t\tp.size = size_string\n\t\tcase reflect.Struct:\n\t\t\tp.stype = t1.Elem()\n\t\t\tp.isMarshaler = isMarshaler(t1)\n\t\t\tp.isUnmarshaler = isUnmarshaler(t1)\n\t\t\tif p.Wire == \"bytes\" {\n\t\t\t\tp.enc = (*Buffer).enc_struct_message\n\t\t\t\tp.dec = (*Buffer).dec_struct_message\n\t\t\t\tp.size = size_struct_message\n\t\t\t} else {\n\t\t\t\tp.enc = (*Buffer).enc_struct_group\n\t\t\t\tp.dec = (*Buffer).dec_struct_group\n\t\t\t\tp.size = size_struct_group\n\t\t\t}\n\t\t}\n\n\tcase reflect.Slice:\n\t\tswitch t2 := t1.Elem(); t2.Kind() {\n\t\tdefault:\n\t\t\tlogNoSliceEnc(t1, t2)\n\t\t\tbreak\n\t\tcase reflect.Bool:\n\t\t\tif p.Packed {\n\t\t\t\tp.enc = (*Buffer).enc_slice_packed_bool\n\t\t\t\tp.size = size_slice_packed_bool\n\t\t\t} else {\n\t\t\t\tp.enc = (*Buffer).enc_slice_bool\n\t\t\t\tp.size = size_slice_bool\n\t\t\t}\n\t\t\tp.dec = (*Buffer).dec_slice_bool\n\t\t\tp.packedDec = (*Buffer).dec_slice_packed_bool\n\t\tcase reflect.Int32:\n\t\t\tif p.Packed {\n\t\t\t\tp.enc = (*Buffer).enc_slice_packed_int32\n\t\t\t\tp.size = size_slice_packed_int32\n\t\t\t} else {\n\t\t\t\tp.enc = (*Buffer).enc_slice_int32\n\t\t\t\tp.size = size_slice_int32\n\t\t\t}\n\t\t\tp.dec = (*Buffer).dec_slice_int32\n\t\t\tp.packedDec = (*Buffer).dec_slice_packed_int32\n\t\tcase reflect.Uint32:\n\t\t\tif p.Packed {\n\t\t\t\tp.enc = (*Buffer).enc_slice_packed_uint32\n\t\t\t\tp.size = size_slice_packed_uint32\n\t\t\t} else {\n\t\t\t\tp.enc = (*Buffer).enc_slice_uint32\n\t\t\t\tp.size = size_slice_uint32\n\t\t\t}\n\t\t\tp.dec = (*Buffer).dec_slice_int32\n\t\t\tp.packedDec = (*Buffer).dec_slice_packed_int32\n\t\tcase reflect.Int64, reflect.Uint64:\n\t\t\tif p.Packed {\n\t\t\t\tp.enc = (*Buffer).enc_slice_packed_int64\n\t\t\t\tp.size = size_slice_packed_int64\n\t\t\t} else {\n\t\t\t\tp.enc = (*Buffer).enc_slice_int64\n\t\t\t\tp.size = size_slice_int64\n\t\t\t}\n\t\t\tp.dec = (*Buffer).dec_slice_int64\n\t\t\tp.packedDec = (*Buffer).dec_slice_packed_int64\n\t\tcase reflect.Uint8:\n\t\t\tp.dec = (*Buffer).dec_slice_byte\n\t\t\tif p.proto3 {\n\t\t\t\tp.enc = (*Buffer).enc_proto3_slice_byte\n\t\t\t\tp.size = size_proto3_slice_byte\n\t\t\t} else {\n\t\t\t\tp.enc = (*Buffer).enc_slice_byte\n\t\t\t\tp.size = size_slice_byte\n\t\t\t}\n\t\tcase reflect.Float32, reflect.Float64:\n\t\t\tswitch t2.Bits() {\n\t\t\tcase 32:\n\t\t\t\t// can just treat them as bits\n\t\t\t\tif p.Packed {\n\t\t\t\t\tp.enc = (*Buffer).enc_slice_packed_uint32\n\t\t\t\t\tp.size = size_slice_packed_uint32\n\t\t\t\t} else {\n\t\t\t\t\tp.enc = (*Buffer).enc_slice_uint32\n\t\t\t\t\tp.size = size_slice_uint32\n\t\t\t\t}\n\t\t\t\tp.dec = (*Buffer).dec_slice_int32\n\t\t\t\tp.packedDec = (*Buffer).dec_slice_packed_int32\n\t\t\tcase 64:\n\t\t\t\t// can just treat them as bits\n\t\t\t\tif p.Packed {\n\t\t\t\t\tp.enc = (*Buffer).enc_slice_packed_int64\n\t\t\t\t\tp.size = size_slice_packed_int64\n\t\t\t\t} else {\n\t\t\t\t\tp.enc = (*Buffer).enc_slice_int64\n\t\t\t\t\tp.size = size_slice_int64\n\t\t\t\t}\n\t\t\t\tp.dec = (*Buffer).dec_slice_int64\n\t\t\t\tp.packedDec = (*Buffer).dec_slice_packed_int64\n\t\t\tdefault:\n\t\t\t\tlogNoSliceEnc(t1, t2)\n\t\t\t\tbreak\n\t\t\t}\n\t\tcase reflect.String:\n\t\t\tp.enc = (*Buffer).enc_slice_string\n\t\t\tp.dec = (*Buffer).dec_slice_string\n\t\t\tp.size = size_slice_string\n\t\tcase reflect.Ptr:\n\t\t\tswitch t3 := t2.Elem(); t3.Kind() {\n\t\t\tdefault:\n\t\t\t\tfmt.Fprintf(os.Stderr, \"proto: no ptr oenc for %T -> %T -> %T\\n\", t1, t2, t3)\n\t\t\t\tbreak\n\t\t\tcase reflect.Struct:\n\t\t\t\tp.stype = t2.Elem()\n\t\t\t\tp.isMarshaler = isMarshaler(t2)\n\t\t\t\tp.isUnmarshaler = isUnmarshaler(t2)\n\t\t\t\tif p.Wire == \"bytes\" {\n\t\t\t\t\tp.enc = (*Buffer).enc_slice_struct_message\n\t\t\t\t\tp.dec = (*Buffer).dec_slice_struct_message\n\t\t\t\t\tp.size = size_slice_struct_message\n\t\t\t\t} else {\n\t\t\t\t\tp.enc = (*Buffer).enc_slice_struct_group\n\t\t\t\t\tp.dec = (*Buffer).dec_slice_struct_group\n\t\t\t\t\tp.size = size_slice_struct_group\n\t\t\t\t}\n\t\t\t}\n\t\tcase reflect.Slice:\n\t\t\tswitch t2.Elem().Kind() {\n\t\t\tdefault:\n\t\t\t\tfmt.Fprintf(os.Stderr, \"proto: no slice elem oenc for %T -> %T -> %T\\n\", t1, t2, t2.Elem())\n\t\t\t\tbreak\n\t\t\tcase reflect.Uint8:\n\t\t\t\tp.enc = (*Buffer).enc_slice_slice_byte\n\t\t\t\tp.dec = (*Buffer).dec_slice_slice_byte\n\t\t\t\tp.size = size_slice_slice_byte\n\t\t\t}\n\t\t}\n\n\tcase reflect.Map:\n\t\tp.enc = (*Buffer).enc_new_map\n\t\tp.dec = (*Buffer).dec_new_map\n\t\tp.size = size_new_map\n\n\t\tp.mtype = t1\n\t\tp.mkeyprop = &Properties{}\n\t\tp.mkeyprop.init(reflect.PtrTo(p.mtype.Key()), \"Key\", f.Tag.Get(\"protobuf_key\"), nil, lockGetProp)\n\t\tp.mvalprop = &Properties{}\n\t\tvtype := p.mtype.Elem()\n\t\tif vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice {\n\t\t\t// The value type is not a message (*T) or bytes ([]byte),\n\t\t\t// so we need encoders for the pointer to this type.\n\t\t\tvtype = reflect.PtrTo(vtype)\n\t\t}\n\t\tp.mvalprop.init(vtype, \"Value\", f.Tag.Get(\"protobuf_val\"), nil, lockGetProp)\n\t}\n\n\t// precalculate tag code\n\twire := p.WireType\n\tif p.Packed {\n\t\twire = WireBytes\n\t}\n\tx := uint32(p.Tag)<<3 | uint32(wire)\n\ti := 0\n\tfor i = 0; x > 127; i++ {\n\t\tp.tagbuf[i] = 0x80 | uint8(x&0x7F)\n\t\tx >>= 7\n\t}\n\tp.tagbuf[i] = uint8(x)\n\tp.tagcode = p.tagbuf[0 : i+1]\n\n\tif p.stype != nil {\n\t\tif lockGetProp {\n\t\t\tp.sprop = GetProperties(p.stype)\n\t\t} else {\n\t\t\tp.sprop = getPropertiesLocked(p.stype)\n\t\t}\n\t}\n}\n\nvar (\n\tmarshalerType   = reflect.TypeOf((*Marshaler)(nil)).Elem()\n\tunmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem()\n)\n\n// isMarshaler reports whether type t implements Marshaler.\nfunc isMarshaler(t reflect.Type) bool {\n\t// We're checking for (likely) pointer-receiver methods\n\t// so if t is not a pointer, something is very wrong.\n\t// The calls above only invoke isMarshaler on pointer types.\n\tif t.Kind() != reflect.Ptr {\n\t\tpanic(\"proto: misuse of isMarshaler\")\n\t}\n\treturn t.Implements(marshalerType)\n}\n\n// isUnmarshaler reports whether type t implements Unmarshaler.\nfunc isUnmarshaler(t reflect.Type) bool {\n\t// We're checking for (likely) pointer-receiver methods\n\t// so if t is not a pointer, something is very wrong.\n\t// The calls above only invoke isUnmarshaler on pointer types.\n\tif t.Kind() != reflect.Ptr {\n\t\tpanic(\"proto: misuse of isUnmarshaler\")\n\t}\n\treturn t.Implements(unmarshalerType)\n}\n\n// Init populates the properties from a protocol buffer struct tag.\nfunc (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) {\n\tp.init(typ, name, tag, f, true)\n}\n\nfunc (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructField, lockGetProp bool) {\n\t// \"bytes,49,opt,def=hello!\"\n\tp.Name = name\n\tp.OrigName = name\n\tif f != nil {\n\t\tp.field = toField(f)\n\t}\n\tif tag == \"\" {\n\t\treturn\n\t}\n\tp.Parse(tag)\n\tp.setEncAndDec(typ, f, lockGetProp)\n}\n\nvar (\n\tpropertiesMu  sync.RWMutex\n\tpropertiesMap = make(map[reflect.Type]*StructProperties)\n)\n\n// GetProperties returns the list of properties for the type represented by t.\n// t must represent a generated struct type of a protocol message.\nfunc GetProperties(t reflect.Type) *StructProperties {\n\tif t.Kind() != reflect.Struct {\n\t\tpanic(\"proto: type must have kind struct\")\n\t}\n\n\t// Most calls to GetProperties in a long-running program will be\n\t// retrieving details for types we have seen before.\n\tpropertiesMu.RLock()\n\tsprop, ok := propertiesMap[t]\n\tpropertiesMu.RUnlock()\n\tif ok {\n\t\tif collectStats {\n\t\t\tstats.Chit++\n\t\t}\n\t\treturn sprop\n\t}\n\n\tpropertiesMu.Lock()\n\tsprop = getPropertiesLocked(t)\n\tpropertiesMu.Unlock()\n\treturn sprop\n}\n\n// getPropertiesLocked requires that propertiesMu is held.\nfunc getPropertiesLocked(t reflect.Type) *StructProperties {\n\tif prop, ok := propertiesMap[t]; ok {\n\t\tif collectStats {\n\t\t\tstats.Chit++\n\t\t}\n\t\treturn prop\n\t}\n\tif collectStats {\n\t\tstats.Cmiss++\n\t}\n\n\tprop := new(StructProperties)\n\t// in case of recursive protos, fill this in now.\n\tpropertiesMap[t] = prop\n\n\t// build properties\n\tprop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) ||\n\t\treflect.PtrTo(t).Implements(extendableProtoV1Type)\n\tprop.unrecField = invalidField\n\tprop.Prop = make([]*Properties, t.NumField())\n\tprop.order = make([]int, t.NumField())\n\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tf := t.Field(i)\n\t\tp := new(Properties)\n\t\tname := f.Name\n\t\tp.init(f.Type, name, f.Tag.Get(\"protobuf\"), &f, false)\n\n\t\tif f.Name == \"XXX_InternalExtensions\" { // special case\n\t\t\tp.enc = (*Buffer).enc_exts\n\t\t\tp.dec = nil // not needed\n\t\t\tp.size = size_exts\n\t\t} else if f.Name == \"XXX_extensions\" { // special case\n\t\t\tp.enc = (*Buffer).enc_map\n\t\t\tp.dec = nil // not needed\n\t\t\tp.size = size_map\n\t\t} else if f.Name == \"XXX_unrecognized\" { // special case\n\t\t\tprop.unrecField = toField(&f)\n\t\t}\n\t\toneof := f.Tag.Get(\"protobuf_oneof\") // special case\n\t\tif oneof != \"\" {\n\t\t\t// Oneof fields don't use the traditional protobuf tag.\n\t\t\tp.OrigName = oneof\n\t\t}\n\t\tprop.Prop[i] = p\n\t\tprop.order[i] = i\n\t\tif debug {\n\t\t\tprint(i, \" \", f.Name, \" \", t.String(), \" \")\n\t\t\tif p.Tag > 0 {\n\t\t\t\tprint(p.String())\n\t\t\t}\n\t\t\tprint(\"\\n\")\n\t\t}\n\t\tif p.enc == nil && !strings.HasPrefix(f.Name, \"XXX_\") && oneof == \"\" {\n\t\t\tfmt.Fprintln(os.Stderr, \"proto: no encoder for\", f.Name, f.Type.String(), \"[GetProperties]\")\n\t\t}\n\t}\n\n\t// Re-order prop.order.\n\tsort.Sort(prop)\n\n\ttype oneofMessage interface {\n\t\tXXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{})\n\t}\n\tif om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok {\n\t\tvar oots []interface{}\n\t\tprop.oneofMarshaler, prop.oneofUnmarshaler, prop.oneofSizer, oots = om.XXX_OneofFuncs()\n\t\tprop.stype = t\n\n\t\t// Interpret oneof metadata.\n\t\tprop.OneofTypes = make(map[string]*OneofProperties)\n\t\tfor _, oot := range oots {\n\t\t\toop := &OneofProperties{\n\t\t\t\tType: reflect.ValueOf(oot).Type(), // *T\n\t\t\t\tProp: new(Properties),\n\t\t\t}\n\t\t\tsft := oop.Type.Elem().Field(0)\n\t\t\toop.Prop.Name = sft.Name\n\t\t\toop.Prop.Parse(sft.Tag.Get(\"protobuf\"))\n\t\t\t// There will be exactly one interface field that\n\t\t\t// this new value is assignable to.\n\t\t\tfor i := 0; i < t.NumField(); i++ {\n\t\t\t\tf := t.Field(i)\n\t\t\t\tif f.Type.Kind() != reflect.Interface {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif !oop.Type.AssignableTo(f.Type) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\toop.Field = i\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tprop.OneofTypes[oop.Prop.OrigName] = oop\n\t\t}\n\t}\n\n\t// build required counts\n\t// build tags\n\treqCount := 0\n\tprop.decoderOrigNames = make(map[string]int)\n\tfor i, p := range prop.Prop {\n\t\tif strings.HasPrefix(p.Name, \"XXX_\") {\n\t\t\t// Internal fields should not appear in tags/origNames maps.\n\t\t\t// They are handled specially when encoding and decoding.\n\t\t\tcontinue\n\t\t}\n\t\tif p.Required {\n\t\t\treqCount++\n\t\t}\n\t\tprop.decoderTags.put(p.Tag, i)\n\t\tprop.decoderOrigNames[p.OrigName] = i\n\t}\n\tprop.reqCount = reqCount\n\n\treturn prop\n}\n\n// Return the Properties object for the x[0]'th field of the structure.\nfunc propByIndex(t reflect.Type, x []int) *Properties {\n\tif len(x) != 1 {\n\t\tfmt.Fprintf(os.Stderr, \"proto: field index dimension %d (not 1) for type %s\\n\", len(x), t)\n\t\treturn nil\n\t}\n\tprop := GetProperties(t)\n\treturn prop.Prop[x[0]]\n}\n\n// Get the address and type of a pointer to a struct from an interface.\nfunc getbase(pb Message) (t reflect.Type, b structPointer, err error) {\n\tif pb == nil {\n\t\terr = ErrNil\n\t\treturn\n\t}\n\t// get the reflect type of the pointer to the struct.\n\tt = reflect.TypeOf(pb)\n\t// get the address of the struct.\n\tvalue := reflect.ValueOf(pb)\n\tb = toStructPointer(value)\n\treturn\n}\n\n// A global registry of enum types.\n// The generated code will register the generated maps by calling RegisterEnum.\n\nvar enumValueMaps = make(map[string]map[string]int32)\n\n// RegisterEnum is called from the generated code to install the enum descriptor\n// maps into the global table to aid parsing text format protocol buffers.\nfunc RegisterEnum(typeName string, unusedNameMap map[int32]string, valueMap map[string]int32) {\n\tif _, ok := enumValueMaps[typeName]; ok {\n\t\tpanic(\"proto: duplicate enum registered: \" + typeName)\n\t}\n\tenumValueMaps[typeName] = valueMap\n}\n\n// EnumValueMap returns the mapping from names to integers of the\n// enum type enumType, or a nil if not found.\nfunc EnumValueMap(enumType string) map[string]int32 {\n\treturn enumValueMaps[enumType]\n}\n\n// A registry of all linked message types.\n// The string is a fully-qualified proto name (\"pkg.Message\").\nvar (\n\tprotoTypes    = make(map[string]reflect.Type)\n\trevProtoTypes = make(map[reflect.Type]string)\n)\n\n// RegisterType is called from generated code and maps from the fully qualified\n// proto name to the type (pointer to struct) of the protocol buffer.\nfunc RegisterType(x Message, name string) {\n\tif _, ok := protoTypes[name]; ok {\n\t\t// TODO: Some day, make this a panic.\n\t\tlog.Printf(\"proto: duplicate proto type registered: %s\", name)\n\t\treturn\n\t}\n\tt := reflect.TypeOf(x)\n\tprotoTypes[name] = t\n\trevProtoTypes[t] = name\n}\n\n// MessageName returns the fully-qualified proto name for the given message type.\nfunc MessageName(x Message) string {\n\ttype xname interface {\n\t\tXXX_MessageName() string\n\t}\n\tif m, ok := x.(xname); ok {\n\t\treturn m.XXX_MessageName()\n\t}\n\treturn revProtoTypes[reflect.TypeOf(x)]\n}\n\n// MessageType returns the message type (pointer to struct) for a named message.\nfunc MessageType(name string) reflect.Type { return protoTypes[name] }\n\n// A registry of all linked proto files.\nvar (\n\tprotoFiles = make(map[string][]byte) // file name => fileDescriptor\n)\n\n// RegisterFile is called from generated code and maps from the\n// full file name of a .proto file to its compressed FileDescriptorProto.\nfunc RegisterFile(filename string, fileDescriptor []byte) {\n\tprotoFiles[filename] = fileDescriptor\n}\n\n// FileDescriptor returns the compressed FileDescriptorProto for a .proto file.\nfunc FileDescriptor(filename string) []byte { return protoFiles[filename] }\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/proto3_test.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2014 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto_test\n\nimport (\n\t\"testing\"\n\n\t\"github.com/golang/protobuf/proto\"\n\tpb \"github.com/golang/protobuf/proto/proto3_proto\"\n\ttpb \"github.com/golang/protobuf/proto/testdata\"\n)\n\nfunc TestProto3ZeroValues(t *testing.T) {\n\ttests := []struct {\n\t\tdesc string\n\t\tm    proto.Message\n\t}{\n\t\t{\"zero message\", &pb.Message{}},\n\t\t{\"empty bytes field\", &pb.Message{Data: []byte{}}},\n\t}\n\tfor _, test := range tests {\n\t\tb, err := proto.Marshal(test.m)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"%s: proto.Marshal: %v\", test.desc, err)\n\t\t\tcontinue\n\t\t}\n\t\tif len(b) > 0 {\n\t\t\tt.Errorf(\"%s: Encoding is non-empty: %q\", test.desc, b)\n\t\t}\n\t}\n}\n\nfunc TestRoundTripProto3(t *testing.T) {\n\tm := &pb.Message{\n\t\tName:         \"David\",          // (2 | 1<<3): 0x0a 0x05 \"David\"\n\t\tHilarity:     pb.Message_PUNS,  // (0 | 2<<3): 0x10 0x01\n\t\tHeightInCm:   178,              // (0 | 3<<3): 0x18 0xb2 0x01\n\t\tData:         []byte(\"roboto\"), // (2 | 4<<3): 0x20 0x06 \"roboto\"\n\t\tResultCount:  47,               // (0 | 7<<3): 0x38 0x2f\n\t\tTrueScotsman: true,             // (0 | 8<<3): 0x40 0x01\n\t\tScore:        8.1,              // (5 | 9<<3): 0x4d <8.1>\n\n\t\tKey: []uint64{1, 0xdeadbeef},\n\t\tNested: &pb.Nested{\n\t\t\tBunny: \"Monty\",\n\t\t},\n\t}\n\tt.Logf(\" m: %v\", m)\n\n\tb, err := proto.Marshal(m)\n\tif err != nil {\n\t\tt.Fatalf(\"proto.Marshal: %v\", err)\n\t}\n\tt.Logf(\" b: %q\", b)\n\n\tm2 := new(pb.Message)\n\tif err := proto.Unmarshal(b, m2); err != nil {\n\t\tt.Fatalf(\"proto.Unmarshal: %v\", err)\n\t}\n\tt.Logf(\"m2: %v\", m2)\n\n\tif !proto.Equal(m, m2) {\n\t\tt.Errorf(\"proto.Equal returned false:\\n m: %v\\nm2: %v\", m, m2)\n\t}\n}\n\nfunc TestGettersForBasicTypesExist(t *testing.T) {\n\tvar m pb.Message\n\tif got := m.GetNested().GetBunny(); got != \"\" {\n\t\tt.Errorf(\"m.GetNested().GetBunny() = %q, want empty string\", got)\n\t}\n\tif got := m.GetNested().GetCute(); got {\n\t\tt.Errorf(\"m.GetNested().GetCute() = %t, want false\", got)\n\t}\n}\n\nfunc TestProto3SetDefaults(t *testing.T) {\n\tin := &pb.Message{\n\t\tTerrain: map[string]*pb.Nested{\n\t\t\t\"meadow\": new(pb.Nested),\n\t\t},\n\t\tProto2Field: new(tpb.SubDefaults),\n\t\tProto2Value: map[string]*tpb.SubDefaults{\n\t\t\t\"badlands\": new(tpb.SubDefaults),\n\t\t},\n\t}\n\n\tgot := proto.Clone(in).(*pb.Message)\n\tproto.SetDefaults(got)\n\n\t// There are no defaults in proto3.  Everything should be the zero value, but\n\t// we need to remember to set defaults for nested proto2 messages.\n\twant := &pb.Message{\n\t\tTerrain: map[string]*pb.Nested{\n\t\t\t\"meadow\": new(pb.Nested),\n\t\t},\n\t\tProto2Field: &tpb.SubDefaults{N: proto.Int64(7)},\n\t\tProto2Value: map[string]*tpb.SubDefaults{\n\t\t\t\"badlands\": &tpb.SubDefaults{N: proto.Int64(7)},\n\t\t},\n\t}\n\n\tif !proto.Equal(got, want) {\n\t\tt.Errorf(\"with in = %v\\nproto.SetDefaults(in) =>\\ngot %v\\nwant %v\", in, got, want)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/size2_test.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2012 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto\n\nimport (\n\t\"testing\"\n)\n\n// This is a separate file and package from size_test.go because that one uses\n// generated messages and thus may not be in package proto without having a circular\n// dependency, whereas this file tests unexported details of size.go.\n\nfunc TestVarintSize(t *testing.T) {\n\t// Check the edge cases carefully.\n\ttestCases := []struct {\n\t\tn    uint64\n\t\tsize int\n\t}{\n\t\t{0, 1},\n\t\t{1, 1},\n\t\t{127, 1},\n\t\t{128, 2},\n\t\t{16383, 2},\n\t\t{16384, 3},\n\t\t{1<<63 - 1, 9},\n\t\t{1 << 63, 10},\n\t}\n\tfor _, tc := range testCases {\n\t\tsize := sizeVarint(tc.n)\n\t\tif size != tc.size {\n\t\t\tt.Errorf(\"sizeVarint(%d) = %d, want %d\", tc.n, size, tc.size)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/size_test.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2012 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto_test\n\nimport (\n\t\"log\"\n\t\"strings\"\n\t\"testing\"\n\n\t. \"github.com/golang/protobuf/proto\"\n\tproto3pb \"github.com/golang/protobuf/proto/proto3_proto\"\n\tpb \"github.com/golang/protobuf/proto/testdata\"\n)\n\nvar messageWithExtension1 = &pb.MyMessage{Count: Int32(7)}\n\n// messageWithExtension2 is in equal_test.go.\nvar messageWithExtension3 = &pb.MyMessage{Count: Int32(8)}\n\nfunc init() {\n\tif err := SetExtension(messageWithExtension1, pb.E_Ext_More, &pb.Ext{Data: String(\"Abbott\")}); err != nil {\n\t\tlog.Panicf(\"SetExtension: %v\", err)\n\t}\n\tif err := SetExtension(messageWithExtension3, pb.E_Ext_More, &pb.Ext{Data: String(\"Costello\")}); err != nil {\n\t\tlog.Panicf(\"SetExtension: %v\", err)\n\t}\n\n\t// Force messageWithExtension3 to have the extension encoded.\n\tMarshal(messageWithExtension3)\n\n}\n\nvar SizeTests = []struct {\n\tdesc string\n\tpb   Message\n}{\n\t{\"empty\", &pb.OtherMessage{}},\n\t// Basic types.\n\t{\"bool\", &pb.Defaults{F_Bool: Bool(true)}},\n\t{\"int32\", &pb.Defaults{F_Int32: Int32(12)}},\n\t{\"negative int32\", &pb.Defaults{F_Int32: Int32(-1)}},\n\t{\"small int64\", &pb.Defaults{F_Int64: Int64(1)}},\n\t{\"big int64\", &pb.Defaults{F_Int64: Int64(1 << 20)}},\n\t{\"negative int64\", &pb.Defaults{F_Int64: Int64(-1)}},\n\t{\"fixed32\", &pb.Defaults{F_Fixed32: Uint32(71)}},\n\t{\"fixed64\", &pb.Defaults{F_Fixed64: Uint64(72)}},\n\t{\"uint32\", &pb.Defaults{F_Uint32: Uint32(123)}},\n\t{\"uint64\", &pb.Defaults{F_Uint64: Uint64(124)}},\n\t{\"float\", &pb.Defaults{F_Float: Float32(12.6)}},\n\t{\"double\", &pb.Defaults{F_Double: Float64(13.9)}},\n\t{\"string\", &pb.Defaults{F_String: String(\"niles\")}},\n\t{\"bytes\", &pb.Defaults{F_Bytes: []byte(\"wowsa\")}},\n\t{\"bytes, empty\", &pb.Defaults{F_Bytes: []byte{}}},\n\t{\"sint32\", &pb.Defaults{F_Sint32: Int32(65)}},\n\t{\"sint64\", &pb.Defaults{F_Sint64: Int64(67)}},\n\t{\"enum\", &pb.Defaults{F_Enum: pb.Defaults_BLUE.Enum()}},\n\t// Repeated.\n\t{\"empty repeated bool\", &pb.MoreRepeated{Bools: []bool{}}},\n\t{\"repeated bool\", &pb.MoreRepeated{Bools: []bool{false, true, true, false}}},\n\t{\"packed repeated bool\", &pb.MoreRepeated{BoolsPacked: []bool{false, true, true, false, true, true, true}}},\n\t{\"repeated int32\", &pb.MoreRepeated{Ints: []int32{1, 12203, 1729, -1}}},\n\t{\"repeated int32 packed\", &pb.MoreRepeated{IntsPacked: []int32{1, 12203, 1729}}},\n\t{\"repeated int64 packed\", &pb.MoreRepeated{Int64SPacked: []int64{\n\t\t// Need enough large numbers to verify that the header is counting the number of bytes\n\t\t// for the field, not the number of elements.\n\t\t1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62,\n\t\t1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62, 1 << 62,\n\t}}},\n\t{\"repeated string\", &pb.MoreRepeated{Strings: []string{\"r\", \"ken\", \"gri\"}}},\n\t{\"repeated fixed\", &pb.MoreRepeated{Fixeds: []uint32{1, 2, 3, 4}}},\n\t// Nested.\n\t{\"nested\", &pb.OldMessage{Nested: &pb.OldMessage_Nested{Name: String(\"whatever\")}}},\n\t{\"group\", &pb.GroupOld{G: &pb.GroupOld_G{X: Int32(12345)}}},\n\t// Other things.\n\t{\"unrecognized\", &pb.MoreRepeated{XXX_unrecognized: []byte{13<<3 | 0, 4}}},\n\t{\"extension (unencoded)\", messageWithExtension1},\n\t{\"extension (encoded)\", messageWithExtension3},\n\t// proto3 message\n\t{\"proto3 empty\", &proto3pb.Message{}},\n\t{\"proto3 bool\", &proto3pb.Message{TrueScotsman: true}},\n\t{\"proto3 int64\", &proto3pb.Message{ResultCount: 1}},\n\t{\"proto3 uint32\", &proto3pb.Message{HeightInCm: 123}},\n\t{\"proto3 float\", &proto3pb.Message{Score: 12.6}},\n\t{\"proto3 string\", &proto3pb.Message{Name: \"Snezana\"}},\n\t{\"proto3 bytes\", &proto3pb.Message{Data: []byte(\"wowsa\")}},\n\t{\"proto3 bytes, empty\", &proto3pb.Message{Data: []byte{}}},\n\t{\"proto3 enum\", &proto3pb.Message{Hilarity: proto3pb.Message_PUNS}},\n\t{\"proto3 map field with empty bytes\", &proto3pb.MessageWithMap{ByteMapping: map[bool][]byte{false: []byte{}}}},\n\n\t{\"map field\", &pb.MessageWithMap{NameMapping: map[int32]string{1: \"Rob\", 7: \"Andrew\"}}},\n\t{\"map field with message\", &pb.MessageWithMap{MsgMapping: map[int64]*pb.FloatingPoint{0x7001: &pb.FloatingPoint{F: Float64(2.0)}}}},\n\t{\"map field with bytes\", &pb.MessageWithMap{ByteMapping: map[bool][]byte{true: []byte(\"this time for sure\")}}},\n\t{\"map field with empty bytes\", &pb.MessageWithMap{ByteMapping: map[bool][]byte{true: []byte{}}}},\n\n\t{\"map field with big entry\", &pb.MessageWithMap{NameMapping: map[int32]string{8: strings.Repeat(\"x\", 125)}}},\n\t{\"map field with big key and val\", &pb.MessageWithMap{StrToStr: map[string]string{strings.Repeat(\"x\", 70): strings.Repeat(\"y\", 70)}}},\n\t{\"map field with big numeric key\", &pb.MessageWithMap{NameMapping: map[int32]string{0xf00d: \"om nom nom\"}}},\n\n\t{\"oneof not set\", &pb.Oneof{}},\n\t{\"oneof bool\", &pb.Oneof{Union: &pb.Oneof_F_Bool{true}}},\n\t{\"oneof zero int32\", &pb.Oneof{Union: &pb.Oneof_F_Int32{0}}},\n\t{\"oneof big int32\", &pb.Oneof{Union: &pb.Oneof_F_Int32{1 << 20}}},\n\t{\"oneof int64\", &pb.Oneof{Union: &pb.Oneof_F_Int64{42}}},\n\t{\"oneof fixed32\", &pb.Oneof{Union: &pb.Oneof_F_Fixed32{43}}},\n\t{\"oneof fixed64\", &pb.Oneof{Union: &pb.Oneof_F_Fixed64{44}}},\n\t{\"oneof uint32\", &pb.Oneof{Union: &pb.Oneof_F_Uint32{45}}},\n\t{\"oneof uint64\", &pb.Oneof{Union: &pb.Oneof_F_Uint64{46}}},\n\t{\"oneof float\", &pb.Oneof{Union: &pb.Oneof_F_Float{47.1}}},\n\t{\"oneof double\", &pb.Oneof{Union: &pb.Oneof_F_Double{48.9}}},\n\t{\"oneof string\", &pb.Oneof{Union: &pb.Oneof_F_String{\"Rhythmic Fman\"}}},\n\t{\"oneof bytes\", &pb.Oneof{Union: &pb.Oneof_F_Bytes{[]byte(\"let go\")}}},\n\t{\"oneof sint32\", &pb.Oneof{Union: &pb.Oneof_F_Sint32{50}}},\n\t{\"oneof sint64\", &pb.Oneof{Union: &pb.Oneof_F_Sint64{51}}},\n\t{\"oneof enum\", &pb.Oneof{Union: &pb.Oneof_F_Enum{pb.MyMessage_BLUE}}},\n\t{\"message for oneof\", &pb.GoTestField{Label: String(\"k\"), Type: String(\"v\")}},\n\t{\"oneof message\", &pb.Oneof{Union: &pb.Oneof_F_Message{&pb.GoTestField{Label: String(\"k\"), Type: String(\"v\")}}}},\n\t{\"oneof group\", &pb.Oneof{Union: &pb.Oneof_FGroup{&pb.Oneof_F_Group{X: Int32(52)}}}},\n\t{\"oneof largest tag\", &pb.Oneof{Union: &pb.Oneof_F_Largest_Tag{1}}},\n\t{\"multiple oneofs\", &pb.Oneof{Union: &pb.Oneof_F_Int32{1}, Tormato: &pb.Oneof_Value{2}}},\n}\n\nfunc TestSize(t *testing.T) {\n\tfor _, tc := range SizeTests {\n\t\tsize := Size(tc.pb)\n\t\tb, err := Marshal(tc.pb)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"%v: Marshal failed: %v\", tc.desc, err)\n\t\t\tcontinue\n\t\t}\n\t\tif size != len(b) {\n\t\t\tt.Errorf(\"%v: Size(%v) = %d, want %d\", tc.desc, tc.pb, size, len(b))\n\t\t\tt.Logf(\"%v: bytes: %#v\", tc.desc, b)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/text.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2010 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto\n\n// Functions for writing the text protocol buffer format.\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"encoding\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"math\"\n\t\"reflect\"\n\t\"sort\"\n\t\"strings\"\n)\n\nvar (\n\tnewline         = []byte(\"\\n\")\n\tspaces          = []byte(\"                                        \")\n\tgtNewline       = []byte(\">\\n\")\n\tendBraceNewline = []byte(\"}\\n\")\n\tbackslashN      = []byte{'\\\\', 'n'}\n\tbackslashR      = []byte{'\\\\', 'r'}\n\tbackslashT      = []byte{'\\\\', 't'}\n\tbackslashDQ     = []byte{'\\\\', '\"'}\n\tbackslashBS     = []byte{'\\\\', '\\\\'}\n\tposInf          = []byte(\"inf\")\n\tnegInf          = []byte(\"-inf\")\n\tnan             = []byte(\"nan\")\n)\n\ntype writer interface {\n\tio.Writer\n\tWriteByte(byte) error\n}\n\n// textWriter is an io.Writer that tracks its indentation level.\ntype textWriter struct {\n\tind      int\n\tcomplete bool // if the current position is a complete line\n\tcompact  bool // whether to write out as a one-liner\n\tw        writer\n}\n\nfunc (w *textWriter) WriteString(s string) (n int, err error) {\n\tif !strings.Contains(s, \"\\n\") {\n\t\tif !w.compact && w.complete {\n\t\t\tw.writeIndent()\n\t\t}\n\t\tw.complete = false\n\t\treturn io.WriteString(w.w, s)\n\t}\n\t// WriteString is typically called without newlines, so this\n\t// codepath and its copy are rare.  We copy to avoid\n\t// duplicating all of Write's logic here.\n\treturn w.Write([]byte(s))\n}\n\nfunc (w *textWriter) Write(p []byte) (n int, err error) {\n\tnewlines := bytes.Count(p, newline)\n\tif newlines == 0 {\n\t\tif !w.compact && w.complete {\n\t\t\tw.writeIndent()\n\t\t}\n\t\tn, err = w.w.Write(p)\n\t\tw.complete = false\n\t\treturn n, err\n\t}\n\n\tfrags := bytes.SplitN(p, newline, newlines+1)\n\tif w.compact {\n\t\tfor i, frag := range frags {\n\t\t\tif i > 0 {\n\t\t\t\tif err := w.w.WriteByte(' '); err != nil {\n\t\t\t\t\treturn n, err\n\t\t\t\t}\n\t\t\t\tn++\n\t\t\t}\n\t\t\tnn, err := w.w.Write(frag)\n\t\t\tn += nn\n\t\t\tif err != nil {\n\t\t\t\treturn n, err\n\t\t\t}\n\t\t}\n\t\treturn n, nil\n\t}\n\n\tfor i, frag := range frags {\n\t\tif w.complete {\n\t\t\tw.writeIndent()\n\t\t}\n\t\tnn, err := w.w.Write(frag)\n\t\tn += nn\n\t\tif err != nil {\n\t\t\treturn n, err\n\t\t}\n\t\tif i+1 < len(frags) {\n\t\t\tif err := w.w.WriteByte('\\n'); err != nil {\n\t\t\t\treturn n, err\n\t\t\t}\n\t\t\tn++\n\t\t}\n\t}\n\tw.complete = len(frags[len(frags)-1]) == 0\n\treturn n, nil\n}\n\nfunc (w *textWriter) WriteByte(c byte) error {\n\tif w.compact && c == '\\n' {\n\t\tc = ' '\n\t}\n\tif !w.compact && w.complete {\n\t\tw.writeIndent()\n\t}\n\terr := w.w.WriteByte(c)\n\tw.complete = c == '\\n'\n\treturn err\n}\n\nfunc (w *textWriter) indent() { w.ind++ }\n\nfunc (w *textWriter) unindent() {\n\tif w.ind == 0 {\n\t\tlog.Print(\"proto: textWriter unindented too far\")\n\t\treturn\n\t}\n\tw.ind--\n}\n\nfunc writeName(w *textWriter, props *Properties) error {\n\tif _, err := w.WriteString(props.OrigName); err != nil {\n\t\treturn err\n\t}\n\tif props.Wire != \"group\" {\n\t\treturn w.WriteByte(':')\n\t}\n\treturn nil\n}\n\n// raw is the interface satisfied by RawMessage.\ntype raw interface {\n\tBytes() []byte\n}\n\nfunc requiresQuotes(u string) bool {\n\t// When type URL contains any characters except [0-9A-Za-z./\\-]*, it must be quoted.\n\tfor _, ch := range u {\n\t\tswitch {\n\t\tcase ch == '.' || ch == '/' || ch == '_':\n\t\t\tcontinue\n\t\tcase '0' <= ch && ch <= '9':\n\t\t\tcontinue\n\t\tcase 'A' <= ch && ch <= 'Z':\n\t\t\tcontinue\n\t\tcase 'a' <= ch && ch <= 'z':\n\t\t\tcontinue\n\t\tdefault:\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// isAny reports whether sv is a google.protobuf.Any message\nfunc isAny(sv reflect.Value) bool {\n\ttype wkt interface {\n\t\tXXX_WellKnownType() string\n\t}\n\tt, ok := sv.Addr().Interface().(wkt)\n\treturn ok && t.XXX_WellKnownType() == \"Any\"\n}\n\n// writeProto3Any writes an expanded google.protobuf.Any message.\n//\n// It returns (false, nil) if sv value can't be unmarshaled (e.g. because\n// required messages are not linked in).\n//\n// It returns (true, error) when sv was written in expanded format or an error\n// was encountered.\nfunc (tm *TextMarshaler) writeProto3Any(w *textWriter, sv reflect.Value) (bool, error) {\n\tturl := sv.FieldByName(\"TypeUrl\")\n\tval := sv.FieldByName(\"Value\")\n\tif !turl.IsValid() || !val.IsValid() {\n\t\treturn true, errors.New(\"proto: invalid google.protobuf.Any message\")\n\t}\n\n\tb, ok := val.Interface().([]byte)\n\tif !ok {\n\t\treturn true, errors.New(\"proto: invalid google.protobuf.Any message\")\n\t}\n\n\tparts := strings.Split(turl.String(), \"/\")\n\tmt := MessageType(parts[len(parts)-1])\n\tif mt == nil {\n\t\treturn false, nil\n\t}\n\tm := reflect.New(mt.Elem())\n\tif err := Unmarshal(b, m.Interface().(Message)); err != nil {\n\t\treturn false, nil\n\t}\n\tw.Write([]byte(\"[\"))\n\tu := turl.String()\n\tif requiresQuotes(u) {\n\t\twriteString(w, u)\n\t} else {\n\t\tw.Write([]byte(u))\n\t}\n\tif w.compact {\n\t\tw.Write([]byte(\"]:<\"))\n\t} else {\n\t\tw.Write([]byte(\"]: <\\n\"))\n\t\tw.ind++\n\t}\n\tif err := tm.writeStruct(w, m.Elem()); err != nil {\n\t\treturn true, err\n\t}\n\tif w.compact {\n\t\tw.Write([]byte(\"> \"))\n\t} else {\n\t\tw.ind--\n\t\tw.Write([]byte(\">\\n\"))\n\t}\n\treturn true, nil\n}\n\nfunc (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {\n\tif tm.ExpandAny && isAny(sv) {\n\t\tif canExpand, err := tm.writeProto3Any(w, sv); canExpand {\n\t\t\treturn err\n\t\t}\n\t}\n\tst := sv.Type()\n\tsprops := GetProperties(st)\n\tfor i := 0; i < sv.NumField(); i++ {\n\t\tfv := sv.Field(i)\n\t\tprops := sprops.Prop[i]\n\t\tname := st.Field(i).Name\n\n\t\tif strings.HasPrefix(name, \"XXX_\") {\n\t\t\t// There are two XXX_ fields:\n\t\t\t//   XXX_unrecognized []byte\n\t\t\t//   XXX_extensions   map[int32]proto.Extension\n\t\t\t// The first is handled here;\n\t\t\t// the second is handled at the bottom of this function.\n\t\t\tif name == \"XXX_unrecognized\" && !fv.IsNil() {\n\t\t\t\tif err := writeUnknownStruct(w, fv.Interface().([]byte)); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif fv.Kind() == reflect.Ptr && fv.IsNil() {\n\t\t\t// Field not filled in. This could be an optional field or\n\t\t\t// a required field that wasn't filled in. Either way, there\n\t\t\t// isn't anything we can show for it.\n\t\t\tcontinue\n\t\t}\n\t\tif fv.Kind() == reflect.Slice && fv.IsNil() {\n\t\t\t// Repeated field that is empty, or a bytes field that is unused.\n\t\t\tcontinue\n\t\t}\n\n\t\tif props.Repeated && fv.Kind() == reflect.Slice {\n\t\t\t// Repeated field.\n\t\t\tfor j := 0; j < fv.Len(); j++ {\n\t\t\t\tif err := writeName(w, props); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif !w.compact {\n\t\t\t\t\tif err := w.WriteByte(' '); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tv := fv.Index(j)\n\t\t\t\tif v.Kind() == reflect.Ptr && v.IsNil() {\n\t\t\t\t\t// A nil message in a repeated field is not valid,\n\t\t\t\t\t// but we can handle that more gracefully than panicking.\n\t\t\t\t\tif _, err := w.Write([]byte(\"<nil>\\n\")); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif err := tm.writeAny(w, v, props); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif err := w.WriteByte('\\n'); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif fv.Kind() == reflect.Map {\n\t\t\t// Map fields are rendered as a repeated struct with key/value fields.\n\t\t\tkeys := fv.MapKeys()\n\t\t\tsort.Sort(mapKeys(keys))\n\t\t\tfor _, key := range keys {\n\t\t\t\tval := fv.MapIndex(key)\n\t\t\t\tif err := writeName(w, props); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif !w.compact {\n\t\t\t\t\tif err := w.WriteByte(' '); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// open struct\n\t\t\t\tif err := w.WriteByte('<'); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif !w.compact {\n\t\t\t\t\tif err := w.WriteByte('\\n'); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tw.indent()\n\t\t\t\t// key\n\t\t\t\tif _, err := w.WriteString(\"key:\"); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif !w.compact {\n\t\t\t\t\tif err := w.WriteByte(' '); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif err := tm.writeAny(w, key, props.mkeyprop); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif err := w.WriteByte('\\n'); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\t// nil values aren't legal, but we can avoid panicking because of them.\n\t\t\t\tif val.Kind() != reflect.Ptr || !val.IsNil() {\n\t\t\t\t\t// value\n\t\t\t\t\tif _, err := w.WriteString(\"value:\"); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tif !w.compact {\n\t\t\t\t\t\tif err := w.WriteByte(' '); err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif err := tm.writeAny(w, val, props.mvalprop); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tif err := w.WriteByte('\\n'); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// close struct\n\t\t\t\tw.unindent()\n\t\t\t\tif err := w.WriteByte('>'); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif err := w.WriteByte('\\n'); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif props.proto3 && fv.Kind() == reflect.Slice && fv.Len() == 0 {\n\t\t\t// empty bytes field\n\t\t\tcontinue\n\t\t}\n\t\tif fv.Kind() != reflect.Ptr && fv.Kind() != reflect.Slice {\n\t\t\t// proto3 non-repeated scalar field; skip if zero value\n\t\t\tif isProto3Zero(fv) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif fv.Kind() == reflect.Interface {\n\t\t\t// Check if it is a oneof.\n\t\t\tif st.Field(i).Tag.Get(\"protobuf_oneof\") != \"\" {\n\t\t\t\t// fv is nil, or holds a pointer to generated struct.\n\t\t\t\t// That generated struct has exactly one field,\n\t\t\t\t// which has a protobuf struct tag.\n\t\t\t\tif fv.IsNil() {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tinner := fv.Elem().Elem() // interface -> *T -> T\n\t\t\t\ttag := inner.Type().Field(0).Tag.Get(\"protobuf\")\n\t\t\t\tprops = new(Properties) // Overwrite the outer props var, but not its pointee.\n\t\t\t\tprops.Parse(tag)\n\t\t\t\t// Write the value in the oneof, not the oneof itself.\n\t\t\t\tfv = inner.Field(0)\n\n\t\t\t\t// Special case to cope with malformed messages gracefully:\n\t\t\t\t// If the value in the oneof is a nil pointer, don't panic\n\t\t\t\t// in writeAny.\n\t\t\t\tif fv.Kind() == reflect.Ptr && fv.IsNil() {\n\t\t\t\t\t// Use errors.New so writeAny won't render quotes.\n\t\t\t\t\tmsg := errors.New(\"/* nil */\")\n\t\t\t\t\tfv = reflect.ValueOf(&msg).Elem()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif err := writeName(w, props); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !w.compact {\n\t\t\tif err := w.WriteByte(' '); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tif b, ok := fv.Interface().(raw); ok {\n\t\t\tif err := writeRaw(w, b.Bytes()); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\t// Enums have a String method, so writeAny will work fine.\n\t\tif err := tm.writeAny(w, fv, props); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := w.WriteByte('\\n'); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Extensions (the XXX_extensions field).\n\tpv := sv.Addr()\n\tif _, ok := extendable(pv.Interface()); ok {\n\t\tif err := tm.writeExtensions(w, pv); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// writeRaw writes an uninterpreted raw message.\nfunc writeRaw(w *textWriter, b []byte) error {\n\tif err := w.WriteByte('<'); err != nil {\n\t\treturn err\n\t}\n\tif !w.compact {\n\t\tif err := w.WriteByte('\\n'); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tw.indent()\n\tif err := writeUnknownStruct(w, b); err != nil {\n\t\treturn err\n\t}\n\tw.unindent()\n\tif err := w.WriteByte('>'); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\n// writeAny writes an arbitrary field.\nfunc (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error {\n\tv = reflect.Indirect(v)\n\n\t// Floats have special cases.\n\tif v.Kind() == reflect.Float32 || v.Kind() == reflect.Float64 {\n\t\tx := v.Float()\n\t\tvar b []byte\n\t\tswitch {\n\t\tcase math.IsInf(x, 1):\n\t\t\tb = posInf\n\t\tcase math.IsInf(x, -1):\n\t\t\tb = negInf\n\t\tcase math.IsNaN(x):\n\t\t\tb = nan\n\t\t}\n\t\tif b != nil {\n\t\t\t_, err := w.Write(b)\n\t\t\treturn err\n\t\t}\n\t\t// Other values are handled below.\n\t}\n\n\t// We don't attempt to serialise every possible value type; only those\n\t// that can occur in protocol buffers.\n\tswitch v.Kind() {\n\tcase reflect.Slice:\n\t\t// Should only be a []byte; repeated fields are handled in writeStruct.\n\t\tif err := writeString(w, string(v.Bytes())); err != nil {\n\t\t\treturn err\n\t\t}\n\tcase reflect.String:\n\t\tif err := writeString(w, v.String()); err != nil {\n\t\t\treturn err\n\t\t}\n\tcase reflect.Struct:\n\t\t// Required/optional group/message.\n\t\tvar bra, ket byte = '<', '>'\n\t\tif props != nil && props.Wire == \"group\" {\n\t\t\tbra, ket = '{', '}'\n\t\t}\n\t\tif err := w.WriteByte(bra); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !w.compact {\n\t\t\tif err := w.WriteByte('\\n'); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tw.indent()\n\t\tif etm, ok := v.Interface().(encoding.TextMarshaler); ok {\n\t\t\ttext, err := etm.MarshalText()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif _, err = w.Write(text); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else if err := tm.writeStruct(w, v); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tw.unindent()\n\t\tif err := w.WriteByte(ket); err != nil {\n\t\t\treturn err\n\t\t}\n\tdefault:\n\t\t_, err := fmt.Fprint(w, v.Interface())\n\t\treturn err\n\t}\n\treturn nil\n}\n\n// equivalent to C's isprint.\nfunc isprint(c byte) bool {\n\treturn c >= 0x20 && c < 0x7f\n}\n\n// writeString writes a string in the protocol buffer text format.\n// It is similar to strconv.Quote except we don't use Go escape sequences,\n// we treat the string as a byte sequence, and we use octal escapes.\n// These differences are to maintain interoperability with the other\n// languages' implementations of the text format.\nfunc writeString(w *textWriter, s string) error {\n\t// use WriteByte here to get any needed indent\n\tif err := w.WriteByte('\"'); err != nil {\n\t\treturn err\n\t}\n\t// Loop over the bytes, not the runes.\n\tfor i := 0; i < len(s); i++ {\n\t\tvar err error\n\t\t// Divergence from C++: we don't escape apostrophes.\n\t\t// There's no need to escape them, and the C++ parser\n\t\t// copes with a naked apostrophe.\n\t\tswitch c := s[i]; c {\n\t\tcase '\\n':\n\t\t\t_, err = w.w.Write(backslashN)\n\t\tcase '\\r':\n\t\t\t_, err = w.w.Write(backslashR)\n\t\tcase '\\t':\n\t\t\t_, err = w.w.Write(backslashT)\n\t\tcase '\"':\n\t\t\t_, err = w.w.Write(backslashDQ)\n\t\tcase '\\\\':\n\t\t\t_, err = w.w.Write(backslashBS)\n\t\tdefault:\n\t\t\tif isprint(c) {\n\t\t\t\terr = w.w.WriteByte(c)\n\t\t\t} else {\n\t\t\t\t_, err = fmt.Fprintf(w.w, \"\\\\%03o\", c)\n\t\t\t}\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn w.WriteByte('\"')\n}\n\nfunc writeUnknownStruct(w *textWriter, data []byte) (err error) {\n\tif !w.compact {\n\t\tif _, err := fmt.Fprintf(w, \"/* %d unknown bytes */\\n\", len(data)); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tb := NewBuffer(data)\n\tfor b.index < len(b.buf) {\n\t\tx, err := b.DecodeVarint()\n\t\tif err != nil {\n\t\t\t_, err := fmt.Fprintf(w, \"/* %v */\\n\", err)\n\t\t\treturn err\n\t\t}\n\t\twire, tag := x&7, x>>3\n\t\tif wire == WireEndGroup {\n\t\t\tw.unindent()\n\t\t\tif _, err := w.Write(endBraceNewline); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif _, err := fmt.Fprint(w, tag); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif wire != WireStartGroup {\n\t\t\tif err := w.WriteByte(':'); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tif !w.compact || wire == WireStartGroup {\n\t\t\tif err := w.WriteByte(' '); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tswitch wire {\n\t\tcase WireBytes:\n\t\t\tbuf, e := b.DecodeRawBytes(false)\n\t\t\tif e == nil {\n\t\t\t\t_, err = fmt.Fprintf(w, \"%q\", buf)\n\t\t\t} else {\n\t\t\t\t_, err = fmt.Fprintf(w, \"/* %v */\", e)\n\t\t\t}\n\t\tcase WireFixed32:\n\t\t\tx, err = b.DecodeFixed32()\n\t\t\terr = writeUnknownInt(w, x, err)\n\t\tcase WireFixed64:\n\t\t\tx, err = b.DecodeFixed64()\n\t\t\terr = writeUnknownInt(w, x, err)\n\t\tcase WireStartGroup:\n\t\t\terr = w.WriteByte('{')\n\t\t\tw.indent()\n\t\tcase WireVarint:\n\t\t\tx, err = b.DecodeVarint()\n\t\t\terr = writeUnknownInt(w, x, err)\n\t\tdefault:\n\t\t\t_, err = fmt.Fprintf(w, \"/* unknown wire type %d */\", wire)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err = w.WriteByte('\\n'); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc writeUnknownInt(w *textWriter, x uint64, err error) error {\n\tif err == nil {\n\t\t_, err = fmt.Fprint(w, x)\n\t} else {\n\t\t_, err = fmt.Fprintf(w, \"/* %v */\", err)\n\t}\n\treturn err\n}\n\ntype int32Slice []int32\n\nfunc (s int32Slice) Len() int           { return len(s) }\nfunc (s int32Slice) Less(i, j int) bool { return s[i] < s[j] }\nfunc (s int32Slice) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }\n\n// writeExtensions writes all the extensions in pv.\n// pv is assumed to be a pointer to a protocol message struct that is extendable.\nfunc (tm *TextMarshaler) writeExtensions(w *textWriter, pv reflect.Value) error {\n\temap := extensionMaps[pv.Type().Elem()]\n\tep, _ := extendable(pv.Interface())\n\n\t// Order the extensions by ID.\n\t// This isn't strictly necessary, but it will give us\n\t// canonical output, which will also make testing easier.\n\tm, mu := ep.extensionsRead()\n\tif m == nil {\n\t\treturn nil\n\t}\n\tmu.Lock()\n\tids := make([]int32, 0, len(m))\n\tfor id := range m {\n\t\tids = append(ids, id)\n\t}\n\tsort.Sort(int32Slice(ids))\n\tmu.Unlock()\n\n\tfor _, extNum := range ids {\n\t\text := m[extNum]\n\t\tvar desc *ExtensionDesc\n\t\tif emap != nil {\n\t\t\tdesc = emap[extNum]\n\t\t}\n\t\tif desc == nil {\n\t\t\t// Unknown extension.\n\t\t\tif err := writeUnknownStruct(w, ext.enc); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tpb, err := GetExtension(ep, desc)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed getting extension: %v\", err)\n\t\t}\n\n\t\t// Repeated extensions will appear as a slice.\n\t\tif !desc.repeated() {\n\t\t\tif err := tm.writeExtension(w, desc.Name, pb); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\tv := reflect.ValueOf(pb)\n\t\t\tfor i := 0; i < v.Len(); i++ {\n\t\t\t\tif err := tm.writeExtension(w, desc.Name, v.Index(i).Interface()); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (tm *TextMarshaler) writeExtension(w *textWriter, name string, pb interface{}) error {\n\tif _, err := fmt.Fprintf(w, \"[%s]:\", name); err != nil {\n\t\treturn err\n\t}\n\tif !w.compact {\n\t\tif err := w.WriteByte(' '); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err := tm.writeAny(w, reflect.ValueOf(pb), nil); err != nil {\n\t\treturn err\n\t}\n\tif err := w.WriteByte('\\n'); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc (w *textWriter) writeIndent() {\n\tif !w.complete {\n\t\treturn\n\t}\n\tremain := w.ind * 2\n\tfor remain > 0 {\n\t\tn := remain\n\t\tif n > len(spaces) {\n\t\t\tn = len(spaces)\n\t\t}\n\t\tw.w.Write(spaces[:n])\n\t\tremain -= n\n\t}\n\tw.complete = false\n}\n\n// TextMarshaler is a configurable text format marshaler.\ntype TextMarshaler struct {\n\tCompact   bool // use compact text format (one line).\n\tExpandAny bool // expand google.protobuf.Any messages of known types\n}\n\n// Marshal writes a given protocol buffer in text format.\n// The only errors returned are from w.\nfunc (tm *TextMarshaler) Marshal(w io.Writer, pb Message) error {\n\tval := reflect.ValueOf(pb)\n\tif pb == nil || val.IsNil() {\n\t\tw.Write([]byte(\"<nil>\"))\n\t\treturn nil\n\t}\n\tvar bw *bufio.Writer\n\tww, ok := w.(writer)\n\tif !ok {\n\t\tbw = bufio.NewWriter(w)\n\t\tww = bw\n\t}\n\taw := &textWriter{\n\t\tw:        ww,\n\t\tcomplete: true,\n\t\tcompact:  tm.Compact,\n\t}\n\n\tif etm, ok := pb.(encoding.TextMarshaler); ok {\n\t\ttext, err := etm.MarshalText()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif _, err = aw.Write(text); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif bw != nil {\n\t\t\treturn bw.Flush()\n\t\t}\n\t\treturn nil\n\t}\n\t// Dereference the received pointer so we don't have outer < and >.\n\tv := reflect.Indirect(val)\n\tif err := tm.writeStruct(aw, v); err != nil {\n\t\treturn err\n\t}\n\tif bw != nil {\n\t\treturn bw.Flush()\n\t}\n\treturn nil\n}\n\n// Text is the same as Marshal, but returns the string directly.\nfunc (tm *TextMarshaler) Text(pb Message) string {\n\tvar buf bytes.Buffer\n\ttm.Marshal(&buf, pb)\n\treturn buf.String()\n}\n\nvar (\n\tdefaultTextMarshaler = TextMarshaler{}\n\tcompactTextMarshaler = TextMarshaler{Compact: true}\n)\n\n// TODO: consider removing some of the Marshal functions below.\n\n// MarshalText writes a given protocol buffer in text format.\n// The only errors returned are from w.\nfunc MarshalText(w io.Writer, pb Message) error { return defaultTextMarshaler.Marshal(w, pb) }\n\n// MarshalTextString is the same as MarshalText, but returns the string directly.\nfunc MarshalTextString(pb Message) string { return defaultTextMarshaler.Text(pb) }\n\n// CompactText writes a given protocol buffer in compact text format (one line).\nfunc CompactText(w io.Writer, pb Message) error { return compactTextMarshaler.Marshal(w, pb) }\n\n// CompactTextString is the same as CompactText, but returns the string directly.\nfunc CompactTextString(pb Message) string { return compactTextMarshaler.Text(pb) }\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/text_parser.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2010 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto\n\n// Functions for parsing the Text protocol buffer format.\n// TODO: message sets.\n\nimport (\n\t\"encoding\"\n\t\"errors\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode/utf8\"\n)\n\n// Error string emitted when deserializing Any and fields are already set\nconst anyRepeatedlyUnpacked = \"Any message unpacked multiple times, or %q already set\"\n\ntype ParseError struct {\n\tMessage string\n\tLine    int // 1-based line number\n\tOffset  int // 0-based byte offset from start of input\n}\n\nfunc (p *ParseError) Error() string {\n\tif p.Line == 1 {\n\t\t// show offset only for first line\n\t\treturn fmt.Sprintf(\"line 1.%d: %v\", p.Offset, p.Message)\n\t}\n\treturn fmt.Sprintf(\"line %d: %v\", p.Line, p.Message)\n}\n\ntype token struct {\n\tvalue    string\n\terr      *ParseError\n\tline     int    // line number\n\toffset   int    // byte number from start of input, not start of line\n\tunquoted string // the unquoted version of value, if it was a quoted string\n}\n\nfunc (t *token) String() string {\n\tif t.err == nil {\n\t\treturn fmt.Sprintf(\"%q (line=%d, offset=%d)\", t.value, t.line, t.offset)\n\t}\n\treturn fmt.Sprintf(\"parse error: %v\", t.err)\n}\n\ntype textParser struct {\n\ts            string // remaining input\n\tdone         bool   // whether the parsing is finished (success or error)\n\tbacked       bool   // whether back() was called\n\toffset, line int\n\tcur          token\n}\n\nfunc newTextParser(s string) *textParser {\n\tp := new(textParser)\n\tp.s = s\n\tp.line = 1\n\tp.cur.line = 1\n\treturn p\n}\n\nfunc (p *textParser) errorf(format string, a ...interface{}) *ParseError {\n\tpe := &ParseError{fmt.Sprintf(format, a...), p.cur.line, p.cur.offset}\n\tp.cur.err = pe\n\tp.done = true\n\treturn pe\n}\n\n// Numbers and identifiers are matched by [-+._A-Za-z0-9]\nfunc isIdentOrNumberChar(c byte) bool {\n\tswitch {\n\tcase 'A' <= c && c <= 'Z', 'a' <= c && c <= 'z':\n\t\treturn true\n\tcase '0' <= c && c <= '9':\n\t\treturn true\n\t}\n\tswitch c {\n\tcase '-', '+', '.', '_':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc isWhitespace(c byte) bool {\n\tswitch c {\n\tcase ' ', '\\t', '\\n', '\\r':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc isQuote(c byte) bool {\n\tswitch c {\n\tcase '\"', '\\'':\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc (p *textParser) skipWhitespace() {\n\ti := 0\n\tfor i < len(p.s) && (isWhitespace(p.s[i]) || p.s[i] == '#') {\n\t\tif p.s[i] == '#' {\n\t\t\t// comment; skip to end of line or input\n\t\t\tfor i < len(p.s) && p.s[i] != '\\n' {\n\t\t\t\ti++\n\t\t\t}\n\t\t\tif i == len(p.s) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif p.s[i] == '\\n' {\n\t\t\tp.line++\n\t\t}\n\t\ti++\n\t}\n\tp.offset += i\n\tp.s = p.s[i:len(p.s)]\n\tif len(p.s) == 0 {\n\t\tp.done = true\n\t}\n}\n\nfunc (p *textParser) advance() {\n\t// Skip whitespace\n\tp.skipWhitespace()\n\tif p.done {\n\t\treturn\n\t}\n\n\t// Start of non-whitespace\n\tp.cur.err = nil\n\tp.cur.offset, p.cur.line = p.offset, p.line\n\tp.cur.unquoted = \"\"\n\tswitch p.s[0] {\n\tcase '<', '>', '{', '}', ':', '[', ']', ';', ',', '/':\n\t\t// Single symbol\n\t\tp.cur.value, p.s = p.s[0:1], p.s[1:len(p.s)]\n\tcase '\"', '\\'':\n\t\t// Quoted string\n\t\ti := 1\n\t\tfor i < len(p.s) && p.s[i] != p.s[0] && p.s[i] != '\\n' {\n\t\t\tif p.s[i] == '\\\\' && i+1 < len(p.s) {\n\t\t\t\t// skip escaped char\n\t\t\t\ti++\n\t\t\t}\n\t\t\ti++\n\t\t}\n\t\tif i >= len(p.s) || p.s[i] != p.s[0] {\n\t\t\tp.errorf(\"unmatched quote\")\n\t\t\treturn\n\t\t}\n\t\tunq, err := unquoteC(p.s[1:i], rune(p.s[0]))\n\t\tif err != nil {\n\t\t\tp.errorf(\"invalid quoted string %s: %v\", p.s[0:i+1], err)\n\t\t\treturn\n\t\t}\n\t\tp.cur.value, p.s = p.s[0:i+1], p.s[i+1:len(p.s)]\n\t\tp.cur.unquoted = unq\n\tdefault:\n\t\ti := 0\n\t\tfor i < len(p.s) && isIdentOrNumberChar(p.s[i]) {\n\t\t\ti++\n\t\t}\n\t\tif i == 0 {\n\t\t\tp.errorf(\"unexpected byte %#x\", p.s[0])\n\t\t\treturn\n\t\t}\n\t\tp.cur.value, p.s = p.s[0:i], p.s[i:len(p.s)]\n\t}\n\tp.offset += len(p.cur.value)\n}\n\nvar (\n\terrBadUTF8 = errors.New(\"proto: bad UTF-8\")\n\terrBadHex  = errors.New(\"proto: bad hexadecimal\")\n)\n\nfunc unquoteC(s string, quote rune) (string, error) {\n\t// This is based on C++'s tokenizer.cc.\n\t// Despite its name, this is *not* parsing C syntax.\n\t// For instance, \"\\0\" is an invalid quoted string.\n\n\t// Avoid allocation in trivial cases.\n\tsimple := true\n\tfor _, r := range s {\n\t\tif r == '\\\\' || r == quote {\n\t\t\tsimple = false\n\t\t\tbreak\n\t\t}\n\t}\n\tif simple {\n\t\treturn s, nil\n\t}\n\n\tbuf := make([]byte, 0, 3*len(s)/2)\n\tfor len(s) > 0 {\n\t\tr, n := utf8.DecodeRuneInString(s)\n\t\tif r == utf8.RuneError && n == 1 {\n\t\t\treturn \"\", errBadUTF8\n\t\t}\n\t\ts = s[n:]\n\t\tif r != '\\\\' {\n\t\t\tif r < utf8.RuneSelf {\n\t\t\t\tbuf = append(buf, byte(r))\n\t\t\t} else {\n\t\t\t\tbuf = append(buf, string(r)...)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tch, tail, err := unescape(s)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tbuf = append(buf, ch...)\n\t\ts = tail\n\t}\n\treturn string(buf), nil\n}\n\nfunc unescape(s string) (ch string, tail string, err error) {\n\tr, n := utf8.DecodeRuneInString(s)\n\tif r == utf8.RuneError && n == 1 {\n\t\treturn \"\", \"\", errBadUTF8\n\t}\n\ts = s[n:]\n\tswitch r {\n\tcase 'a':\n\t\treturn \"\\a\", s, nil\n\tcase 'b':\n\t\treturn \"\\b\", s, nil\n\tcase 'f':\n\t\treturn \"\\f\", s, nil\n\tcase 'n':\n\t\treturn \"\\n\", s, nil\n\tcase 'r':\n\t\treturn \"\\r\", s, nil\n\tcase 't':\n\t\treturn \"\\t\", s, nil\n\tcase 'v':\n\t\treturn \"\\v\", s, nil\n\tcase '?':\n\t\treturn \"?\", s, nil // trigraph workaround\n\tcase '\\'', '\"', '\\\\':\n\t\treturn string(r), s, nil\n\tcase '0', '1', '2', '3', '4', '5', '6', '7', 'x', 'X':\n\t\tif len(s) < 2 {\n\t\t\treturn \"\", \"\", fmt.Errorf(`\\%c requires 2 following digits`, r)\n\t\t}\n\t\tbase := 8\n\t\tss := s[:2]\n\t\ts = s[2:]\n\t\tif r == 'x' || r == 'X' {\n\t\t\tbase = 16\n\t\t} else {\n\t\t\tss = string(r) + ss\n\t\t}\n\t\ti, err := strconv.ParseUint(ss, base, 8)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", err\n\t\t}\n\t\treturn string([]byte{byte(i)}), s, nil\n\tcase 'u', 'U':\n\t\tn := 4\n\t\tif r == 'U' {\n\t\t\tn = 8\n\t\t}\n\t\tif len(s) < n {\n\t\t\treturn \"\", \"\", fmt.Errorf(`\\%c requires %d digits`, r, n)\n\t\t}\n\n\t\tbs := make([]byte, n/2)\n\t\tfor i := 0; i < n; i += 2 {\n\t\t\ta, ok1 := unhex(s[i])\n\t\t\tb, ok2 := unhex(s[i+1])\n\t\t\tif !ok1 || !ok2 {\n\t\t\t\treturn \"\", \"\", errBadHex\n\t\t\t}\n\t\t\tbs[i/2] = a<<4 | b\n\t\t}\n\t\ts = s[n:]\n\t\treturn string(bs), s, nil\n\t}\n\treturn \"\", \"\", fmt.Errorf(`unknown escape \\%c`, r)\n}\n\n// Adapted from src/pkg/strconv/quote.go.\nfunc unhex(b byte) (v byte, ok bool) {\n\tswitch {\n\tcase '0' <= b && b <= '9':\n\t\treturn b - '0', true\n\tcase 'a' <= b && b <= 'f':\n\t\treturn b - 'a' + 10, true\n\tcase 'A' <= b && b <= 'F':\n\t\treturn b - 'A' + 10, true\n\t}\n\treturn 0, false\n}\n\n// Back off the parser by one token. Can only be done between calls to next().\n// It makes the next advance() a no-op.\nfunc (p *textParser) back() { p.backed = true }\n\n// Advances the parser and returns the new current token.\nfunc (p *textParser) next() *token {\n\tif p.backed || p.done {\n\t\tp.backed = false\n\t\treturn &p.cur\n\t}\n\tp.advance()\n\tif p.done {\n\t\tp.cur.value = \"\"\n\t} else if len(p.cur.value) > 0 && isQuote(p.cur.value[0]) {\n\t\t// Look for multiple quoted strings separated by whitespace,\n\t\t// and concatenate them.\n\t\tcat := p.cur\n\t\tfor {\n\t\t\tp.skipWhitespace()\n\t\t\tif p.done || !isQuote(p.s[0]) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tp.advance()\n\t\t\tif p.cur.err != nil {\n\t\t\t\treturn &p.cur\n\t\t\t}\n\t\t\tcat.value += \" \" + p.cur.value\n\t\t\tcat.unquoted += p.cur.unquoted\n\t\t}\n\t\tp.done = false // parser may have seen EOF, but we want to return cat\n\t\tp.cur = cat\n\t}\n\treturn &p.cur\n}\n\nfunc (p *textParser) consumeToken(s string) error {\n\ttok := p.next()\n\tif tok.err != nil {\n\t\treturn tok.err\n\t}\n\tif tok.value != s {\n\t\tp.back()\n\t\treturn p.errorf(\"expected %q, found %q\", s, tok.value)\n\t}\n\treturn nil\n}\n\n// Return a RequiredNotSetError indicating which required field was not set.\nfunc (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSetError {\n\tst := sv.Type()\n\tsprops := GetProperties(st)\n\tfor i := 0; i < st.NumField(); i++ {\n\t\tif !isNil(sv.Field(i)) {\n\t\t\tcontinue\n\t\t}\n\n\t\tprops := sprops.Prop[i]\n\t\tif props.Required {\n\t\t\treturn &RequiredNotSetError{fmt.Sprintf(\"%v.%v\", st, props.OrigName)}\n\t\t}\n\t}\n\treturn &RequiredNotSetError{fmt.Sprintf(\"%v.<unknown field name>\", st)} // should not happen\n}\n\n// Returns the index in the struct for the named field, as well as the parsed tag properties.\nfunc structFieldByName(sprops *StructProperties, name string) (int, *Properties, bool) {\n\ti, ok := sprops.decoderOrigNames[name]\n\tif ok {\n\t\treturn i, sprops.Prop[i], true\n\t}\n\treturn -1, nil, false\n}\n\n// Consume a ':' from the input stream (if the next token is a colon),\n// returning an error if a colon is needed but not present.\nfunc (p *textParser) checkForColon(props *Properties, typ reflect.Type) *ParseError {\n\ttok := p.next()\n\tif tok.err != nil {\n\t\treturn tok.err\n\t}\n\tif tok.value != \":\" {\n\t\t// Colon is optional when the field is a group or message.\n\t\tneedColon := true\n\t\tswitch props.Wire {\n\t\tcase \"group\":\n\t\t\tneedColon = false\n\t\tcase \"bytes\":\n\t\t\t// A \"bytes\" field is either a message, a string, or a repeated field;\n\t\t\t// those three become *T, *string and []T respectively, so we can check for\n\t\t\t// this field being a pointer to a non-string.\n\t\t\tif typ.Kind() == reflect.Ptr {\n\t\t\t\t// *T or *string\n\t\t\t\tif typ.Elem().Kind() == reflect.String {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else if typ.Kind() == reflect.Slice {\n\t\t\t\t// []T or []*T\n\t\t\t\tif typ.Elem().Kind() != reflect.Ptr {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else if typ.Kind() == reflect.String {\n\t\t\t\t// The proto3 exception is for a string field,\n\t\t\t\t// which requires a colon.\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tneedColon = false\n\t\t}\n\t\tif needColon {\n\t\t\treturn p.errorf(\"expected ':', found %q\", tok.value)\n\t\t}\n\t\tp.back()\n\t}\n\treturn nil\n}\n\nfunc (p *textParser) readStruct(sv reflect.Value, terminator string) error {\n\tst := sv.Type()\n\tsprops := GetProperties(st)\n\treqCount := sprops.reqCount\n\tvar reqFieldErr error\n\tfieldSet := make(map[string]bool)\n\t// A struct is a sequence of \"name: value\", terminated by one of\n\t// '>' or '}', or the end of the input.  A name may also be\n\t// \"[extension]\" or \"[type/url]\".\n\t//\n\t// The whole struct can also be an expanded Any message, like:\n\t// [type/url] < ... struct contents ... >\n\tfor {\n\t\ttok := p.next()\n\t\tif tok.err != nil {\n\t\t\treturn tok.err\n\t\t}\n\t\tif tok.value == terminator {\n\t\t\tbreak\n\t\t}\n\t\tif tok.value == \"[\" {\n\t\t\t// Looks like an extension or an Any.\n\t\t\t//\n\t\t\t// TODO: Check whether we need to handle\n\t\t\t// namespace rooted names (e.g. \".something.Foo\").\n\t\t\textName, err := p.consumeExtName()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif s := strings.LastIndex(extName, \"/\"); s >= 0 {\n\t\t\t\t// If it contains a slash, it's an Any type URL.\n\t\t\t\tmessageName := extName[s+1:]\n\t\t\t\tmt := MessageType(messageName)\n\t\t\t\tif mt == nil {\n\t\t\t\t\treturn p.errorf(\"unrecognized message %q in google.protobuf.Any\", messageName)\n\t\t\t\t}\n\t\t\t\ttok = p.next()\n\t\t\t\tif tok.err != nil {\n\t\t\t\t\treturn tok.err\n\t\t\t\t}\n\t\t\t\t// consume an optional colon\n\t\t\t\tif tok.value == \":\" {\n\t\t\t\t\ttok = p.next()\n\t\t\t\t\tif tok.err != nil {\n\t\t\t\t\t\treturn tok.err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tvar terminator string\n\t\t\t\tswitch tok.value {\n\t\t\t\tcase \"<\":\n\t\t\t\t\tterminator = \">\"\n\t\t\t\tcase \"{\":\n\t\t\t\t\tterminator = \"}\"\n\t\t\t\tdefault:\n\t\t\t\t\treturn p.errorf(\"expected '{' or '<', found %q\", tok.value)\n\t\t\t\t}\n\t\t\t\tv := reflect.New(mt.Elem())\n\t\t\t\tif pe := p.readStruct(v.Elem(), terminator); pe != nil {\n\t\t\t\t\treturn pe\n\t\t\t\t}\n\t\t\t\tb, err := Marshal(v.Interface().(Message))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn p.errorf(\"failed to marshal message of type %q: %v\", messageName, err)\n\t\t\t\t}\n\t\t\t\tif fieldSet[\"type_url\"] {\n\t\t\t\t\treturn p.errorf(anyRepeatedlyUnpacked, \"type_url\")\n\t\t\t\t}\n\t\t\t\tif fieldSet[\"value\"] {\n\t\t\t\t\treturn p.errorf(anyRepeatedlyUnpacked, \"value\")\n\t\t\t\t}\n\t\t\t\tsv.FieldByName(\"TypeUrl\").SetString(extName)\n\t\t\t\tsv.FieldByName(\"Value\").SetBytes(b)\n\t\t\t\tfieldSet[\"type_url\"] = true\n\t\t\t\tfieldSet[\"value\"] = true\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tvar desc *ExtensionDesc\n\t\t\t// This could be faster, but it's functional.\n\t\t\t// TODO: Do something smarter than a linear scan.\n\t\t\tfor _, d := range RegisteredExtensions(reflect.New(st).Interface().(Message)) {\n\t\t\t\tif d.Name == extName {\n\t\t\t\t\tdesc = d\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif desc == nil {\n\t\t\t\treturn p.errorf(\"unrecognized extension %q\", extName)\n\t\t\t}\n\n\t\t\tprops := &Properties{}\n\t\t\tprops.Parse(desc.Tag)\n\n\t\t\ttyp := reflect.TypeOf(desc.ExtensionType)\n\t\t\tif err := p.checkForColon(props, typ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\trep := desc.repeated()\n\n\t\t\t// Read the extension structure, and set it in\n\t\t\t// the value we're constructing.\n\t\t\tvar ext reflect.Value\n\t\t\tif !rep {\n\t\t\t\text = reflect.New(typ).Elem()\n\t\t\t} else {\n\t\t\t\text = reflect.New(typ.Elem()).Elem()\n\t\t\t}\n\t\t\tif err := p.readAny(ext, props); err != nil {\n\t\t\t\tif _, ok := err.(*RequiredNotSetError); !ok {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\treqFieldErr = err\n\t\t\t}\n\t\t\tep := sv.Addr().Interface().(Message)\n\t\t\tif !rep {\n\t\t\t\tSetExtension(ep, desc, ext.Interface())\n\t\t\t} else {\n\t\t\t\told, err := GetExtension(ep, desc)\n\t\t\t\tvar sl reflect.Value\n\t\t\t\tif err == nil {\n\t\t\t\t\tsl = reflect.ValueOf(old) // existing slice\n\t\t\t\t} else {\n\t\t\t\t\tsl = reflect.MakeSlice(typ, 0, 1)\n\t\t\t\t}\n\t\t\t\tsl = reflect.Append(sl, ext)\n\t\t\t\tSetExtension(ep, desc, sl.Interface())\n\t\t\t}\n\t\t\tif err := p.consumeOptionalSeparator(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\t// This is a normal, non-extension field.\n\t\tname := tok.value\n\t\tvar dst reflect.Value\n\t\tfi, props, ok := structFieldByName(sprops, name)\n\t\tif ok {\n\t\t\tdst = sv.Field(fi)\n\t\t} else if oop, ok := sprops.OneofTypes[name]; ok {\n\t\t\t// It is a oneof.\n\t\t\tprops = oop.Prop\n\t\t\tnv := reflect.New(oop.Type.Elem())\n\t\t\tdst = nv.Elem().Field(0)\n\t\t\tfield := sv.Field(oop.Field)\n\t\t\tif !field.IsNil() {\n\t\t\t\treturn p.errorf(\"field '%s' would overwrite already parsed oneof '%s'\", name, sv.Type().Field(oop.Field).Name)\n\t\t\t}\n\t\t\tfield.Set(nv)\n\t\t}\n\t\tif !dst.IsValid() {\n\t\t\treturn p.errorf(\"unknown field name %q in %v\", name, st)\n\t\t}\n\n\t\tif dst.Kind() == reflect.Map {\n\t\t\t// Consume any colon.\n\t\t\tif err := p.checkForColon(props, dst.Type()); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// Construct the map if it doesn't already exist.\n\t\t\tif dst.IsNil() {\n\t\t\t\tdst.Set(reflect.MakeMap(dst.Type()))\n\t\t\t}\n\t\t\tkey := reflect.New(dst.Type().Key()).Elem()\n\t\t\tval := reflect.New(dst.Type().Elem()).Elem()\n\n\t\t\t// The map entry should be this sequence of tokens:\n\t\t\t//\t< key : KEY value : VALUE >\n\t\t\t// However, implementations may omit key or value, and technically\n\t\t\t// we should support them in any order.  See b/28924776 for a time\n\t\t\t// this went wrong.\n\n\t\t\ttok := p.next()\n\t\t\tvar terminator string\n\t\t\tswitch tok.value {\n\t\t\tcase \"<\":\n\t\t\t\tterminator = \">\"\n\t\t\tcase \"{\":\n\t\t\t\tterminator = \"}\"\n\t\t\tdefault:\n\t\t\t\treturn p.errorf(\"expected '{' or '<', found %q\", tok.value)\n\t\t\t}\n\t\t\tfor {\n\t\t\t\ttok := p.next()\n\t\t\t\tif tok.err != nil {\n\t\t\t\t\treturn tok.err\n\t\t\t\t}\n\t\t\t\tif tok.value == terminator {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tswitch tok.value {\n\t\t\t\tcase \"key\":\n\t\t\t\t\tif err := p.consumeToken(\":\"); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tif err := p.readAny(key, props.mkeyprop); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tif err := p.consumeOptionalSeparator(); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\tcase \"value\":\n\t\t\t\t\tif err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tif err := p.readAny(val, props.mvalprop); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tif err := p.consumeOptionalSeparator(); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tp.back()\n\t\t\t\t\treturn p.errorf(`expected \"key\", \"value\", or %q, found %q`, terminator, tok.value)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdst.SetMapIndex(key, val)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Check that it's not already set if it's not a repeated field.\n\t\tif !props.Repeated && fieldSet[name] {\n\t\t\treturn p.errorf(\"non-repeated field %q was repeated\", name)\n\t\t}\n\n\t\tif err := p.checkForColon(props, dst.Type()); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Parse into the field.\n\t\tfieldSet[name] = true\n\t\tif err := p.readAny(dst, props); err != nil {\n\t\t\tif _, ok := err.(*RequiredNotSetError); !ok {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treqFieldErr = err\n\t\t}\n\t\tif props.Required {\n\t\t\treqCount--\n\t\t}\n\n\t\tif err := p.consumeOptionalSeparator(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif reqCount > 0 {\n\t\treturn p.missingRequiredFieldError(sv)\n\t}\n\treturn reqFieldErr\n}\n\n// consumeExtName consumes extension name or expanded Any type URL and the\n// following ']'. It returns the name or URL consumed.\nfunc (p *textParser) consumeExtName() (string, error) {\n\ttok := p.next()\n\tif tok.err != nil {\n\t\treturn \"\", tok.err\n\t}\n\n\t// If extension name or type url is quoted, it's a single token.\n\tif len(tok.value) > 2 && isQuote(tok.value[0]) && tok.value[len(tok.value)-1] == tok.value[0] {\n\t\tname, err := unquoteC(tok.value[1:len(tok.value)-1], rune(tok.value[0]))\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn name, p.consumeToken(\"]\")\n\t}\n\n\t// Consume everything up to \"]\"\n\tvar parts []string\n\tfor tok.value != \"]\" {\n\t\tparts = append(parts, tok.value)\n\t\ttok = p.next()\n\t\tif tok.err != nil {\n\t\t\treturn \"\", p.errorf(\"unrecognized type_url or extension name: %s\", tok.err)\n\t\t}\n\t}\n\treturn strings.Join(parts, \"\"), nil\n}\n\n// consumeOptionalSeparator consumes an optional semicolon or comma.\n// It is used in readStruct to provide backward compatibility.\nfunc (p *textParser) consumeOptionalSeparator() error {\n\ttok := p.next()\n\tif tok.err != nil {\n\t\treturn tok.err\n\t}\n\tif tok.value != \";\" && tok.value != \",\" {\n\t\tp.back()\n\t}\n\treturn nil\n}\n\nfunc (p *textParser) readAny(v reflect.Value, props *Properties) error {\n\ttok := p.next()\n\tif tok.err != nil {\n\t\treturn tok.err\n\t}\n\tif tok.value == \"\" {\n\t\treturn p.errorf(\"unexpected EOF\")\n\t}\n\n\tswitch fv := v; fv.Kind() {\n\tcase reflect.Slice:\n\t\tat := v.Type()\n\t\tif at.Elem().Kind() == reflect.Uint8 {\n\t\t\t// Special case for []byte\n\t\t\tif tok.value[0] != '\"' && tok.value[0] != '\\'' {\n\t\t\t\t// Deliberately written out here, as the error after\n\t\t\t\t// this switch statement would write \"invalid []byte: ...\",\n\t\t\t\t// which is not as user-friendly.\n\t\t\t\treturn p.errorf(\"invalid string: %v\", tok.value)\n\t\t\t}\n\t\t\tbytes := []byte(tok.unquoted)\n\t\t\tfv.Set(reflect.ValueOf(bytes))\n\t\t\treturn nil\n\t\t}\n\t\t// Repeated field.\n\t\tif tok.value == \"[\" {\n\t\t\t// Repeated field with list notation, like [1,2,3].\n\t\t\tfor {\n\t\t\t\tfv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem()))\n\t\t\t\terr := p.readAny(fv.Index(fv.Len()-1), props)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\ttok := p.next()\n\t\t\t\tif tok.err != nil {\n\t\t\t\t\treturn tok.err\n\t\t\t\t}\n\t\t\t\tif tok.value == \"]\" {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif tok.value != \",\" {\n\t\t\t\t\treturn p.errorf(\"Expected ']' or ',' found %q\", tok.value)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t\t// One value of the repeated field.\n\t\tp.back()\n\t\tfv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem()))\n\t\treturn p.readAny(fv.Index(fv.Len()-1), props)\n\tcase reflect.Bool:\n\t\t// true/1/t/True or false/f/0/False.\n\t\tswitch tok.value {\n\t\tcase \"true\", \"1\", \"t\", \"True\":\n\t\t\tfv.SetBool(true)\n\t\t\treturn nil\n\t\tcase \"false\", \"0\", \"f\", \"False\":\n\t\t\tfv.SetBool(false)\n\t\t\treturn nil\n\t\t}\n\tcase reflect.Float32, reflect.Float64:\n\t\tv := tok.value\n\t\t// Ignore 'f' for compatibility with output generated by C++, but don't\n\t\t// remove 'f' when the value is \"-inf\" or \"inf\".\n\t\tif strings.HasSuffix(v, \"f\") && tok.value != \"-inf\" && tok.value != \"inf\" {\n\t\t\tv = v[:len(v)-1]\n\t\t}\n\t\tif f, err := strconv.ParseFloat(v, fv.Type().Bits()); err == nil {\n\t\t\tfv.SetFloat(f)\n\t\t\treturn nil\n\t\t}\n\tcase reflect.Int32:\n\t\tif x, err := strconv.ParseInt(tok.value, 0, 32); err == nil {\n\t\t\tfv.SetInt(x)\n\t\t\treturn nil\n\t\t}\n\n\t\tif len(props.Enum) == 0 {\n\t\t\tbreak\n\t\t}\n\t\tm, ok := enumValueMaps[props.Enum]\n\t\tif !ok {\n\t\t\tbreak\n\t\t}\n\t\tx, ok := m[tok.value]\n\t\tif !ok {\n\t\t\tbreak\n\t\t}\n\t\tfv.SetInt(int64(x))\n\t\treturn nil\n\tcase reflect.Int64:\n\t\tif x, err := strconv.ParseInt(tok.value, 0, 64); err == nil {\n\t\t\tfv.SetInt(x)\n\t\t\treturn nil\n\t\t}\n\n\tcase reflect.Ptr:\n\t\t// A basic field (indirected through pointer), or a repeated message/group\n\t\tp.back()\n\t\tfv.Set(reflect.New(fv.Type().Elem()))\n\t\treturn p.readAny(fv.Elem(), props)\n\tcase reflect.String:\n\t\tif tok.value[0] == '\"' || tok.value[0] == '\\'' {\n\t\t\tfv.SetString(tok.unquoted)\n\t\t\treturn nil\n\t\t}\n\tcase reflect.Struct:\n\t\tvar terminator string\n\t\tswitch tok.value {\n\t\tcase \"{\":\n\t\t\tterminator = \"}\"\n\t\tcase \"<\":\n\t\t\tterminator = \">\"\n\t\tdefault:\n\t\t\treturn p.errorf(\"expected '{' or '<', found %q\", tok.value)\n\t\t}\n\t\t// TODO: Handle nested messages which implement encoding.TextUnmarshaler.\n\t\treturn p.readStruct(fv, terminator)\n\tcase reflect.Uint32:\n\t\tif x, err := strconv.ParseUint(tok.value, 0, 32); err == nil {\n\t\t\tfv.SetUint(x)\n\t\t\treturn nil\n\t\t}\n\tcase reflect.Uint64:\n\t\tif x, err := strconv.ParseUint(tok.value, 0, 64); err == nil {\n\t\t\tfv.SetUint(x)\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn p.errorf(\"invalid %v: %v\", v.Type(), tok.value)\n}\n\n// UnmarshalText reads a protocol buffer in Text format. UnmarshalText resets pb\n// before starting to unmarshal, so any existing data in pb is always removed.\n// If a required field is not set and no other error occurs,\n// UnmarshalText returns *RequiredNotSetError.\nfunc UnmarshalText(s string, pb Message) error {\n\tif um, ok := pb.(encoding.TextUnmarshaler); ok {\n\t\terr := um.UnmarshalText([]byte(s))\n\t\treturn err\n\t}\n\tpb.Reset()\n\tv := reflect.ValueOf(pb)\n\tif pe := newTextParser(s).readStruct(v.Elem(), \"\"); pe != nil {\n\t\treturn pe\n\t}\n\treturn nil\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/text_parser_test.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2010 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto_test\n\nimport (\n\t\"math\"\n\t\"reflect\"\n\t\"testing\"\n\n\t. \"github.com/golang/protobuf/proto\"\n\tproto3pb \"github.com/golang/protobuf/proto/proto3_proto\"\n\t. \"github.com/golang/protobuf/proto/testdata\"\n)\n\ntype UnmarshalTextTest struct {\n\tin  string\n\terr string // if \"\", no error expected\n\tout *MyMessage\n}\n\nfunc buildExtStructTest(text string) UnmarshalTextTest {\n\tmsg := &MyMessage{\n\t\tCount: Int32(42),\n\t}\n\tSetExtension(msg, E_Ext_More, &Ext{\n\t\tData: String(\"Hello, world!\"),\n\t})\n\treturn UnmarshalTextTest{in: text, out: msg}\n}\n\nfunc buildExtDataTest(text string) UnmarshalTextTest {\n\tmsg := &MyMessage{\n\t\tCount: Int32(42),\n\t}\n\tSetExtension(msg, E_Ext_Text, String(\"Hello, world!\"))\n\tSetExtension(msg, E_Ext_Number, Int32(1729))\n\treturn UnmarshalTextTest{in: text, out: msg}\n}\n\nfunc buildExtRepStringTest(text string) UnmarshalTextTest {\n\tmsg := &MyMessage{\n\t\tCount: Int32(42),\n\t}\n\tif err := SetExtension(msg, E_Greeting, []string{\"bula\", \"hola\"}); err != nil {\n\t\tpanic(err)\n\t}\n\treturn UnmarshalTextTest{in: text, out: msg}\n}\n\nvar unMarshalTextTests = []UnmarshalTextTest{\n\t// Basic\n\t{\n\t\tin: \" count:42\\n  name:\\\"Dave\\\" \",\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tName:  String(\"Dave\"),\n\t\t},\n\t},\n\n\t// Empty quoted string\n\t{\n\t\tin: `count:42 name:\"\"`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tName:  String(\"\"),\n\t\t},\n\t},\n\n\t// Quoted string concatenation with double quotes\n\t{\n\t\tin: `count:42 name: \"My name is \"` + \"\\n\" + `\"elsewhere\"`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tName:  String(\"My name is elsewhere\"),\n\t\t},\n\t},\n\n\t// Quoted string concatenation with single quotes\n\t{\n\t\tin: \"count:42 name: 'My name is '\\n'elsewhere'\",\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tName:  String(\"My name is elsewhere\"),\n\t\t},\n\t},\n\n\t// Quoted string concatenations with mixed quotes\n\t{\n\t\tin: \"count:42 name: 'My name is '\\n\\\"elsewhere\\\"\",\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tName:  String(\"My name is elsewhere\"),\n\t\t},\n\t},\n\t{\n\t\tin: \"count:42 name: \\\"My name is \\\"\\n'elsewhere'\",\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tName:  String(\"My name is elsewhere\"),\n\t\t},\n\t},\n\n\t// Quoted string with escaped apostrophe\n\t{\n\t\tin: `count:42 name: \"HOLIDAY - New Year\\'s Day\"`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tName:  String(\"HOLIDAY - New Year's Day\"),\n\t\t},\n\t},\n\n\t// Quoted string with single quote\n\t{\n\t\tin: `count:42 name: 'Roger \"The Ramster\" Ramjet'`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tName:  String(`Roger \"The Ramster\" Ramjet`),\n\t\t},\n\t},\n\n\t// Quoted string with all the accepted special characters from the C++ test\n\t{\n\t\tin: `count:42 name: ` + \"\\\"\\\\\\\"A string with \\\\' characters \\\\n and \\\\r newlines and \\\\t tabs and \\\\001 slashes \\\\\\\\ and  multiple   spaces\\\"\",\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tName:  String(\"\\\"A string with ' characters \\n and \\r newlines and \\t tabs and \\001 slashes \\\\ and  multiple   spaces\"),\n\t\t},\n\t},\n\n\t// Quoted string with quoted backslash\n\t{\n\t\tin: `count:42 name: \"\\\\'xyz\"`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tName:  String(`\\'xyz`),\n\t\t},\n\t},\n\n\t// Quoted string with UTF-8 bytes.\n\t{\n\t\tin: \"count:42 name: '\\303\\277\\302\\201\\xAB'\",\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tName:  String(\"\\303\\277\\302\\201\\xAB\"),\n\t\t},\n\t},\n\n\t// Bad quoted string\n\t{\n\t\tin:  `inner: < host: \"\\0\" >` + \"\\n\",\n\t\terr: `line 1.15: invalid quoted string \"\\0\": \\0 requires 2 following digits`,\n\t},\n\n\t// Number too large for int64\n\t{\n\t\tin:  \"count: 1 others { key: 123456789012345678901 }\",\n\t\terr: \"line 1.23: invalid int64: 123456789012345678901\",\n\t},\n\n\t// Number too large for int32\n\t{\n\t\tin:  \"count: 1234567890123\",\n\t\terr: \"line 1.7: invalid int32: 1234567890123\",\n\t},\n\n\t// Number in hexadecimal\n\t{\n\t\tin: \"count: 0x2beef\",\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(0x2beef),\n\t\t},\n\t},\n\n\t// Number in octal\n\t{\n\t\tin: \"count: 024601\",\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(024601),\n\t\t},\n\t},\n\n\t// Floating point number with \"f\" suffix\n\t{\n\t\tin: \"count: 4 others:< weight: 17.0f >\",\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(4),\n\t\t\tOthers: []*OtherMessage{\n\t\t\t\t{\n\t\t\t\t\tWeight: Float32(17),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\n\t// Floating point positive infinity\n\t{\n\t\tin: \"count: 4 bigfloat: inf\",\n\t\tout: &MyMessage{\n\t\t\tCount:    Int32(4),\n\t\t\tBigfloat: Float64(math.Inf(1)),\n\t\t},\n\t},\n\n\t// Floating point negative infinity\n\t{\n\t\tin: \"count: 4 bigfloat: -inf\",\n\t\tout: &MyMessage{\n\t\t\tCount:    Int32(4),\n\t\t\tBigfloat: Float64(math.Inf(-1)),\n\t\t},\n\t},\n\n\t// Number too large for float32\n\t{\n\t\tin:  \"others:< weight: 12345678901234567890123456789012345678901234567890 >\",\n\t\terr: \"line 1.17: invalid float32: 12345678901234567890123456789012345678901234567890\",\n\t},\n\n\t// Number posing as a quoted string\n\t{\n\t\tin:  `inner: < host: 12 >` + \"\\n\",\n\t\terr: `line 1.15: invalid string: 12`,\n\t},\n\n\t// Quoted string posing as int32\n\t{\n\t\tin:  `count: \"12\"`,\n\t\terr: `line 1.7: invalid int32: \"12\"`,\n\t},\n\n\t// Quoted string posing a float32\n\t{\n\t\tin:  `others:< weight: \"17.4\" >`,\n\t\terr: `line 1.17: invalid float32: \"17.4\"`,\n\t},\n\n\t// Enum\n\t{\n\t\tin: `count:42 bikeshed: BLUE`,\n\t\tout: &MyMessage{\n\t\t\tCount:    Int32(42),\n\t\t\tBikeshed: MyMessage_BLUE.Enum(),\n\t\t},\n\t},\n\n\t// Repeated field\n\t{\n\t\tin: `count:42 pet: \"horsey\" pet:\"bunny\"`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tPet:   []string{\"horsey\", \"bunny\"},\n\t\t},\n\t},\n\n\t// Repeated field with list notation\n\t{\n\t\tin: `count:42 pet: [\"horsey\", \"bunny\"]`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tPet:   []string{\"horsey\", \"bunny\"},\n\t\t},\n\t},\n\n\t// Repeated message with/without colon and <>/{}\n\t{\n\t\tin: `count:42 others:{} others{} others:<> others:{}`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tOthers: []*OtherMessage{\n\t\t\t\t{},\n\t\t\t\t{},\n\t\t\t\t{},\n\t\t\t\t{},\n\t\t\t},\n\t\t},\n\t},\n\n\t// Missing colon for inner message\n\t{\n\t\tin: `count:42 inner < host: \"cauchy.syd\" >`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tInner: &InnerMessage{\n\t\t\t\tHost: String(\"cauchy.syd\"),\n\t\t\t},\n\t\t},\n\t},\n\n\t// Missing colon for string field\n\t{\n\t\tin:  `name \"Dave\"`,\n\t\terr: `line 1.5: expected ':', found \"\\\"Dave\\\"\"`,\n\t},\n\n\t// Missing colon for int32 field\n\t{\n\t\tin:  `count 42`,\n\t\terr: `line 1.6: expected ':', found \"42\"`,\n\t},\n\n\t// Missing required field\n\t{\n\t\tin:  `name: \"Pawel\"`,\n\t\terr: `proto: required field \"testdata.MyMessage.count\" not set`,\n\t\tout: &MyMessage{\n\t\t\tName: String(\"Pawel\"),\n\t\t},\n\t},\n\n\t// Missing required field in a required submessage\n\t{\n\t\tin:  `count: 42 we_must_go_deeper < leo_finally_won_an_oscar <> >`,\n\t\terr: `proto: required field \"testdata.InnerMessage.host\" not set`,\n\t\tout: &MyMessage{\n\t\t\tCount:          Int32(42),\n\t\t\tWeMustGoDeeper: &RequiredInnerMessage{LeoFinallyWonAnOscar: &InnerMessage{}},\n\t\t},\n\t},\n\n\t// Repeated non-repeated field\n\t{\n\t\tin:  `name: \"Rob\" name: \"Russ\"`,\n\t\terr: `line 1.12: non-repeated field \"name\" was repeated`,\n\t},\n\n\t// Group\n\t{\n\t\tin: `count: 17 SomeGroup { group_field: 12 }`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(17),\n\t\t\tSomegroup: &MyMessage_SomeGroup{\n\t\t\t\tGroupField: Int32(12),\n\t\t\t},\n\t\t},\n\t},\n\n\t// Semicolon between fields\n\t{\n\t\tin: `count:3;name:\"Calvin\"`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(3),\n\t\t\tName:  String(\"Calvin\"),\n\t\t},\n\t},\n\t// Comma between fields\n\t{\n\t\tin: `count:4,name:\"Ezekiel\"`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(4),\n\t\t\tName:  String(\"Ezekiel\"),\n\t\t},\n\t},\n\n\t// Boolean false\n\t{\n\t\tin: `count:42 inner { host: \"example.com\" connected: false }`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tInner: &InnerMessage{\n\t\t\t\tHost:      String(\"example.com\"),\n\t\t\t\tConnected: Bool(false),\n\t\t\t},\n\t\t},\n\t},\n\t// Boolean true\n\t{\n\t\tin: `count:42 inner { host: \"example.com\" connected: true }`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tInner: &InnerMessage{\n\t\t\t\tHost:      String(\"example.com\"),\n\t\t\t\tConnected: Bool(true),\n\t\t\t},\n\t\t},\n\t},\n\t// Boolean 0\n\t{\n\t\tin: `count:42 inner { host: \"example.com\" connected: 0 }`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tInner: &InnerMessage{\n\t\t\t\tHost:      String(\"example.com\"),\n\t\t\t\tConnected: Bool(false),\n\t\t\t},\n\t\t},\n\t},\n\t// Boolean 1\n\t{\n\t\tin: `count:42 inner { host: \"example.com\" connected: 1 }`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tInner: &InnerMessage{\n\t\t\t\tHost:      String(\"example.com\"),\n\t\t\t\tConnected: Bool(true),\n\t\t\t},\n\t\t},\n\t},\n\t// Boolean f\n\t{\n\t\tin: `count:42 inner { host: \"example.com\" connected: f }`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tInner: &InnerMessage{\n\t\t\t\tHost:      String(\"example.com\"),\n\t\t\t\tConnected: Bool(false),\n\t\t\t},\n\t\t},\n\t},\n\t// Boolean t\n\t{\n\t\tin: `count:42 inner { host: \"example.com\" connected: t }`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tInner: &InnerMessage{\n\t\t\t\tHost:      String(\"example.com\"),\n\t\t\t\tConnected: Bool(true),\n\t\t\t},\n\t\t},\n\t},\n\t// Boolean False\n\t{\n\t\tin: `count:42 inner { host: \"example.com\" connected: False }`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tInner: &InnerMessage{\n\t\t\t\tHost:      String(\"example.com\"),\n\t\t\t\tConnected: Bool(false),\n\t\t\t},\n\t\t},\n\t},\n\t// Boolean True\n\t{\n\t\tin: `count:42 inner { host: \"example.com\" connected: True }`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tInner: &InnerMessage{\n\t\t\t\tHost:      String(\"example.com\"),\n\t\t\t\tConnected: Bool(true),\n\t\t\t},\n\t\t},\n\t},\n\n\t// Extension\n\tbuildExtStructTest(`count: 42 [testdata.Ext.more]:<data:\"Hello, world!\" >`),\n\tbuildExtStructTest(`count: 42 [testdata.Ext.more] {data:\"Hello, world!\"}`),\n\tbuildExtDataTest(`count: 42 [testdata.Ext.text]:\"Hello, world!\" [testdata.Ext.number]:1729`),\n\tbuildExtRepStringTest(`count: 42 [testdata.greeting]:\"bula\" [testdata.greeting]:\"hola\"`),\n\n\t// Big all-in-one\n\t{\n\t\tin: \"count:42  # Meaning\\n\" +\n\t\t\t`name:\"Dave\" ` +\n\t\t\t`quote:\"\\\"I didn't want to go.\\\"\" ` +\n\t\t\t`pet:\"bunny\" ` +\n\t\t\t`pet:\"kitty\" ` +\n\t\t\t`pet:\"horsey\" ` +\n\t\t\t`inner:<` +\n\t\t\t`  host:\"footrest.syd\" ` +\n\t\t\t`  port:7001 ` +\n\t\t\t`  connected:true ` +\n\t\t\t`> ` +\n\t\t\t`others:<` +\n\t\t\t`  key:3735928559 ` +\n\t\t\t`  value:\"\\x01A\\a\\f\" ` +\n\t\t\t`> ` +\n\t\t\t`others:<` +\n\t\t\t\"  weight:58.9  # Atomic weight of Co\\n\" +\n\t\t\t`  inner:<` +\n\t\t\t`    host:\"lesha.mtv\" ` +\n\t\t\t`    port:8002 ` +\n\t\t\t`  >` +\n\t\t\t`>`,\n\t\tout: &MyMessage{\n\t\t\tCount: Int32(42),\n\t\t\tName:  String(\"Dave\"),\n\t\t\tQuote: String(`\"I didn't want to go.\"`),\n\t\t\tPet:   []string{\"bunny\", \"kitty\", \"horsey\"},\n\t\t\tInner: &InnerMessage{\n\t\t\t\tHost:      String(\"footrest.syd\"),\n\t\t\t\tPort:      Int32(7001),\n\t\t\t\tConnected: Bool(true),\n\t\t\t},\n\t\t\tOthers: []*OtherMessage{\n\t\t\t\t{\n\t\t\t\t\tKey:   Int64(3735928559),\n\t\t\t\t\tValue: []byte{0x1, 'A', '\\a', '\\f'},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tWeight: Float32(58.9),\n\t\t\t\t\tInner: &InnerMessage{\n\t\t\t\t\t\tHost: String(\"lesha.mtv\"),\n\t\t\t\t\t\tPort: Int32(8002),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n}\n\nfunc TestUnmarshalText(t *testing.T) {\n\tfor i, test := range unMarshalTextTests {\n\t\tpb := new(MyMessage)\n\t\terr := UnmarshalText(test.in, pb)\n\t\tif test.err == \"\" {\n\t\t\t// We don't expect failure.\n\t\t\tif err != nil {\n\t\t\t\tt.Errorf(\"Test %d: Unexpected error: %v\", i, err)\n\t\t\t} else if !reflect.DeepEqual(pb, test.out) {\n\t\t\t\tt.Errorf(\"Test %d: Incorrect populated \\nHave: %v\\nWant: %v\",\n\t\t\t\t\ti, pb, test.out)\n\t\t\t}\n\t\t} else {\n\t\t\t// We do expect failure.\n\t\t\tif err == nil {\n\t\t\t\tt.Errorf(\"Test %d: Didn't get expected error: %v\", i, test.err)\n\t\t\t} else if err.Error() != test.err {\n\t\t\t\tt.Errorf(\"Test %d: Incorrect error.\\nHave: %v\\nWant: %v\",\n\t\t\t\t\ti, err.Error(), test.err)\n\t\t\t} else if _, ok := err.(*RequiredNotSetError); ok && test.out != nil && !reflect.DeepEqual(pb, test.out) {\n\t\t\t\tt.Errorf(\"Test %d: Incorrect populated \\nHave: %v\\nWant: %v\",\n\t\t\t\t\ti, pb, test.out)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc TestUnmarshalTextCustomMessage(t *testing.T) {\n\tmsg := &textMessage{}\n\tif err := UnmarshalText(\"custom\", msg); err != nil {\n\t\tt.Errorf(\"Unexpected error from custom unmarshal: %v\", err)\n\t}\n\tif UnmarshalText(\"not custom\", msg) == nil {\n\t\tt.Errorf(\"Didn't get expected error from custom unmarshal\")\n\t}\n}\n\n// Regression test; this caused a panic.\nfunc TestRepeatedEnum(t *testing.T) {\n\tpb := new(RepeatedEnum)\n\tif err := UnmarshalText(\"color: RED\", pb); err != nil {\n\t\tt.Fatal(err)\n\t}\n\texp := &RepeatedEnum{\n\t\tColor: []RepeatedEnum_Color{RepeatedEnum_RED},\n\t}\n\tif !Equal(pb, exp) {\n\t\tt.Errorf(\"Incorrect populated \\nHave: %v\\nWant: %v\", pb, exp)\n\t}\n}\n\nfunc TestProto3TextParsing(t *testing.T) {\n\tm := new(proto3pb.Message)\n\tconst in = `name: \"Wallace\" true_scotsman: true`\n\twant := &proto3pb.Message{\n\t\tName:         \"Wallace\",\n\t\tTrueScotsman: true,\n\t}\n\tif err := UnmarshalText(in, m); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif !Equal(m, want) {\n\t\tt.Errorf(\"\\n got %v\\nwant %v\", m, want)\n\t}\n}\n\nfunc TestMapParsing(t *testing.T) {\n\tm := new(MessageWithMap)\n\tconst in = `name_mapping:<key:1234 value:\"Feist\"> name_mapping:<key:1 value:\"Beatles\">` +\n\t\t`msg_mapping:<key:-4, value:<f: 2.0>,>` + // separating commas are okay\n\t\t`msg_mapping<key:-2 value<f: 4.0>>` + // no colon after \"value\"\n\t\t`msg_mapping:<value:<f: 5.0>>` + // omitted key\n\t\t`msg_mapping:<key:1>` + // omitted value\n\t\t`byte_mapping:<key:true value:\"so be it\">` +\n\t\t`byte_mapping:<>` // omitted key and value\n\twant := &MessageWithMap{\n\t\tNameMapping: map[int32]string{\n\t\t\t1:    \"Beatles\",\n\t\t\t1234: \"Feist\",\n\t\t},\n\t\tMsgMapping: map[int64]*FloatingPoint{\n\t\t\t-4: {F: Float64(2.0)},\n\t\t\t-2: {F: Float64(4.0)},\n\t\t\t0:  {F: Float64(5.0)},\n\t\t\t1:  nil,\n\t\t},\n\t\tByteMapping: map[bool][]byte{\n\t\t\tfalse: nil,\n\t\t\ttrue:  []byte(\"so be it\"),\n\t\t},\n\t}\n\tif err := UnmarshalText(in, m); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif !Equal(m, want) {\n\t\tt.Errorf(\"\\n got %v\\nwant %v\", m, want)\n\t}\n}\n\nfunc TestOneofParsing(t *testing.T) {\n\tconst in = `name:\"Shrek\"`\n\tm := new(Communique)\n\twant := &Communique{Union: &Communique_Name{\"Shrek\"}}\n\tif err := UnmarshalText(in, m); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif !Equal(m, want) {\n\t\tt.Errorf(\"\\n got %v\\nwant %v\", m, want)\n\t}\n\n\tconst inOverwrite = `name:\"Shrek\" number:42`\n\tm = new(Communique)\n\ttestErr := \"line 1.13: field 'number' would overwrite already parsed oneof 'Union'\"\n\tif err := UnmarshalText(inOverwrite, m); err == nil {\n\t\tt.Errorf(\"TestOneofParsing: Didn't get expected error: %v\", testErr)\n\t} else if err.Error() != testErr {\n\t\tt.Errorf(\"TestOneofParsing: Incorrect error.\\nHave: %v\\nWant: %v\",\n\t\t\terr.Error(), testErr)\n\t}\n\n}\n\nvar benchInput string\n\nfunc init() {\n\tbenchInput = \"count: 4\\n\"\n\tfor i := 0; i < 1000; i++ {\n\t\tbenchInput += \"pet: \\\"fido\\\"\\n\"\n\t}\n\n\t// Check it is valid input.\n\tpb := new(MyMessage)\n\terr := UnmarshalText(benchInput, pb)\n\tif err != nil {\n\t\tpanic(\"Bad benchmark input: \" + err.Error())\n\t}\n}\n\nfunc BenchmarkUnmarshalText(b *testing.B) {\n\tpb := new(MyMessage)\n\tfor i := 0; i < b.N; i++ {\n\t\tUnmarshalText(benchInput, pb)\n\t}\n\tb.SetBytes(int64(len(benchInput)))\n}\n"
  },
  {
    "path": "vendor/github.com/golang/protobuf/proto/text_test.go",
    "content": "// Go support for Protocol Buffers - Google's data interchange format\n//\n// Copyright 2010 The Go Authors.  All rights reserved.\n// https://github.com/golang/protobuf\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\npackage proto_test\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"io/ioutil\"\n\t\"math\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/golang/protobuf/proto\"\n\n\tproto3pb \"github.com/golang/protobuf/proto/proto3_proto\"\n\tpb \"github.com/golang/protobuf/proto/testdata\"\n)\n\n// textMessage implements the methods that allow it to marshal and unmarshal\n// itself as text.\ntype textMessage struct {\n}\n\nfunc (*textMessage) MarshalText() ([]byte, error) {\n\treturn []byte(\"custom\"), nil\n}\n\nfunc (*textMessage) UnmarshalText(bytes []byte) error {\n\tif string(bytes) != \"custom\" {\n\t\treturn errors.New(\"expected 'custom'\")\n\t}\n\treturn nil\n}\n\nfunc (*textMessage) Reset()         {}\nfunc (*textMessage) String() string { return \"\" }\nfunc (*textMessage) ProtoMessage()  {}\n\nfunc newTestMessage() *pb.MyMessage {\n\tmsg := &pb.MyMessage{\n\t\tCount: proto.Int32(42),\n\t\tName:  proto.String(\"Dave\"),\n\t\tQuote: proto.String(`\"I didn't want to go.\"`),\n\t\tPet:   []string{\"bunny\", \"kitty\", \"horsey\"},\n\t\tInner: &pb.InnerMessage{\n\t\t\tHost:      proto.String(\"footrest.syd\"),\n\t\t\tPort:      proto.Int32(7001),\n\t\t\tConnected: proto.Bool(true),\n\t\t},\n\t\tOthers: []*pb.OtherMessage{\n\t\t\t{\n\t\t\t\tKey:   proto.Int64(0xdeadbeef),\n\t\t\t\tValue: []byte{1, 65, 7, 12},\n\t\t\t},\n\t\t\t{\n\t\t\t\tWeight: proto.Float32(6.022),\n\t\t\t\tInner: &pb.InnerMessage{\n\t\t\t\t\tHost: proto.String(\"lesha.mtv\"),\n\t\t\t\t\tPort: proto.Int32(8002),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tBikeshed: pb.MyMessage_BLUE.Enum(),\n\t\tSomegroup: &pb.MyMessage_SomeGroup{\n\t\t\tGroupField: proto.Int32(8),\n\t\t},\n\t\t// One normally wouldn't do this.\n\t\t// This is an undeclared tag 13, as a varint (wire type 0) with value 4.\n\t\tXXX_unrecognized: []byte{13<<3 | 0, 4},\n\t}\n\text := &pb.Ext{\n\t\tData: proto.String(\"Big gobs for big rats\"),\n\t}\n\tif err := proto.SetExtension(msg, pb.E_Ext_More, ext); err != nil {\n\t\tpanic(err)\n\t}\n\tgreetings := []string{\"adg\", \"easy\", \"cow\"}\n\tif err := proto.SetExtension(msg, pb.E_Greeting, greetings); err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Add an unknown extension. We marshal a pb.Ext, and fake the ID.\n\tb, err := proto.Marshal(&pb.Ext{Data: proto.String(\"3G skiing\")})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tb = append(proto.EncodeVarint(201<<3|proto.WireBytes), b...)\n\tproto.SetRawExtension(msg, 201, b)\n\n\t// Extensions can be plain fields, too, so let's test that.\n\tb = append(proto.EncodeVarint(202<<3|proto.WireVarint), 19)\n\tproto.SetRawExtension(msg, 202, b)\n\n\treturn msg\n}\n\nconst text = `count: 42\nname: \"Dave\"\nquote: \"\\\"I didn't want to go.\\\"\"\npet: \"bunny\"\npet: \"kitty\"\npet: \"horsey\"\ninner: <\n  host: \"footrest.syd\"\n  port: 7001\n  connected: true\n>\nothers: <\n  key: 3735928559\n  value: \"\\001A\\007\\014\"\n>\nothers: <\n  weight: 6.022\n  inner: <\n    host: \"lesha.mtv\"\n    port: 8002\n  >\n>\nbikeshed: BLUE\nSomeGroup {\n  group_field: 8\n}\n/* 2 unknown bytes */\n13: 4\n[testdata.Ext.more]: <\n  data: \"Big gobs for big rats\"\n>\n[testdata.greeting]: \"adg\"\n[testdata.greeting]: \"easy\"\n[testdata.greeting]: \"cow\"\n/* 13 unknown bytes */\n201: \"\\t3G skiing\"\n/* 3 unknown bytes */\n202: 19\n`\n\nfunc TestMarshalText(t *testing.T) {\n\tbuf := new(bytes.Buffer)\n\tif err := proto.MarshalText(buf, newTestMessage()); err != nil {\n\t\tt.Fatalf(\"proto.MarshalText: %v\", err)\n\t}\n\ts := buf.String()\n\tif s != text {\n\t\tt.Errorf(\"Got:\\n===\\n%v===\\nExpected:\\n===\\n%v===\\n\", s, text)\n\t}\n}\n\nfunc TestMarshalTextCustomMessage(t *testing.T) {\n\tbuf := new(bytes.Buffer)\n\tif err := proto.MarshalText(buf, &textMessage{}); err != nil {\n\t\tt.Fatalf(\"proto.MarshalText: %v\", err)\n\t}\n\ts := buf.String()\n\tif s != \"custom\" {\n\t\tt.Errorf(\"Got %q, expected %q\", s, \"custom\")\n\t}\n}\nfunc TestMarshalTextNil(t *testing.T) {\n\twant := \"<nil>\"\n\ttests := []proto.Message{nil, (*pb.MyMessage)(nil)}\n\tfor i, test := range tests {\n\t\tbuf := new(bytes.Buffer)\n\t\tif err := proto.MarshalText(buf, test); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tif got := buf.String(); got != want {\n\t\t\tt.Errorf(\"%d: got %q want %q\", i, got, want)\n\t\t}\n\t}\n}\n\nfunc TestMarshalTextUnknownEnum(t *testing.T) {\n\t// The Color enum only specifies values 0-2.\n\tm := &pb.MyMessage{Bikeshed: pb.MyMessage_Color(3).Enum()}\n\tgot := m.String()\n\tconst want = `bikeshed:3 `\n\tif got != want {\n\t\tt.Errorf(\"\\n got %q\\nwant %q\", got, want)\n\t}\n}\n\nfunc TestTextOneof(t *testing.T) {\n\ttests := []struct {\n\t\tm    proto.Message\n\t\twant string\n\t}{\n\t\t// zero message\n\t\t{&pb.Communique{}, ``},\n\t\t// scalar field\n\t\t{&pb.Communique{Union: &pb.Communique_Number{4}}, `number:4`},\n\t\t// message field\n\t\t{&pb.Communique{Union: &pb.Communique_Msg{\n\t\t\t&pb.Strings{StringField: proto.String(\"why hello!\")},\n\t\t}}, `msg:<string_field:\"why hello!\" >`},\n\t\t// bad oneof (should not panic)\n\t\t{&pb.Communique{Union: &pb.Communique_Msg{nil}}, `msg:/* nil */`},\n\t}\n\tfor _, test := range tests {\n\t\tgot := strings.TrimSpace(test.m.String())\n\t\tif got != test.want {\n\t\t\tt.Errorf(\"\\n got %s\\nwant %s\", got, test.want)\n\t\t}\n\t}\n}\n\nfunc BenchmarkMarshalTextBuffered(b *testing.B) {\n\tbuf := new(bytes.Buffer)\n\tm := newTestMessage()\n\tfor i := 0; i < b.N; i++ {\n\t\tbuf.Reset()\n\t\tproto.MarshalText(buf, m)\n\t}\n}\n\nfunc BenchmarkMarshalTextUnbuffered(b *testing.B) {\n\tw := ioutil.Discard\n\tm := newTestMessage()\n\tfor i := 0; i < b.N; i++ {\n\t\tproto.MarshalText(w, m)\n\t}\n}\n\nfunc compact(src string) string {\n\t// s/[ \\n]+/ /g; s/ $//;\n\tdst := make([]byte, len(src))\n\tspace, comment := false, false\n\tj := 0\n\tfor i := 0; i < len(src); i++ {\n\t\tif strings.HasPrefix(src[i:], \"/*\") {\n\t\t\tcomment = true\n\t\t\ti++\n\t\t\tcontinue\n\t\t}\n\t\tif comment && strings.HasPrefix(src[i:], \"*/\") {\n\t\t\tcomment = false\n\t\t\ti++\n\t\t\tcontinue\n\t\t}\n\t\tif comment {\n\t\t\tcontinue\n\t\t}\n\t\tc := src[i]\n\t\tif c == ' ' || c == '\\n' {\n\t\t\tspace = true\n\t\t\tcontinue\n\t\t}\n\t\tif j > 0 && (dst[j-1] == ':' || dst[j-1] == '<' || dst[j-1] == '{') {\n\t\t\tspace = false\n\t\t}\n\t\tif c == '{' {\n\t\t\tspace = false\n\t\t}\n\t\tif space {\n\t\t\tdst[j] = ' '\n\t\t\tj++\n\t\t\tspace = false\n\t\t}\n\t\tdst[j] = c\n\t\tj++\n\t}\n\tif space {\n\t\tdst[j] = ' '\n\t\tj++\n\t}\n\treturn string(dst[0:j])\n}\n\nvar compactText = compact(text)\n\nfunc TestCompactText(t *testing.T) {\n\ts := proto.CompactTextString(newTestMessage())\n\tif s != compactText {\n\t\tt.Errorf(\"Got:\\n===\\n%v===\\nExpected:\\n===\\n%v\\n===\\n\", s, compactText)\n\t}\n}\n\nfunc TestStringEscaping(t *testing.T) {\n\ttestCases := []struct {\n\t\tin  *pb.Strings\n\t\tout string\n\t}{\n\t\t{\n\t\t\t// Test data from C++ test (TextFormatTest.StringEscape).\n\t\t\t// Single divergence: we don't escape apostrophes.\n\t\t\t&pb.Strings{StringField: proto.String(\"\\\"A string with ' characters \\n and \\r newlines and \\t tabs and \\001 slashes \\\\ and  multiple   spaces\")},\n\t\t\t\"string_field: \\\"\\\\\\\"A string with ' characters \\\\n and \\\\r newlines and \\\\t tabs and \\\\001 slashes \\\\\\\\ and  multiple   spaces\\\"\\n\",\n\t\t},\n\t\t{\n\t\t\t// Test data from the same C++ test.\n\t\t\t&pb.Strings{StringField: proto.String(\"\\350\\260\\267\\346\\255\\214\")},\n\t\t\t\"string_field: \\\"\\\\350\\\\260\\\\267\\\\346\\\\255\\\\214\\\"\\n\",\n\t\t},\n\t\t{\n\t\t\t// Some UTF-8.\n\t\t\t&pb.Strings{StringField: proto.String(\"\\x00\\x01\\xff\\x81\")},\n\t\t\t`string_field: \"\\000\\001\\377\\201\"` + \"\\n\",\n\t\t},\n\t}\n\n\tfor i, tc := range testCases {\n\t\tvar buf bytes.Buffer\n\t\tif err := proto.MarshalText(&buf, tc.in); err != nil {\n\t\t\tt.Errorf(\"proto.MarsalText: %v\", err)\n\t\t\tcontinue\n\t\t}\n\t\ts := buf.String()\n\t\tif s != tc.out {\n\t\t\tt.Errorf(\"#%d: Got:\\n%s\\nExpected:\\n%s\\n\", i, s, tc.out)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Check round-trip.\n\t\tpb := new(pb.Strings)\n\t\tif err := proto.UnmarshalText(s, pb); err != nil {\n\t\t\tt.Errorf(\"#%d: UnmarshalText: %v\", i, err)\n\t\t\tcontinue\n\t\t}\n\t\tif !proto.Equal(pb, tc.in) {\n\t\t\tt.Errorf(\"#%d: Round-trip failed:\\nstart: %v\\n  end: %v\", i, tc.in, pb)\n\t\t}\n\t}\n}\n\n// A limitedWriter accepts some output before it fails.\n// This is a proxy for something like a nearly-full or imminently-failing disk,\n// or a network connection that is about to die.\ntype limitedWriter struct {\n\tb     bytes.Buffer\n\tlimit int\n}\n\nvar outOfSpace = errors.New(\"proto: insufficient space\")\n\nfunc (w *limitedWriter) Write(p []byte) (n int, err error) {\n\tvar avail = w.limit - w.b.Len()\n\tif avail <= 0 {\n\t\treturn 0, outOfSpace\n\t}\n\tif len(p) <= avail {\n\t\treturn w.b.Write(p)\n\t}\n\tn, _ = w.b.Write(p[:avail])\n\treturn n, outOfSpace\n}\n\nfunc TestMarshalTextFailing(t *testing.T) {\n\t// Try lots of different sizes to exercise more error code-paths.\n\tfor lim := 0; lim < len(text); lim++ {\n\t\tbuf := new(limitedWriter)\n\t\tbuf.limit = lim\n\t\terr := proto.MarshalText(buf, newTestMessage())\n\t\t// We expect a certain error, but also some partial results in the buffer.\n\t\tif err != outOfSpace {\n\t\t\tt.Errorf(\"Got:\\n===\\n%v===\\nExpected:\\n===\\n%v===\\n\", err, outOfSpace)\n\t\t}\n\t\ts := buf.b.String()\n\t\tx := text[:buf.limit]\n\t\tif s != x {\n\t\t\tt.Errorf(\"Got:\\n===\\n%v===\\nExpected:\\n===\\n%v===\\n\", s, x)\n\t\t}\n\t}\n}\n\nfunc TestFloats(t *testing.T) {\n\ttests := []struct {\n\t\tf    float64\n\t\twant string\n\t}{\n\t\t{0, \"0\"},\n\t\t{4.7, \"4.7\"},\n\t\t{math.Inf(1), \"inf\"},\n\t\t{math.Inf(-1), \"-inf\"},\n\t\t{math.NaN(), \"nan\"},\n\t}\n\tfor _, test := range tests {\n\t\tmsg := &pb.FloatingPoint{F: &test.f}\n\t\tgot := strings.TrimSpace(msg.String())\n\t\twant := `f:` + test.want\n\t\tif got != want {\n\t\t\tt.Errorf(\"f=%f: got %q, want %q\", test.f, got, want)\n\t\t}\n\t}\n}\n\nfunc TestRepeatedNilText(t *testing.T) {\n\tm := &pb.MessageList{\n\t\tMessage: []*pb.MessageList_Message{\n\t\t\tnil,\n\t\t\t&pb.MessageList_Message{\n\t\t\t\tName: proto.String(\"Horse\"),\n\t\t\t},\n\t\t\tnil,\n\t\t},\n\t}\n\twant := `Message <nil>\nMessage {\n  name: \"Horse\"\n}\nMessage <nil>\n`\n\tif s := proto.MarshalTextString(m); s != want {\n\t\tt.Errorf(\" got: %s\\nwant: %s\", s, want)\n\t}\n}\n\nfunc TestProto3Text(t *testing.T) {\n\ttests := []struct {\n\t\tm    proto.Message\n\t\twant string\n\t}{\n\t\t// zero message\n\t\t{&proto3pb.Message{}, ``},\n\t\t// zero message except for an empty byte slice\n\t\t{&proto3pb.Message{Data: []byte{}}, ``},\n\t\t// trivial case\n\t\t{&proto3pb.Message{Name: \"Rob\", HeightInCm: 175}, `name:\"Rob\" height_in_cm:175`},\n\t\t// empty map\n\t\t{&pb.MessageWithMap{}, ``},\n\t\t// non-empty map; map format is the same as a repeated struct,\n\t\t// and they are sorted by key (numerically for numeric keys).\n\t\t{\n\t\t\t&pb.MessageWithMap{NameMapping: map[int32]string{\n\t\t\t\t-1:      \"Negatory\",\n\t\t\t\t7:       \"Lucky\",\n\t\t\t\t1234:    \"Feist\",\n\t\t\t\t6345789: \"Otis\",\n\t\t\t}},\n\t\t\t`name_mapping:<key:-1 value:\"Negatory\" > ` +\n\t\t\t\t`name_mapping:<key:7 value:\"Lucky\" > ` +\n\t\t\t\t`name_mapping:<key:1234 value:\"Feist\" > ` +\n\t\t\t\t`name_mapping:<key:6345789 value:\"Otis\" >`,\n\t\t},\n\t\t// map with nil value; not well-defined, but we shouldn't crash\n\t\t{\n\t\t\t&pb.MessageWithMap{MsgMapping: map[int64]*pb.FloatingPoint{7: nil}},\n\t\t\t`msg_mapping:<key:7 >`,\n\t\t},\n\t}\n\tfor _, test := range tests {\n\t\tgot := strings.TrimSpace(test.m.String())\n\t\tif got != test.want {\n\t\t\tt.Errorf(\"\\n got %s\\nwant %s\", got, test.want)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/inconshreveable/mousetrap/LICENSE",
    "content": "Copyright 2014 Alan Shreve\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n"
  },
  {
    "path": "vendor/github.com/inconshreveable/mousetrap/README.md",
    "content": "# mousetrap\n\nmousetrap is a tiny library that answers a single question.\n\nOn a Windows machine, was the process invoked by someone double clicking on\nthe executable file while browsing in explorer?\n\n### Motivation\n\nWindows developers unfamiliar with command line tools will often \"double-click\"\nthe executable for a tool. Because most CLI tools print the help and then exit\nwhen invoked without arguments, this is often very frustrating for those users.\n\nmousetrap provides a way to detect these invocations so that you can provide\nmore helpful behavior and instructions on how to run the CLI tool. To see what\nthis looks like, both from an organizational and a technical perspective, see\nhttps://inconshreveable.com/09-09-2014/sweat-the-small-stuff/\n\n### The interface\n\nThe library exposes a single interface:\n\n    func StartedByExplorer() (bool)\n"
  },
  {
    "path": "vendor/github.com/inconshreveable/mousetrap/trap_others.go",
    "content": "// +build !windows\n\npackage mousetrap\n\n// StartedByExplorer returns true if the program was invoked by the user\n// double-clicking on the executable from explorer.exe\n//\n// It is conservative and returns false if any of the internal calls fail.\n// It does not guarantee that the program was run from a terminal. It only can tell you\n// whether it was launched from explorer.exe\n//\n// On non-Windows platforms, it always returns false.\nfunc StartedByExplorer() bool {\n\treturn false\n}\n"
  },
  {
    "path": "vendor/github.com/inconshreveable/mousetrap/trap_windows.go",
    "content": "// +build windows\n// +build !go1.4\n\npackage mousetrap\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"syscall\"\n\t\"unsafe\"\n)\n\nconst (\n\t// defined by the Win32 API\n\tth32cs_snapprocess uintptr = 0x2\n)\n\nvar (\n\tkernel                   = syscall.MustLoadDLL(\"kernel32.dll\")\n\tCreateToolhelp32Snapshot = kernel.MustFindProc(\"CreateToolhelp32Snapshot\")\n\tProcess32First           = kernel.MustFindProc(\"Process32FirstW\")\n\tProcess32Next            = kernel.MustFindProc(\"Process32NextW\")\n)\n\n// ProcessEntry32 structure defined by the Win32 API\ntype processEntry32 struct {\n\tdwSize              uint32\n\tcntUsage            uint32\n\tth32ProcessID       uint32\n\tth32DefaultHeapID   int\n\tth32ModuleID        uint32\n\tcntThreads          uint32\n\tth32ParentProcessID uint32\n\tpcPriClassBase      int32\n\tdwFlags             uint32\n\tszExeFile           [syscall.MAX_PATH]uint16\n}\n\nfunc getProcessEntry(pid int) (pe *processEntry32, err error) {\n\tsnapshot, _, e1 := CreateToolhelp32Snapshot.Call(th32cs_snapprocess, uintptr(0))\n\tif snapshot == uintptr(syscall.InvalidHandle) {\n\t\terr = fmt.Errorf(\"CreateToolhelp32Snapshot: %v\", e1)\n\t\treturn\n\t}\n\tdefer syscall.CloseHandle(syscall.Handle(snapshot))\n\n\tvar processEntry processEntry32\n\tprocessEntry.dwSize = uint32(unsafe.Sizeof(processEntry))\n\tok, _, e1 := Process32First.Call(snapshot, uintptr(unsafe.Pointer(&processEntry)))\n\tif ok == 0 {\n\t\terr = fmt.Errorf(\"Process32First: %v\", e1)\n\t\treturn\n\t}\n\n\tfor {\n\t\tif processEntry.th32ProcessID == uint32(pid) {\n\t\t\tpe = &processEntry\n\t\t\treturn\n\t\t}\n\n\t\tok, _, e1 = Process32Next.Call(snapshot, uintptr(unsafe.Pointer(&processEntry)))\n\t\tif ok == 0 {\n\t\t\terr = fmt.Errorf(\"Process32Next: %v\", e1)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc getppid() (pid int, err error) {\n\tpe, err := getProcessEntry(os.Getpid())\n\tif err != nil {\n\t\treturn\n\t}\n\n\tpid = int(pe.th32ParentProcessID)\n\treturn\n}\n\n// StartedByExplorer returns true if the program was invoked by the user double-clicking\n// on the executable from explorer.exe\n//\n// It is conservative and returns false if any of the internal calls fail.\n// It does not guarantee that the program was run from a terminal. It only can tell you\n// whether it was launched from explorer.exe\nfunc StartedByExplorer() bool {\n\tppid, err := getppid()\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tpe, err := getProcessEntry(ppid)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tname := syscall.UTF16ToString(pe.szExeFile[:])\n\treturn name == \"explorer.exe\"\n}\n"
  },
  {
    "path": "vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go",
    "content": "// +build windows\n// +build go1.4\n\npackage mousetrap\n\nimport (\n\t\"os\"\n\t\"syscall\"\n\t\"unsafe\"\n)\n\nfunc getProcessEntry(pid int) (*syscall.ProcessEntry32, error) {\n\tsnapshot, err := syscall.CreateToolhelp32Snapshot(syscall.TH32CS_SNAPPROCESS, 0)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer syscall.CloseHandle(snapshot)\n\tvar procEntry syscall.ProcessEntry32\n\tprocEntry.Size = uint32(unsafe.Sizeof(procEntry))\n\tif err = syscall.Process32First(snapshot, &procEntry); err != nil {\n\t\treturn nil, err\n\t}\n\tfor {\n\t\tif procEntry.ProcessID == uint32(pid) {\n\t\t\treturn &procEntry, nil\n\t\t}\n\t\terr = syscall.Process32Next(snapshot, &procEntry)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n}\n\n// StartedByExplorer returns true if the program was invoked by the user double-clicking\n// on the executable from explorer.exe\n//\n// It is conservative and returns false if any of the internal calls fail.\n// It does not guarantee that the program was run from a terminal. It only can tell you\n// whether it was launched from explorer.exe\nfunc StartedByExplorer() bool {\n\tpe, err := getProcessEntry(os.Getppid())\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn \"explorer.exe\" == syscall.UTF16ToString(pe.ExeFile[:])\n}\n"
  },
  {
    "path": "vendor/github.com/maruel/panicparse/.travis.yml",
    "content": "# Copyright 2014 Marc-Antoine Ruel. All rights reserved.\n# Use of this source code is governed under the Apache License, Version 2.0\n# that can be found in the LICENSE file.\n\nsudo: false\nlanguage: go\n\ngo:\n- 1.8.x\n- 1.x\n\nbefore_install:\n- go get github.com/maruel/pre-commit-go/cmd/pcg\n\nscript:\n- pcg\n"
  },
  {
    "path": "vendor/github.com/maruel/panicparse/Gopkg.toml",
    "content": "\n# Gopkg.toml example\n#\n# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md\n# for detailed Gopkg.toml documentation.\n#\n# required = [\"github.com/user/thing/cmd/thing\"]\n# ignored = [\"github.com/user/project/pkgX\", \"bitbucket.org/user/project/pkgA/pkgY\"]\n#\n# [[constraint]]\n#   name = \"github.com/user/project\"\n#   version = \"1.0.0\"\n#\n# [[constraint]]\n#   name = \"github.com/user/project2\"\n#   branch = \"dev\"\n#   source = \"github.com/myfork/project2\"\n#\n# [[override]]\n#  name = \"github.com/x/y\"\n#  version = \"2.4.0\"\n\n\n[[constraint]]\n  name = \"github.com/maruel/ut\"\n  version = \"1.0.0\"\n\n[[constraint]]\n  name = \"github.com/mattn/go-colorable\"\n  version = \"0.0.9\"\n\n[[constraint]]\n  name = \"github.com/mattn/go-isatty\"\n  version = \"0.0.2\"\n\n[[constraint]]\n  branch = \"master\"\n  name = \"github.com/mgutz/ansi\"\n"
  },
  {
    "path": "vendor/github.com/maruel/panicparse/LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright 2015 Marc-Antoine Ruel\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "vendor/github.com/maruel/panicparse/README.md",
    "content": "panicparse\n==========\n\nParses panic stack traces, densifies and deduplicates goroutines with similar\nstack traces. Helps debugging crashes and deadlocks in heavily parallelized\nprocess.\n\n[![Build Status](https://travis-ci.org/maruel/panicparse.svg?branch=master)](https://travis-ci.org/maruel/panicparse)\n\npanicparse helps make sense of Go crash dumps:\n\n![Screencast](https://raw.githubusercontent.com/wiki/maruel/panicparse/parse.gif \"Screencast\")\n\n\nFeatures\n--------\n\n   * &gt;50% more compact output than original stack dump yet more readable.\n   * Exported symbols are bold, private symbols are darker.\n   * Stdlib is green, main is yellow, rest is red.\n   * Deduplicates redundant goroutine stacks. Useful for large server crashes.\n   * Arguments as pointer IDs instead of raw pointer values.\n   * Pushes stdlib-only stacks at the bottom to help focus on important code.\n   * Usable as a library!\n     [![GoDoc](https://godoc.org/github.com/maruel/panicparse/stack?status.svg)](https://godoc.org/github.com/maruel/panicparse/stack)\n     * Warning: please pin the version (e.g. vendor it). Breaking changes are\n       not planned but may happen.\n   * Parses the source files if available to augment the output.\n   * Works on Windows.\n\n\nInstallation\n------------\n\n    go get github.com/maruel/panicparse/cmd/pp\n\n\nUsage\n-----\n\n### Piping a stack trace from another process\n\n#### TL;DR\n\n   * Ubuntu (bash v4 or zsh): `|&`\n   * OSX, [install bash 4+](README.md#updating-bash-on-osx), then: `|&`\n   * Windows _or_ OSX with stock bash v3: `2>&1 |`\n   * [Fish](http://fishshell.com/) shell: `^|`\n\n\n#### Longer version\n\n`pp` streams its stdin to stdout as long as it doesn't detect any panic.\n`panic()` and Go's native deadlock detector [print to\nstderr](https://golang.org/src/runtime/panic1.go) via the native [`print()`\nfunction](https://golang.org/pkg/builtin/#print).\n\n\n**Bash v4** or **zsh**: `|&` tells the shell to redirect stderr to stdout,\nit's an alias for `2>&1 |` ([bash\nv4](https://www.gnu.org/software/bash/manual/bash.html#Pipelines),\n[zsh](http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines)):\n\n    go test -v |&pp\n\n\n**Windows or OSX native bash** [(which is\n3.2.57)](http://meta.ath0.com/2012/02/05/apples-great-gpl-purge/): They don't\nhave this shortcut, so use the long form:\n\n    go test -v 2>&1 | pp\n\n\n**Fish**: It uses [^ for stderr\nredirection](http://fishshell.com/docs/current/tutorial.html#tut_pipes_and_redirections)\nso the shortcut is `^|`:\n\n    go test -v ^|pp\n\n\n**PowerShell**: [It has broken `2>&1` redirection](https://connect.microsoft.com/PowerShell/feedback/details/765551/in-powershell-v3-you-cant-redirect-stderr-to-stdout-without-generating-error-records). The workaround is to shell out to cmd.exe. :(\n\n\n### Investigate deadlock\n\nOn POSIX, use `Ctrl-\\` to send SIGQUIT to your process, `pp` will ignore\nthe signal and will parse the stack trace.\n\n\n### Parsing from a file\n\nTo dump to a file then parse, pass the file path of a stack trace\n\n    go test 2> stack.txt\n    pp stack.txt\n\n\nTips\n----\n\n### GOTRACEBACK\n\nStarting with Go 1.6, [`GOTRACEBACK`](https://golang.org/pkg/runtime/) defaults\nto `single` instead of `all` / `1` that was used in 1.5 and before. To get all\ngoroutines trace and not just the crashing one, set the environment variable:\n\n    export GOTRACEBACK=all\n\nor `set GOTRACEBACK=all` on Windows. Probably worth to put it in your `.bashrc`.\n\n\n### Updating bash on OSX\n\nInstall bash v4+ on OSX via [homebrew](http://brew.sh) or\n[macports](https://www.macports.org/). Your future self will appreciate having\ndone that.\n\n\n### If you have `/usr/bin/pp` installed\n\nIf you try `pp` for the first time and you get:\n\n    Creating tables and indexes...\n    Done.\n\nand/or\n\n    /usr/bin/pp5.18: No input files specified\n\nyou may be running the _Perl PAR Packager_ instead of panicparse.\n\nYou have two choices, either you put `$GOPATH/bin` at the begining of `$PATH` or\nuse long name `panicparse` with:\n\n    go get github.com/maruel/panicparse\n\nthen using `panicparse` instead of `pp`:\n\n    go test 2> panicparse\n"
  },
  {
    "path": "vendor/github.com/maruel/panicparse/main.go",
    "content": "// Copyright 2015 Marc-Antoine Ruel. All rights reserved.\n// Use of this source code is governed under the Apache License, Version 2.0\n// that can be found in the LICENSE file.\n\n// panicparse: analyzes stack dump of Go processes and simplifies it.\n//\n// It is mostly useful on servers will large number of identical goroutines,\n// making the crash dump harder to read than strictly necesary.\n//\n// Colors:\n//  - Magenta: first goroutine to be listed.\n//  - Yellow: main package.\n//  - Green: standard library.\n//  - Red: other packages.\n//\n// Bright colors are used for exported symbols.\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/maruel/panicparse/internal\"\n)\n\nfunc main() {\n\tif err := internal.Main(); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"Failed: %s\\n\", err)\n\t\tos.Exit(1)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/maruel/panicparse/stack/source.go",
    "content": "// Copyright 2015 Marc-Antoine Ruel. All rights reserved.\n// Use of this source code is governed under the Apache License, Version 2.0\n// that can be found in the LICENSE file.\n\n// This file contains the code to process sources, to be able to deduct the\n// original types.\n\npackage stack\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"go/ast\"\n\t\"go/parser\"\n\t\"go/token\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"math\"\n\t\"strings\"\n)\n\n// cache is a cache of sources on the file system.\ntype cache struct {\n\tfiles  map[string][]byte\n\tparsed map[string]*parsedFile\n}\n\n// Augment processes source files to improve calls to be more descriptive.\n//\n// It modifies goroutines in place.\nfunc Augment(goroutines []Goroutine) {\n\tc := &cache{}\n\tfor i := range goroutines {\n\t\tc.augmentGoroutine(&goroutines[i])\n\t}\n}\n\n// augmentGoroutine processes source files to improve call to be more\n// descriptive.\n//\n// It modifies the routine.\nfunc (c *cache) augmentGoroutine(goroutine *Goroutine) {\n\tif c.files == nil {\n\t\tc.files = map[string][]byte{}\n\t}\n\tif c.parsed == nil {\n\t\tc.parsed = map[string]*parsedFile{}\n\t}\n\t// For each call site, look at the next call and populate it. Then we can\n\t// walk back and reformat things.\n\tfor i := range goroutine.Stack.Calls {\n\t\tc.load(goroutine.Stack.Calls[i].SourcePath)\n\t}\n\n\t// Once all loaded, we can look at the next call when available.\n\tfor i := 0; i < len(goroutine.Stack.Calls)-1; i++ {\n\t\t// Get the AST from the previous call and process the call line with it.\n\t\tif f := c.getFuncAST(&goroutine.Stack.Calls[i]); f != nil {\n\t\t\tprocessCall(&goroutine.Stack.Calls[i], f)\n\t\t}\n\t}\n}\n\n// Private stuff.\n\n// load loads a source file and parses the AST tree. Failures are ignored.\nfunc (c *cache) load(fileName string) {\n\tif _, ok := c.parsed[fileName]; ok {\n\t\treturn\n\t}\n\tc.parsed[fileName] = nil\n\tif !strings.HasSuffix(fileName, \".go\") {\n\t\t// Ignore C and assembly.\n\t\tc.files[fileName] = nil\n\t\treturn\n\t}\n\tlog.Printf(\"load(%s)\", fileName)\n\tif _, ok := c.files[fileName]; !ok {\n\t\tvar err error\n\t\tif c.files[fileName], err = ioutil.ReadFile(fileName); err != nil {\n\t\t\tlog.Printf(\"Failed to read %s: %s\", fileName, err)\n\t\t\tc.files[fileName] = nil\n\t\t\treturn\n\t\t}\n\t}\n\tfset := token.NewFileSet()\n\tsrc := c.files[fileName]\n\tparsed, err := parser.ParseFile(fset, fileName, src, 0)\n\tif err != nil {\n\t\tlog.Printf(\"Failed to parse %s: %s\", fileName, err)\n\t\treturn\n\t}\n\t// Convert the line number into raw file offset.\n\toffsets := []int{0, 0}\n\tstart := 0\n\tfor l := 1; start < len(src); l++ {\n\t\tstart += bytes.IndexByte(src[start:], '\\n') + 1\n\t\toffsets = append(offsets, start)\n\t}\n\tc.parsed[fileName] = &parsedFile{offsets, parsed}\n}\n\nfunc (c *cache) getFuncAST(call *Call) *ast.FuncDecl {\n\tif p := c.parsed[call.SourcePath]; p != nil {\n\t\treturn p.getFuncAST(call.Func.Name(), call.Line)\n\t}\n\treturn nil\n}\n\ntype parsedFile struct {\n\tlineToByteOffset []int\n\tparsed           *ast.File\n}\n\n// getFuncAST gets the callee site function AST representation for the code\n// inside the function f at line l.\nfunc (p *parsedFile) getFuncAST(f string, l int) (d *ast.FuncDecl) {\n\tif len(p.lineToByteOffset) <= l {\n\t\t// The line number in the stack trace line does not exist in the file. That\n\t\t// can only mean that the sources on disk do not match the sources used to\n\t\t// build the binary.\n\t\t// TODO(maruel): This should be surfaced, so that source parsing is\n\t\t// completely ignored.\n\t\treturn\n\t}\n\n\t// Walk the AST to find the lineToByteOffset that fits the line number.\n\tvar lastFunc *ast.FuncDecl\n\tvar found ast.Node\n\t// Inspect() goes depth first. This means for example that a function like:\n\t// func a() {\n\t//   b := func() {}\n\t//   c()\n\t// }\n\t//\n\t// Were we are looking at the c() call can return confused values. It is\n\t// important to look at the actual ast.Node hierarchy.\n\tast.Inspect(p.parsed, func(n ast.Node) bool {\n\t\tif d != nil {\n\t\t\treturn false\n\t\t}\n\t\tif n == nil {\n\t\t\treturn true\n\t\t}\n\t\tif found != nil {\n\t\t\t// We are walking up.\n\t\t}\n\t\tif int(n.Pos()) >= p.lineToByteOffset[l] {\n\t\t\t// We are expecting a ast.CallExpr node. It can be harder to figure out\n\t\t\t// when there are multiple calls on a single line, as the stack trace\n\t\t\t// doesn't have file byte offset information, only line based.\n\t\t\t// gofmt will always format to one function call per line but there can\n\t\t\t// be edge cases, like:\n\t\t\t//   a = A{Foo(), Bar()}\n\t\t\td = lastFunc\n\t\t\t//p.processNode(call, n)\n\t\t\treturn false\n\t\t} else if f, ok := n.(*ast.FuncDecl); ok {\n\t\t\tlastFunc = f\n\t\t}\n\t\treturn true\n\t})\n\treturn\n}\n\nfunc name(n ast.Node) string {\n\tswitch t := n.(type) {\n\tcase *ast.InterfaceType:\n\t\treturn \"interface{}\"\n\tcase *ast.Ident:\n\t\treturn t.Name\n\tcase *ast.SelectorExpr:\n\t\treturn t.Sel.Name\n\tcase *ast.StarExpr:\n\t\treturn \"*\" + name(t.X)\n\tdefault:\n\t\treturn \"<unknown>\"\n\t}\n}\n\n// fieldToType returns the type name and whether if it's an ellipsis.\nfunc fieldToType(f *ast.Field) (string, bool) {\n\tswitch arg := f.Type.(type) {\n\tcase *ast.ArrayType:\n\t\treturn \"[]\" + name(arg.Elt), false\n\tcase *ast.Ellipsis:\n\t\treturn name(arg.Elt), true\n\tcase *ast.FuncType:\n\t\t// Do not print the function signature to not overload the trace.\n\t\treturn \"func\", false\n\tcase *ast.Ident:\n\t\treturn arg.Name, false\n\tcase *ast.InterfaceType:\n\t\treturn \"interface{}\", false\n\tcase *ast.SelectorExpr:\n\t\treturn arg.Sel.Name, false\n\tcase *ast.StarExpr:\n\t\treturn \"*\" + name(arg.X), false\n\tcase *ast.MapType:\n\t\treturn fmt.Sprintf(\"map[%s]%s\", name(arg.Key), name(arg.Value)), false\n\tcase *ast.ChanType:\n\t\treturn fmt.Sprintf(\"chan %s\", name(arg.Value)), false\n\tdefault:\n\t\t// TODO(maruel): Implement anything missing.\n\t\treturn \"<unknown>\", false\n\t}\n}\n\n// extractArgumentsType returns the name of the type of each input argument.\nfunc extractArgumentsType(f *ast.FuncDecl) ([]string, bool) {\n\tvar fields []*ast.Field\n\tif f.Recv != nil {\n\t\tif len(f.Recv.List) != 1 {\n\t\t\tpanic(\"Expect only one receiver; please fix panicparse's code\")\n\t\t}\n\t\t// If it is an object receiver (vs a pointer receiver), its address is not\n\t\t// printed in the stack trace so it needs to be ignored.\n\t\tif _, ok := f.Recv.List[0].Type.(*ast.StarExpr); ok {\n\t\t\tfields = append(fields, f.Recv.List[0])\n\t\t}\n\t}\n\tvar types []string\n\textra := false\n\tfor _, arg := range append(fields, f.Type.Params.List...) {\n\t\t// Assert that extra is only set on the last item of fields?\n\t\tvar t string\n\t\tt, extra = fieldToType(arg)\n\t\tmult := len(arg.Names)\n\t\tif mult == 0 {\n\t\t\tmult = 1\n\t\t}\n\t\tfor i := 0; i < mult; i++ {\n\t\t\ttypes = append(types, t)\n\t\t}\n\t}\n\treturn types, extra\n}\n\n// processCall walks the function and populate call accordingly.\nfunc processCall(call *Call, f *ast.FuncDecl) {\n\tvalues := make([]uint64, len(call.Args.Values))\n\tfor i := range call.Args.Values {\n\t\tvalues[i] = call.Args.Values[i].Value\n\t}\n\tindex := 0\n\tpop := func() uint64 {\n\t\tif len(values) != 0 {\n\t\t\tx := values[0]\n\t\t\tvalues = values[1:]\n\t\t\tindex++\n\t\t\treturn x\n\t\t}\n\t\treturn 0\n\t}\n\tpopName := func() string {\n\t\tn := call.Args.Values[index].Name\n\t\tv := pop()\n\t\tif len(n) == 0 {\n\t\t\treturn fmt.Sprintf(\"0x%x\", v)\n\t\t}\n\t\treturn n\n\t}\n\n\ttypes, extra := extractArgumentsType(f)\n\tfor i := 0; len(values) != 0; i++ {\n\t\tvar t string\n\t\tif i >= len(types) {\n\t\t\tif !extra {\n\t\t\t\t// These are unexpected value! Print them as hex.\n\t\t\t\tcall.Args.Processed = append(call.Args.Processed, popName())\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tt = types[len(types)-1]\n\t\t} else {\n\t\t\tt = types[i]\n\t\t}\n\t\tswitch t {\n\t\tcase \"float32\":\n\t\t\tcall.Args.Processed = append(call.Args.Processed, fmt.Sprintf(\"%g\", math.Float32frombits(uint32(pop()))))\n\t\tcase \"float64\":\n\t\t\tcall.Args.Processed = append(call.Args.Processed, fmt.Sprintf(\"%g\", math.Float64frombits(pop())))\n\t\tcase \"int\", \"int8\", \"int16\", \"int32\", \"int64\", \"uint\", \"uint8\", \"uint16\", \"uint32\", \"uint64\":\n\t\t\tcall.Args.Processed = append(call.Args.Processed, fmt.Sprintf(\"%d\", pop()))\n\t\tcase \"string\":\n\t\t\tcall.Args.Processed = append(call.Args.Processed, fmt.Sprintf(\"%s(%s, len=%d)\", t, popName(), pop()))\n\t\tdefault:\n\t\t\tif strings.HasPrefix(t, \"*\") {\n\t\t\t\tcall.Args.Processed = append(call.Args.Processed, fmt.Sprintf(\"%s(%s)\", t, popName()))\n\t\t\t} else if strings.HasPrefix(t, \"[]\") {\n\t\t\t\tcall.Args.Processed = append(call.Args.Processed, fmt.Sprintf(\"%s(%s len=%d cap=%d)\", t, popName(), pop(), pop()))\n\t\t\t} else {\n\t\t\t\t// Assumes it's an interface. For now, discard the object value, which\n\t\t\t\t// is probably not a good idea.\n\t\t\t\tcall.Args.Processed = append(call.Args.Processed, fmt.Sprintf(\"%s(%s)\", t, popName()))\n\t\t\t\tpop()\n\t\t\t}\n\t\t}\n\t\tif len(values) == 0 && call.Args.Elided {\n\t\t\treturn\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/maruel/panicparse/stack/source_test.go",
    "content": "// Copyright 2015 Marc-Antoine Ruel. All rights reserved.\n// Use of this source code is governed under the Apache License, Version 2.0\n// that can be found in the LICENSE file.\n\npackage stack\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/maruel/ut\"\n)\n\nfunc TestAugment(t *testing.T) {\n\tdata := []struct {\n\t\tname     string\n\t\tinput    string\n\t\texpected Stack\n\t}{\n\t\t{\n\t\t\t\"Local function doesn't interfere\",\n\t\t\t`package main\n\t\t\tfunc f(s string) {\n\t\t\t\ta := func(i int) int {\n\t\t\t\t\treturn 1 + i\n\t\t\t\t}\n\t\t\t\t_ = a(3)\n\t\t\t\tpanic(\"ooh\")\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(\"yo\")\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 7, Func: Function{\"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\tValues: []Arg{{Value: pointer, Name: \"\"}, {Value: 0x2}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 10, Func: Function{\"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"func\",\n\t\t\t`package main\n\t\t\tfunc f(a func() string) {\n\t\t\t\tpanic(a())\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(func() string { return \"ooh\" })\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{Values: []Arg{{Value: pointer}}},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"func ellipsis\",\n\t\t\t`package main\n\t\t\tfunc f(a ...func() string) {\n\t\t\t\tpanic(a[0]())\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(func() string { return \"ooh\" })\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\tValues: []Arg{{Value: pointer}, {Value: 0x1}, {Value: 0x1}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"interface{}\",\n\t\t\t`package main\n\t\t\tfunc f(a []interface{}) {\n\t\t\t\tpanic(\"ooh\")\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(make([]interface{}, 5, 7))\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\tValues: []Arg{{Value: pointer}, {Value: 0x5}, {Value: 0x7}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"[]int\",\n\t\t\t`package main\n\t\t\tfunc f(a []int) {\n\t\t\t\tpanic(\"ooh\")\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(make([]int, 5, 7))\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\tValues: []Arg{{Value: pointer}, {Value: 5}, {Value: 7}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"[]interface{}\",\n\t\t\t`package main\n\t\t\tfunc f(a []interface{}) {\n\t\t\t\tpanic(a[0].(string))\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf([]interface{}{\"ooh\"})\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\tValues: []Arg{{Value: pointer}, {Value: 1}, {Value: 1}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"map[int]int\",\n\t\t\t`package main\n\t\t\tfunc f(a map[int]int) {\n\t\t\t\tpanic(\"ooh\")\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(map[int]int{1: 2})\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\tValues: []Arg{{Value: pointer}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"map[interface{}]interface{}\",\n\t\t\t`package main\n\t\t\tfunc f(a map[interface{}]interface{}) {\n\t\t\t\tpanic(\"ooh\")\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(make(map[interface{}]interface{}))\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\tValues: []Arg{{Value: pointer}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"chan int\",\n\t\t\t`package main\n\t\t\tfunc f(a chan int) {\n\t\t\t\tpanic(\"ooh\")\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(make(chan int))\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\tValues: []Arg{{Value: pointer}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"chan interface{}\",\n\t\t\t`package main\n\t\t\tfunc f(a chan interface{}) {\n\t\t\t\tpanic(\"ooh\")\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(make(chan interface{}))\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\tValues: []Arg{{Value: pointer}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"non-pointer method\",\n\t\t\t`package main\n\t\t\ttype S struct {\n\t\t\t}\n\t\t\tfunc (s S) f() {\n\t\t\t\tpanic(\"ooh\")\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tvar s S\n\t\t\t\ts.f()\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 5, Func: Function{Raw: \"main.S.f\"}},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 9, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"pointer method\",\n\t\t\t`package main\n\t\t\ttype S struct {\n\t\t\t}\n\t\t\tfunc (s *S) f() {\n\t\t\t\tpanic(\"ooh\")\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tvar s S\n\t\t\t\ts.f()\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 5, Func: Function{Raw: \"main.(*S).f\"},\n\t\t\t\t\t\tArgs: Args{Values: []Arg{{Value: pointer}}},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 9, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"string\",\n\t\t\t`package main\n\t\t\tfunc f(s string) {\n\t\t\t\tpanic(s)\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t  f(\"ooh\")\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{Values: []Arg{{Value: pointer}, {Value: 0x3}}},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"string and int\",\n\t\t\t`package main\n\t\t\tfunc f(s string, i int) {\n\t\t\t\tpanic(s)\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t  f(\"ooh\", 42)\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{Values: []Arg{{Value: pointer}, {Value: 0x3}, {Value: 42}}},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"values are elided\",\n\t\t\t`package main\n\t\t\tfunc f(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12 int, s13 interface{}) {\n\t\t\t\tpanic(\"ooh\")\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(0, 0, 0, 0, 0, 0, 0, 0, 42, 43, 44, 45, nil)\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\tValues: []Arg{{}, {}, {}, {}, {}, {}, {}, {}, {Value: 42}, {Value: 43}},\n\t\t\t\t\t\t\tElided: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"error\",\n\t\t\t`package main\n\t\t\timport \"errors\"\n\t\t\tfunc f(err error) {\n\t\t\t\tpanic(err.Error())\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(errors.New(\"ooh\"))\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 4, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\tValues: []Arg{{Value: pointer}, {Value: pointer}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 7, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"error unnamed\",\n\t\t\t`package main\n\t\t\timport \"errors\"\n\t\t\tfunc f(error) {\n\t\t\t\tpanic(\"ooh\")\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(errors.New(\"ooh\"))\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 4, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\tValues: []Arg{{Value: pointer}, {Value: pointer}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 7, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"float32\",\n\t\t\t`package main\n\t\t\tfunc f(v float32) {\n\t\t\t\tpanic(\"ooh\")\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(0.5)\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\t// The value is NOT a pointer but floating point encoding is not\n\t\t\t\t\t\t\t// deterministic.\n\t\t\t\t\t\t\tValues: []Arg{{Value: pointer}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"float64\",\n\t\t\t`package main\n\t\t\tfunc f(v float64) {\n\t\t\t\tpanic(\"ooh\")\n\t\t\t}\n\t\t\tfunc main() {\n\t\t\t\tf(0.5)\n\t\t\t}`,\n\t\t\tStack{\n\t\t\t\tCalls: []Call{\n\t\t\t\t\t{\n\t\t\t\t\t\tSourcePath: \"main.go\", Line: 3, Func: Function{Raw: \"main.f\"},\n\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\t// The value is NOT a pointer but floating point encoding is not\n\t\t\t\t\t\t\t// deterministic.\n\t\t\t\t\t\t\tValues: []Arg{{Value: pointer}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{SourcePath: \"main.go\", Line: 6, Func: Function{Raw: \"main.main\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tfor i, line := range data {\n\t\textra := bytes.Buffer{}\n\t\t_, content := getCrash(t, line.input)\n\t\tgoroutines, err := ParseDump(bytes.NewBuffer(content), &extra)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"failed to parse input for test %s: %v\", line.name, err)\n\t\t}\n\t\t// On go1.4, there's one less space.\n\t\tactual := extra.String()\n\t\tif actual != \"panic: ooh\\n\\nexit status 2\\n\" && actual != \"panic: ooh\\nexit status 2\\n\" {\n\t\t\tt.Fatalf(\"Unexpected panic output:\\n%#v\", actual)\n\t\t}\n\t\ts := goroutines[0].Signature.Stack\n\t\tt.Logf(\"Test: %v\", line.name)\n\t\tzapPointers(t, line.name, &line.expected, &s)\n\t\tzapPaths(&s)\n\t\tut.AssertEqualIndex(t, i, line.expected, s)\n\t}\n}\n\nfunc TestAugmentDummy(t *testing.T) {\n\tgoroutines := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{{SourcePath: \"missing.go\"}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\tAugment(goroutines)\n}\n\nfunc TestLoad(t *testing.T) {\n\tc := &cache{\n\t\tfiles:  map[string][]byte{\"bad.go\": []byte(\"bad content\")},\n\t\tparsed: map[string]*parsedFile{},\n\t}\n\tc.load(\"foo.asm\")\n\tc.load(\"bad.go\")\n\tc.load(\"doesnt_exist.go\")\n\tif l := len(c.parsed); l != 3 {\n\t\tt.Fatalf(\"expected 3, got %d\", l)\n\t}\n\tif c.parsed[\"foo.asm\"] != nil {\n\t\tt.Fatalf(\"foo.asm is not present; should not have been loaded\")\n\t}\n\tif c.parsed[\"bad.go\"] != nil {\n\t\tt.Fatalf(\"bad.go is not valid code; should not have been loaded\")\n\t}\n\tif c.parsed[\"doesnt_exist.go\"] != nil {\n\t\tt.Fatalf(\"doesnt_exist.go is not present; should not have been loaded\")\n\t}\n\tif c.getFuncAST(&Call{SourcePath: \"other\"}) != nil {\n\t\tt.Fatalf(\"there's no 'other'\")\n\t}\n}\n\n//\n\nconst pointer = uint64(0xfffffffff)\nconst pointerStr = \"0xfffffffff\"\n\nfunc overrideEnv(env []string, key, value string) []string {\n\tprefix := key + \"=\"\n\tfor i, e := range env {\n\t\tif strings.HasPrefix(e, prefix) {\n\t\t\tenv[i] = prefix + value\n\t\t\treturn env\n\t\t}\n\t}\n\treturn append(env, prefix+value)\n}\n\nfunc getCrash(t *testing.T, content string) (string, []byte) {\n\tname, err := ioutil.TempDir(\"\", \"panicparse\")\n\tif err != nil {\n\t\tt.Fatalf(\"failed to create temporary directory: %v\", err)\n\t}\n\tdefer func() {\n\t\tif err := os.RemoveAll(name); err != nil {\n\t\t\tt.Fatalf(\"failed to remove temporary directory %q: %v\", name, err)\n\t\t}\n\t}()\n\tmain := filepath.Join(name, \"main.go\")\n\tif err := ioutil.WriteFile(main, []byte(content), 0500); err != nil {\n\t\tt.Fatalf(\"failed to write %q: %v\", main, err)\n\t}\n\tcmd := exec.Command(\"go\", \"run\", main)\n\t// Use the Go 1.4 compatible format.\n\tcmd.Env = overrideEnv(os.Environ(), \"GOTRACEBACK\", \"1\")\n\tout, err := cmd.CombinedOutput()\n\tif err == nil {\n\t\tt.Fatal(\"expected error since this is supposed to crash\")\n\t}\n\treturn main, out\n}\n\n// zapPointers zaps out pointers.\nfunc zapPointers(t *testing.T, name string, expected, s *Stack) {\n\tfor i := range s.Calls {\n\t\tif i >= len(expected.Calls) {\n\t\t\t// When using GOTRACEBACK=2, it'll include runtime.main() and\n\t\t\t// runtime.goexit(). Ignore these since they could be changed in a future\n\t\t\t// version.\n\t\t\ts.Calls = s.Calls[:len(expected.Calls)]\n\t\t\tbreak\n\t\t}\n\t\tfor j := range s.Calls[i].Args.Values {\n\t\t\tif j >= len(expected.Calls[i].Args.Values) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif expected.Calls[i].Args.Values[j].Value == pointer {\n\t\t\t\t// Replace the pointer value.\n\t\t\t\tif s.Calls[i].Args.Values[j].Value == 0 {\n\t\t\t\t\tt.Fatalf(\"%s: Call %d, value %d, expected pointer, got 0\", name, i, j)\n\t\t\t\t}\n\t\t\t\told := fmt.Sprintf(\"0x%x\", s.Calls[i].Args.Values[j].Value)\n\t\t\t\ts.Calls[i].Args.Values[j].Value = pointer\n\t\t\t\tfor k := range s.Calls[i].Args.Processed {\n\t\t\t\t\ts.Calls[i].Args.Processed[k] = strings.Replace(s.Calls[i].Args.Processed[k], old, pointerStr, -1)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n// zapPaths removes the directory part and only keep the base file name.\nfunc zapPaths(s *Stack) {\n\tfor j := range s.Calls {\n\t\ts.Calls[j].SourcePath = filepath.Base(s.Calls[j].SourcePath)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/maruel/panicparse/stack/stack.go",
    "content": "// Copyright 2015 Marc-Antoine Ruel. All rights reserved.\n// Use of this source code is governed under the Apache License, Version 2.0\n// that can be found in the LICENSE file.\n\n// Package stack analyzes stack dump of Go processes and simplifies it.\n//\n// It is mostly useful on servers will large number of identical goroutines,\n// making the crash dump harder to read than strictly necesary.\npackage stack\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"net/url\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"runtime\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\t\"unicode\"\n\t\"unicode/utf8\"\n)\n\nconst lockedToThread = \"locked to thread\"\n\nvar (\n\t// TODO(maruel): Handle corrupted stack cases:\n\t// - missed stack barrier\n\t// - found next stack barrier at 0x123; expected\n\t// - runtime: unexpected return pc for FUNC_NAME called from 0x123\n\n\treRoutineHeader = regexp.MustCompile(\"^goroutine (\\\\d+) \\\\[([^\\\\]]+)\\\\]\\\\:\\r?\\n$\")\n\treMinutes       = regexp.MustCompile(\"^(\\\\d+) minutes$\")\n\treUnavail       = regexp.MustCompile(\"^(?:\\t| +)goroutine running on other thread; stack unavailable\")\n\t// See gentraceback() in src/runtime/traceback.go for more information.\n\t// - Sometimes the source file comes up as \"<autogenerated>\". It is the\n\t//   compiler than generated these, not the runtime.\n\t// - The tab may be replaced with spaces when a user copy-paste it, handle\n\t//   this transparently.\n\t// - \"runtime.gopanic\" is explicitly replaced with \"panic\" by gentraceback().\n\t// - The +0x123 byte offset is printed when frame.pc > _func.entry. _func is\n\t//   generated by the linker.\n\t// - The +0x123 byte offset is not included with generated code, e.g. unnamed\n\t//   functions \"func·006()\" which is generally go func() { ... }()\n\t//   statements. Since the _func is generated at runtime, it's probably why\n\t//   _func.entry is not set.\n\t// - C calls may have fp=0x123 sp=0x123 appended. I think it normally happens\n\t//   when a signal is not correctly handled. It is printed with m.throwing>0.\n\t//   These are discarded.\n\t// - For cgo, the source file may be \"??\".\n\treFile = regexp.MustCompile(\"^(?:\\t| +)(\\\\?\\\\?|\\\\<autogenerated\\\\>|.+\\\\.(?:c|go|s))\\\\:(\\\\d+)(?:| \\\\+0x[0-9a-f]+)(?:| fp=0x[0-9a-f]+ sp=0x[0-9a-f]+)\\r?\\n$\")\n\t// Sadly, it doesn't note the goroutine number so we could cascade them per\n\t// parenthood.\n\treCreated = regexp.MustCompile(\"^created by (.+)\\r?\\n$\")\n\treFunc    = regexp.MustCompile(\"^(.+)\\\\((.*)\\\\)\\r?\\n$\")\n\treElided  = regexp.MustCompile(\"^\\\\.\\\\.\\\\.additional frames elided\\\\.\\\\.\\\\.\\r?\\n$\")\n\t// Include frequent GOROOT value on Windows, distro provided and user\n\t// installed path. This simplifies the user's life when processing a trace\n\t// generated on another VM.\n\t// TODO(maruel): Guess the path automatically via traces containing the\n\t// 'runtime' package, which is very frequent. This would be \"less bad\" than\n\t// throwing up random values at the parser.\n\tgoroots = []string{runtime.GOROOT(), \"c:/go\", \"/usr/lib/go\", \"/usr/local/go\"}\n)\n\n// Similarity is the level at which two call lines arguments must match to be\n// considered similar enough to coalesce them.\ntype Similarity int\n\nconst (\n\t// ExactFlags requires same bits (e.g. Locked).\n\tExactFlags Similarity = iota\n\t// ExactLines requests the exact same arguments on the call line.\n\tExactLines\n\t// AnyPointer considers different pointers a similar call line.\n\tAnyPointer\n\t// AnyValue accepts any value as similar call line.\n\tAnyValue\n)\n\n// Function is a function call.\n//\n// Go stack traces print a mangled function call, this wrapper unmangle the\n// string before printing and adds other filtering methods.\ntype Function struct {\n\tRaw string\n}\n\n// String is the fully qualified function name.\n//\n// Sadly Go is a bit confused when the package name doesn't match the directory\n// containing the source file and will use the directory name instead of the\n// real package name.\nfunc (f Function) String() string {\n\ts, _ := url.QueryUnescape(f.Raw)\n\treturn s\n}\n\n// Name is the naked function name.\nfunc (f Function) Name() string {\n\tparts := strings.SplitN(filepath.Base(f.Raw), \".\", 2)\n\tif len(parts) == 1 {\n\t\treturn parts[0]\n\t}\n\treturn parts[1]\n}\n\n// PkgName is the package name for this function reference.\nfunc (f Function) PkgName() string {\n\tparts := strings.SplitN(filepath.Base(f.Raw), \".\", 2)\n\tif len(parts) == 1 {\n\t\treturn \"\"\n\t}\n\ts, _ := url.QueryUnescape(parts[0])\n\treturn s\n}\n\n// PkgDotName returns \"<package>.<func>\" format.\nfunc (f Function) PkgDotName() string {\n\tparts := strings.SplitN(filepath.Base(f.Raw), \".\", 2)\n\ts, _ := url.QueryUnescape(parts[0])\n\tif len(parts) == 1 {\n\t\treturn parts[0]\n\t}\n\tif s != \"\" || parts[1] != \"\" {\n\t\treturn s + \".\" + parts[1]\n\t}\n\treturn \"\"\n}\n\n// IsExported returns true if the function is exported.\nfunc (f Function) IsExported() bool {\n\tname := f.Name()\n\tparts := strings.Split(name, \".\")\n\tr, _ := utf8.DecodeRuneInString(parts[len(parts)-1])\n\tif unicode.ToUpper(r) == r {\n\t\treturn true\n\t}\n\treturn f.PkgName() == \"main\" && name == \"main\"\n}\n\n// Arg is an argument on a Call.\ntype Arg struct {\n\tValue uint64 // Value is the raw value as found in the stack trace\n\tName  string // Name is a pseudo name given to the argument\n}\n\n// IsPtr returns true if we guess it's a pointer. It's only a guess, it can be\n// easily be confused by a bitmask.\nfunc (a *Arg) IsPtr() bool {\n\t// Assumes all pointers are above 16Mb and positive.\n\treturn a.Value > 16*1024*1024 && a.Value < math.MaxInt64\n}\n\nfunc (a Arg) String() string {\n\tif a.Name != \"\" {\n\t\treturn a.Name\n\t}\n\tif a.Value == 0 {\n\t\treturn \"0\"\n\t}\n\treturn fmt.Sprintf(\"0x%x\", a.Value)\n}\n\n// Args is a series of function call arguments.\ntype Args struct {\n\tValues    []Arg    // Values is the arguments as shown on the stack trace. They are mangled via simplification.\n\tProcessed []string // Processed is the arguments generated from processing the source files. It can have a length lower than Values.\n\tElided    bool     // If set, it means there was a trailing \", ...\"\n}\n\nfunc (a Args) String() string {\n\tvar v []string\n\tif len(a.Processed) != 0 {\n\t\tv = make([]string, 0, len(a.Processed))\n\t\tfor _, item := range a.Processed {\n\t\t\tv = append(v, item)\n\t\t}\n\t} else {\n\t\tv = make([]string, 0, len(a.Values))\n\t\tfor _, item := range a.Values {\n\t\t\tv = append(v, item.String())\n\t\t}\n\t}\n\tif a.Elided {\n\t\tv = append(v, \"...\")\n\t}\n\treturn strings.Join(v, \", \")\n}\n\n// Equal returns true only if both arguments are exactly equal.\nfunc (a *Args) Equal(r *Args) bool {\n\tif a.Elided != r.Elided || len(a.Values) != len(r.Values) {\n\t\treturn false\n\t}\n\tfor i, l := range a.Values {\n\t\tif l != r.Values[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n// Similar returns true if the two Args are equal or almost but not quite\n// equal.\nfunc (a *Args) Similar(r *Args, similar Similarity) bool {\n\tif a.Elided != r.Elided || len(a.Values) != len(r.Values) {\n\t\treturn false\n\t}\n\tif similar == AnyValue {\n\t\treturn true\n\t}\n\tfor i, l := range a.Values {\n\t\tswitch similar {\n\t\tcase ExactFlags, ExactLines:\n\t\t\tif l != r.Values[i] {\n\t\t\t\treturn false\n\t\t\t}\n\t\tdefault:\n\t\t\tif l.IsPtr() != r.Values[i].IsPtr() || (!l.IsPtr() && l != r.Values[i]) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}\n\n// Merge merges two similar Args, zapping out differences.\nfunc (a *Args) Merge(r *Args) Args {\n\tout := Args{\n\t\tValues: make([]Arg, len(a.Values)),\n\t\tElided: a.Elided,\n\t}\n\tfor i, l := range a.Values {\n\t\tif l != r.Values[i] {\n\t\t\tout.Values[i].Name = \"*\"\n\t\t\tout.Values[i].Value = l.Value\n\t\t} else {\n\t\t\tout.Values[i] = l\n\t\t}\n\t}\n\treturn out\n}\n\n// Call is an item in the stack trace.\ntype Call struct {\n\tSourcePath string   // Full path name of the source file\n\tLine       int      // Line number\n\tFunc       Function // Fully qualified function name (encoded).\n\tArgs       Args     // Call arguments\n}\n\n// Equal returns true only if both calls are exactly equal.\nfunc (c *Call) Equal(r *Call) bool {\n\treturn c.SourcePath == r.SourcePath && c.Line == r.Line && c.Func == r.Func && c.Args.Equal(&r.Args)\n}\n\n// Similar returns true if the two Call are equal or almost but not quite\n// equal.\nfunc (c *Call) Similar(r *Call, similar Similarity) bool {\n\treturn c.SourcePath == r.SourcePath && c.Line == r.Line && c.Func == r.Func && c.Args.Similar(&r.Args, similar)\n}\n\n// Merge merges two similar Call, zapping out differences.\nfunc (c *Call) Merge(r *Call) Call {\n\treturn Call{\n\t\tSourcePath: c.SourcePath,\n\t\tLine:       c.Line,\n\t\tFunc:       c.Func,\n\t\tArgs:       c.Args.Merge(&r.Args),\n\t}\n}\n\n// SourceName returns the base file name of the source file.\nfunc (c *Call) SourceName() string {\n\treturn filepath.Base(c.SourcePath)\n}\n\n// SourceLine returns \"source.go:line\", including only the base file name.\nfunc (c *Call) SourceLine() string {\n\treturn fmt.Sprintf(\"%s:%d\", c.SourceName(), c.Line)\n}\n\n// FullSourceLine returns \"/path/to/source.go:line\".\nfunc (c *Call) FullSourceLine() string {\n\treturn fmt.Sprintf(\"%s:%d\", c.SourcePath, c.Line)\n}\n\n// PkgSource is one directory plus the file name of the source file.\nfunc (c *Call) PkgSource() string {\n\treturn filepath.Join(filepath.Base(filepath.Dir(c.SourcePath)), c.SourceName())\n}\n\nconst testMainSource = \"_test\" + string(os.PathSeparator) + \"_testmain.go\"\n\n// IsStdlib returns true if it is a Go standard library function. This includes\n// the 'go test' generated main executable.\nfunc (c *Call) IsStdlib() bool {\n\tfor _, goroot := range goroots {\n\t\tif strings.HasPrefix(c.SourcePath, goroot) {\n\t\t\treturn true\n\t\t}\n\t}\n\t// Consider _test/_testmain.go as stdlib since it's injected by \"go test\".\n\treturn c.PkgSource() == testMainSource\n}\n\n// IsPkgMain returns true if it is in the main package.\nfunc (c *Call) IsPkgMain() bool {\n\treturn c.Func.PkgName() == \"main\"\n}\n\n// Stack is a call stack.\ntype Stack struct {\n\tCalls  []Call // Call stack. First is original function, last is leaf function.\n\tElided bool   // Happens when there's >100 items in Stack, currently hardcoded in package runtime.\n}\n\n// Equal returns true on if both call stacks are exactly equal.\nfunc (s *Stack) Equal(r *Stack) bool {\n\tif len(s.Calls) != len(r.Calls) || s.Elided != r.Elided {\n\t\treturn false\n\t}\n\tfor i := range s.Calls {\n\t\tif !s.Calls[i].Equal(&r.Calls[i]) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n// Similar returns true if the two Stack are equal or almost but not quite\n// equal.\nfunc (s *Stack) Similar(r *Stack, similar Similarity) bool {\n\tif len(s.Calls) != len(r.Calls) || s.Elided != r.Elided {\n\t\treturn false\n\t}\n\tfor i := range s.Calls {\n\t\tif !s.Calls[i].Similar(&r.Calls[i], similar) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n// Merge merges two similar Stack, zapping out differences.\nfunc (s *Stack) Merge(r *Stack) *Stack {\n\t// Assumes similar stacks have the same length.\n\tout := &Stack{\n\t\tCalls:  make([]Call, len(s.Calls)),\n\t\tElided: s.Elided,\n\t}\n\tfor i := range s.Calls {\n\t\tout.Calls[i] = s.Calls[i].Merge(&r.Calls[i])\n\t}\n\treturn out\n}\n\n// Less compares two Stack, where the ones that are less are more\n// important, so they come up front. A Stack with more private functions is\n// 'less' so it is at the top. Inversely, a Stack with only public\n// functions is 'more' so it is at the bottom.\nfunc (s *Stack) Less(r *Stack) bool {\n\tlStdlib := 0\n\tlPrivate := 0\n\tfor _, c := range s.Calls {\n\t\tif c.IsStdlib() {\n\t\t\tlStdlib++\n\t\t} else {\n\t\t\tlPrivate++\n\t\t}\n\t}\n\trStdlib := 0\n\trPrivate := 0\n\tfor _, s := range r.Calls {\n\t\tif s.IsStdlib() {\n\t\t\trStdlib++\n\t\t} else {\n\t\t\trPrivate++\n\t\t}\n\t}\n\tif lPrivate > rPrivate {\n\t\treturn true\n\t}\n\tif lPrivate < rPrivate {\n\t\treturn false\n\t}\n\tif lStdlib > rStdlib {\n\t\treturn false\n\t}\n\tif lStdlib < rStdlib {\n\t\treturn true\n\t}\n\n\t// Stack lengths are the same.\n\tfor x := range s.Calls {\n\t\tif s.Calls[x].Func.Raw < r.Calls[x].Func.Raw {\n\t\t\treturn true\n\t\t}\n\t\tif s.Calls[x].Func.Raw > r.Calls[x].Func.Raw {\n\t\t\treturn true\n\t\t}\n\t\tif s.Calls[x].PkgSource() < r.Calls[x].PkgSource() {\n\t\t\treturn true\n\t\t}\n\t\tif s.Calls[x].PkgSource() > r.Calls[x].PkgSource() {\n\t\t\treturn true\n\t\t}\n\t\tif s.Calls[x].Line < r.Calls[x].Line {\n\t\t\treturn true\n\t\t}\n\t\tif s.Calls[x].Line > r.Calls[x].Line {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// Signature represents the signature of one or multiple goroutines.\n//\n// It is effectively the stack trace plus the goroutine internal bits, like\n// it's state, if it is thread locked, which call site created this goroutine,\n// etc.\ntype Signature struct {\n\t// Use git grep 'gopark(|unlock)\\(' to find them all plus everything listed\n\t// in runtime/traceback.go. Valid values includes:\n\t//     - chan send, chan receive, select\n\t//     - finalizer wait, mark wait (idle),\n\t//     - Concurrent GC wait, GC sweep wait, force gc (idle)\n\t//     - IO wait, panicwait\n\t//     - semacquire, semarelease\n\t//     - sleep, timer goroutine (idle)\n\t//     - trace reader (blocked)\n\t// Stuck cases:\n\t//     - chan send (nil chan), chan receive (nil chan), select (no cases)\n\t// Runnable states:\n\t//    - idle, runnable, running, syscall, waiting, dead, enqueue, copystack,\n\t// Scan states:\n\t//    - scan, scanrunnable, scanrunning, scansyscall, scanwaiting, scandead,\n\t//      scanenqueue\n\tState     string\n\tCreatedBy Call // Which other goroutine which created this one.\n\tSleepMin  int  // Wait time in minutes, if applicable.\n\tSleepMax  int  // Wait time in minutes, if applicable.\n\tStack     Stack\n\tLocked    bool // Locked to an OS thread.\n}\n\n// Equal returns true only if both signatures are exactly equal.\nfunc (s *Signature) Equal(r *Signature) bool {\n\tif s.State != r.State || !s.CreatedBy.Equal(&r.CreatedBy) || s.Locked != r.Locked || s.SleepMin != r.SleepMin || s.SleepMax != r.SleepMax {\n\t\treturn false\n\t}\n\treturn s.Stack.Equal(&r.Stack)\n}\n\n// Similar returns true if the two Signature are equal or almost but not quite\n// equal.\nfunc (s *Signature) Similar(r *Signature, similar Similarity) bool {\n\tif s.State != r.State || !s.CreatedBy.Similar(&r.CreatedBy, similar) {\n\t\treturn false\n\t}\n\tif similar == ExactFlags && s.Locked != r.Locked {\n\t\treturn false\n\t}\n\treturn s.Stack.Similar(&r.Stack, similar)\n}\n\n// Merge merges two similar Signature, zapping out differences.\nfunc (s *Signature) Merge(r *Signature) *Signature {\n\tmin := s.SleepMin\n\tif r.SleepMin < min {\n\t\tmin = r.SleepMin\n\t}\n\tmax := s.SleepMax\n\tif r.SleepMax > max {\n\t\tmax = r.SleepMax\n\t}\n\treturn &Signature{\n\t\tState:     s.State,     // Drop right side.\n\t\tCreatedBy: s.CreatedBy, // Drop right side.\n\t\tSleepMin:  min,\n\t\tSleepMax:  max,\n\t\tStack:     *s.Stack.Merge(&r.Stack),\n\t\tLocked:    s.Locked || r.Locked, // TODO(maruel): This is weirdo.\n\t}\n}\n\n// Less compares two Signature, where the ones that are less are more\n// important, so they come up front. A Signature with more private functions is\n// 'less' so it is at the top. Inversely, a Signature with only public\n// functions is 'more' so it is at the bottom.\nfunc (s *Signature) Less(r *Signature) bool {\n\tif s.Stack.Less(&r.Stack) {\n\t\treturn true\n\t}\n\tif r.Stack.Less(&s.Stack) {\n\t\treturn false\n\t}\n\tif s.Locked && !r.Locked {\n\t\treturn true\n\t}\n\tif r.Locked && !s.Locked {\n\t\treturn false\n\t}\n\tif s.State < r.State {\n\t\treturn true\n\t}\n\tif s.State > r.State {\n\t\treturn false\n\t}\n\treturn false\n}\n\n// Goroutine represents the state of one goroutine, including the stack trace.\ntype Goroutine struct {\n\tSignature      // It's stack trace, internal bits, state, which call site created it, etc.\n\tID        int  // Goroutine ID.\n\tFirst     bool // First is the goroutine first printed, normally the one that crashed.\n}\n\n// Bucketize returns the number of similar goroutines.\nfunc Bucketize(goroutines []Goroutine, similar Similarity) map[*Signature][]Goroutine {\n\tout := map[*Signature][]Goroutine{}\n\t// O(n²). Fix eventually.\n\tfor _, routine := range goroutines {\n\t\tfound := false\n\t\tfor key := range out {\n\t\t\t// When a match is found, this effectively drops the other goroutine ID.\n\t\t\tif key.Similar(&routine.Signature, similar) {\n\t\t\t\tfound = true\n\t\t\t\tif !key.Equal(&routine.Signature) {\n\t\t\t\t\t// Almost but not quite equal. There's different pointers passed\n\t\t\t\t\t// around but the same values. Zap out the different values.\n\t\t\t\t\tnewKey := key.Merge(&routine.Signature)\n\t\t\t\t\tout[newKey] = append(out[key], routine)\n\t\t\t\t\tdelete(out, key)\n\t\t\t\t} else {\n\t\t\t\t\tout[key] = append(out[key], routine)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tkey := &Signature{}\n\t\t\t*key = routine.Signature\n\t\t\tout[key] = []Goroutine{routine}\n\t\t}\n\t}\n\treturn out\n}\n\n// Bucket is a stack trace signature and the list of goroutines that fits this\n// signature.\ntype Bucket struct {\n\tSignature\n\tRoutines []Goroutine\n}\n\n// First returns true if it contains the first goroutine, e.g. the ones that\n// likely generated the panic() call, if any.\nfunc (b *Bucket) First() bool {\n\tfor _, r := range b.Routines {\n\t\tif r.First {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// Less does reverse sort.\nfunc (b *Bucket) Less(r *Bucket) bool {\n\tif b.First() {\n\t\treturn true\n\t}\n\tif r.First() {\n\t\treturn false\n\t}\n\treturn b.Signature.Less(&r.Signature)\n}\n\n// Buckets is a list of Bucket sorted by repeation count.\ntype Buckets []Bucket\n\nfunc (b Buckets) Len() int {\n\treturn len(b)\n}\n\nfunc (b Buckets) Less(i, j int) bool {\n\treturn b[i].Less(&b[j])\n}\n\nfunc (b Buckets) Swap(i, j int) {\n\tb[j], b[i] = b[i], b[j]\n}\n\n// SortBuckets creates a list of Bucket from each goroutine stack trace count.\nfunc SortBuckets(buckets map[*Signature][]Goroutine) Buckets {\n\tout := make(Buckets, 0, len(buckets))\n\tfor signature, count := range buckets {\n\t\tout = append(out, Bucket{*signature, count})\n\t}\n\tsort.Sort(out)\n\treturn out\n}\n\n// scanLines is similar to bufio.ScanLines except that it:\n//     - doesn't drop '\\n'\n//     - doesn't strip '\\r'\n//     - returns when the data is bufio.MaxScanTokenSize bytes\nfunc scanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {\n\tif atEOF && len(data) == 0 {\n\t\treturn 0, nil, nil\n\t}\n\tif i := bytes.IndexByte(data, '\\n'); i >= 0 {\n\t\treturn i + 1, data[0 : i+1], nil\n\t}\n\tif atEOF {\n\t\treturn len(data), data, nil\n\t}\n\tif len(data) >= bufio.MaxScanTokenSize {\n\t\t// Returns the line even if it is not at EOF nor has a '\\n', otherwise the\n\t\t// scanner will return bufio.ErrTooLong which is definitely not what we\n\t\t// want.\n\t\treturn len(data), data, nil\n\t}\n\treturn 0, nil, nil\n}\n\n// ParseDump processes the output from runtime.Stack().\n//\n// It supports piping from another command and assumes there is junk before the\n// actual stack trace. The junk is streamed to out.\nfunc ParseDump(r io.Reader, out io.Writer) ([]Goroutine, error) {\n\tgoroutines := make([]Goroutine, 0, 16)\n\tvar goroutine *Goroutine\n\tscanner := bufio.NewScanner(r)\n\tscanner.Split(scanLines)\n\t// TODO(maruel): Use a formal state machine. Patterns follows:\n\t// - reRoutineHeader\n\t//   Either:\n\t//     - reUnavail\n\t//     - reFunc + reFile in a loop\n\t//     - reElided\n\t//   Optionally ends with:\n\t//     - reCreated + reFile\n\t// Between each goroutine stack dump: an empty line\n\tcreated := false\n\t// firstLine is the first line after the reRoutineHeader header line.\n\tfirstLine := false\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tif line == \"\\n\" || line == \"\\r\\n\" {\n\t\t\tif goroutine != nil {\n\t\t\t\tgoroutine = nil\n\t\t\t\tcontinue\n\t\t\t}\n\t\t} else if line[len(line)-1] == '\\n' {\n\t\t\tif goroutine == nil {\n\t\t\t\tif match := reRoutineHeader.FindStringSubmatch(line); match != nil {\n\t\t\t\t\tif id, err := strconv.Atoi(match[1]); err == nil {\n\t\t\t\t\t\t// See runtime/traceback.go.\n\t\t\t\t\t\t// \"<state>, \\d+ minutes, locked to thread\"\n\t\t\t\t\t\titems := strings.Split(match[2], \", \")\n\t\t\t\t\t\tsleep := 0\n\t\t\t\t\t\tlocked := false\n\t\t\t\t\t\tfor i := 1; i < len(items); i++ {\n\t\t\t\t\t\t\tif items[i] == lockedToThread {\n\t\t\t\t\t\t\t\tlocked = true\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Look for duration, if any.\n\t\t\t\t\t\t\tif match2 := reMinutes.FindStringSubmatch(items[i]); match2 != nil {\n\t\t\t\t\t\t\t\tsleep, _ = strconv.Atoi(match2[1])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgoroutines = append(goroutines, Goroutine{\n\t\t\t\t\t\t\tSignature: Signature{\n\t\t\t\t\t\t\t\tState:    items[0],\n\t\t\t\t\t\t\t\tSleepMin: sleep,\n\t\t\t\t\t\t\t\tSleepMax: sleep,\n\t\t\t\t\t\t\t\tLocked:   locked,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tID:    id,\n\t\t\t\t\t\t\tFirst: len(goroutines) == 0,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tgoroutine = &goroutines[len(goroutines)-1]\n\t\t\t\t\t\tfirstLine = true\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif firstLine {\n\t\t\t\t\tfirstLine = false\n\t\t\t\t\tif match := reUnavail.FindStringSubmatch(line); match != nil {\n\t\t\t\t\t\t// Generate a fake stack entry.\n\t\t\t\t\t\tgoroutine.Stack.Calls = []Call{{SourcePath: \"<unavailable>\"}}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif match := reFile.FindStringSubmatch(line); match != nil {\n\t\t\t\t\t// Triggers after a reFunc or a reCreated.\n\t\t\t\t\tnum, err := strconv.Atoi(match[2])\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn goroutines, fmt.Errorf(\"failed to parse int on line: \\\"%s\\\"\", line)\n\t\t\t\t\t}\n\t\t\t\t\tif created {\n\t\t\t\t\t\tcreated = false\n\t\t\t\t\t\tgoroutine.CreatedBy.SourcePath = match[1]\n\t\t\t\t\t\tgoroutine.CreatedBy.Line = num\n\t\t\t\t\t} else {\n\t\t\t\t\t\ti := len(goroutine.Stack.Calls) - 1\n\t\t\t\t\t\tif i < 0 {\n\t\t\t\t\t\t\treturn goroutines, errors.New(\"unexpected order\")\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgoroutine.Stack.Calls[i].SourcePath = match[1]\n\t\t\t\t\t\tgoroutine.Stack.Calls[i].Line = num\n\t\t\t\t\t}\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif match := reCreated.FindStringSubmatch(line); match != nil {\n\t\t\t\t\tcreated = true\n\t\t\t\t\tgoroutine.CreatedBy.Func.Raw = match[1]\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif match := reFunc.FindStringSubmatch(line); match != nil {\n\t\t\t\t\targs := Args{}\n\t\t\t\t\tfor _, a := range strings.Split(match[2], \", \") {\n\t\t\t\t\t\tif a == \"...\" {\n\t\t\t\t\t\t\targs.Elided = true\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif a == \"\" {\n\t\t\t\t\t\t\t// Remaining values were dropped.\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tv, err := strconv.ParseUint(a, 0, 64)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn goroutines, fmt.Errorf(\"failed to parse int on line: \\\"%s\\\"\", line)\n\t\t\t\t\t\t}\n\t\t\t\t\t\targs.Values = append(args.Values, Arg{Value: v})\n\t\t\t\t\t}\n\t\t\t\t\tgoroutine.Stack.Calls = append(goroutine.Stack.Calls, Call{Func: Function{match[1]}, Args: args})\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif match := reElided.FindStringSubmatch(line); match != nil {\n\t\t\t\t\tgoroutine.Stack.Elided = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t_, _ = io.WriteString(out, line)\n\t\tgoroutine = nil\n\t}\n\tnameArguments(goroutines)\n\treturn goroutines, scanner.Err()\n}\n\n// Private stuff.\n\nfunc nameArguments(goroutines []Goroutine) {\n\t// Set a name for any pointer occuring more than once.\n\ttype object struct {\n\t\targs      []*Arg\n\t\tinPrimary bool\n\t\tid        int\n\t}\n\tobjects := map[uint64]object{}\n\t// Enumerate all the arguments.\n\tfor i := range goroutines {\n\t\tfor j := range goroutines[i].Stack.Calls {\n\t\t\tfor k := range goroutines[i].Stack.Calls[j].Args.Values {\n\t\t\t\targ := goroutines[i].Stack.Calls[j].Args.Values[k]\n\t\t\t\tif arg.IsPtr() {\n\t\t\t\t\tobjects[arg.Value] = object{\n\t\t\t\t\t\targs:      append(objects[arg.Value].args, &goroutines[i].Stack.Calls[j].Args.Values[k]),\n\t\t\t\t\t\tinPrimary: objects[arg.Value].inPrimary || i == 0,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// CreatedBy.Args is never set.\n\t}\n\torder := uint64Slice{}\n\tfor k, obj := range objects {\n\t\tif len(obj.args) > 1 && obj.inPrimary {\n\t\t\torder = append(order, k)\n\t\t}\n\t}\n\tsort.Sort(order)\n\tnextID := 1\n\tfor _, k := range order {\n\t\tfor _, arg := range objects[k].args {\n\t\t\targ.Name = fmt.Sprintf(\"#%d\", nextID)\n\t\t}\n\t\tnextID++\n\t}\n\n\t// Now do the rest. This is done so the output is deterministic.\n\torder = uint64Slice{}\n\tfor k := range objects {\n\t\torder = append(order, k)\n\t}\n\tsort.Sort(order)\n\tfor _, k := range order {\n\t\t// Process the remaining pointers, they were not referenced by primary\n\t\t// thread so will have higher IDs.\n\t\tif objects[k].inPrimary {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, arg := range objects[k].args {\n\t\t\targ.Name = fmt.Sprintf(\"#%d\", nextID)\n\t\t}\n\t\tnextID++\n\t}\n}\n\ntype uint64Slice []uint64\n\nfunc (a uint64Slice) Len() int           { return len(a) }\nfunc (a uint64Slice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }\nfunc (a uint64Slice) Less(i, j int) bool { return a[i] < a[j] }\n"
  },
  {
    "path": "vendor/github.com/maruel/panicparse/stack/stack_test.go",
    "content": "// Copyright 2015 Marc-Antoine Ruel. All rights reserved.\n// Use of this source code is governed under the Apache License, Version 2.0\n// that can be found in the LICENSE file.\n\npackage stack\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"errors\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/maruel/ut\"\n)\n\nvar goroot = goroots[0]\n\nconst crash = `panic: oh no!\n\ngoroutine 1 [running]:\npanic(0x0, 0x0)\n\t/home/user/src/golang/src/runtime/panic.go:464 +0x3e6\nmain.crash2(0x7fe50b49d028, 0xc82000a1e0)\n\t/home/user/src/foo.go:45 +0x23\nmain.main()\n\t/home/user/src/foo.go:50 +0xa6\n`\n\nfunc Example() {\n\tin := bytes.NewBufferString(crash)\n\tgoroutines, err := ParseDump(in, os.Stdout)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Optional: Check for GOTRACEBACK being set, in particular if there is only\n\t// one goroutine returned.\n\n\t// Use a color palette based on ANSI code.\n\tp := &Palette{}\n\tbuckets := SortBuckets(Bucketize(goroutines, AnyValue))\n\tsrcLen, pkgLen := CalcLengths(buckets, false)\n\tfor _, bucket := range buckets {\n\t\tio.WriteString(os.Stdout, p.BucketHeader(&bucket, false, len(buckets) > 1))\n\t\tio.WriteString(os.Stdout, p.StackLines(&bucket.Signature, srcLen, pkgLen, false))\n\t}\n\t// Output:\n\t// panic: oh no!\n\t//\n\t// 1: running\n\t//          panic.go:464 panic(0, 0)\n\t//     main foo.go:45    crash2(0x7fe50b49d028, 0xc82000a1e0)\n\t//     main foo.go:50    main()\n}\n\nfunc TestParseDump1(t *testing.T) {\n\t// One call from main, one from stdlib, one from third party.\n\t// Create a long first line that will be ignored. It is to guard against\n\t// https://github.com/maruel/panicparse/issues/17.\n\tlong := strings.Repeat(\"a\", bufio.MaxScanTokenSize+1)\n\tdata := []string{\n\t\tlong,\n\t\t\"panic: reflect.Set: value of type\",\n\t\t\"\",\n\t\t\"goroutine 1 [running]:\",\n\t\t\"github.com/cockroachdb/cockroach/storage/engine._Cfunc_DBIterSeek()\",\n\t\t\" ??:0 +0x6d\",\n\t\t\"gopkg.in/yaml%2ev2.handleErr(0xc208033b20)\",\n\t\t\"\t/gopath/src/gopkg.in/yaml.v2/yaml.go:153 +0xc6\",\n\t\t\"reflect.Value.assignTo(0x570860, 0xc20803f3e0, 0x15)\",\n\t\t\"\t\" + goroot + \"/src/reflect/value.go:2125 +0x368\",\n\t\t\"main.main()\",\n\t\t\"\t/gopath/src/github.com/foo/bar/baz.go:428 +0x27\",\n\t\t\"\",\n\t}\n\textra := &bytes.Buffer{}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), extra)\n\tut.AssertEqual(t, nil, err)\n\tut.AssertEqual(t, long+\"\\npanic: reflect.Set: value of type\\n\\n\", extra.String())\n\texpected := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState: \"running\",\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"??\",\n\t\t\t\t\t\t\tFunc:       Function{\"github.com/cockroachdb/cockroach/storage/engine._Cfunc_DBIterSeek\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/gopkg.in/yaml.v2/yaml.go\",\n\t\t\t\t\t\t\tLine:       153,\n\t\t\t\t\t\t\tFunc:       Function{\"gopkg.in/yaml%2ev2.handleErr\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{Value: 0xc208033b20}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: goroot + \"/src/reflect/value.go\",\n\t\t\t\t\t\t\tLine:       2125,\n\t\t\t\t\t\t\tFunc:       Function{\"reflect.Value.assignTo\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{Value: 0x570860}, {Value: 0xc20803f3e0}, {Value: 0x15}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\t\t\t\tLine:       428,\n\t\t\t\t\t\t\tFunc:       Function{\"main.main\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID:    1,\n\t\t\tFirst: true,\n\t\t},\n\t}\n\tut.AssertEqual(t, expected, goroutines)\n}\n\nfunc TestParseDumpLongWait(t *testing.T) {\n\t// One call from main, one from stdlib, one from third party.\n\tdata := []string{\n\t\t\"panic: bleh\",\n\t\t\"\",\n\t\t\"goroutine 1 [chan send, 100 minutes]:\",\n\t\t\"gopkg.in/yaml%2ev2.handleErr(0xc208033b20)\",\n\t\t\"\t/gopath/src/gopkg.in/yaml.v2/yaml.go:153 +0xc6\",\n\t\t\"\",\n\t\t\"goroutine 2 [chan send, locked to thread]:\",\n\t\t\"gopkg.in/yaml%2ev2.handleErr(0xc208033b21)\",\n\t\t\"\t/gopath/src/gopkg.in/yaml.v2/yaml.go:153 +0xc6\",\n\t\t\"\",\n\t\t\"goroutine 3 [chan send, 101 minutes, locked to thread]:\",\n\t\t\"gopkg.in/yaml%2ev2.handleErr(0xc208033b22)\",\n\t\t\"\t/gopath/src/gopkg.in/yaml.v2/yaml.go:153 +0xc6\",\n\t\t\"\",\n\t}\n\textra := &bytes.Buffer{}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), extra)\n\tut.AssertEqual(t, nil, err)\n\tut.AssertEqual(t, \"panic: bleh\\n\\n\", extra.String())\n\texpected := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState:    \"chan send\",\n\t\t\t\tSleepMin: 100,\n\t\t\t\tSleepMax: 100,\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/gopkg.in/yaml.v2/yaml.go\",\n\t\t\t\t\t\t\tLine:       153,\n\t\t\t\t\t\t\tFunc:       Function{\"gopkg.in/yaml%2ev2.handleErr\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{Value: 0xc208033b20}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID:    1,\n\t\t\tFirst: true,\n\t\t},\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState:  \"chan send\",\n\t\t\t\tLocked: true,\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/gopkg.in/yaml.v2/yaml.go\",\n\t\t\t\t\t\t\tLine:       153,\n\t\t\t\t\t\t\tFunc:       Function{\"gopkg.in/yaml%2ev2.handleErr\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{Value: 0xc208033b21, Name: \"#1\"}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID: 2,\n\t\t},\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState:    \"chan send\",\n\t\t\t\tSleepMin: 101,\n\t\t\t\tSleepMax: 101,\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/gopkg.in/yaml.v2/yaml.go\",\n\t\t\t\t\t\t\tLine:       153,\n\t\t\t\t\t\t\tFunc:       Function{\"gopkg.in/yaml%2ev2.handleErr\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{Value: 0xc208033b22, Name: \"#2\"}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tLocked: true,\n\t\t\t},\n\t\t\tID: 3,\n\t\t},\n\t}\n\tut.AssertEqual(t, expected, goroutines)\n}\n\nfunc TestParseDumpAsm(t *testing.T) {\n\tdata := []string{\n\t\t\"panic: reflect.Set: value of type\",\n\t\t\"\",\n\t\t\"goroutine 16 [garbage collection]:\",\n\t\t\"runtime.switchtoM()\",\n\t\t\"\\t\" + goroot + \"/src/runtime/asm_amd64.s:198 fp=0xc20cfb80d8 sp=0xc20cfb80d0\",\n\t\t\"\",\n\t}\n\textra := &bytes.Buffer{}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), extra)\n\tut.AssertEqual(t, nil, err)\n\texpected := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState: \"garbage collection\",\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: goroot + \"/src/runtime/asm_amd64.s\",\n\t\t\t\t\t\t\tLine:       198,\n\t\t\t\t\t\t\tFunc:       Function{Raw: \"runtime.switchtoM\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID:    16,\n\t\t\tFirst: true,\n\t\t},\n\t}\n\tut.AssertEqual(t, expected, goroutines)\n\tut.AssertEqual(t, \"panic: reflect.Set: value of type\\n\\n\", extra.String())\n}\n\nfunc TestParseDumpLineErr(t *testing.T) {\n\tdata := []string{\n\t\t\"panic: reflect.Set: value of type\",\n\t\t\"\",\n\t\t\"goroutine 1 [running]:\",\n\t\t\"github.com/foo/bar.recurseType()\",\n\t\t\"\\t/gopath/src/github.com/foo/bar/baz.go:12345678901234567890\",\n\t\t\"\",\n\t}\n\textra := &bytes.Buffer{}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), extra)\n\tut.AssertEqual(t, errors.New(\"failed to parse int on line: \\\"\\t/gopath/src/github.com/foo/bar/baz.go:12345678901234567890\\n\\\"\"), err)\n\texpected := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState: \"running\",\n\t\t\t\tStack: Stack{Calls: []Call{{Func: Function{Raw: \"github.com/foo/bar.recurseType\"}}}},\n\t\t\t},\n\t\t\tID:    1,\n\t\t\tFirst: true,\n\t\t},\n\t}\n\n\tut.AssertEqual(t, expected, goroutines)\n}\n\nfunc TestParseDumpValueErr(t *testing.T) {\n\tdata := []string{\n\t\t\"panic: reflect.Set: value of type\",\n\t\t\"\",\n\t\t\"goroutine 1 [running]:\",\n\t\t\"github.com/foo/bar.recurseType(123456789012345678901)\",\n\t\t\"\\t/gopath/src/github.com/foo/bar/baz.go:9\",\n\t\t\"\",\n\t}\n\textra := &bytes.Buffer{}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), extra)\n\tut.AssertEqual(t, errors.New(\"failed to parse int on line: \\\"github.com/foo/bar.recurseType(123456789012345678901)\\n\\\"\"), err)\n\texpected := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{State: \"running\"},\n\t\t\tID:        1,\n\t\t\tFirst:     true,\n\t\t},\n\t}\n\n\tut.AssertEqual(t, expected, goroutines)\n}\n\nfunc TestParseDumpOrderErr(t *testing.T) {\n\tdata := []string{\n\t\t\"panic: reflect.Set: value of type\",\n\t\t\"\",\n\t\t\"goroutine 16 [garbage collection]:\",\n\t\t\"\t/gopath/src/gopkg.in/yaml.v2/yaml.go:153 +0xc6\",\n\t\t\"runtime.switchtoM()\",\n\t\t\"\\t\" + goroot + \"/src/runtime/asm_amd64.s:198 fp=0xc20cfb80d8 sp=0xc20cfb80d0\",\n\t\t\"\",\n\t}\n\textra := &bytes.Buffer{}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), extra)\n\tut.AssertEqual(t, errors.New(\"unexpected order\"), err)\n\texpected := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{State: \"garbage collection\"},\n\t\t\tID:        16,\n\t\t\tFirst:     true,\n\t\t},\n\t}\n\tut.AssertEqual(t, expected, goroutines)\n\tut.AssertEqual(t, \"panic: reflect.Set: value of type\\n\\n\", extra.String())\n}\n\nfunc TestParseDumpElided(t *testing.T) {\n\tdata := []string{\n\t\t\"panic: reflect.Set: value of type\",\n\t\t\"\",\n\t\t\"goroutine 16 [garbage collection]:\",\n\t\t\"github.com/foo/bar.recurseType(0x7f4fa9a3ec70, 0xc208062580, 0x7f4fa9a3e818, 0x50a820, 0xc20803a8a0)\",\n\t\t\"\\t/gopath/src/github.com/foo/bar/baz.go:53 +0x845 fp=0xc20cfc66d8 sp=0xc20cfc6470\",\n\t\t\"...additional frames elided...\",\n\t\t\"created by testing.RunTests\",\n\t\t\"\\t\" + goroot + \"/src/testing/testing.go:555 +0xa8b\",\n\t\t\"\",\n\t}\n\textra := &bytes.Buffer{}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), extra)\n\tut.AssertEqual(t, nil, err)\n\texpected := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState: \"garbage collection\",\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\t\t\t\tLine:       53,\n\t\t\t\t\t\t\tFunc:       Function{Raw: \"github.com/foo/bar.recurseType\"},\n\t\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\t\tValues: []Arg{\n\t\t\t\t\t\t\t\t\t{Value: 0x7f4fa9a3ec70},\n\t\t\t\t\t\t\t\t\t{Value: 0xc208062580},\n\t\t\t\t\t\t\t\t\t{Value: 0x7f4fa9a3e818},\n\t\t\t\t\t\t\t\t\t{Value: 0x50a820},\n\t\t\t\t\t\t\t\t\t{Value: 0xc20803a8a0},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tElided: true,\n\t\t\t\t},\n\t\t\t\tCreatedBy: Call{\n\t\t\t\t\tSourcePath: goroot + \"/src/testing/testing.go\",\n\t\t\t\t\tLine:       555,\n\t\t\t\t\tFunc:       Function{Raw: \"testing.RunTests\"},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID:    16,\n\t\t\tFirst: true,\n\t\t},\n\t}\n\tut.AssertEqual(t, expected, goroutines)\n\tut.AssertEqual(t, \"panic: reflect.Set: value of type\\n\\n\", extra.String())\n}\n\nfunc TestParseDumpSysCall(t *testing.T) {\n\tdata := []string{\n\t\t\"panic: reflect.Set: value of type\",\n\t\t\"\",\n\t\t\"goroutine 5 [syscall]:\",\n\t\t\"runtime.notetsleepg(0x918100, 0xffffffffffffffff, 0x1)\",\n\t\t\"\\t\" + goroot + \"/src/runtime/lock_futex.go:201 +0x52 fp=0xc208018f68 sp=0xc208018f40\",\n\t\t\"runtime.signal_recv(0x0)\",\n\t\t\"\\t\" + goroot + \"/src/runtime/sigqueue.go:109 +0x135 fp=0xc208018fa0 sp=0xc208018f68\",\n\t\t\"os/signal.loop()\",\n\t\t\"\\t\" + goroot + \"/src/os/signal/signal_unix.go:21 +0x1f fp=0xc208018fe0 sp=0xc208018fa0\",\n\t\t\"runtime.goexit()\",\n\t\t\"\\t\" + goroot + \"/src/runtime/asm_amd64.s:2232 +0x1 fp=0xc208018fe8 sp=0xc208018fe0\",\n\t\t\"created by os/signal.init·1\",\n\t\t\"\\t\" + goroot + \"/src/os/signal/signal_unix.go:27 +0x35\",\n\t\t\"\",\n\t}\n\textra := &bytes.Buffer{}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), extra)\n\tut.AssertEqual(t, nil, err)\n\texpected := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState: \"syscall\",\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: goroot + \"/src/runtime/lock_futex.go\",\n\t\t\t\t\t\t\tLine:       201,\n\t\t\t\t\t\t\tFunc:       Function{Raw: \"runtime.notetsleepg\"},\n\t\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\t\tValues: []Arg{\n\t\t\t\t\t\t\t\t\t{Value: 0x918100},\n\t\t\t\t\t\t\t\t\t{Value: 0xffffffffffffffff},\n\t\t\t\t\t\t\t\t\t{Value: 0x1},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: goroot + \"/src/runtime/sigqueue.go\",\n\t\t\t\t\t\t\tLine:       109,\n\t\t\t\t\t\t\tFunc:       Function{Raw: \"runtime.signal_recv\"},\n\t\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\t\tValues: []Arg{{}},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: goroot + \"/src/os/signal/signal_unix.go\",\n\t\t\t\t\t\t\tLine:       21,\n\t\t\t\t\t\t\tFunc:       Function{Raw: \"os/signal.loop\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: goroot + \"/src/runtime/asm_amd64.s\",\n\t\t\t\t\t\t\tLine:       2232,\n\t\t\t\t\t\t\tFunc:       Function{Raw: \"runtime.goexit\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tCreatedBy: Call{\n\t\t\t\t\tSourcePath: goroot + \"/src/os/signal/signal_unix.go\",\n\t\t\t\t\tLine:       27,\n\t\t\t\t\tFunc:       Function{Raw: \"os/signal.init·1\"},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID:    5,\n\t\t\tFirst: true,\n\t\t},\n\t}\n\tut.AssertEqual(t, expected, goroutines)\n\tut.AssertEqual(t, \"panic: reflect.Set: value of type\\n\\n\", extra.String())\n}\n\nfunc TestParseDumpUnavail(t *testing.T) {\n\tdata := []string{\n\t\t\"panic: reflect.Set: value of type\",\n\t\t\"\",\n\t\t\"goroutine 24 [running]:\",\n\t\t\"\\tgoroutine running on other thread; stack unavailable\",\n\t\t\"created by github.com/foo.New\",\n\t\t\"\\t/gopath/src/github.com/foo/bar.go:131 +0x381\",\n\t\t\"\",\n\t}\n\textra := &bytes.Buffer{}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), extra)\n\tut.AssertEqual(t, nil, err)\n\texpected := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState: \"running\",\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{{SourcePath: \"<unavailable>\"}},\n\t\t\t\t},\n\t\t\t\tCreatedBy: Call{\n\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar.go\",\n\t\t\t\t\tLine:       131,\n\t\t\t\t\tFunc:       Function{Raw: \"github.com/foo.New\"},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID:    24,\n\t\t\tFirst: true,\n\t\t},\n\t}\n\tut.AssertEqual(t, expected, goroutines)\n\tut.AssertEqual(t, \"panic: reflect.Set: value of type\\n\\n\", extra.String())\n}\n\nfunc TestParseDumpSameBucket(t *testing.T) {\n\t// 2 goroutines with the same signature\n\tdata := []string{\n\t\t\"panic: runtime error: index out of range\",\n\t\t\"\",\n\t\t\"goroutine 6 [chan receive]:\",\n\t\t\"main.func·001()\",\n\t\t\"\t/gopath/src/github.com/foo/bar/baz.go:72 +0x49\",\n\t\t\"created by main.mainImpl\",\n\t\t\"\t/gopath/src/github.com/foo/bar/baz.go:74 +0xeb\",\n\t\t\"\",\n\t\t\"goroutine 7 [chan receive]:\",\n\t\t\"main.func·001()\",\n\t\t\"\t/gopath/src/github.com/foo/bar/baz.go:72 +0x49\",\n\t\t\"created by main.mainImpl\",\n\t\t\"\t/gopath/src/github.com/foo/bar/baz.go:74 +0xeb\",\n\t\t\"\",\n\t}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), &bytes.Buffer{})\n\tut.AssertEqual(t, nil, err)\n\texpectedGR := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState: \"chan receive\",\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\t\t\t\tLine:       72,\n\t\t\t\t\t\t\tFunc:       Function{\"main.func·001\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tCreatedBy: Call{\n\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\t\tLine:       74,\n\t\t\t\t\tFunc:       Function{\"main.mainImpl\"},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID:    6,\n\t\t\tFirst: true,\n\t\t},\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState: \"chan receive\",\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\t\t\t\tLine:       72,\n\t\t\t\t\t\t\tFunc:       Function{\"main.func·001\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tCreatedBy: Call{\n\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\t\tLine:       74,\n\t\t\t\t\tFunc:       Function{\"main.mainImpl\"},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID: 7,\n\t\t},\n\t}\n\tut.AssertEqual(t, expectedGR, goroutines)\n\texpectedBuckets := Buckets{{expectedGR[0].Signature, []Goroutine{expectedGR[0], expectedGR[1]}}}\n\tut.AssertEqual(t, expectedBuckets, SortBuckets(Bucketize(goroutines, ExactLines)))\n}\n\nfunc TestBucketizeNotAggressive(t *testing.T) {\n\t// 2 goroutines with the same signature\n\tdata := []string{\n\t\t\"panic: runtime error: index out of range\",\n\t\t\"\",\n\t\t\"goroutine 6 [chan receive]:\",\n\t\t\"main.func·001(0x11000000, 2)\",\n\t\t\"\t/gopath/src/github.com/foo/bar/baz.go:72 +0x49\",\n\t\t\"\",\n\t\t\"goroutine 7 [chan receive]:\",\n\t\t\"main.func·001(0x21000000, 2)\",\n\t\t\"\t/gopath/src/github.com/foo/bar/baz.go:72 +0x49\",\n\t\t\"\",\n\t}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), &bytes.Buffer{})\n\tut.AssertEqual(t, nil, err)\n\texpectedGR := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState: \"chan receive\",\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\t\t\t\tLine:       72,\n\t\t\t\t\t\t\tFunc:       Function{\"main.func·001\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{0x11000000, \"\"}, {Value: 2}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID:    6,\n\t\t\tFirst: true,\n\t\t},\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState: \"chan receive\",\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\t\t\t\tLine:       72,\n\t\t\t\t\t\t\tFunc:       Function{\"main.func·001\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{0x21000000, \"#1\"}, {Value: 2}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID: 7,\n\t\t},\n\t}\n\tut.AssertEqual(t, expectedGR, goroutines)\n\texpectedBuckets := Buckets{\n\t\t{expectedGR[0].Signature, []Goroutine{expectedGR[0]}},\n\t\t{expectedGR[1].Signature, []Goroutine{expectedGR[1]}},\n\t}\n\tut.AssertEqual(t, expectedBuckets, SortBuckets(Bucketize(goroutines, ExactLines)))\n}\n\nfunc TestBucketizeAggressive(t *testing.T) {\n\t// 2 goroutines with the same signature\n\tdata := []string{\n\t\t\"panic: runtime error: index out of range\",\n\t\t\"\",\n\t\t\"goroutine 6 [chan receive, 10 minutes]:\",\n\t\t\"main.func·001(0x11000000, 2)\",\n\t\t\"\t/gopath/src/github.com/foo/bar/baz.go:72 +0x49\",\n\t\t\"\",\n\t\t\"goroutine 7 [chan receive, 50 minutes]:\",\n\t\t\"main.func·001(0x21000000, 2)\",\n\t\t\"\t/gopath/src/github.com/foo/bar/baz.go:72 +0x49\",\n\t\t\"\",\n\t\t\"goroutine 8 [chan receive, 100 minutes]:\",\n\t\t\"main.func·001(0x21000000, 2)\",\n\t\t\"\t/gopath/src/github.com/foo/bar/baz.go:72 +0x49\",\n\t\t\"\",\n\t}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), &bytes.Buffer{})\n\tut.AssertEqual(t, nil, err)\n\texpectedGR := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState:    \"chan receive\",\n\t\t\t\tSleepMin: 10,\n\t\t\t\tSleepMax: 10,\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\t\t\t\tLine:       72,\n\t\t\t\t\t\t\tFunc:       Function{\"main.func·001\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{0x11000000, \"\"}, {Value: 2}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID:    6,\n\t\t\tFirst: true,\n\t\t},\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState:    \"chan receive\",\n\t\t\t\tSleepMin: 50,\n\t\t\t\tSleepMax: 50,\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\t\t\t\tLine:       72,\n\t\t\t\t\t\t\tFunc:       Function{\"main.func·001\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{0x21000000, \"#1\"}, {Value: 2}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID: 7,\n\t\t},\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState:    \"chan receive\",\n\t\t\t\tSleepMin: 100,\n\t\t\t\tSleepMax: 100,\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\t\t\t\tLine:       72,\n\t\t\t\t\t\t\tFunc:       Function{\"main.func·001\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{0x21000000, \"#1\"}, {Value: 2}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID: 8,\n\t\t},\n\t}\n\tut.AssertEqual(t, expectedGR, goroutines)\n\tsignature := Signature{\n\t\tState:    \"chan receive\",\n\t\tSleepMin: 10,\n\t\tSleepMax: 100,\n\t\tStack: Stack{\n\t\t\tCalls: []Call{\n\t\t\t\t{\n\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\t\tLine:       72,\n\t\t\t\t\tFunc:       Function{\"main.func·001\"},\n\t\t\t\t\tArgs:       Args{Values: []Arg{{0x11000000, \"*\"}, {Value: 2}}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\texpectedBuckets := Buckets{{signature, []Goroutine{expectedGR[0], expectedGR[1], expectedGR[2]}}}\n\tut.AssertEqual(t, expectedBuckets, SortBuckets(Bucketize(goroutines, AnyPointer)))\n}\n\nfunc TestParseDumpNoOffset(t *testing.T) {\n\tdata := []string{\n\t\t\"panic: runtime error: index out of range\",\n\t\t\"\",\n\t\t\"goroutine 37 [runnable]:\",\n\t\t\"github.com/foo.func·002()\",\n\t\t\"\t/gopath/src/github.com/foo/bar.go:110\",\n\t\t\"created by github.com/foo.New\",\n\t\t\"\t/gopath/src/github.com/foo/bar.go:113 +0x43b\",\n\t\t\"\",\n\t}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), &bytes.Buffer{})\n\tut.AssertEqual(t, nil, err)\n\texpectedGR := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState: \"runnable\",\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar.go\",\n\t\t\t\t\t\t\tLine:       110,\n\t\t\t\t\t\t\tFunc:       Function{\"github.com/foo.func·002\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tCreatedBy: Call{\n\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar.go\",\n\t\t\t\t\tLine:       113,\n\t\t\t\t\tFunc:       Function{\"github.com/foo.New\"},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID:    37,\n\t\t\tFirst: true,\n\t\t},\n\t}\n\tut.AssertEqual(t, expectedGR, goroutines)\n}\n\nfunc TestParseDumpJunk(t *testing.T) {\n\t// For coverage of scanLines.\n\tdata := []string{\n\t\t\"panic: reflect.Set: value of type\",\n\t\t\"\",\n\t\t\"goroutine 1 [running]:\",\n\t\t\"junk\",\n\t}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), &bytes.Buffer{})\n\tut.AssertEqual(t, nil, err)\n\texpectedGR := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{State: \"running\"},\n\t\t\tID:        1,\n\t\t\tFirst:     true,\n\t\t},\n\t}\n\tut.AssertEqual(t, expectedGR, goroutines)\n}\n\nfunc TestParseCCode(t *testing.T) {\n\tdata := []string{\n\t\t\"SIGQUIT: quit\",\n\t\t\"PC=0x43f349\",\n\t\t\"\",\n\t\t\"goroutine 0 [idle]:\",\n\t\t\"runtime.epollwait(0x4, 0x7fff671c7118, 0xffffffff00000080, 0x0, 0xffffffff0028c1be, 0x0, 0x0, 0x0, 0x0, 0x0, ...)\",\n\t\t\"        \" + goroot + \"/src/runtime/sys_linux_amd64.s:400 +0x19\",\n\t\t\"runtime.netpoll(0x901b01, 0x0)\",\n\t\t\"        \" + goroot + \"/src/runtime/netpoll_epoll.go:68 +0xa3\",\n\t\t\"findrunnable(0xc208012000)\",\n\t\t\"        \" + goroot + \"/src/runtime/proc.c:1472 +0x485\",\n\t\t\"schedule()\",\n\t\t\"        \" + goroot + \"/src/runtime/proc.c:1575 +0x151\",\n\t\t\"runtime.park_m(0xc2080017a0)\",\n\t\t\"        \" + goroot + \"/src/runtime/proc.c:1654 +0x113\",\n\t\t\"runtime.mcall(0x432684)\",\n\t\t\"        \" + goroot + \"/src/runtime/asm_amd64.s:186 +0x5a\",\n\t\t\"\",\n\t}\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\n\")), &bytes.Buffer{})\n\tut.AssertEqual(t, nil, err)\n\texpectedGR := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState: \"idle\",\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: goroot + \"/src/runtime/sys_linux_amd64.s\",\n\t\t\t\t\t\t\tLine:       400,\n\t\t\t\t\t\t\tFunc:       Function{\"runtime.epollwait\"},\n\t\t\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\t\t\tValues: []Arg{\n\t\t\t\t\t\t\t\t\t{Value: 0x4},\n\t\t\t\t\t\t\t\t\t{Value: 0x7fff671c7118},\n\t\t\t\t\t\t\t\t\t{Value: 0xffffffff00000080},\n\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t{Value: 0xffffffff0028c1be},\n\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tElided: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: goroot + \"/src/runtime/netpoll_epoll.go\",\n\t\t\t\t\t\t\tLine:       68,\n\t\t\t\t\t\t\tFunc:       Function{\"runtime.netpoll\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{Value: 0x901b01}, {}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: goroot + \"/src/runtime/proc.c\",\n\t\t\t\t\t\t\tLine:       1472,\n\t\t\t\t\t\t\tFunc:       Function{\"findrunnable\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{Value: 0xc208012000}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: goroot + \"/src/runtime/proc.c\",\n\t\t\t\t\t\t\tLine:       1575,\n\t\t\t\t\t\t\tFunc:       Function{\"schedule\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: goroot + \"/src/runtime/proc.c\",\n\t\t\t\t\t\t\tLine:       1654,\n\t\t\t\t\t\t\tFunc:       Function{\"runtime.park_m\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{Value: 0xc2080017a0}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: goroot + \"/src/runtime/asm_amd64.s\",\n\t\t\t\t\t\t\tLine:       186,\n\t\t\t\t\t\t\tFunc:       Function{\"runtime.mcall\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{Value: 0x432684}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID:    0,\n\t\t\tFirst: true,\n\t\t},\n\t}\n\tut.AssertEqual(t, expectedGR, goroutines)\n}\n\nfunc TestParseWithCarriageReturn(t *testing.T) {\n\tdata := []string{\n\t\t\"goroutine 1 [running]:\",\n\t\t\"github.com/cockroachdb/cockroach/storage/engine._Cfunc_DBIterSeek()\",\n\t\t\" ??:0 +0x6d\",\n\t\t\"gopkg.in/yaml%2ev2.handleErr(0xc208033b20)\",\n\t\t\"\t/gopath/src/gopkg.in/yaml.v2/yaml.go:153 +0xc6\",\n\t\t\"reflect.Value.assignTo(0x570860, 0xc20803f3e0, 0x15)\",\n\t\t\"\t\" + goroot + \"/src/reflect/value.go:2125 +0x368\",\n\t\t\"main.main()\",\n\t\t\"\t/gopath/src/github.com/foo/bar/baz.go:428 +0x27\",\n\t\t\"\",\n\t}\n\n\tgoroutines, err := ParseDump(bytes.NewBufferString(strings.Join(data, \"\\r\\n\")), ioutil.Discard)\n\tut.AssertEqual(t, nil, err)\n\texpected := []Goroutine{\n\t\t{\n\t\t\tSignature: Signature{\n\t\t\t\tState: \"running\",\n\t\t\t\tStack: Stack{\n\t\t\t\t\tCalls: []Call{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"??\",\n\t\t\t\t\t\t\tFunc:       Function{\"github.com/cockroachdb/cockroach/storage/engine._Cfunc_DBIterSeek\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/gopkg.in/yaml.v2/yaml.go\",\n\t\t\t\t\t\t\tLine:       153,\n\t\t\t\t\t\t\tFunc:       Function{\"gopkg.in/yaml%2ev2.handleErr\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{Value: 0xc208033b20}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: goroot + \"/src/reflect/value.go\",\n\t\t\t\t\t\t\tLine:       2125,\n\t\t\t\t\t\t\tFunc:       Function{\"reflect.Value.assignTo\"},\n\t\t\t\t\t\t\tArgs:       Args{Values: []Arg{{Value: 0x570860}, {Value: 0xc20803f3e0}, {Value: 0x15}}},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\t\t\t\tLine:       428,\n\t\t\t\t\t\t\tFunc:       Function{\"main.main\"},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tID:    1,\n\t\t\tFirst: true,\n\t\t},\n\t}\n\tut.AssertEqual(t, expected, goroutines)\n}\n\nfunc TestCallPkg1(t *testing.T) {\n\tc := Call{\n\t\tSourcePath: \"/gopath/src/gopkg.in/yaml.v2/yaml.go\",\n\t\tLine:       153,\n\t\tFunc:       Function{\"gopkg.in/yaml%2ev2.handleErr\"},\n\t\tArgs:       Args{Values: []Arg{{Value: 0xc208033b20}}},\n\t}\n\tut.AssertEqual(t, \"yaml.go\", c.SourceName())\n\tut.AssertEqual(t, filepath.Join(\"yaml.v2\", \"yaml.go\"), c.PkgSource())\n\tut.AssertEqual(t, \"gopkg.in/yaml.v2.handleErr\", c.Func.String())\n\tut.AssertEqual(t, \"handleErr\", c.Func.Name())\n\t// This is due to directory name not matching the package name.\n\tut.AssertEqual(t, \"yaml.v2\", c.Func.PkgName())\n\tut.AssertEqual(t, false, c.Func.IsExported())\n\tut.AssertEqual(t, false, c.IsStdlib())\n\tut.AssertEqual(t, false, c.IsPkgMain())\n}\n\nfunc TestCallPkg2(t *testing.T) {\n\tc := Call{\n\t\tSourcePath: \"/gopath/src/gopkg.in/yaml.v2/yaml.go\",\n\t\tLine:       153,\n\t\tFunc:       Function{\"gopkg.in/yaml%2ev2.(*decoder).unmarshal\"},\n\t\tArgs:       Args{Values: []Arg{{Value: 0xc208033b20}}},\n\t}\n\tut.AssertEqual(t, \"yaml.go\", c.SourceName())\n\tut.AssertEqual(t, filepath.Join(\"yaml.v2\", \"yaml.go\"), c.PkgSource())\n\t// TODO(maruel): Using '/' for this function is inconsistent on Windows\n\t// w.r.t. other functions.\n\tut.AssertEqual(t, \"gopkg.in/yaml.v2.(*decoder).unmarshal\", c.Func.String())\n\tut.AssertEqual(t, \"(*decoder).unmarshal\", c.Func.Name())\n\t// This is due to directory name not matching the package name.\n\tut.AssertEqual(t, \"yaml.v2\", c.Func.PkgName())\n\tut.AssertEqual(t, false, c.Func.IsExported())\n\tut.AssertEqual(t, false, c.IsStdlib())\n\tut.AssertEqual(t, false, c.IsPkgMain())\n}\n\nfunc TestCallStdlib(t *testing.T) {\n\tc := Call{\n\t\tSourcePath: goroot + \"/src/reflect/value.go\",\n\t\tLine:       2125,\n\t\tFunc:       Function{\"reflect.Value.assignTo\"},\n\t\tArgs:       Args{Values: []Arg{{Value: 0x570860}, {Value: 0xc20803f3e0}, {Value: 0x15}}},\n\t}\n\tut.AssertEqual(t, \"value.go\", c.SourceName())\n\tut.AssertEqual(t, \"value.go:2125\", c.SourceLine())\n\tut.AssertEqual(t, filepath.Join(\"reflect\", \"value.go\"), c.PkgSource())\n\tut.AssertEqual(t, \"reflect.Value.assignTo\", c.Func.String())\n\tut.AssertEqual(t, \"Value.assignTo\", c.Func.Name())\n\tut.AssertEqual(t, \"reflect\", c.Func.PkgName())\n\tut.AssertEqual(t, false, c.Func.IsExported())\n\tut.AssertEqual(t, true, c.IsStdlib())\n\tut.AssertEqual(t, false, c.IsPkgMain())\n}\n\nfunc TestCallMain(t *testing.T) {\n\tc := Call{\n\t\tSourcePath: \"/gopath/src/github.com/foo/bar/main.go\",\n\t\tLine:       428,\n\t\tFunc:       Function{\"main.main\"},\n\t}\n\tut.AssertEqual(t, \"main.go\", c.SourceName())\n\tut.AssertEqual(t, \"main.go:428\", c.SourceLine())\n\tut.AssertEqual(t, filepath.Join(\"bar\", \"main.go\"), c.PkgSource())\n\tut.AssertEqual(t, \"main.main\", c.Func.String())\n\tut.AssertEqual(t, \"main\", c.Func.Name())\n\tut.AssertEqual(t, \"main\", c.Func.PkgName())\n\tut.AssertEqual(t, true, c.Func.IsExported())\n\tut.AssertEqual(t, false, c.IsStdlib())\n\tut.AssertEqual(t, true, c.IsPkgMain())\n}\n\nfunc TestCallC(t *testing.T) {\n\tc := Call{\n\t\tSourcePath: goroot + \"/src/runtime/proc.c\",\n\t\tLine:       1472,\n\t\tFunc:       Function{\"findrunnable\"},\n\t\tArgs:       Args{Values: []Arg{{Value: 0xc208012000}}},\n\t}\n\tut.AssertEqual(t, \"proc.c\", c.SourceName())\n\tut.AssertEqual(t, \"proc.c:1472\", c.SourceLine())\n\tut.AssertEqual(t, filepath.Join(\"runtime\", \"proc.c\"), c.PkgSource())\n\tut.AssertEqual(t, \"findrunnable\", c.Func.String())\n\tut.AssertEqual(t, \"findrunnable\", c.Func.Name())\n\tut.AssertEqual(t, \"\", c.Func.PkgName())\n\tut.AssertEqual(t, false, c.Func.IsExported())\n\tut.AssertEqual(t, true, c.IsStdlib())\n\tut.AssertEqual(t, false, c.IsPkgMain())\n}\n\nfunc TestArgs(t *testing.T) {\n\ta := Args{\n\t\tValues: []Arg{\n\t\t\t{Value: 0x4},\n\t\t\t{Value: 0x7fff671c7118},\n\t\t\t{Value: 0xffffffff00000080},\n\t\t\t{},\n\t\t\t{Value: 0xffffffff0028c1be},\n\t\t\t{},\n\t\t\t{},\n\t\t\t{},\n\t\t\t{},\n\t\t\t{},\n\t\t},\n\t\tElided: true,\n\t}\n\tut.AssertEqual(t, \"0x4, 0x7fff671c7118, 0xffffffff00000080, 0, 0xffffffff0028c1be, 0, 0, 0, 0, 0, ...\", a.String())\n}\n\nfunc TestFunctionAnonymous(t *testing.T) {\n\tf := Function{\"main.func·001\"}\n\tut.AssertEqual(t, \"main.func·001\", f.String())\n\tut.AssertEqual(t, \"main.func·001\", f.PkgDotName())\n\tut.AssertEqual(t, \"func·001\", f.Name())\n\tut.AssertEqual(t, \"main\", f.PkgName())\n\tut.AssertEqual(t, false, f.IsExported())\n}\n\nfunc TestFunctionGC(t *testing.T) {\n\tf := Function{\"gc\"}\n\tut.AssertEqual(t, \"gc\", f.String())\n\tut.AssertEqual(t, \"gc\", f.PkgDotName())\n\tut.AssertEqual(t, \"gc\", f.Name())\n\tut.AssertEqual(t, \"\", f.PkgName())\n\tut.AssertEqual(t, false, f.IsExported())\n}\n"
  },
  {
    "path": "vendor/github.com/maruel/panicparse/stack/ui.go",
    "content": "// Copyright 2016 Marc-Antoine Ruel. All rights reserved.\n// Use of this source code is governed under the Apache License, Version 2.0\n// that can be found in the LICENSE file.\n\npackage stack\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\n// Palette defines the color used.\n//\n// An empty object Palette{} can be used to disable coloring.\ntype Palette struct {\n\tEOLReset string\n\n\t// Routine header.\n\tRoutineFirst string // The first routine printed.\n\tRoutine      string // Following routines.\n\tCreatedBy    string\n\n\t// Call line.\n\tPackage                string\n\tSourceFile             string\n\tFunctionStdLib         string\n\tFunctionStdLibExported string\n\tFunctionMain           string\n\tFunctionOther          string\n\tFunctionOtherExported  string\n\tArguments              string\n}\n\n// CalcLengths returns the maximum length of the source lines and package names.\nfunc CalcLengths(buckets Buckets, fullPath bool) (int, int) {\n\tsrcLen := 0\n\tpkgLen := 0\n\tfor _, bucket := range buckets {\n\t\tfor _, line := range bucket.Signature.Stack.Calls {\n\t\t\tl := 0\n\t\t\tif fullPath {\n\t\t\t\tl = len(line.FullSourceLine())\n\t\t\t} else {\n\t\t\t\tl = len(line.SourceLine())\n\t\t\t}\n\t\t\tif l > srcLen {\n\t\t\t\tsrcLen = l\n\t\t\t}\n\t\t\tl = len(line.Func.PkgName())\n\t\t\tif l > pkgLen {\n\t\t\t\tpkgLen = l\n\t\t\t}\n\t\t}\n\t}\n\treturn srcLen, pkgLen\n}\n\n// functionColor returns the color to be used for the function name based on\n// the type of package the function is in.\nfunc (p *Palette) functionColor(line *Call) string {\n\tif line.IsStdlib() {\n\t\tif line.Func.IsExported() {\n\t\t\treturn p.FunctionStdLibExported\n\t\t}\n\t\treturn p.FunctionStdLib\n\t} else if line.IsPkgMain() {\n\t\treturn p.FunctionMain\n\t} else if line.Func.IsExported() {\n\t\treturn p.FunctionOtherExported\n\t}\n\treturn p.FunctionOther\n}\n\n// routineColor returns the color for the header of the goroutines bucket.\nfunc (p *Palette) routineColor(bucket *Bucket, multipleBuckets bool) string {\n\tif bucket.First() && multipleBuckets {\n\t\treturn p.RoutineFirst\n\t}\n\treturn p.Routine\n}\n\n// BucketHeader prints the header of a goroutine signature.\nfunc (p *Palette) BucketHeader(bucket *Bucket, fullPath, multipleBuckets bool) string {\n\textra := \"\"\n\tif bucket.SleepMax != 0 {\n\t\tif bucket.SleepMin != bucket.SleepMax {\n\t\t\textra += fmt.Sprintf(\" [%d~%d minutes]\", bucket.SleepMin, bucket.SleepMax)\n\t\t} else {\n\t\t\textra += fmt.Sprintf(\" [%d minutes]\", bucket.SleepMax)\n\t\t}\n\t}\n\tif bucket.Locked {\n\t\textra += \" [locked]\"\n\t}\n\tcreated := bucket.CreatedBy.Func.PkgDotName()\n\tif created != \"\" {\n\t\tcreated += \" @ \"\n\t\tif fullPath {\n\t\t\tcreated += bucket.CreatedBy.FullSourceLine()\n\t\t} else {\n\t\t\tcreated += bucket.CreatedBy.SourceLine()\n\t\t}\n\t\textra += p.CreatedBy + \" [Created by \" + created + \"]\"\n\t}\n\treturn fmt.Sprintf(\n\t\t\"%s%d: %s%s%s\\n\",\n\t\tp.routineColor(bucket, multipleBuckets), len(bucket.Routines),\n\t\tbucket.State, extra,\n\t\tp.EOLReset)\n}\n\n// callLine prints one stack line.\nfunc (p *Palette) callLine(line *Call, srcLen, pkgLen int, fullPath bool) string {\n\tsrc := \"\"\n\tif fullPath {\n\t\tsrc = line.FullSourceLine()\n\t} else {\n\t\tsrc = line.SourceLine()\n\t}\n\treturn fmt.Sprintf(\n\t\t\"    %s%-*s %s%-*s %s%s%s(%s)%s\",\n\t\tp.Package, pkgLen, line.Func.PkgName(),\n\t\tp.SourceFile, srcLen, src,\n\t\tp.functionColor(line), line.Func.Name(),\n\t\tp.Arguments, line.Args,\n\t\tp.EOLReset)\n}\n\n// StackLines prints one complete stack trace, without the header.\nfunc (p *Palette) StackLines(signature *Signature, srcLen, pkgLen int, fullPath bool) string {\n\tout := make([]string, len(signature.Stack.Calls))\n\tfor i := range signature.Stack.Calls {\n\t\tout[i] = p.callLine(&signature.Stack.Calls[i], srcLen, pkgLen, fullPath)\n\t}\n\tif signature.Stack.Elided {\n\t\tout = append(out, \"    (...)\")\n\t}\n\treturn strings.Join(out, \"\\n\") + \"\\n\"\n}\n"
  },
  {
    "path": "vendor/github.com/maruel/panicparse/stack/ui_test.go",
    "content": "// Copyright 2016 Marc-Antoine Ruel. All rights reserved.\n// Use of this source code is governed under the Apache License, Version 2.0\n// that can be found in the LICENSE file.\n\npackage stack\n\nimport (\n\t\"testing\"\n\n\t\"github.com/maruel/ut\"\n)\n\nvar p = &Palette{\n\tEOLReset:               \"A\",\n\tRoutineFirst:           \"B\",\n\tRoutine:                \"C\",\n\tCreatedBy:              \"D\",\n\tPackage:                \"E\",\n\tSourceFile:             \"F\",\n\tFunctionStdLib:         \"G\",\n\tFunctionStdLibExported: \"H\",\n\tFunctionMain:           \"I\",\n\tFunctionOther:          \"J\",\n\tFunctionOtherExported:  \"K\",\n\tArguments:              \"L\",\n}\n\nfunc TestCalcLengths(t *testing.T) {\n\tt.Parallel()\n\tb := Buckets{\n\t\t{\n\t\t\tSignature{Stack: Stack{Calls: []Call{{SourcePath: \"/gopath/baz.go\", Func: Function{\"main.func·001\"}}}}},\n\t\t\tnil,\n\t\t},\n\t}\n\tsrcLen, pkgLen := CalcLengths(b, true)\n\tut.AssertEqual(t, 16, srcLen)\n\tut.AssertEqual(t, 4, pkgLen)\n\tsrcLen, pkgLen = CalcLengths(b, false)\n\tut.AssertEqual(t, 8, srcLen)\n\tut.AssertEqual(t, 4, pkgLen)\n}\n\nfunc TestBucketHeader(t *testing.T) {\n\tt.Parallel()\n\tb := &Bucket{\n\t\tSignature{\n\t\t\tState: \"chan receive\",\n\t\t\tCreatedBy: Call{\n\t\t\t\tSourcePath: \"/gopath/src/github.com/foo/bar/baz.go\",\n\t\t\t\tLine:       74,\n\t\t\t\tFunc:       Function{\"main.mainImpl\"},\n\t\t\t},\n\t\t\tSleepMax: 6,\n\t\t\tSleepMin: 2,\n\t\t},\n\t\t[]Goroutine{\n\t\t\t{\n\t\t\t\tFirst: true,\n\t\t\t},\n\t\t\t{},\n\t\t},\n\t}\n\tut.AssertEqual(t, \"B2: chan receive [2~6 minutes]D [Created by main.mainImpl @ /gopath/src/github.com/foo/bar/baz.go:74]A\\n\", p.BucketHeader(b, true, true))\n\tut.AssertEqual(t, \"C2: chan receive [2~6 minutes]D [Created by main.mainImpl @ /gopath/src/github.com/foo/bar/baz.go:74]A\\n\", p.BucketHeader(b, true, false))\n\tut.AssertEqual(t, \"B2: chan receive [2~6 minutes]D [Created by main.mainImpl @ baz.go:74]A\\n\", p.BucketHeader(b, false, true))\n\tut.AssertEqual(t, \"C2: chan receive [2~6 minutes]D [Created by main.mainImpl @ baz.go:74]A\\n\", p.BucketHeader(b, false, false))\n\n\tb = &Bucket{\n\t\tSignature{\n\t\t\tState:    \"b0rked\",\n\t\t\tSleepMax: 6,\n\t\t\tSleepMin: 6,\n\t\t\tLocked:   true,\n\t\t},\n\t\tnil,\n\t}\n\tut.AssertEqual(t, \"C0: b0rked [6 minutes] [locked]A\\n\", p.BucketHeader(b, false, false))\n}\n\nfunc TestStackLines(t *testing.T) {\n\tt.Parallel()\n\ts := &Signature{\n\t\tState: \"idle\",\n\t\tStack: Stack{\n\t\t\tCalls: []Call{\n\t\t\t\t{\n\t\t\t\t\tSourcePath: goroot + \"/src/runtime/sys_linux_amd64.s\",\n\t\t\t\t\tLine:       400,\n\t\t\t\t\tFunc:       Function{\"runtime.Epollwait\"},\n\t\t\t\t\tArgs: Args{\n\t\t\t\t\t\tValues: []Arg{\n\t\t\t\t\t\t\t{Value: 0x4},\n\t\t\t\t\t\t\t{Value: 0x7fff671c7118},\n\t\t\t\t\t\t\t{Value: 0xffffffff00000080},\n\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t{Value: 0xffffffff0028c1be},\n\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tElided: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tSourcePath: goroot + \"/src/runtime/netpoll_epoll.go\",\n\t\t\t\t\tLine:       68,\n\t\t\t\t\tFunc:       Function{\"runtime.netpoll\"},\n\t\t\t\t\tArgs:       Args{Values: []Arg{{Value: 0x901b01}, {}}},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tSourcePath: \"/src/main.go\",\n\t\t\t\t\tLine:       1472,\n\t\t\t\t\tFunc:       Function{\"main.Main\"},\n\t\t\t\t\tArgs:       Args{Values: []Arg{{Value: 0xc208012000}}},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tSourcePath: \"/src/foo/bar.go\",\n\t\t\t\t\tLine:       1575,\n\t\t\t\t\tFunc:       Function{\"foo.OtherExported\"},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tSourcePath: \"/src/foo/bar.go\",\n\t\t\t\t\tLine:       10,\n\t\t\t\t\tFunc:       Function{\"foo.otherPrivate\"},\n\t\t\t\t},\n\t\t\t},\n\t\t\tElided: true,\n\t\t},\n\t}\n\texpected := \"\" +\n\t\t\"    Eruntime    F\" + goroot + \"/src/runtime/sys_linux_amd64.s:400 HEpollwaitL(0x4, 0x7fff671c7118, 0xffffffff00000080, 0, 0xffffffff0028c1be, 0, 0, 0, 0, 0, ...)A\\n\" +\n\t\t\"    Eruntime    F\" + goroot + \"/src/runtime/netpoll_epoll.go:68 GnetpollL(0x901b01, 0)A\\n\" +\n\t\t\"    Emain       F/src/main.go:1472 IMainL(0xc208012000)A\\n\" +\n\t\t\"    Efoo        F/src/foo/bar.go:1575 KOtherExportedL()A\\n\" +\n\t\t\"    Efoo        F/src/foo/bar.go:10 JotherPrivateL()A\\n\" +\n\t\t\"    (...)\\n\"\n\tut.AssertEqual(t, expected, p.StackLines(s, 10, 10, true))\n\texpected = \"\" +\n\t\t\"    Eruntime    Fsys_linux_amd64.s:400 HEpollwaitL(0x4, 0x7fff671c7118, 0xffffffff00000080, 0, 0xffffffff0028c1be, 0, 0, 0, 0, 0, ...)A\\n\" +\n\t\t\"    Eruntime    Fnetpoll_epoll.go:68 GnetpollL(0x901b01, 0)A\\n\" +\n\t\t\"    Emain       Fmain.go:1472 IMainL(0xc208012000)A\\n\" +\n\t\t\"    Efoo        Fbar.go:1575 KOtherExportedL()A\\n\" +\n\t\t\"    Efoo        Fbar.go:10  JotherPrivateL()A\\n\" +\n\t\t\"    (...)\\n\"\n\tut.AssertEqual(t, expected, p.StackLines(s, 10, 10, false))\n}\n"
  },
  {
    "path": "vendor/github.com/mattn/go-runewidth/.travis.yml",
    "content": "language: go\ngo:\n  - tip\nbefore_install:\n  - go get github.com/mattn/goveralls\n  - go get golang.org/x/tools/cmd/cover\nscript:\n    - $HOME/gopath/bin/goveralls -repotoken lAKAWPzcGsD3A8yBX3BGGtRUdJ6CaGERL\n"
  },
  {
    "path": "vendor/github.com/mattn/go-runewidth/LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2016 Yasuhiro Matsumoto\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "vendor/github.com/mattn/go-runewidth/README.mkd",
    "content": "go-runewidth\n============\n\n[![Build Status](https://travis-ci.org/mattn/go-runewidth.png?branch=master)](https://travis-ci.org/mattn/go-runewidth)\n[![Coverage Status](https://coveralls.io/repos/mattn/go-runewidth/badge.png?branch=HEAD)](https://coveralls.io/r/mattn/go-runewidth?branch=HEAD)\n[![GoDoc](https://godoc.org/github.com/mattn/go-runewidth?status.svg)](http://godoc.org/github.com/mattn/go-runewidth)\n[![Go Report Card](https://goreportcard.com/badge/github.com/mattn/go-runewidth)](https://goreportcard.com/report/github.com/mattn/go-runewidth)\n\nProvides functions to get fixed width of the character or string.\n\nUsage\n-----\n\n```go\nrunewidth.StringWidth(\"つのだ☆HIRO\") == 12\n```\n\n\nAuthor\n------\n\nYasuhiro Matsumoto\n\nLicense\n-------\n\nunder the MIT License: http://mattn.mit-license.org/2013\n"
  },
  {
    "path": "vendor/github.com/mattn/go-runewidth/runewidth.go",
    "content": "package runewidth\n\nvar (\n\t// EastAsianWidth will be set true if the current locale is CJK\n\tEastAsianWidth = IsEastAsian()\n\n\t// DefaultCondition is a condition in current locale\n\tDefaultCondition = &Condition{EastAsianWidth}\n)\n\ntype interval struct {\n\tfirst rune\n\tlast  rune\n}\n\ntype table []interval\n\nfunc inTables(r rune, ts ...table) bool {\n\tfor _, t := range ts {\n\t\tif inTable(r, t) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc inTable(r rune, t table) bool {\n\t// func (t table) IncludesRune(r rune) bool {\n\tif r < t[0].first {\n\t\treturn false\n\t}\n\n\tbot := 0\n\ttop := len(t) - 1\n\tfor top >= bot {\n\t\tmid := (bot + top) / 2\n\n\t\tswitch {\n\t\tcase t[mid].last < r:\n\t\t\tbot = mid + 1\n\t\tcase t[mid].first > r:\n\t\t\ttop = mid - 1\n\t\tdefault:\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nvar private = table{\n\t{0x00E000, 0x00F8FF}, {0x0F0000, 0x0FFFFD}, {0x100000, 0x10FFFD},\n}\n\nvar nonprint = table{\n\t{0x0000, 0x001F}, {0x007F, 0x009F}, {0x00AD, 0x00AD},\n\t{0x070F, 0x070F}, {0x180B, 0x180E}, {0x200B, 0x200F},\n\t{0x202A, 0x202E}, {0x206A, 0x206F}, {0xD800, 0xDFFF},\n\t{0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFB}, {0xFFFE, 0xFFFF},\n}\n\nvar combining = table{\n\t{0x0300, 0x036F}, {0x0483, 0x0489}, {0x0591, 0x05BD},\n\t{0x05BF, 0x05BF}, {0x05C1, 0x05C2}, {0x05C4, 0x05C5},\n\t{0x05C7, 0x05C7}, {0x0610, 0x061A}, {0x064B, 0x065F},\n\t{0x0670, 0x0670}, {0x06D6, 0x06DC}, {0x06DF, 0x06E4},\n\t{0x06E7, 0x06E8}, {0x06EA, 0x06ED}, {0x0711, 0x0711},\n\t{0x0730, 0x074A}, {0x07A6, 0x07B0}, {0x07EB, 0x07F3},\n\t{0x0816, 0x0819}, {0x081B, 0x0823}, {0x0825, 0x0827},\n\t{0x0829, 0x082D}, {0x0859, 0x085B}, {0x08D4, 0x08E1},\n\t{0x08E3, 0x0903}, {0x093A, 0x093C}, {0x093E, 0x094F},\n\t{0x0951, 0x0957}, {0x0962, 0x0963}, {0x0981, 0x0983},\n\t{0x09BC, 0x09BC}, {0x09BE, 0x09C4}, {0x09C7, 0x09C8},\n\t{0x09CB, 0x09CD}, {0x09D7, 0x09D7}, {0x09E2, 0x09E3},\n\t{0x0A01, 0x0A03}, {0x0A3C, 0x0A3C}, {0x0A3E, 0x0A42},\n\t{0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A51, 0x0A51},\n\t{0x0A70, 0x0A71}, {0x0A75, 0x0A75}, {0x0A81, 0x0A83},\n\t{0x0ABC, 0x0ABC}, {0x0ABE, 0x0AC5}, {0x0AC7, 0x0AC9},\n\t{0x0ACB, 0x0ACD}, {0x0AE2, 0x0AE3}, {0x0B01, 0x0B03},\n\t{0x0B3C, 0x0B3C}, {0x0B3E, 0x0B44}, {0x0B47, 0x0B48},\n\t{0x0B4B, 0x0B4D}, {0x0B56, 0x0B57}, {0x0B62, 0x0B63},\n\t{0x0B82, 0x0B82}, {0x0BBE, 0x0BC2}, {0x0BC6, 0x0BC8},\n\t{0x0BCA, 0x0BCD}, {0x0BD7, 0x0BD7}, {0x0C00, 0x0C03},\n\t{0x0C3E, 0x0C44}, {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D},\n\t{0x0C55, 0x0C56}, {0x0C62, 0x0C63}, {0x0C81, 0x0C83},\n\t{0x0CBC, 0x0CBC}, {0x0CBE, 0x0CC4}, {0x0CC6, 0x0CC8},\n\t{0x0CCA, 0x0CCD}, {0x0CD5, 0x0CD6}, {0x0CE2, 0x0CE3},\n\t{0x0D01, 0x0D03}, {0x0D3E, 0x0D44}, {0x0D46, 0x0D48},\n\t{0x0D4A, 0x0D4D}, {0x0D57, 0x0D57}, {0x0D62, 0x0D63},\n\t{0x0D82, 0x0D83}, {0x0DCA, 0x0DCA}, {0x0DCF, 0x0DD4},\n\t{0x0DD6, 0x0DD6}, {0x0DD8, 0x0DDF}, {0x0DF2, 0x0DF3},\n\t{0x0E31, 0x0E31}, {0x0E34, 0x0E3A}, {0x0E47, 0x0E4E},\n\t{0x0EB1, 0x0EB1}, {0x0EB4, 0x0EB9}, {0x0EBB, 0x0EBC},\n\t{0x0EC8, 0x0ECD}, {0x0F18, 0x0F19}, {0x0F35, 0x0F35},\n\t{0x0F37, 0x0F37}, {0x0F39, 0x0F39}, {0x0F3E, 0x0F3F},\n\t{0x0F71, 0x0F84}, {0x0F86, 0x0F87}, {0x0F8D, 0x0F97},\n\t{0x0F99, 0x0FBC}, {0x0FC6, 0x0FC6}, {0x102B, 0x103E},\n\t{0x1056, 0x1059}, {0x105E, 0x1060}, {0x1062, 0x1064},\n\t{0x1067, 0x106D}, {0x1071, 0x1074}, {0x1082, 0x108D},\n\t{0x108F, 0x108F}, {0x109A, 0x109D}, {0x135D, 0x135F},\n\t{0x1712, 0x1714}, {0x1732, 0x1734}, {0x1752, 0x1753},\n\t{0x1772, 0x1773}, {0x17B4, 0x17D3}, {0x17DD, 0x17DD},\n\t{0x180B, 0x180D}, {0x1885, 0x1886}, {0x18A9, 0x18A9},\n\t{0x1920, 0x192B}, {0x1930, 0x193B}, {0x1A17, 0x1A1B},\n\t{0x1A55, 0x1A5E}, {0x1A60, 0x1A7C}, {0x1A7F, 0x1A7F},\n\t{0x1AB0, 0x1ABE}, {0x1B00, 0x1B04}, {0x1B34, 0x1B44},\n\t{0x1B6B, 0x1B73}, {0x1B80, 0x1B82}, {0x1BA1, 0x1BAD},\n\t{0x1BE6, 0x1BF3}, {0x1C24, 0x1C37}, {0x1CD0, 0x1CD2},\n\t{0x1CD4, 0x1CE8}, {0x1CED, 0x1CED}, {0x1CF2, 0x1CF4},\n\t{0x1CF8, 0x1CF9}, {0x1DC0, 0x1DF5}, {0x1DFB, 0x1DFF},\n\t{0x20D0, 0x20F0}, {0x2CEF, 0x2CF1}, {0x2D7F, 0x2D7F},\n\t{0x2DE0, 0x2DFF}, {0x302A, 0x302F}, {0x3099, 0x309A},\n\t{0xA66F, 0xA672}, {0xA674, 0xA67D}, {0xA69E, 0xA69F},\n\t{0xA6F0, 0xA6F1}, {0xA802, 0xA802}, {0xA806, 0xA806},\n\t{0xA80B, 0xA80B}, {0xA823, 0xA827}, {0xA880, 0xA881},\n\t{0xA8B4, 0xA8C5}, {0xA8E0, 0xA8F1}, {0xA926, 0xA92D},\n\t{0xA947, 0xA953}, {0xA980, 0xA983}, {0xA9B3, 0xA9C0},\n\t{0xA9E5, 0xA9E5}, {0xAA29, 0xAA36}, {0xAA43, 0xAA43},\n\t{0xAA4C, 0xAA4D}, {0xAA7B, 0xAA7D}, {0xAAB0, 0xAAB0},\n\t{0xAAB2, 0xAAB4}, {0xAAB7, 0xAAB8}, {0xAABE, 0xAABF},\n\t{0xAAC1, 0xAAC1}, {0xAAEB, 0xAAEF}, {0xAAF5, 0xAAF6},\n\t{0xABE3, 0xABEA}, {0xABEC, 0xABED}, {0xFB1E, 0xFB1E},\n\t{0xFE00, 0xFE0F}, {0xFE20, 0xFE2F}, {0x101FD, 0x101FD},\n\t{0x102E0, 0x102E0}, {0x10376, 0x1037A}, {0x10A01, 0x10A03},\n\t{0x10A05, 0x10A06}, {0x10A0C, 0x10A0F}, {0x10A38, 0x10A3A},\n\t{0x10A3F, 0x10A3F}, {0x10AE5, 0x10AE6}, {0x11000, 0x11002},\n\t{0x11038, 0x11046}, {0x1107F, 0x11082}, {0x110B0, 0x110BA},\n\t{0x11100, 0x11102}, {0x11127, 0x11134}, {0x11173, 0x11173},\n\t{0x11180, 0x11182}, {0x111B3, 0x111C0}, {0x111CA, 0x111CC},\n\t{0x1122C, 0x11237}, {0x1123E, 0x1123E}, {0x112DF, 0x112EA},\n\t{0x11300, 0x11303}, {0x1133C, 0x1133C}, {0x1133E, 0x11344},\n\t{0x11347, 0x11348}, {0x1134B, 0x1134D}, {0x11357, 0x11357},\n\t{0x11362, 0x11363}, {0x11366, 0x1136C}, {0x11370, 0x11374},\n\t{0x11435, 0x11446}, {0x114B0, 0x114C3}, {0x115AF, 0x115B5},\n\t{0x115B8, 0x115C0}, {0x115DC, 0x115DD}, {0x11630, 0x11640},\n\t{0x116AB, 0x116B7}, {0x1171D, 0x1172B}, {0x11C2F, 0x11C36},\n\t{0x11C38, 0x11C3F}, {0x11C92, 0x11CA7}, {0x11CA9, 0x11CB6},\n\t{0x16AF0, 0x16AF4}, {0x16B30, 0x16B36}, {0x16F51, 0x16F7E},\n\t{0x16F8F, 0x16F92}, {0x1BC9D, 0x1BC9E}, {0x1D165, 0x1D169},\n\t{0x1D16D, 0x1D172}, {0x1D17B, 0x1D182}, {0x1D185, 0x1D18B},\n\t{0x1D1AA, 0x1D1AD}, {0x1D242, 0x1D244}, {0x1DA00, 0x1DA36},\n\t{0x1DA3B, 0x1DA6C}, {0x1DA75, 0x1DA75}, {0x1DA84, 0x1DA84},\n\t{0x1DA9B, 0x1DA9F}, {0x1DAA1, 0x1DAAF}, {0x1E000, 0x1E006},\n\t{0x1E008, 0x1E018}, {0x1E01B, 0x1E021}, {0x1E023, 0x1E024},\n\t{0x1E026, 0x1E02A}, {0x1E8D0, 0x1E8D6}, {0x1E944, 0x1E94A},\n\t{0xE0100, 0xE01EF},\n}\n\nvar doublewidth = table{\n\t{0x1100, 0x115F}, {0x231A, 0x231B}, {0x2329, 0x232A},\n\t{0x23E9, 0x23EC}, {0x23F0, 0x23F0}, {0x23F3, 0x23F3},\n\t{0x25FD, 0x25FE}, {0x2614, 0x2615}, {0x2648, 0x2653},\n\t{0x267F, 0x267F}, {0x2693, 0x2693}, {0x26A1, 0x26A1},\n\t{0x26AA, 0x26AB}, {0x26BD, 0x26BE}, {0x26C4, 0x26C5},\n\t{0x26CE, 0x26CE}, {0x26D4, 0x26D4}, {0x26EA, 0x26EA},\n\t{0x26F2, 0x26F3}, {0x26F5, 0x26F5}, {0x26FA, 0x26FA},\n\t{0x26FD, 0x26FD}, {0x2705, 0x2705}, {0x270A, 0x270B},\n\t{0x2728, 0x2728}, {0x274C, 0x274C}, {0x274E, 0x274E},\n\t{0x2753, 0x2755}, {0x2757, 0x2757}, {0x2795, 0x2797},\n\t{0x27B0, 0x27B0}, {0x27BF, 0x27BF}, {0x2B1B, 0x2B1C},\n\t{0x2B50, 0x2B50}, {0x2B55, 0x2B55}, {0x2E80, 0x2E99},\n\t{0x2E9B, 0x2EF3}, {0x2F00, 0x2FD5}, {0x2FF0, 0x2FFB},\n\t{0x3000, 0x303E}, {0x3041, 0x3096}, {0x3099, 0x30FF},\n\t{0x3105, 0x312D}, {0x3131, 0x318E}, {0x3190, 0x31BA},\n\t{0x31C0, 0x31E3}, {0x31F0, 0x321E}, {0x3220, 0x3247},\n\t{0x3250, 0x32FE}, {0x3300, 0x4DBF}, {0x4E00, 0xA48C},\n\t{0xA490, 0xA4C6}, {0xA960, 0xA97C}, {0xAC00, 0xD7A3},\n\t{0xF900, 0xFAFF}, {0xFE10, 0xFE19}, {0xFE30, 0xFE52},\n\t{0xFE54, 0xFE66}, {0xFE68, 0xFE6B}, {0xFF01, 0xFF60},\n\t{0xFFE0, 0xFFE6}, {0x16FE0, 0x16FE0}, {0x17000, 0x187EC},\n\t{0x18800, 0x18AF2}, {0x1B000, 0x1B001}, {0x1F004, 0x1F004},\n\t{0x1F0CF, 0x1F0CF}, {0x1F18E, 0x1F18E}, {0x1F191, 0x1F19A},\n\t{0x1F200, 0x1F202}, {0x1F210, 0x1F23B}, {0x1F240, 0x1F248},\n\t{0x1F250, 0x1F251}, {0x1F300, 0x1F320}, {0x1F32D, 0x1F335},\n\t{0x1F337, 0x1F37C}, {0x1F37E, 0x1F393}, {0x1F3A0, 0x1F3CA},\n\t{0x1F3CF, 0x1F3D3}, {0x1F3E0, 0x1F3F0}, {0x1F3F4, 0x1F3F4},\n\t{0x1F3F8, 0x1F43E}, {0x1F440, 0x1F440}, {0x1F442, 0x1F4FC},\n\t{0x1F4FF, 0x1F53D}, {0x1F54B, 0x1F54E}, {0x1F550, 0x1F567},\n\t{0x1F57A, 0x1F57A}, {0x1F595, 0x1F596}, {0x1F5A4, 0x1F5A4},\n\t{0x1F5FB, 0x1F64F}, {0x1F680, 0x1F6C5}, {0x1F6CC, 0x1F6CC},\n\t{0x1F6D0, 0x1F6D2}, {0x1F6EB, 0x1F6EC}, {0x1F6F4, 0x1F6F6},\n\t{0x1F910, 0x1F91E}, {0x1F920, 0x1F927}, {0x1F930, 0x1F930},\n\t{0x1F933, 0x1F93E}, {0x1F940, 0x1F94B}, {0x1F950, 0x1F95E},\n\t{0x1F980, 0x1F991}, {0x1F9C0, 0x1F9C0}, {0x20000, 0x2FFFD},\n\t{0x30000, 0x3FFFD},\n}\n\nvar ambiguous = table{\n\t{0x00A1, 0x00A1}, {0x00A4, 0x00A4}, {0x00A7, 0x00A8},\n\t{0x00AA, 0x00AA}, {0x00AD, 0x00AE}, {0x00B0, 0x00B4},\n\t{0x00B6, 0x00BA}, {0x00BC, 0x00BF}, {0x00C6, 0x00C6},\n\t{0x00D0, 0x00D0}, {0x00D7, 0x00D8}, {0x00DE, 0x00E1},\n\t{0x00E6, 0x00E6}, {0x00E8, 0x00EA}, {0x00EC, 0x00ED},\n\t{0x00F0, 0x00F0}, {0x00F2, 0x00F3}, {0x00F7, 0x00FA},\n\t{0x00FC, 0x00FC}, {0x00FE, 0x00FE}, {0x0101, 0x0101},\n\t{0x0111, 0x0111}, {0x0113, 0x0113}, {0x011B, 0x011B},\n\t{0x0126, 0x0127}, {0x012B, 0x012B}, {0x0131, 0x0133},\n\t{0x0138, 0x0138}, {0x013F, 0x0142}, {0x0144, 0x0144},\n\t{0x0148, 0x014B}, {0x014D, 0x014D}, {0x0152, 0x0153},\n\t{0x0166, 0x0167}, {0x016B, 0x016B}, {0x01CE, 0x01CE},\n\t{0x01D0, 0x01D0}, {0x01D2, 0x01D2}, {0x01D4, 0x01D4},\n\t{0x01D6, 0x01D6}, {0x01D8, 0x01D8}, {0x01DA, 0x01DA},\n\t{0x01DC, 0x01DC}, {0x0251, 0x0251}, {0x0261, 0x0261},\n\t{0x02C4, 0x02C4}, {0x02C7, 0x02C7}, {0x02C9, 0x02CB},\n\t{0x02CD, 0x02CD}, {0x02D0, 0x02D0}, {0x02D8, 0x02DB},\n\t{0x02DD, 0x02DD}, {0x02DF, 0x02DF}, {0x0300, 0x036F},\n\t{0x0391, 0x03A1}, {0x03A3, 0x03A9}, {0x03B1, 0x03C1},\n\t{0x03C3, 0x03C9}, {0x0401, 0x0401}, {0x0410, 0x044F},\n\t{0x0451, 0x0451}, {0x2010, 0x2010}, {0x2013, 0x2016},\n\t{0x2018, 0x2019}, {0x201C, 0x201D}, {0x2020, 0x2022},\n\t{0x2024, 0x2027}, {0x2030, 0x2030}, {0x2032, 0x2033},\n\t{0x2035, 0x2035}, {0x203B, 0x203B}, {0x203E, 0x203E},\n\t{0x2074, 0x2074}, {0x207F, 0x207F}, {0x2081, 0x2084},\n\t{0x20AC, 0x20AC}, {0x2103, 0x2103}, {0x2105, 0x2105},\n\t{0x2109, 0x2109}, {0x2113, 0x2113}, {0x2116, 0x2116},\n\t{0x2121, 0x2122}, {0x2126, 0x2126}, {0x212B, 0x212B},\n\t{0x2153, 0x2154}, {0x215B, 0x215E}, {0x2160, 0x216B},\n\t{0x2170, 0x2179}, {0x2189, 0x2189}, {0x2190, 0x2199},\n\t{0x21B8, 0x21B9}, {0x21D2, 0x21D2}, {0x21D4, 0x21D4},\n\t{0x21E7, 0x21E7}, {0x2200, 0x2200}, {0x2202, 0x2203},\n\t{0x2207, 0x2208}, {0x220B, 0x220B}, {0x220F, 0x220F},\n\t{0x2211, 0x2211}, {0x2215, 0x2215}, {0x221A, 0x221A},\n\t{0x221D, 0x2220}, {0x2223, 0x2223}, {0x2225, 0x2225},\n\t{0x2227, 0x222C}, {0x222E, 0x222E}, {0x2234, 0x2237},\n\t{0x223C, 0x223D}, {0x2248, 0x2248}, {0x224C, 0x224C},\n\t{0x2252, 0x2252}, {0x2260, 0x2261}, {0x2264, 0x2267},\n\t{0x226A, 0x226B}, {0x226E, 0x226F}, {0x2282, 0x2283},\n\t{0x2286, 0x2287}, {0x2295, 0x2295}, {0x2299, 0x2299},\n\t{0x22A5, 0x22A5}, {0x22BF, 0x22BF}, {0x2312, 0x2312},\n\t{0x2460, 0x24E9}, {0x24EB, 0x254B}, {0x2550, 0x2573},\n\t{0x2580, 0x258F}, {0x2592, 0x2595}, {0x25A0, 0x25A1},\n\t{0x25A3, 0x25A9}, {0x25B2, 0x25B3}, {0x25B6, 0x25B7},\n\t{0x25BC, 0x25BD}, {0x25C0, 0x25C1}, {0x25C6, 0x25C8},\n\t{0x25CB, 0x25CB}, {0x25CE, 0x25D1}, {0x25E2, 0x25E5},\n\t{0x25EF, 0x25EF}, {0x2605, 0x2606}, {0x2609, 0x2609},\n\t{0x260E, 0x260F}, {0x261C, 0x261C}, {0x261E, 0x261E},\n\t{0x2640, 0x2640}, {0x2642, 0x2642}, {0x2660, 0x2661},\n\t{0x2663, 0x2665}, {0x2667, 0x266A}, {0x266C, 0x266D},\n\t{0x266F, 0x266F}, {0x269E, 0x269F}, {0x26BF, 0x26BF},\n\t{0x26C6, 0x26CD}, {0x26CF, 0x26D3}, {0x26D5, 0x26E1},\n\t{0x26E3, 0x26E3}, {0x26E8, 0x26E9}, {0x26EB, 0x26F1},\n\t{0x26F4, 0x26F4}, {0x26F6, 0x26F9}, {0x26FB, 0x26FC},\n\t{0x26FE, 0x26FF}, {0x273D, 0x273D}, {0x2776, 0x277F},\n\t{0x2B56, 0x2B59}, {0x3248, 0x324F}, {0xE000, 0xF8FF},\n\t{0xFE00, 0xFE0F}, {0xFFFD, 0xFFFD}, {0x1F100, 0x1F10A},\n\t{0x1F110, 0x1F12D}, {0x1F130, 0x1F169}, {0x1F170, 0x1F18D},\n\t{0x1F18F, 0x1F190}, {0x1F19B, 0x1F1AC}, {0xE0100, 0xE01EF},\n\t{0xF0000, 0xFFFFD}, {0x100000, 0x10FFFD},\n}\n\nvar emoji = table{\n\t{0x1F1E6, 0x1F1FF}, {0x1F321, 0x1F321}, {0x1F324, 0x1F32C},\n\t{0x1F336, 0x1F336}, {0x1F37D, 0x1F37D}, {0x1F396, 0x1F397},\n\t{0x1F399, 0x1F39B}, {0x1F39E, 0x1F39F}, {0x1F3CB, 0x1F3CE},\n\t{0x1F3D4, 0x1F3DF}, {0x1F3F3, 0x1F3F5}, {0x1F3F7, 0x1F3F7},\n\t{0x1F43F, 0x1F43F}, {0x1F441, 0x1F441}, {0x1F4FD, 0x1F4FD},\n\t{0x1F549, 0x1F54A}, {0x1F56F, 0x1F570}, {0x1F573, 0x1F579},\n\t{0x1F587, 0x1F587}, {0x1F58A, 0x1F58D}, {0x1F590, 0x1F590},\n\t{0x1F5A5, 0x1F5A5}, {0x1F5A8, 0x1F5A8}, {0x1F5B1, 0x1F5B2},\n\t{0x1F5BC, 0x1F5BC}, {0x1F5C2, 0x1F5C4}, {0x1F5D1, 0x1F5D3},\n\t{0x1F5DC, 0x1F5DE}, {0x1F5E1, 0x1F5E1}, {0x1F5E3, 0x1F5E3},\n\t{0x1F5E8, 0x1F5E8}, {0x1F5EF, 0x1F5EF}, {0x1F5F3, 0x1F5F3},\n\t{0x1F5FA, 0x1F5FA}, {0x1F6CB, 0x1F6CF}, {0x1F6E0, 0x1F6E5},\n\t{0x1F6E9, 0x1F6E9}, {0x1F6F0, 0x1F6F0}, {0x1F6F3, 0x1F6F3},\n}\n\nvar notassigned = table{\n\t{0x0378, 0x0379}, {0x0380, 0x0383}, {0x038B, 0x038B},\n\t{0x038D, 0x038D}, {0x03A2, 0x03A2}, {0x0530, 0x0530},\n\t{0x0557, 0x0558}, {0x0560, 0x0560}, {0x0588, 0x0588},\n\t{0x058B, 0x058C}, {0x0590, 0x0590}, {0x05C8, 0x05CF},\n\t{0x05EB, 0x05EF}, {0x05F5, 0x05FF}, {0x061D, 0x061D},\n\t{0x070E, 0x070E}, {0x074B, 0x074C}, {0x07B2, 0x07BF},\n\t{0x07FB, 0x07FF}, {0x082E, 0x082F}, {0x083F, 0x083F},\n\t{0x085C, 0x085D}, {0x085F, 0x089F}, {0x08B5, 0x08B5},\n\t{0x08BE, 0x08D3}, {0x0984, 0x0984}, {0x098D, 0x098E},\n\t{0x0991, 0x0992}, {0x09A9, 0x09A9}, {0x09B1, 0x09B1},\n\t{0x09B3, 0x09B5}, {0x09BA, 0x09BB}, {0x09C5, 0x09C6},\n\t{0x09C9, 0x09CA}, {0x09CF, 0x09D6}, {0x09D8, 0x09DB},\n\t{0x09DE, 0x09DE}, {0x09E4, 0x09E5}, {0x09FC, 0x0A00},\n\t{0x0A04, 0x0A04}, {0x0A0B, 0x0A0E}, {0x0A11, 0x0A12},\n\t{0x0A29, 0x0A29}, {0x0A31, 0x0A31}, {0x0A34, 0x0A34},\n\t{0x0A37, 0x0A37}, {0x0A3A, 0x0A3B}, {0x0A3D, 0x0A3D},\n\t{0x0A43, 0x0A46}, {0x0A49, 0x0A4A}, {0x0A4E, 0x0A50},\n\t{0x0A52, 0x0A58}, {0x0A5D, 0x0A5D}, {0x0A5F, 0x0A65},\n\t{0x0A76, 0x0A80}, {0x0A84, 0x0A84}, {0x0A8E, 0x0A8E},\n\t{0x0A92, 0x0A92}, {0x0AA9, 0x0AA9}, {0x0AB1, 0x0AB1},\n\t{0x0AB4, 0x0AB4}, {0x0ABA, 0x0ABB}, {0x0AC6, 0x0AC6},\n\t{0x0ACA, 0x0ACA}, {0x0ACE, 0x0ACF}, {0x0AD1, 0x0ADF},\n\t{0x0AE4, 0x0AE5}, {0x0AF2, 0x0AF8}, {0x0AFA, 0x0B00},\n\t{0x0B04, 0x0B04}, {0x0B0D, 0x0B0E}, {0x0B11, 0x0B12},\n\t{0x0B29, 0x0B29}, {0x0B31, 0x0B31}, {0x0B34, 0x0B34},\n\t{0x0B3A, 0x0B3B}, {0x0B45, 0x0B46}, {0x0B49, 0x0B4A},\n\t{0x0B4E, 0x0B55}, {0x0B58, 0x0B5B}, {0x0B5E, 0x0B5E},\n\t{0x0B64, 0x0B65}, {0x0B78, 0x0B81}, {0x0B84, 0x0B84},\n\t{0x0B8B, 0x0B8D}, {0x0B91, 0x0B91}, {0x0B96, 0x0B98},\n\t{0x0B9B, 0x0B9B}, {0x0B9D, 0x0B9D}, {0x0BA0, 0x0BA2},\n\t{0x0BA5, 0x0BA7}, {0x0BAB, 0x0BAD}, {0x0BBA, 0x0BBD},\n\t{0x0BC3, 0x0BC5}, {0x0BC9, 0x0BC9}, {0x0BCE, 0x0BCF},\n\t{0x0BD1, 0x0BD6}, {0x0BD8, 0x0BE5}, {0x0BFB, 0x0BFF},\n\t{0x0C04, 0x0C04}, {0x0C0D, 0x0C0D}, {0x0C11, 0x0C11},\n\t{0x0C29, 0x0C29}, {0x0C3A, 0x0C3C}, {0x0C45, 0x0C45},\n\t{0x0C49, 0x0C49}, {0x0C4E, 0x0C54}, {0x0C57, 0x0C57},\n\t{0x0C5B, 0x0C5F}, {0x0C64, 0x0C65}, {0x0C70, 0x0C77},\n\t{0x0C84, 0x0C84}, {0x0C8D, 0x0C8D}, {0x0C91, 0x0C91},\n\t{0x0CA9, 0x0CA9}, {0x0CB4, 0x0CB4}, {0x0CBA, 0x0CBB},\n\t{0x0CC5, 0x0CC5}, {0x0CC9, 0x0CC9}, {0x0CCE, 0x0CD4},\n\t{0x0CD7, 0x0CDD}, {0x0CDF, 0x0CDF}, {0x0CE4, 0x0CE5},\n\t{0x0CF0, 0x0CF0}, {0x0CF3, 0x0D00}, {0x0D04, 0x0D04},\n\t{0x0D0D, 0x0D0D}, {0x0D11, 0x0D11}, {0x0D3B, 0x0D3C},\n\t{0x0D45, 0x0D45}, {0x0D49, 0x0D49}, {0x0D50, 0x0D53},\n\t{0x0D64, 0x0D65}, {0x0D80, 0x0D81}, {0x0D84, 0x0D84},\n\t{0x0D97, 0x0D99}, {0x0DB2, 0x0DB2}, {0x0DBC, 0x0DBC},\n\t{0x0DBE, 0x0DBF}, {0x0DC7, 0x0DC9}, {0x0DCB, 0x0DCE},\n\t{0x0DD5, 0x0DD5}, {0x0DD7, 0x0DD7}, {0x0DE0, 0x0DE5},\n\t{0x0DF0, 0x0DF1}, {0x0DF5, 0x0E00}, {0x0E3B, 0x0E3E},\n\t{0x0E5C, 0x0E80}, {0x0E83, 0x0E83}, {0x0E85, 0x0E86},\n\t{0x0E89, 0x0E89}, {0x0E8B, 0x0E8C}, {0x0E8E, 0x0E93},\n\t{0x0E98, 0x0E98}, {0x0EA0, 0x0EA0}, {0x0EA4, 0x0EA4},\n\t{0x0EA6, 0x0EA6}, {0x0EA8, 0x0EA9}, {0x0EAC, 0x0EAC},\n\t{0x0EBA, 0x0EBA}, {0x0EBE, 0x0EBF}, {0x0EC5, 0x0EC5},\n\t{0x0EC7, 0x0EC7}, {0x0ECE, 0x0ECF}, {0x0EDA, 0x0EDB},\n\t{0x0EE0, 0x0EFF}, {0x0F48, 0x0F48}, {0x0F6D, 0x0F70},\n\t{0x0F98, 0x0F98}, {0x0FBD, 0x0FBD}, {0x0FCD, 0x0FCD},\n\t{0x0FDB, 0x0FFF}, {0x10C6, 0x10C6}, {0x10C8, 0x10CC},\n\t{0x10CE, 0x10CF}, {0x1249, 0x1249}, {0x124E, 0x124F},\n\t{0x1257, 0x1257}, {0x1259, 0x1259}, {0x125E, 0x125F},\n\t{0x1289, 0x1289}, {0x128E, 0x128F}, {0x12B1, 0x12B1},\n\t{0x12B6, 0x12B7}, {0x12BF, 0x12BF}, {0x12C1, 0x12C1},\n\t{0x12C6, 0x12C7}, {0x12D7, 0x12D7}, {0x1311, 0x1311},\n\t{0x1316, 0x1317}, {0x135B, 0x135C}, {0x137D, 0x137F},\n\t{0x139A, 0x139F}, {0x13F6, 0x13F7}, {0x13FE, 0x13FF},\n\t{0x169D, 0x169F}, {0x16F9, 0x16FF}, {0x170D, 0x170D},\n\t{0x1715, 0x171F}, {0x1737, 0x173F}, {0x1754, 0x175F},\n\t{0x176D, 0x176D}, {0x1771, 0x1771}, {0x1774, 0x177F},\n\t{0x17DE, 0x17DF}, {0x17EA, 0x17EF}, {0x17FA, 0x17FF},\n\t{0x180F, 0x180F}, {0x181A, 0x181F}, {0x1878, 0x187F},\n\t{0x18AB, 0x18AF}, {0x18F6, 0x18FF}, {0x191F, 0x191F},\n\t{0x192C, 0x192F}, {0x193C, 0x193F}, {0x1941, 0x1943},\n\t{0x196E, 0x196F}, {0x1975, 0x197F}, {0x19AC, 0x19AF},\n\t{0x19CA, 0x19CF}, {0x19DB, 0x19DD}, {0x1A1C, 0x1A1D},\n\t{0x1A5F, 0x1A5F}, {0x1A7D, 0x1A7E}, {0x1A8A, 0x1A8F},\n\t{0x1A9A, 0x1A9F}, {0x1AAE, 0x1AAF}, {0x1ABF, 0x1AFF},\n\t{0x1B4C, 0x1B4F}, {0x1B7D, 0x1B7F}, {0x1BF4, 0x1BFB},\n\t{0x1C38, 0x1C3A}, {0x1C4A, 0x1C4C}, {0x1C89, 0x1CBF},\n\t{0x1CC8, 0x1CCF}, {0x1CF7, 0x1CF7}, {0x1CFA, 0x1CFF},\n\t{0x1DF6, 0x1DFA}, {0x1F16, 0x1F17}, {0x1F1E, 0x1F1F},\n\t{0x1F46, 0x1F47}, {0x1F4E, 0x1F4F}, {0x1F58, 0x1F58},\n\t{0x1F5A, 0x1F5A}, {0x1F5C, 0x1F5C}, {0x1F5E, 0x1F5E},\n\t{0x1F7E, 0x1F7F}, {0x1FB5, 0x1FB5}, {0x1FC5, 0x1FC5},\n\t{0x1FD4, 0x1FD5}, {0x1FDC, 0x1FDC}, {0x1FF0, 0x1FF1},\n\t{0x1FF5, 0x1FF5}, {0x1FFF, 0x1FFF}, {0x2065, 0x2065},\n\t{0x2072, 0x2073}, {0x208F, 0x208F}, {0x209D, 0x209F},\n\t{0x20BF, 0x20CF}, {0x20F1, 0x20FF}, {0x218C, 0x218F},\n\t{0x23FF, 0x23FF}, {0x2427, 0x243F}, {0x244B, 0x245F},\n\t{0x2B74, 0x2B75}, {0x2B96, 0x2B97}, {0x2BBA, 0x2BBC},\n\t{0x2BC9, 0x2BC9}, {0x2BD2, 0x2BEB}, {0x2BF0, 0x2BFF},\n\t{0x2C2F, 0x2C2F}, {0x2C5F, 0x2C5F}, {0x2CF4, 0x2CF8},\n\t{0x2D26, 0x2D26}, {0x2D28, 0x2D2C}, {0x2D2E, 0x2D2F},\n\t{0x2D68, 0x2D6E}, {0x2D71, 0x2D7E}, {0x2D97, 0x2D9F},\n\t{0x2DA7, 0x2DA7}, {0x2DAF, 0x2DAF}, {0x2DB7, 0x2DB7},\n\t{0x2DBF, 0x2DBF}, {0x2DC7, 0x2DC7}, {0x2DCF, 0x2DCF},\n\t{0x2DD7, 0x2DD7}, {0x2DDF, 0x2DDF}, {0x2E45, 0x2E7F},\n\t{0x2E9A, 0x2E9A}, {0x2EF4, 0x2EFF}, {0x2FD6, 0x2FEF},\n\t{0x2FFC, 0x2FFF}, {0x3040, 0x3040}, {0x3097, 0x3098},\n\t{0x3100, 0x3104}, {0x312E, 0x3130}, {0x318F, 0x318F},\n\t{0x31BB, 0x31BF}, {0x31E4, 0x31EF}, {0x321F, 0x321F},\n\t{0x32FF, 0x32FF}, {0x4DB6, 0x4DBF}, {0x9FD6, 0x9FFF},\n\t{0xA48D, 0xA48F}, {0xA4C7, 0xA4CF}, {0xA62C, 0xA63F},\n\t{0xA6F8, 0xA6FF}, {0xA7AF, 0xA7AF}, {0xA7B8, 0xA7F6},\n\t{0xA82C, 0xA82F}, {0xA83A, 0xA83F}, {0xA878, 0xA87F},\n\t{0xA8C6, 0xA8CD}, {0xA8DA, 0xA8DF}, {0xA8FE, 0xA8FF},\n\t{0xA954, 0xA95E}, {0xA97D, 0xA97F}, {0xA9CE, 0xA9CE},\n\t{0xA9DA, 0xA9DD}, {0xA9FF, 0xA9FF}, {0xAA37, 0xAA3F},\n\t{0xAA4E, 0xAA4F}, {0xAA5A, 0xAA5B}, {0xAAC3, 0xAADA},\n\t{0xAAF7, 0xAB00}, {0xAB07, 0xAB08}, {0xAB0F, 0xAB10},\n\t{0xAB17, 0xAB1F}, {0xAB27, 0xAB27}, {0xAB2F, 0xAB2F},\n\t{0xAB66, 0xAB6F}, {0xABEE, 0xABEF}, {0xABFA, 0xABFF},\n\t{0xD7A4, 0xD7AF}, {0xD7C7, 0xD7CA}, {0xD7FC, 0xD7FF},\n\t{0xFA6E, 0xFA6F}, {0xFADA, 0xFAFF}, {0xFB07, 0xFB12},\n\t{0xFB18, 0xFB1C}, {0xFB37, 0xFB37}, {0xFB3D, 0xFB3D},\n\t{0xFB3F, 0xFB3F}, {0xFB42, 0xFB42}, {0xFB45, 0xFB45},\n\t{0xFBC2, 0xFBD2}, {0xFD40, 0xFD4F}, {0xFD90, 0xFD91},\n\t{0xFDC8, 0xFDEF}, {0xFDFE, 0xFDFF}, {0xFE1A, 0xFE1F},\n\t{0xFE53, 0xFE53}, {0xFE67, 0xFE67}, {0xFE6C, 0xFE6F},\n\t{0xFE75, 0xFE75}, {0xFEFD, 0xFEFE}, {0xFF00, 0xFF00},\n\t{0xFFBF, 0xFFC1}, {0xFFC8, 0xFFC9}, {0xFFD0, 0xFFD1},\n\t{0xFFD8, 0xFFD9}, {0xFFDD, 0xFFDF}, {0xFFE7, 0xFFE7},\n\t{0xFFEF, 0xFFF8}, {0xFFFE, 0xFFFF}, {0x1000C, 0x1000C},\n\t{0x10027, 0x10027}, {0x1003B, 0x1003B}, {0x1003E, 0x1003E},\n\t{0x1004E, 0x1004F}, {0x1005E, 0x1007F}, {0x100FB, 0x100FF},\n\t{0x10103, 0x10106}, {0x10134, 0x10136}, {0x1018F, 0x1018F},\n\t{0x1019C, 0x1019F}, {0x101A1, 0x101CF}, {0x101FE, 0x1027F},\n\t{0x1029D, 0x1029F}, {0x102D1, 0x102DF}, {0x102FC, 0x102FF},\n\t{0x10324, 0x1032F}, {0x1034B, 0x1034F}, {0x1037B, 0x1037F},\n\t{0x1039E, 0x1039E}, {0x103C4, 0x103C7}, {0x103D6, 0x103FF},\n\t{0x1049E, 0x1049F}, {0x104AA, 0x104AF}, {0x104D4, 0x104D7},\n\t{0x104FC, 0x104FF}, {0x10528, 0x1052F}, {0x10564, 0x1056E},\n\t{0x10570, 0x105FF}, {0x10737, 0x1073F}, {0x10756, 0x1075F},\n\t{0x10768, 0x107FF}, {0x10806, 0x10807}, {0x10809, 0x10809},\n\t{0x10836, 0x10836}, {0x10839, 0x1083B}, {0x1083D, 0x1083E},\n\t{0x10856, 0x10856}, {0x1089F, 0x108A6}, {0x108B0, 0x108DF},\n\t{0x108F3, 0x108F3}, {0x108F6, 0x108FA}, {0x1091C, 0x1091E},\n\t{0x1093A, 0x1093E}, {0x10940, 0x1097F}, {0x109B8, 0x109BB},\n\t{0x109D0, 0x109D1}, {0x10A04, 0x10A04}, {0x10A07, 0x10A0B},\n\t{0x10A14, 0x10A14}, {0x10A18, 0x10A18}, {0x10A34, 0x10A37},\n\t{0x10A3B, 0x10A3E}, {0x10A48, 0x10A4F}, {0x10A59, 0x10A5F},\n\t{0x10AA0, 0x10ABF}, {0x10AE7, 0x10AEA}, {0x10AF7, 0x10AFF},\n\t{0x10B36, 0x10B38}, {0x10B56, 0x10B57}, {0x10B73, 0x10B77},\n\t{0x10B92, 0x10B98}, {0x10B9D, 0x10BA8}, {0x10BB0, 0x10BFF},\n\t{0x10C49, 0x10C7F}, {0x10CB3, 0x10CBF}, {0x10CF3, 0x10CF9},\n\t{0x10D00, 0x10E5F}, {0x10E7F, 0x10FFF}, {0x1104E, 0x11051},\n\t{0x11070, 0x1107E}, {0x110C2, 0x110CF}, {0x110E9, 0x110EF},\n\t{0x110FA, 0x110FF}, {0x11135, 0x11135}, {0x11144, 0x1114F},\n\t{0x11177, 0x1117F}, {0x111CE, 0x111CF}, {0x111E0, 0x111E0},\n\t{0x111F5, 0x111FF}, {0x11212, 0x11212}, {0x1123F, 0x1127F},\n\t{0x11287, 0x11287}, {0x11289, 0x11289}, {0x1128E, 0x1128E},\n\t{0x1129E, 0x1129E}, {0x112AA, 0x112AF}, {0x112EB, 0x112EF},\n\t{0x112FA, 0x112FF}, {0x11304, 0x11304}, {0x1130D, 0x1130E},\n\t{0x11311, 0x11312}, {0x11329, 0x11329}, {0x11331, 0x11331},\n\t{0x11334, 0x11334}, {0x1133A, 0x1133B}, {0x11345, 0x11346},\n\t{0x11349, 0x1134A}, {0x1134E, 0x1134F}, {0x11351, 0x11356},\n\t{0x11358, 0x1135C}, {0x11364, 0x11365}, {0x1136D, 0x1136F},\n\t{0x11375, 0x113FF}, {0x1145A, 0x1145A}, {0x1145C, 0x1145C},\n\t{0x1145E, 0x1147F}, {0x114C8, 0x114CF}, {0x114DA, 0x1157F},\n\t{0x115B6, 0x115B7}, {0x115DE, 0x115FF}, {0x11645, 0x1164F},\n\t{0x1165A, 0x1165F}, {0x1166D, 0x1167F}, {0x116B8, 0x116BF},\n\t{0x116CA, 0x116FF}, {0x1171A, 0x1171C}, {0x1172C, 0x1172F},\n\t{0x11740, 0x1189F}, {0x118F3, 0x118FE}, {0x11900, 0x11ABF},\n\t{0x11AF9, 0x11BFF}, {0x11C09, 0x11C09}, {0x11C37, 0x11C37},\n\t{0x11C46, 0x11C4F}, {0x11C6D, 0x11C6F}, {0x11C90, 0x11C91},\n\t{0x11CA8, 0x11CA8}, {0x11CB7, 0x11FFF}, {0x1239A, 0x123FF},\n\t{0x1246F, 0x1246F}, {0x12475, 0x1247F}, {0x12544, 0x12FFF},\n\t{0x1342F, 0x143FF}, {0x14647, 0x167FF}, {0x16A39, 0x16A3F},\n\t{0x16A5F, 0x16A5F}, {0x16A6A, 0x16A6D}, {0x16A70, 0x16ACF},\n\t{0x16AEE, 0x16AEF}, {0x16AF6, 0x16AFF}, {0x16B46, 0x16B4F},\n\t{0x16B5A, 0x16B5A}, {0x16B62, 0x16B62}, {0x16B78, 0x16B7C},\n\t{0x16B90, 0x16EFF}, {0x16F45, 0x16F4F}, {0x16F7F, 0x16F8E},\n\t{0x16FA0, 0x16FDF}, {0x16FE1, 0x16FFF}, {0x187ED, 0x187FF},\n\t{0x18AF3, 0x1AFFF}, {0x1B002, 0x1BBFF}, {0x1BC6B, 0x1BC6F},\n\t{0x1BC7D, 0x1BC7F}, {0x1BC89, 0x1BC8F}, {0x1BC9A, 0x1BC9B},\n\t{0x1BCA4, 0x1CFFF}, {0x1D0F6, 0x1D0FF}, {0x1D127, 0x1D128},\n\t{0x1D1E9, 0x1D1FF}, {0x1D246, 0x1D2FF}, {0x1D357, 0x1D35F},\n\t{0x1D372, 0x1D3FF}, {0x1D455, 0x1D455}, {0x1D49D, 0x1D49D},\n\t{0x1D4A0, 0x1D4A1}, {0x1D4A3, 0x1D4A4}, {0x1D4A7, 0x1D4A8},\n\t{0x1D4AD, 0x1D4AD}, {0x1D4BA, 0x1D4BA}, {0x1D4BC, 0x1D4BC},\n\t{0x1D4C4, 0x1D4C4}, {0x1D506, 0x1D506}, {0x1D50B, 0x1D50C},\n\t{0x1D515, 0x1D515}, {0x1D51D, 0x1D51D}, {0x1D53A, 0x1D53A},\n\t{0x1D53F, 0x1D53F}, {0x1D545, 0x1D545}, {0x1D547, 0x1D549},\n\t{0x1D551, 0x1D551}, {0x1D6A6, 0x1D6A7}, {0x1D7CC, 0x1D7CD},\n\t{0x1DA8C, 0x1DA9A}, {0x1DAA0, 0x1DAA0}, {0x1DAB0, 0x1DFFF},\n\t{0x1E007, 0x1E007}, {0x1E019, 0x1E01A}, {0x1E022, 0x1E022},\n\t{0x1E025, 0x1E025}, {0x1E02B, 0x1E7FF}, {0x1E8C5, 0x1E8C6},\n\t{0x1E8D7, 0x1E8FF}, {0x1E94B, 0x1E94F}, {0x1E95A, 0x1E95D},\n\t{0x1E960, 0x1EDFF}, {0x1EE04, 0x1EE04}, {0x1EE20, 0x1EE20},\n\t{0x1EE23, 0x1EE23}, {0x1EE25, 0x1EE26}, {0x1EE28, 0x1EE28},\n\t{0x1EE33, 0x1EE33}, {0x1EE38, 0x1EE38}, {0x1EE3A, 0x1EE3A},\n\t{0x1EE3C, 0x1EE41}, {0x1EE43, 0x1EE46}, {0x1EE48, 0x1EE48},\n\t{0x1EE4A, 0x1EE4A}, {0x1EE4C, 0x1EE4C}, {0x1EE50, 0x1EE50},\n\t{0x1EE53, 0x1EE53}, {0x1EE55, 0x1EE56}, {0x1EE58, 0x1EE58},\n\t{0x1EE5A, 0x1EE5A}, {0x1EE5C, 0x1EE5C}, {0x1EE5E, 0x1EE5E},\n\t{0x1EE60, 0x1EE60}, {0x1EE63, 0x1EE63}, {0x1EE65, 0x1EE66},\n\t{0x1EE6B, 0x1EE6B}, {0x1EE73, 0x1EE73}, {0x1EE78, 0x1EE78},\n\t{0x1EE7D, 0x1EE7D}, {0x1EE7F, 0x1EE7F}, {0x1EE8A, 0x1EE8A},\n\t{0x1EE9C, 0x1EEA0}, {0x1EEA4, 0x1EEA4}, {0x1EEAA, 0x1EEAA},\n\t{0x1EEBC, 0x1EEEF}, {0x1EEF2, 0x1EFFF}, {0x1F02C, 0x1F02F},\n\t{0x1F094, 0x1F09F}, {0x1F0AF, 0x1F0B0}, {0x1F0C0, 0x1F0C0},\n\t{0x1F0D0, 0x1F0D0}, {0x1F0F6, 0x1F0FF}, {0x1F10D, 0x1F10F},\n\t{0x1F12F, 0x1F12F}, {0x1F16C, 0x1F16F}, {0x1F1AD, 0x1F1E5},\n\t{0x1F203, 0x1F20F}, {0x1F23C, 0x1F23F}, {0x1F249, 0x1F24F},\n\t{0x1F252, 0x1F2FF}, {0x1F6D3, 0x1F6DF}, {0x1F6ED, 0x1F6EF},\n\t{0x1F6F7, 0x1F6FF}, {0x1F774, 0x1F77F}, {0x1F7D5, 0x1F7FF},\n\t{0x1F80C, 0x1F80F}, {0x1F848, 0x1F84F}, {0x1F85A, 0x1F85F},\n\t{0x1F888, 0x1F88F}, {0x1F8AE, 0x1F90F}, {0x1F91F, 0x1F91F},\n\t{0x1F928, 0x1F92F}, {0x1F931, 0x1F932}, {0x1F93F, 0x1F93F},\n\t{0x1F94C, 0x1F94F}, {0x1F95F, 0x1F97F}, {0x1F992, 0x1F9BF},\n\t{0x1F9C1, 0x1FFFF}, {0x2A6D7, 0x2A6FF}, {0x2B735, 0x2B73F},\n\t{0x2B81E, 0x2B81F}, {0x2CEA2, 0x2F7FF}, {0x2FA1E, 0xE0000},\n\t{0xE0002, 0xE001F}, {0xE0080, 0xE00FF}, {0xE01F0, 0xEFFFF},\n\t{0xFFFFE, 0xFFFFF},\n}\n\nvar neutral = table{\n\t{0x0000, 0x001F}, {0x007F, 0x007F}, {0x0080, 0x009F},\n\t{0x00A0, 0x00A0}, {0x00A9, 0x00A9}, {0x00AB, 0x00AB},\n\t{0x00B5, 0x00B5}, {0x00BB, 0x00BB}, {0x00C0, 0x00C5},\n\t{0x00C7, 0x00CF}, {0x00D1, 0x00D6}, {0x00D9, 0x00DD},\n\t{0x00E2, 0x00E5}, {0x00E7, 0x00E7}, {0x00EB, 0x00EB},\n\t{0x00EE, 0x00EF}, {0x00F1, 0x00F1}, {0x00F4, 0x00F6},\n\t{0x00FB, 0x00FB}, {0x00FD, 0x00FD}, {0x00FF, 0x00FF},\n\t{0x0100, 0x0100}, {0x0102, 0x0110}, {0x0112, 0x0112},\n\t{0x0114, 0x011A}, {0x011C, 0x0125}, {0x0128, 0x012A},\n\t{0x012C, 0x0130}, {0x0134, 0x0137}, {0x0139, 0x013E},\n\t{0x0143, 0x0143}, {0x0145, 0x0147}, {0x014C, 0x014C},\n\t{0x014E, 0x0151}, {0x0154, 0x0165}, {0x0168, 0x016A},\n\t{0x016C, 0x017F}, {0x0180, 0x01BA}, {0x01BB, 0x01BB},\n\t{0x01BC, 0x01BF}, {0x01C0, 0x01C3}, {0x01C4, 0x01CD},\n\t{0x01CF, 0x01CF}, {0x01D1, 0x01D1}, {0x01D3, 0x01D3},\n\t{0x01D5, 0x01D5}, {0x01D7, 0x01D7}, {0x01D9, 0x01D9},\n\t{0x01DB, 0x01DB}, {0x01DD, 0x024F}, {0x0250, 0x0250},\n\t{0x0252, 0x0260}, {0x0262, 0x0293}, {0x0294, 0x0294},\n\t{0x0295, 0x02AF}, {0x02B0, 0x02C1}, {0x02C2, 0x02C3},\n\t{0x02C5, 0x02C5}, {0x02C6, 0x02C6}, {0x02C8, 0x02C8},\n\t{0x02CC, 0x02CC}, {0x02CE, 0x02CF}, {0x02D1, 0x02D1},\n\t{0x02D2, 0x02D7}, {0x02DC, 0x02DC}, {0x02DE, 0x02DE},\n\t{0x02E0, 0x02E4}, {0x02E5, 0x02EB}, {0x02EC, 0x02EC},\n\t{0x02ED, 0x02ED}, {0x02EE, 0x02EE}, {0x02EF, 0x02FF},\n\t{0x0370, 0x0373}, {0x0374, 0x0374}, {0x0375, 0x0375},\n\t{0x0376, 0x0377}, {0x037A, 0x037A}, {0x037B, 0x037D},\n\t{0x037E, 0x037E}, {0x037F, 0x037F}, {0x0384, 0x0385},\n\t{0x0386, 0x0386}, {0x0387, 0x0387}, {0x0388, 0x038A},\n\t{0x038C, 0x038C}, {0x038E, 0x0390}, {0x03AA, 0x03B0},\n\t{0x03C2, 0x03C2}, {0x03CA, 0x03F5}, {0x03F6, 0x03F6},\n\t{0x03F7, 0x03FF}, {0x0400, 0x0400}, {0x0402, 0x040F},\n\t{0x0450, 0x0450}, {0x0452, 0x0481}, {0x0482, 0x0482},\n\t{0x0483, 0x0487}, {0x0488, 0x0489}, {0x048A, 0x04FF},\n\t{0x0500, 0x052F}, {0x0531, 0x0556}, {0x0559, 0x0559},\n\t{0x055A, 0x055F}, {0x0561, 0x0587}, {0x0589, 0x0589},\n\t{0x058A, 0x058A}, {0x058D, 0x058E}, {0x058F, 0x058F},\n\t{0x0591, 0x05BD}, {0x05BE, 0x05BE}, {0x05BF, 0x05BF},\n\t{0x05C0, 0x05C0}, {0x05C1, 0x05C2}, {0x05C3, 0x05C3},\n\t{0x05C4, 0x05C5}, {0x05C6, 0x05C6}, {0x05C7, 0x05C7},\n\t{0x05D0, 0x05EA}, {0x05F0, 0x05F2}, {0x05F3, 0x05F4},\n\t{0x0600, 0x0605}, {0x0606, 0x0608}, {0x0609, 0x060A},\n\t{0x060B, 0x060B}, {0x060C, 0x060D}, {0x060E, 0x060F},\n\t{0x0610, 0x061A}, {0x061B, 0x061B}, {0x061C, 0x061C},\n\t{0x061E, 0x061F}, {0x0620, 0x063F}, {0x0640, 0x0640},\n\t{0x0641, 0x064A}, {0x064B, 0x065F}, {0x0660, 0x0669},\n\t{0x066A, 0x066D}, {0x066E, 0x066F}, {0x0670, 0x0670},\n\t{0x0671, 0x06D3}, {0x06D4, 0x06D4}, {0x06D5, 0x06D5},\n\t{0x06D6, 0x06DC}, {0x06DD, 0x06DD}, {0x06DE, 0x06DE},\n\t{0x06DF, 0x06E4}, {0x06E5, 0x06E6}, {0x06E7, 0x06E8},\n\t{0x06E9, 0x06E9}, {0x06EA, 0x06ED}, {0x06EE, 0x06EF},\n\t{0x06F0, 0x06F9}, {0x06FA, 0x06FC}, {0x06FD, 0x06FE},\n\t{0x06FF, 0x06FF}, {0x0700, 0x070D}, {0x070F, 0x070F},\n\t{0x0710, 0x0710}, {0x0711, 0x0711}, {0x0712, 0x072F},\n\t{0x0730, 0x074A}, {0x074D, 0x074F}, {0x0750, 0x077F},\n\t{0x0780, 0x07A5}, {0x07A6, 0x07B0}, {0x07B1, 0x07B1},\n\t{0x07C0, 0x07C9}, {0x07CA, 0x07EA}, {0x07EB, 0x07F3},\n\t{0x07F4, 0x07F5}, {0x07F6, 0x07F6}, {0x07F7, 0x07F9},\n\t{0x07FA, 0x07FA}, {0x0800, 0x0815}, {0x0816, 0x0819},\n\t{0x081A, 0x081A}, {0x081B, 0x0823}, {0x0824, 0x0824},\n\t{0x0825, 0x0827}, {0x0828, 0x0828}, {0x0829, 0x082D},\n\t{0x0830, 0x083E}, {0x0840, 0x0858}, {0x0859, 0x085B},\n\t{0x085E, 0x085E}, {0x08A0, 0x08B4}, {0x08B6, 0x08BD},\n\t{0x08D4, 0x08E1}, {0x08E2, 0x08E2}, {0x08E3, 0x08FF},\n\t{0x0900, 0x0902}, {0x0903, 0x0903}, {0x0904, 0x0939},\n\t{0x093A, 0x093A}, {0x093B, 0x093B}, {0x093C, 0x093C},\n\t{0x093D, 0x093D}, {0x093E, 0x0940}, {0x0941, 0x0948},\n\t{0x0949, 0x094C}, {0x094D, 0x094D}, {0x094E, 0x094F},\n\t{0x0950, 0x0950}, {0x0951, 0x0957}, {0x0958, 0x0961},\n\t{0x0962, 0x0963}, {0x0964, 0x0965}, {0x0966, 0x096F},\n\t{0x0970, 0x0970}, {0x0971, 0x0971}, {0x0972, 0x097F},\n\t{0x0980, 0x0980}, {0x0981, 0x0981}, {0x0982, 0x0983},\n\t{0x0985, 0x098C}, {0x098F, 0x0990}, {0x0993, 0x09A8},\n\t{0x09AA, 0x09B0}, {0x09B2, 0x09B2}, {0x09B6, 0x09B9},\n\t{0x09BC, 0x09BC}, {0x09BD, 0x09BD}, {0x09BE, 0x09C0},\n\t{0x09C1, 0x09C4}, {0x09C7, 0x09C8}, {0x09CB, 0x09CC},\n\t{0x09CD, 0x09CD}, {0x09CE, 0x09CE}, {0x09D7, 0x09D7},\n\t{0x09DC, 0x09DD}, {0x09DF, 0x09E1}, {0x09E2, 0x09E3},\n\t{0x09E6, 0x09EF}, {0x09F0, 0x09F1}, {0x09F2, 0x09F3},\n\t{0x09F4, 0x09F9}, {0x09FA, 0x09FA}, {0x09FB, 0x09FB},\n\t{0x0A01, 0x0A02}, {0x0A03, 0x0A03}, {0x0A05, 0x0A0A},\n\t{0x0A0F, 0x0A10}, {0x0A13, 0x0A28}, {0x0A2A, 0x0A30},\n\t{0x0A32, 0x0A33}, {0x0A35, 0x0A36}, {0x0A38, 0x0A39},\n\t{0x0A3C, 0x0A3C}, {0x0A3E, 0x0A40}, {0x0A41, 0x0A42},\n\t{0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A51, 0x0A51},\n\t{0x0A59, 0x0A5C}, {0x0A5E, 0x0A5E}, {0x0A66, 0x0A6F},\n\t{0x0A70, 0x0A71}, {0x0A72, 0x0A74}, {0x0A75, 0x0A75},\n\t{0x0A81, 0x0A82}, {0x0A83, 0x0A83}, {0x0A85, 0x0A8D},\n\t{0x0A8F, 0x0A91}, {0x0A93, 0x0AA8}, {0x0AAA, 0x0AB0},\n\t{0x0AB2, 0x0AB3}, {0x0AB5, 0x0AB9}, {0x0ABC, 0x0ABC},\n\t{0x0ABD, 0x0ABD}, {0x0ABE, 0x0AC0}, {0x0AC1, 0x0AC5},\n\t{0x0AC7, 0x0AC8}, {0x0AC9, 0x0AC9}, {0x0ACB, 0x0ACC},\n\t{0x0ACD, 0x0ACD}, {0x0AD0, 0x0AD0}, {0x0AE0, 0x0AE1},\n\t{0x0AE2, 0x0AE3}, {0x0AE6, 0x0AEF}, {0x0AF0, 0x0AF0},\n\t{0x0AF1, 0x0AF1}, {0x0AF9, 0x0AF9}, {0x0B01, 0x0B01},\n\t{0x0B02, 0x0B03}, {0x0B05, 0x0B0C}, {0x0B0F, 0x0B10},\n\t{0x0B13, 0x0B28}, {0x0B2A, 0x0B30}, {0x0B32, 0x0B33},\n\t{0x0B35, 0x0B39}, {0x0B3C, 0x0B3C}, {0x0B3D, 0x0B3D},\n\t{0x0B3E, 0x0B3E}, {0x0B3F, 0x0B3F}, {0x0B40, 0x0B40},\n\t{0x0B41, 0x0B44}, {0x0B47, 0x0B48}, {0x0B4B, 0x0B4C},\n\t{0x0B4D, 0x0B4D}, {0x0B56, 0x0B56}, {0x0B57, 0x0B57},\n\t{0x0B5C, 0x0B5D}, {0x0B5F, 0x0B61}, {0x0B62, 0x0B63},\n\t{0x0B66, 0x0B6F}, {0x0B70, 0x0B70}, {0x0B71, 0x0B71},\n\t{0x0B72, 0x0B77}, {0x0B82, 0x0B82}, {0x0B83, 0x0B83},\n\t{0x0B85, 0x0B8A}, {0x0B8E, 0x0B90}, {0x0B92, 0x0B95},\n\t{0x0B99, 0x0B9A}, {0x0B9C, 0x0B9C}, {0x0B9E, 0x0B9F},\n\t{0x0BA3, 0x0BA4}, {0x0BA8, 0x0BAA}, {0x0BAE, 0x0BB9},\n\t{0x0BBE, 0x0BBF}, {0x0BC0, 0x0BC0}, {0x0BC1, 0x0BC2},\n\t{0x0BC6, 0x0BC8}, {0x0BCA, 0x0BCC}, {0x0BCD, 0x0BCD},\n\t{0x0BD0, 0x0BD0}, {0x0BD7, 0x0BD7}, {0x0BE6, 0x0BEF},\n\t{0x0BF0, 0x0BF2}, {0x0BF3, 0x0BF8}, {0x0BF9, 0x0BF9},\n\t{0x0BFA, 0x0BFA}, {0x0C00, 0x0C00}, {0x0C01, 0x0C03},\n\t{0x0C05, 0x0C0C}, {0x0C0E, 0x0C10}, {0x0C12, 0x0C28},\n\t{0x0C2A, 0x0C39}, {0x0C3D, 0x0C3D}, {0x0C3E, 0x0C40},\n\t{0x0C41, 0x0C44}, {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D},\n\t{0x0C55, 0x0C56}, {0x0C58, 0x0C5A}, {0x0C60, 0x0C61},\n\t{0x0C62, 0x0C63}, {0x0C66, 0x0C6F}, {0x0C78, 0x0C7E},\n\t{0x0C7F, 0x0C7F}, {0x0C80, 0x0C80}, {0x0C81, 0x0C81},\n\t{0x0C82, 0x0C83}, {0x0C85, 0x0C8C}, {0x0C8E, 0x0C90},\n\t{0x0C92, 0x0CA8}, {0x0CAA, 0x0CB3}, {0x0CB5, 0x0CB9},\n\t{0x0CBC, 0x0CBC}, {0x0CBD, 0x0CBD}, {0x0CBE, 0x0CBE},\n\t{0x0CBF, 0x0CBF}, {0x0CC0, 0x0CC4}, {0x0CC6, 0x0CC6},\n\t{0x0CC7, 0x0CC8}, {0x0CCA, 0x0CCB}, {0x0CCC, 0x0CCD},\n\t{0x0CD5, 0x0CD6}, {0x0CDE, 0x0CDE}, {0x0CE0, 0x0CE1},\n\t{0x0CE2, 0x0CE3}, {0x0CE6, 0x0CEF}, {0x0CF1, 0x0CF2},\n\t{0x0D01, 0x0D01}, {0x0D02, 0x0D03}, {0x0D05, 0x0D0C},\n\t{0x0D0E, 0x0D10}, {0x0D12, 0x0D3A}, {0x0D3D, 0x0D3D},\n\t{0x0D3E, 0x0D40}, {0x0D41, 0x0D44}, {0x0D46, 0x0D48},\n\t{0x0D4A, 0x0D4C}, {0x0D4D, 0x0D4D}, {0x0D4E, 0x0D4E},\n\t{0x0D4F, 0x0D4F}, {0x0D54, 0x0D56}, {0x0D57, 0x0D57},\n\t{0x0D58, 0x0D5E}, {0x0D5F, 0x0D61}, {0x0D62, 0x0D63},\n\t{0x0D66, 0x0D6F}, {0x0D70, 0x0D78}, {0x0D79, 0x0D79},\n\t{0x0D7A, 0x0D7F}, {0x0D82, 0x0D83}, {0x0D85, 0x0D96},\n\t{0x0D9A, 0x0DB1}, {0x0DB3, 0x0DBB}, {0x0DBD, 0x0DBD},\n\t{0x0DC0, 0x0DC6}, {0x0DCA, 0x0DCA}, {0x0DCF, 0x0DD1},\n\t{0x0DD2, 0x0DD4}, {0x0DD6, 0x0DD6}, {0x0DD8, 0x0DDF},\n\t{0x0DE6, 0x0DEF}, {0x0DF2, 0x0DF3}, {0x0DF4, 0x0DF4},\n\t{0x0E01, 0x0E30}, {0x0E31, 0x0E31}, {0x0E32, 0x0E33},\n\t{0x0E34, 0x0E3A}, {0x0E3F, 0x0E3F}, {0x0E40, 0x0E45},\n\t{0x0E46, 0x0E46}, {0x0E47, 0x0E4E}, {0x0E4F, 0x0E4F},\n\t{0x0E50, 0x0E59}, {0x0E5A, 0x0E5B}, {0x0E81, 0x0E82},\n\t{0x0E84, 0x0E84}, {0x0E87, 0x0E88}, {0x0E8A, 0x0E8A},\n\t{0x0E8D, 0x0E8D}, {0x0E94, 0x0E97}, {0x0E99, 0x0E9F},\n\t{0x0EA1, 0x0EA3}, {0x0EA5, 0x0EA5}, {0x0EA7, 0x0EA7},\n\t{0x0EAA, 0x0EAB}, {0x0EAD, 0x0EB0}, {0x0EB1, 0x0EB1},\n\t{0x0EB2, 0x0EB3}, {0x0EB4, 0x0EB9}, {0x0EBB, 0x0EBC},\n\t{0x0EBD, 0x0EBD}, {0x0EC0, 0x0EC4}, {0x0EC6, 0x0EC6},\n\t{0x0EC8, 0x0ECD}, {0x0ED0, 0x0ED9}, {0x0EDC, 0x0EDF},\n\t{0x0F00, 0x0F00}, {0x0F01, 0x0F03}, {0x0F04, 0x0F12},\n\t{0x0F13, 0x0F13}, {0x0F14, 0x0F14}, {0x0F15, 0x0F17},\n\t{0x0F18, 0x0F19}, {0x0F1A, 0x0F1F}, {0x0F20, 0x0F29},\n\t{0x0F2A, 0x0F33}, {0x0F34, 0x0F34}, {0x0F35, 0x0F35},\n\t{0x0F36, 0x0F36}, {0x0F37, 0x0F37}, {0x0F38, 0x0F38},\n\t{0x0F39, 0x0F39}, {0x0F3A, 0x0F3A}, {0x0F3B, 0x0F3B},\n\t{0x0F3C, 0x0F3C}, {0x0F3D, 0x0F3D}, {0x0F3E, 0x0F3F},\n\t{0x0F40, 0x0F47}, {0x0F49, 0x0F6C}, {0x0F71, 0x0F7E},\n\t{0x0F7F, 0x0F7F}, {0x0F80, 0x0F84}, {0x0F85, 0x0F85},\n\t{0x0F86, 0x0F87}, {0x0F88, 0x0F8C}, {0x0F8D, 0x0F97},\n\t{0x0F99, 0x0FBC}, {0x0FBE, 0x0FC5}, {0x0FC6, 0x0FC6},\n\t{0x0FC7, 0x0FCC}, {0x0FCE, 0x0FCF}, {0x0FD0, 0x0FD4},\n\t{0x0FD5, 0x0FD8}, {0x0FD9, 0x0FDA}, {0x1000, 0x102A},\n\t{0x102B, 0x102C}, {0x102D, 0x1030}, {0x1031, 0x1031},\n\t{0x1032, 0x1037}, {0x1038, 0x1038}, {0x1039, 0x103A},\n\t{0x103B, 0x103C}, {0x103D, 0x103E}, {0x103F, 0x103F},\n\t{0x1040, 0x1049}, {0x104A, 0x104F}, {0x1050, 0x1055},\n\t{0x1056, 0x1057}, {0x1058, 0x1059}, {0x105A, 0x105D},\n\t{0x105E, 0x1060}, {0x1061, 0x1061}, {0x1062, 0x1064},\n\t{0x1065, 0x1066}, {0x1067, 0x106D}, {0x106E, 0x1070},\n\t{0x1071, 0x1074}, {0x1075, 0x1081}, {0x1082, 0x1082},\n\t{0x1083, 0x1084}, {0x1085, 0x1086}, {0x1087, 0x108C},\n\t{0x108D, 0x108D}, {0x108E, 0x108E}, {0x108F, 0x108F},\n\t{0x1090, 0x1099}, {0x109A, 0x109C}, {0x109D, 0x109D},\n\t{0x109E, 0x109F}, {0x10A0, 0x10C5}, {0x10C7, 0x10C7},\n\t{0x10CD, 0x10CD}, {0x10D0, 0x10FA}, {0x10FB, 0x10FB},\n\t{0x10FC, 0x10FC}, {0x10FD, 0x10FF}, {0x1160, 0x11FF},\n\t{0x1200, 0x1248}, {0x124A, 0x124D}, {0x1250, 0x1256},\n\t{0x1258, 0x1258}, {0x125A, 0x125D}, {0x1260, 0x1288},\n\t{0x128A, 0x128D}, {0x1290, 0x12B0}, {0x12B2, 0x12B5},\n\t{0x12B8, 0x12BE}, {0x12C0, 0x12C0}, {0x12C2, 0x12C5},\n\t{0x12C8, 0x12D6}, {0x12D8, 0x1310}, {0x1312, 0x1315},\n\t{0x1318, 0x135A}, {0x135D, 0x135F}, {0x1360, 0x1368},\n\t{0x1369, 0x137C}, {0x1380, 0x138F}, {0x1390, 0x1399},\n\t{0x13A0, 0x13F5}, {0x13F8, 0x13FD}, {0x1400, 0x1400},\n\t{0x1401, 0x166C}, {0x166D, 0x166E}, {0x166F, 0x167F},\n\t{0x1680, 0x1680}, {0x1681, 0x169A}, {0x169B, 0x169B},\n\t{0x169C, 0x169C}, {0x16A0, 0x16EA}, {0x16EB, 0x16ED},\n\t{0x16EE, 0x16F0}, {0x16F1, 0x16F8}, {0x1700, 0x170C},\n\t{0x170E, 0x1711}, {0x1712, 0x1714}, {0x1720, 0x1731},\n\t{0x1732, 0x1734}, {0x1735, 0x1736}, {0x1740, 0x1751},\n\t{0x1752, 0x1753}, {0x1760, 0x176C}, {0x176E, 0x1770},\n\t{0x1772, 0x1773}, {0x1780, 0x17B3}, {0x17B4, 0x17B5},\n\t{0x17B6, 0x17B6}, {0x17B7, 0x17BD}, {0x17BE, 0x17C5},\n\t{0x17C6, 0x17C6}, {0x17C7, 0x17C8}, {0x17C9, 0x17D3},\n\t{0x17D4, 0x17D6}, {0x17D7, 0x17D7}, {0x17D8, 0x17DA},\n\t{0x17DB, 0x17DB}, {0x17DC, 0x17DC}, {0x17DD, 0x17DD},\n\t{0x17E0, 0x17E9}, {0x17F0, 0x17F9}, {0x1800, 0x1805},\n\t{0x1806, 0x1806}, {0x1807, 0x180A}, {0x180B, 0x180D},\n\t{0x180E, 0x180E}, {0x1810, 0x1819}, {0x1820, 0x1842},\n\t{0x1843, 0x1843}, {0x1844, 0x1877}, {0x1880, 0x1884},\n\t{0x1885, 0x1886}, {0x1887, 0x18A8}, {0x18A9, 0x18A9},\n\t{0x18AA, 0x18AA}, {0x18B0, 0x18F5}, {0x1900, 0x191E},\n\t{0x1920, 0x1922}, {0x1923, 0x1926}, {0x1927, 0x1928},\n\t{0x1929, 0x192B}, {0x1930, 0x1931}, {0x1932, 0x1932},\n\t{0x1933, 0x1938}, {0x1939, 0x193B}, {0x1940, 0x1940},\n\t{0x1944, 0x1945}, {0x1946, 0x194F}, {0x1950, 0x196D},\n\t{0x1970, 0x1974}, {0x1980, 0x19AB}, {0x19B0, 0x19C9},\n\t{0x19D0, 0x19D9}, {0x19DA, 0x19DA}, {0x19DE, 0x19DF},\n\t{0x19E0, 0x19FF}, {0x1A00, 0x1A16}, {0x1A17, 0x1A18},\n\t{0x1A19, 0x1A1A}, {0x1A1B, 0x1A1B}, {0x1A1E, 0x1A1F},\n\t{0x1A20, 0x1A54}, {0x1A55, 0x1A55}, {0x1A56, 0x1A56},\n\t{0x1A57, 0x1A57}, {0x1A58, 0x1A5E}, {0x1A60, 0x1A60},\n\t{0x1A61, 0x1A61}, {0x1A62, 0x1A62}, {0x1A63, 0x1A64},\n\t{0x1A65, 0x1A6C}, {0x1A6D, 0x1A72}, {0x1A73, 0x1A7C},\n\t{0x1A7F, 0x1A7F}, {0x1A80, 0x1A89}, {0x1A90, 0x1A99},\n\t{0x1AA0, 0x1AA6}, {0x1AA7, 0x1AA7}, {0x1AA8, 0x1AAD},\n\t{0x1AB0, 0x1ABD}, {0x1ABE, 0x1ABE}, {0x1B00, 0x1B03},\n\t{0x1B04, 0x1B04}, {0x1B05, 0x1B33}, {0x1B34, 0x1B34},\n\t{0x1B35, 0x1B35}, {0x1B36, 0x1B3A}, {0x1B3B, 0x1B3B},\n\t{0x1B3C, 0x1B3C}, {0x1B3D, 0x1B41}, {0x1B42, 0x1B42},\n\t{0x1B43, 0x1B44}, {0x1B45, 0x1B4B}, {0x1B50, 0x1B59},\n\t{0x1B5A, 0x1B60}, {0x1B61, 0x1B6A}, {0x1B6B, 0x1B73},\n\t{0x1B74, 0x1B7C}, {0x1B80, 0x1B81}, {0x1B82, 0x1B82},\n\t{0x1B83, 0x1BA0}, {0x1BA1, 0x1BA1}, {0x1BA2, 0x1BA5},\n\t{0x1BA6, 0x1BA7}, {0x1BA8, 0x1BA9}, {0x1BAA, 0x1BAA},\n\t{0x1BAB, 0x1BAD}, {0x1BAE, 0x1BAF}, {0x1BB0, 0x1BB9},\n\t{0x1BBA, 0x1BBF}, {0x1BC0, 0x1BE5}, {0x1BE6, 0x1BE6},\n\t{0x1BE7, 0x1BE7}, {0x1BE8, 0x1BE9}, {0x1BEA, 0x1BEC},\n\t{0x1BED, 0x1BED}, {0x1BEE, 0x1BEE}, {0x1BEF, 0x1BF1},\n\t{0x1BF2, 0x1BF3}, {0x1BFC, 0x1BFF}, {0x1C00, 0x1C23},\n\t{0x1C24, 0x1C2B}, {0x1C2C, 0x1C33}, {0x1C34, 0x1C35},\n\t{0x1C36, 0x1C37}, {0x1C3B, 0x1C3F}, {0x1C40, 0x1C49},\n\t{0x1C4D, 0x1C4F}, {0x1C50, 0x1C59}, {0x1C5A, 0x1C77},\n\t{0x1C78, 0x1C7D}, {0x1C7E, 0x1C7F}, {0x1C80, 0x1C88},\n\t{0x1CC0, 0x1CC7}, {0x1CD0, 0x1CD2}, {0x1CD3, 0x1CD3},\n\t{0x1CD4, 0x1CE0}, {0x1CE1, 0x1CE1}, {0x1CE2, 0x1CE8},\n\t{0x1CE9, 0x1CEC}, {0x1CED, 0x1CED}, {0x1CEE, 0x1CF1},\n\t{0x1CF2, 0x1CF3}, {0x1CF4, 0x1CF4}, {0x1CF5, 0x1CF6},\n\t{0x1CF8, 0x1CF9}, {0x1D00, 0x1D2B}, {0x1D2C, 0x1D6A},\n\t{0x1D6B, 0x1D77}, {0x1D78, 0x1D78}, {0x1D79, 0x1D7F},\n\t{0x1D80, 0x1D9A}, {0x1D9B, 0x1DBF}, {0x1DC0, 0x1DF5},\n\t{0x1DFB, 0x1DFF}, {0x1E00, 0x1EFF}, {0x1F00, 0x1F15},\n\t{0x1F18, 0x1F1D}, {0x1F20, 0x1F45}, {0x1F48, 0x1F4D},\n\t{0x1F50, 0x1F57}, {0x1F59, 0x1F59}, {0x1F5B, 0x1F5B},\n\t{0x1F5D, 0x1F5D}, {0x1F5F, 0x1F7D}, {0x1F80, 0x1FB4},\n\t{0x1FB6, 0x1FBC}, {0x1FBD, 0x1FBD}, {0x1FBE, 0x1FBE},\n\t{0x1FBF, 0x1FC1}, {0x1FC2, 0x1FC4}, {0x1FC6, 0x1FCC},\n\t{0x1FCD, 0x1FCF}, {0x1FD0, 0x1FD3}, {0x1FD6, 0x1FDB},\n\t{0x1FDD, 0x1FDF}, {0x1FE0, 0x1FEC}, {0x1FED, 0x1FEF},\n\t{0x1FF2, 0x1FF4}, {0x1FF6, 0x1FFC}, {0x1FFD, 0x1FFE},\n\t{0x2000, 0x200A}, {0x200B, 0x200F}, {0x2011, 0x2012},\n\t{0x2017, 0x2017}, {0x201A, 0x201A}, {0x201B, 0x201B},\n\t{0x201E, 0x201E}, {0x201F, 0x201F}, {0x2023, 0x2023},\n\t{0x2028, 0x2028}, {0x2029, 0x2029}, {0x202A, 0x202E},\n\t{0x202F, 0x202F}, {0x2031, 0x2031}, {0x2034, 0x2034},\n\t{0x2036, 0x2038}, {0x2039, 0x2039}, {0x203A, 0x203A},\n\t{0x203C, 0x203D}, {0x203F, 0x2040}, {0x2041, 0x2043},\n\t{0x2044, 0x2044}, {0x2045, 0x2045}, {0x2046, 0x2046},\n\t{0x2047, 0x2051}, {0x2052, 0x2052}, {0x2053, 0x2053},\n\t{0x2054, 0x2054}, {0x2055, 0x205E}, {0x205F, 0x205F},\n\t{0x2060, 0x2064}, {0x2066, 0x206F}, {0x2070, 0x2070},\n\t{0x2071, 0x2071}, {0x2075, 0x2079}, {0x207A, 0x207C},\n\t{0x207D, 0x207D}, {0x207E, 0x207E}, {0x2080, 0x2080},\n\t{0x2085, 0x2089}, {0x208A, 0x208C}, {0x208D, 0x208D},\n\t{0x208E, 0x208E}, {0x2090, 0x209C}, {0x20A0, 0x20A8},\n\t{0x20AA, 0x20AB}, {0x20AD, 0x20BE}, {0x20D0, 0x20DC},\n\t{0x20DD, 0x20E0}, {0x20E1, 0x20E1}, {0x20E2, 0x20E4},\n\t{0x20E5, 0x20F0}, {0x2100, 0x2101}, {0x2102, 0x2102},\n\t{0x2104, 0x2104}, {0x2106, 0x2106}, {0x2107, 0x2107},\n\t{0x2108, 0x2108}, {0x210A, 0x2112}, {0x2114, 0x2114},\n\t{0x2115, 0x2115}, {0x2117, 0x2117}, {0x2118, 0x2118},\n\t{0x2119, 0x211D}, {0x211E, 0x2120}, {0x2123, 0x2123},\n\t{0x2124, 0x2124}, {0x2125, 0x2125}, {0x2127, 0x2127},\n\t{0x2128, 0x2128}, {0x2129, 0x2129}, {0x212A, 0x212A},\n\t{0x212C, 0x212D}, {0x212E, 0x212E}, {0x212F, 0x2134},\n\t{0x2135, 0x2138}, {0x2139, 0x2139}, {0x213A, 0x213B},\n\t{0x213C, 0x213F}, {0x2140, 0x2144}, {0x2145, 0x2149},\n\t{0x214A, 0x214A}, {0x214B, 0x214B}, {0x214C, 0x214D},\n\t{0x214E, 0x214E}, {0x214F, 0x214F}, {0x2150, 0x2152},\n\t{0x2155, 0x215A}, {0x215F, 0x215F}, {0x216C, 0x216F},\n\t{0x217A, 0x2182}, {0x2183, 0x2184}, {0x2185, 0x2188},\n\t{0x218A, 0x218B}, {0x219A, 0x219B}, {0x219C, 0x219F},\n\t{0x21A0, 0x21A0}, {0x21A1, 0x21A2}, {0x21A3, 0x21A3},\n\t{0x21A4, 0x21A5}, {0x21A6, 0x21A6}, {0x21A7, 0x21AD},\n\t{0x21AE, 0x21AE}, {0x21AF, 0x21B7}, {0x21BA, 0x21CD},\n\t{0x21CE, 0x21CF}, {0x21D0, 0x21D1}, {0x21D3, 0x21D3},\n\t{0x21D5, 0x21E6}, {0x21E8, 0x21F3}, {0x21F4, 0x21FF},\n\t{0x2201, 0x2201}, {0x2204, 0x2206}, {0x2209, 0x220A},\n\t{0x220C, 0x220E}, {0x2210, 0x2210}, {0x2212, 0x2214},\n\t{0x2216, 0x2219}, {0x221B, 0x221C}, {0x2221, 0x2222},\n\t{0x2224, 0x2224}, {0x2226, 0x2226}, {0x222D, 0x222D},\n\t{0x222F, 0x2233}, {0x2238, 0x223B}, {0x223E, 0x2247},\n\t{0x2249, 0x224B}, {0x224D, 0x2251}, {0x2253, 0x225F},\n\t{0x2262, 0x2263}, {0x2268, 0x2269}, {0x226C, 0x226D},\n\t{0x2270, 0x2281}, {0x2284, 0x2285}, {0x2288, 0x2294},\n\t{0x2296, 0x2298}, {0x229A, 0x22A4}, {0x22A6, 0x22BE},\n\t{0x22C0, 0x22FF}, {0x2300, 0x2307}, {0x2308, 0x2308},\n\t{0x2309, 0x2309}, {0x230A, 0x230A}, {0x230B, 0x230B},\n\t{0x230C, 0x2311}, {0x2313, 0x2319}, {0x231C, 0x231F},\n\t{0x2320, 0x2321}, {0x2322, 0x2328}, {0x232B, 0x237B},\n\t{0x237C, 0x237C}, {0x237D, 0x239A}, {0x239B, 0x23B3},\n\t{0x23B4, 0x23DB}, {0x23DC, 0x23E1}, {0x23E2, 0x23E8},\n\t{0x23ED, 0x23EF}, {0x23F1, 0x23F2}, {0x23F4, 0x23FE},\n\t{0x2400, 0x2426}, {0x2440, 0x244A}, {0x24EA, 0x24EA},\n\t{0x254C, 0x254F}, {0x2574, 0x257F}, {0x2590, 0x2591},\n\t{0x2596, 0x259F}, {0x25A2, 0x25A2}, {0x25AA, 0x25B1},\n\t{0x25B4, 0x25B5}, {0x25B8, 0x25BB}, {0x25BE, 0x25BF},\n\t{0x25C2, 0x25C5}, {0x25C9, 0x25CA}, {0x25CC, 0x25CD},\n\t{0x25D2, 0x25E1}, {0x25E6, 0x25EE}, {0x25F0, 0x25F7},\n\t{0x25F8, 0x25FC}, {0x25FF, 0x25FF}, {0x2600, 0x2604},\n\t{0x2607, 0x2608}, {0x260A, 0x260D}, {0x2610, 0x2613},\n\t{0x2616, 0x261B}, {0x261D, 0x261D}, {0x261F, 0x263F},\n\t{0x2641, 0x2641}, {0x2643, 0x2647}, {0x2654, 0x265F},\n\t{0x2662, 0x2662}, {0x2666, 0x2666}, {0x266B, 0x266B},\n\t{0x266E, 0x266E}, {0x2670, 0x267E}, {0x2680, 0x2692},\n\t{0x2694, 0x269D}, {0x26A0, 0x26A0}, {0x26A2, 0x26A9},\n\t{0x26AC, 0x26BC}, {0x26C0, 0x26C3}, {0x26E2, 0x26E2},\n\t{0x26E4, 0x26E7}, {0x2700, 0x2704}, {0x2706, 0x2709},\n\t{0x270C, 0x2727}, {0x2729, 0x273C}, {0x273E, 0x274B},\n\t{0x274D, 0x274D}, {0x274F, 0x2752}, {0x2756, 0x2756},\n\t{0x2758, 0x2767}, {0x2768, 0x2768}, {0x2769, 0x2769},\n\t{0x276A, 0x276A}, {0x276B, 0x276B}, {0x276C, 0x276C},\n\t{0x276D, 0x276D}, {0x276E, 0x276E}, {0x276F, 0x276F},\n\t{0x2770, 0x2770}, {0x2771, 0x2771}, {0x2772, 0x2772},\n\t{0x2773, 0x2773}, {0x2774, 0x2774}, {0x2775, 0x2775},\n\t{0x2780, 0x2793}, {0x2794, 0x2794}, {0x2798, 0x27AF},\n\t{0x27B1, 0x27BE}, {0x27C0, 0x27C4}, {0x27C5, 0x27C5},\n\t{0x27C6, 0x27C6}, {0x27C7, 0x27E5}, {0x27EE, 0x27EE},\n\t{0x27EF, 0x27EF}, {0x27F0, 0x27FF}, {0x2800, 0x28FF},\n\t{0x2900, 0x297F}, {0x2980, 0x2982}, {0x2983, 0x2983},\n\t{0x2984, 0x2984}, {0x2987, 0x2987}, {0x2988, 0x2988},\n\t{0x2989, 0x2989}, {0x298A, 0x298A}, {0x298B, 0x298B},\n\t{0x298C, 0x298C}, {0x298D, 0x298D}, {0x298E, 0x298E},\n\t{0x298F, 0x298F}, {0x2990, 0x2990}, {0x2991, 0x2991},\n\t{0x2992, 0x2992}, {0x2993, 0x2993}, {0x2994, 0x2994},\n\t{0x2995, 0x2995}, {0x2996, 0x2996}, {0x2997, 0x2997},\n\t{0x2998, 0x2998}, {0x2999, 0x29D7}, {0x29D8, 0x29D8},\n\t{0x29D9, 0x29D9}, {0x29DA, 0x29DA}, {0x29DB, 0x29DB},\n\t{0x29DC, 0x29FB}, {0x29FC, 0x29FC}, {0x29FD, 0x29FD},\n\t{0x29FE, 0x29FF}, {0x2A00, 0x2AFF}, {0x2B00, 0x2B1A},\n\t{0x2B1D, 0x2B2F}, {0x2B30, 0x2B44}, {0x2B45, 0x2B46},\n\t{0x2B47, 0x2B4C}, {0x2B4D, 0x2B4F}, {0x2B51, 0x2B54},\n\t{0x2B5A, 0x2B73}, {0x2B76, 0x2B95}, {0x2B98, 0x2BB9},\n\t{0x2BBD, 0x2BC8}, {0x2BCA, 0x2BD1}, {0x2BEC, 0x2BEF},\n\t{0x2C00, 0x2C2E}, {0x2C30, 0x2C5E}, {0x2C60, 0x2C7B},\n\t{0x2C7C, 0x2C7D}, {0x2C7E, 0x2C7F}, {0x2C80, 0x2CE4},\n\t{0x2CE5, 0x2CEA}, {0x2CEB, 0x2CEE}, {0x2CEF, 0x2CF1},\n\t{0x2CF2, 0x2CF3}, {0x2CF9, 0x2CFC}, {0x2CFD, 0x2CFD},\n\t{0x2CFE, 0x2CFF}, {0x2D00, 0x2D25}, {0x2D27, 0x2D27},\n\t{0x2D2D, 0x2D2D}, {0x2D30, 0x2D67}, {0x2D6F, 0x2D6F},\n\t{0x2D70, 0x2D70}, {0x2D7F, 0x2D7F}, {0x2D80, 0x2D96},\n\t{0x2DA0, 0x2DA6}, {0x2DA8, 0x2DAE}, {0x2DB0, 0x2DB6},\n\t{0x2DB8, 0x2DBE}, {0x2DC0, 0x2DC6}, {0x2DC8, 0x2DCE},\n\t{0x2DD0, 0x2DD6}, {0x2DD8, 0x2DDE}, {0x2DE0, 0x2DFF},\n\t{0x2E00, 0x2E01}, {0x2E02, 0x2E02}, {0x2E03, 0x2E03},\n\t{0x2E04, 0x2E04}, {0x2E05, 0x2E05}, {0x2E06, 0x2E08},\n\t{0x2E09, 0x2E09}, {0x2E0A, 0x2E0A}, {0x2E0B, 0x2E0B},\n\t{0x2E0C, 0x2E0C}, {0x2E0D, 0x2E0D}, {0x2E0E, 0x2E16},\n\t{0x2E17, 0x2E17}, {0x2E18, 0x2E19}, {0x2E1A, 0x2E1A},\n\t{0x2E1B, 0x2E1B}, {0x2E1C, 0x2E1C}, {0x2E1D, 0x2E1D},\n\t{0x2E1E, 0x2E1F}, {0x2E20, 0x2E20}, {0x2E21, 0x2E21},\n\t{0x2E22, 0x2E22}, {0x2E23, 0x2E23}, {0x2E24, 0x2E24},\n\t{0x2E25, 0x2E25}, {0x2E26, 0x2E26}, {0x2E27, 0x2E27},\n\t{0x2E28, 0x2E28}, {0x2E29, 0x2E29}, {0x2E2A, 0x2E2E},\n\t{0x2E2F, 0x2E2F}, {0x2E30, 0x2E39}, {0x2E3A, 0x2E3B},\n\t{0x2E3C, 0x2E3F}, {0x2E40, 0x2E40}, {0x2E41, 0x2E41},\n\t{0x2E42, 0x2E42}, {0x2E43, 0x2E44}, {0x303F, 0x303F},\n\t{0x4DC0, 0x4DFF}, {0xA4D0, 0xA4F7}, {0xA4F8, 0xA4FD},\n\t{0xA4FE, 0xA4FF}, {0xA500, 0xA60B}, {0xA60C, 0xA60C},\n\t{0xA60D, 0xA60F}, {0xA610, 0xA61F}, {0xA620, 0xA629},\n\t{0xA62A, 0xA62B}, {0xA640, 0xA66D}, {0xA66E, 0xA66E},\n\t{0xA66F, 0xA66F}, {0xA670, 0xA672}, {0xA673, 0xA673},\n\t{0xA674, 0xA67D}, {0xA67E, 0xA67E}, {0xA67F, 0xA67F},\n\t{0xA680, 0xA69B}, {0xA69C, 0xA69D}, {0xA69E, 0xA69F},\n\t{0xA6A0, 0xA6E5}, {0xA6E6, 0xA6EF}, {0xA6F0, 0xA6F1},\n\t{0xA6F2, 0xA6F7}, {0xA700, 0xA716}, {0xA717, 0xA71F},\n\t{0xA720, 0xA721}, {0xA722, 0xA76F}, {0xA770, 0xA770},\n\t{0xA771, 0xA787}, {0xA788, 0xA788}, {0xA789, 0xA78A},\n\t{0xA78B, 0xA78E}, {0xA78F, 0xA78F}, {0xA790, 0xA7AE},\n\t{0xA7B0, 0xA7B7}, {0xA7F7, 0xA7F7}, {0xA7F8, 0xA7F9},\n\t{0xA7FA, 0xA7FA}, {0xA7FB, 0xA7FF}, {0xA800, 0xA801},\n\t{0xA802, 0xA802}, {0xA803, 0xA805}, {0xA806, 0xA806},\n\t{0xA807, 0xA80A}, {0xA80B, 0xA80B}, {0xA80C, 0xA822},\n\t{0xA823, 0xA824}, {0xA825, 0xA826}, {0xA827, 0xA827},\n\t{0xA828, 0xA82B}, {0xA830, 0xA835}, {0xA836, 0xA837},\n\t{0xA838, 0xA838}, {0xA839, 0xA839}, {0xA840, 0xA873},\n\t{0xA874, 0xA877}, {0xA880, 0xA881}, {0xA882, 0xA8B3},\n\t{0xA8B4, 0xA8C3}, {0xA8C4, 0xA8C5}, {0xA8CE, 0xA8CF},\n\t{0xA8D0, 0xA8D9}, {0xA8E0, 0xA8F1}, {0xA8F2, 0xA8F7},\n\t{0xA8F8, 0xA8FA}, {0xA8FB, 0xA8FB}, {0xA8FC, 0xA8FC},\n\t{0xA8FD, 0xA8FD}, {0xA900, 0xA909}, {0xA90A, 0xA925},\n\t{0xA926, 0xA92D}, {0xA92E, 0xA92F}, {0xA930, 0xA946},\n\t{0xA947, 0xA951}, {0xA952, 0xA953}, {0xA95F, 0xA95F},\n\t{0xA980, 0xA982}, {0xA983, 0xA983}, {0xA984, 0xA9B2},\n\t{0xA9B3, 0xA9B3}, {0xA9B4, 0xA9B5}, {0xA9B6, 0xA9B9},\n\t{0xA9BA, 0xA9BB}, {0xA9BC, 0xA9BC}, {0xA9BD, 0xA9C0},\n\t{0xA9C1, 0xA9CD}, {0xA9CF, 0xA9CF}, {0xA9D0, 0xA9D9},\n\t{0xA9DE, 0xA9DF}, {0xA9E0, 0xA9E4}, {0xA9E5, 0xA9E5},\n\t{0xA9E6, 0xA9E6}, {0xA9E7, 0xA9EF}, {0xA9F0, 0xA9F9},\n\t{0xA9FA, 0xA9FE}, {0xAA00, 0xAA28}, {0xAA29, 0xAA2E},\n\t{0xAA2F, 0xAA30}, {0xAA31, 0xAA32}, {0xAA33, 0xAA34},\n\t{0xAA35, 0xAA36}, {0xAA40, 0xAA42}, {0xAA43, 0xAA43},\n\t{0xAA44, 0xAA4B}, {0xAA4C, 0xAA4C}, {0xAA4D, 0xAA4D},\n\t{0xAA50, 0xAA59}, {0xAA5C, 0xAA5F}, {0xAA60, 0xAA6F},\n\t{0xAA70, 0xAA70}, {0xAA71, 0xAA76}, {0xAA77, 0xAA79},\n\t{0xAA7A, 0xAA7A}, {0xAA7B, 0xAA7B}, {0xAA7C, 0xAA7C},\n\t{0xAA7D, 0xAA7D}, {0xAA7E, 0xAA7F}, {0xAA80, 0xAAAF},\n\t{0xAAB0, 0xAAB0}, {0xAAB1, 0xAAB1}, {0xAAB2, 0xAAB4},\n\t{0xAAB5, 0xAAB6}, {0xAAB7, 0xAAB8}, {0xAAB9, 0xAABD},\n\t{0xAABE, 0xAABF}, {0xAAC0, 0xAAC0}, {0xAAC1, 0xAAC1},\n\t{0xAAC2, 0xAAC2}, {0xAADB, 0xAADC}, {0xAADD, 0xAADD},\n\t{0xAADE, 0xAADF}, {0xAAE0, 0xAAEA}, {0xAAEB, 0xAAEB},\n\t{0xAAEC, 0xAAED}, {0xAAEE, 0xAAEF}, {0xAAF0, 0xAAF1},\n\t{0xAAF2, 0xAAF2}, {0xAAF3, 0xAAF4}, {0xAAF5, 0xAAF5},\n\t{0xAAF6, 0xAAF6}, {0xAB01, 0xAB06}, {0xAB09, 0xAB0E},\n\t{0xAB11, 0xAB16}, {0xAB20, 0xAB26}, {0xAB28, 0xAB2E},\n\t{0xAB30, 0xAB5A}, {0xAB5B, 0xAB5B}, {0xAB5C, 0xAB5F},\n\t{0xAB60, 0xAB65}, {0xAB70, 0xABBF}, {0xABC0, 0xABE2},\n\t{0xABE3, 0xABE4}, {0xABE5, 0xABE5}, {0xABE6, 0xABE7},\n\t{0xABE8, 0xABE8}, {0xABE9, 0xABEA}, {0xABEB, 0xABEB},\n\t{0xABEC, 0xABEC}, {0xABED, 0xABED}, {0xABF0, 0xABF9},\n\t{0xD7B0, 0xD7C6}, {0xD7CB, 0xD7FB}, {0xD800, 0xDB7F},\n\t{0xDB80, 0xDBFF}, {0xDC00, 0xDFFF}, {0xFB00, 0xFB06},\n\t{0xFB13, 0xFB17}, {0xFB1D, 0xFB1D}, {0xFB1E, 0xFB1E},\n\t{0xFB1F, 0xFB28}, {0xFB29, 0xFB29}, {0xFB2A, 0xFB36},\n\t{0xFB38, 0xFB3C}, {0xFB3E, 0xFB3E}, {0xFB40, 0xFB41},\n\t{0xFB43, 0xFB44}, {0xFB46, 0xFB4F}, {0xFB50, 0xFBB1},\n\t{0xFBB2, 0xFBC1}, {0xFBD3, 0xFD3D}, {0xFD3E, 0xFD3E},\n\t{0xFD3F, 0xFD3F}, {0xFD50, 0xFD8F}, {0xFD92, 0xFDC7},\n\t{0xFDF0, 0xFDFB}, {0xFDFC, 0xFDFC}, {0xFDFD, 0xFDFD},\n\t{0xFE20, 0xFE2F}, {0xFE70, 0xFE74}, {0xFE76, 0xFEFC},\n\t{0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFB}, {0xFFFC, 0xFFFC},\n\t{0x10000, 0x1000B}, {0x1000D, 0x10026}, {0x10028, 0x1003A},\n\t{0x1003C, 0x1003D}, {0x1003F, 0x1004D}, {0x10050, 0x1005D},\n\t{0x10080, 0x100FA}, {0x10100, 0x10102}, {0x10107, 0x10133},\n\t{0x10137, 0x1013F}, {0x10140, 0x10174}, {0x10175, 0x10178},\n\t{0x10179, 0x10189}, {0x1018A, 0x1018B}, {0x1018C, 0x1018E},\n\t{0x10190, 0x1019B}, {0x101A0, 0x101A0}, {0x101D0, 0x101FC},\n\t{0x101FD, 0x101FD}, {0x10280, 0x1029C}, {0x102A0, 0x102D0},\n\t{0x102E0, 0x102E0}, {0x102E1, 0x102FB}, {0x10300, 0x1031F},\n\t{0x10320, 0x10323}, {0x10330, 0x10340}, {0x10341, 0x10341},\n\t{0x10342, 0x10349}, {0x1034A, 0x1034A}, {0x10350, 0x10375},\n\t{0x10376, 0x1037A}, {0x10380, 0x1039D}, {0x1039F, 0x1039F},\n\t{0x103A0, 0x103C3}, {0x103C8, 0x103CF}, {0x103D0, 0x103D0},\n\t{0x103D1, 0x103D5}, {0x10400, 0x1044F}, {0x10450, 0x1047F},\n\t{0x10480, 0x1049D}, {0x104A0, 0x104A9}, {0x104B0, 0x104D3},\n\t{0x104D8, 0x104FB}, {0x10500, 0x10527}, {0x10530, 0x10563},\n\t{0x1056F, 0x1056F}, {0x10600, 0x10736}, {0x10740, 0x10755},\n\t{0x10760, 0x10767}, {0x10800, 0x10805}, {0x10808, 0x10808},\n\t{0x1080A, 0x10835}, {0x10837, 0x10838}, {0x1083C, 0x1083C},\n\t{0x1083F, 0x1083F}, {0x10840, 0x10855}, {0x10857, 0x10857},\n\t{0x10858, 0x1085F}, {0x10860, 0x10876}, {0x10877, 0x10878},\n\t{0x10879, 0x1087F}, {0x10880, 0x1089E}, {0x108A7, 0x108AF},\n\t{0x108E0, 0x108F2}, {0x108F4, 0x108F5}, {0x108FB, 0x108FF},\n\t{0x10900, 0x10915}, {0x10916, 0x1091B}, {0x1091F, 0x1091F},\n\t{0x10920, 0x10939}, {0x1093F, 0x1093F}, {0x10980, 0x1099F},\n\t{0x109A0, 0x109B7}, {0x109BC, 0x109BD}, {0x109BE, 0x109BF},\n\t{0x109C0, 0x109CF}, {0x109D2, 0x109FF}, {0x10A00, 0x10A00},\n\t{0x10A01, 0x10A03}, {0x10A05, 0x10A06}, {0x10A0C, 0x10A0F},\n\t{0x10A10, 0x10A13}, {0x10A15, 0x10A17}, {0x10A19, 0x10A33},\n\t{0x10A38, 0x10A3A}, {0x10A3F, 0x10A3F}, {0x10A40, 0x10A47},\n\t{0x10A50, 0x10A58}, {0x10A60, 0x10A7C}, {0x10A7D, 0x10A7E},\n\t{0x10A7F, 0x10A7F}, {0x10A80, 0x10A9C}, {0x10A9D, 0x10A9F},\n\t{0x10AC0, 0x10AC7}, {0x10AC8, 0x10AC8}, {0x10AC9, 0x10AE4},\n\t{0x10AE5, 0x10AE6}, {0x10AEB, 0x10AEF}, {0x10AF0, 0x10AF6},\n\t{0x10B00, 0x10B35}, {0x10B39, 0x10B3F}, {0x10B40, 0x10B55},\n\t{0x10B58, 0x10B5F}, {0x10B60, 0x10B72}, {0x10B78, 0x10B7F},\n\t{0x10B80, 0x10B91}, {0x10B99, 0x10B9C}, {0x10BA9, 0x10BAF},\n\t{0x10C00, 0x10C48}, {0x10C80, 0x10CB2}, {0x10CC0, 0x10CF2},\n\t{0x10CFA, 0x10CFF}, {0x10E60, 0x10E7E}, {0x11000, 0x11000},\n\t{0x11001, 0x11001}, {0x11002, 0x11002}, {0x11003, 0x11037},\n\t{0x11038, 0x11046}, {0x11047, 0x1104D}, {0x11052, 0x11065},\n\t{0x11066, 0x1106F}, {0x1107F, 0x1107F}, {0x11080, 0x11081},\n\t{0x11082, 0x11082}, {0x11083, 0x110AF}, {0x110B0, 0x110B2},\n\t{0x110B3, 0x110B6}, {0x110B7, 0x110B8}, {0x110B9, 0x110BA},\n\t{0x110BB, 0x110BC}, {0x110BD, 0x110BD}, {0x110BE, 0x110C1},\n\t{0x110D0, 0x110E8}, {0x110F0, 0x110F9}, {0x11100, 0x11102},\n\t{0x11103, 0x11126}, {0x11127, 0x1112B}, {0x1112C, 0x1112C},\n\t{0x1112D, 0x11134}, {0x11136, 0x1113F}, {0x11140, 0x11143},\n\t{0x11150, 0x11172}, {0x11173, 0x11173}, {0x11174, 0x11175},\n\t{0x11176, 0x11176}, {0x11180, 0x11181}, {0x11182, 0x11182},\n\t{0x11183, 0x111B2}, {0x111B3, 0x111B5}, {0x111B6, 0x111BE},\n\t{0x111BF, 0x111C0}, {0x111C1, 0x111C4}, {0x111C5, 0x111C9},\n\t{0x111CA, 0x111CC}, {0x111CD, 0x111CD}, {0x111D0, 0x111D9},\n\t{0x111DA, 0x111DA}, {0x111DB, 0x111DB}, {0x111DC, 0x111DC},\n\t{0x111DD, 0x111DF}, {0x111E1, 0x111F4}, {0x11200, 0x11211},\n\t{0x11213, 0x1122B}, {0x1122C, 0x1122E}, {0x1122F, 0x11231},\n\t{0x11232, 0x11233}, {0x11234, 0x11234}, {0x11235, 0x11235},\n\t{0x11236, 0x11237}, {0x11238, 0x1123D}, {0x1123E, 0x1123E},\n\t{0x11280, 0x11286}, {0x11288, 0x11288}, {0x1128A, 0x1128D},\n\t{0x1128F, 0x1129D}, {0x1129F, 0x112A8}, {0x112A9, 0x112A9},\n\t{0x112B0, 0x112DE}, {0x112DF, 0x112DF}, {0x112E0, 0x112E2},\n\t{0x112E3, 0x112EA}, {0x112F0, 0x112F9}, {0x11300, 0x11301},\n\t{0x11302, 0x11303}, {0x11305, 0x1130C}, {0x1130F, 0x11310},\n\t{0x11313, 0x11328}, {0x1132A, 0x11330}, {0x11332, 0x11333},\n\t{0x11335, 0x11339}, {0x1133C, 0x1133C}, {0x1133D, 0x1133D},\n\t{0x1133E, 0x1133F}, {0x11340, 0x11340}, {0x11341, 0x11344},\n\t{0x11347, 0x11348}, {0x1134B, 0x1134D}, {0x11350, 0x11350},\n\t{0x11357, 0x11357}, {0x1135D, 0x11361}, {0x11362, 0x11363},\n\t{0x11366, 0x1136C}, {0x11370, 0x11374}, {0x11400, 0x11434},\n\t{0x11435, 0x11437}, {0x11438, 0x1143F}, {0x11440, 0x11441},\n\t{0x11442, 0x11444}, {0x11445, 0x11445}, {0x11446, 0x11446},\n\t{0x11447, 0x1144A}, {0x1144B, 0x1144F}, {0x11450, 0x11459},\n\t{0x1145B, 0x1145B}, {0x1145D, 0x1145D}, {0x11480, 0x114AF},\n\t{0x114B0, 0x114B2}, {0x114B3, 0x114B8}, {0x114B9, 0x114B9},\n\t{0x114BA, 0x114BA}, {0x114BB, 0x114BE}, {0x114BF, 0x114C0},\n\t{0x114C1, 0x114C1}, {0x114C2, 0x114C3}, {0x114C4, 0x114C5},\n\t{0x114C6, 0x114C6}, {0x114C7, 0x114C7}, {0x114D0, 0x114D9},\n\t{0x11580, 0x115AE}, {0x115AF, 0x115B1}, {0x115B2, 0x115B5},\n\t{0x115B8, 0x115BB}, {0x115BC, 0x115BD}, {0x115BE, 0x115BE},\n\t{0x115BF, 0x115C0}, {0x115C1, 0x115D7}, {0x115D8, 0x115DB},\n\t{0x115DC, 0x115DD}, {0x11600, 0x1162F}, {0x11630, 0x11632},\n\t{0x11633, 0x1163A}, {0x1163B, 0x1163C}, {0x1163D, 0x1163D},\n\t{0x1163E, 0x1163E}, {0x1163F, 0x11640}, {0x11641, 0x11643},\n\t{0x11644, 0x11644}, {0x11650, 0x11659}, {0x11660, 0x1166C},\n\t{0x11680, 0x116AA}, {0x116AB, 0x116AB}, {0x116AC, 0x116AC},\n\t{0x116AD, 0x116AD}, {0x116AE, 0x116AF}, {0x116B0, 0x116B5},\n\t{0x116B6, 0x116B6}, {0x116B7, 0x116B7}, {0x116C0, 0x116C9},\n\t{0x11700, 0x11719}, {0x1171D, 0x1171F}, {0x11720, 0x11721},\n\t{0x11722, 0x11725}, {0x11726, 0x11726}, {0x11727, 0x1172B},\n\t{0x11730, 0x11739}, {0x1173A, 0x1173B}, {0x1173C, 0x1173E},\n\t{0x1173F, 0x1173F}, {0x118A0, 0x118DF}, {0x118E0, 0x118E9},\n\t{0x118EA, 0x118F2}, {0x118FF, 0x118FF}, {0x11AC0, 0x11AF8},\n\t{0x11C00, 0x11C08}, {0x11C0A, 0x11C2E}, {0x11C2F, 0x11C2F},\n\t{0x11C30, 0x11C36}, {0x11C38, 0x11C3D}, {0x11C3E, 0x11C3E},\n\t{0x11C3F, 0x11C3F}, {0x11C40, 0x11C40}, {0x11C41, 0x11C45},\n\t{0x11C50, 0x11C59}, {0x11C5A, 0x11C6C}, {0x11C70, 0x11C71},\n\t{0x11C72, 0x11C8F}, {0x11C92, 0x11CA7}, {0x11CA9, 0x11CA9},\n\t{0x11CAA, 0x11CB0}, {0x11CB1, 0x11CB1}, {0x11CB2, 0x11CB3},\n\t{0x11CB4, 0x11CB4}, {0x11CB5, 0x11CB6}, {0x12000, 0x12399},\n\t{0x12400, 0x1246E}, {0x12470, 0x12474}, {0x12480, 0x12543},\n\t{0x13000, 0x1342E}, {0x14400, 0x14646}, {0x16800, 0x16A38},\n\t{0x16A40, 0x16A5E}, {0x16A60, 0x16A69}, {0x16A6E, 0x16A6F},\n\t{0x16AD0, 0x16AED}, {0x16AF0, 0x16AF4}, {0x16AF5, 0x16AF5},\n\t{0x16B00, 0x16B2F}, {0x16B30, 0x16B36}, {0x16B37, 0x16B3B},\n\t{0x16B3C, 0x16B3F}, {0x16B40, 0x16B43}, {0x16B44, 0x16B44},\n\t{0x16B45, 0x16B45}, {0x16B50, 0x16B59}, {0x16B5B, 0x16B61},\n\t{0x16B63, 0x16B77}, {0x16B7D, 0x16B8F}, {0x16F00, 0x16F44},\n\t{0x16F50, 0x16F50}, {0x16F51, 0x16F7E}, {0x16F8F, 0x16F92},\n\t{0x16F93, 0x16F9F}, {0x1BC00, 0x1BC6A}, {0x1BC70, 0x1BC7C},\n\t{0x1BC80, 0x1BC88}, {0x1BC90, 0x1BC99}, {0x1BC9C, 0x1BC9C},\n\t{0x1BC9D, 0x1BC9E}, {0x1BC9F, 0x1BC9F}, {0x1BCA0, 0x1BCA3},\n\t{0x1D000, 0x1D0F5}, {0x1D100, 0x1D126}, {0x1D129, 0x1D164},\n\t{0x1D165, 0x1D166}, {0x1D167, 0x1D169}, {0x1D16A, 0x1D16C},\n\t{0x1D16D, 0x1D172}, {0x1D173, 0x1D17A}, {0x1D17B, 0x1D182},\n\t{0x1D183, 0x1D184}, {0x1D185, 0x1D18B}, {0x1D18C, 0x1D1A9},\n\t{0x1D1AA, 0x1D1AD}, {0x1D1AE, 0x1D1E8}, {0x1D200, 0x1D241},\n\t{0x1D242, 0x1D244}, {0x1D245, 0x1D245}, {0x1D300, 0x1D356},\n\t{0x1D360, 0x1D371}, {0x1D400, 0x1D454}, {0x1D456, 0x1D49C},\n\t{0x1D49E, 0x1D49F}, {0x1D4A2, 0x1D4A2}, {0x1D4A5, 0x1D4A6},\n\t{0x1D4A9, 0x1D4AC}, {0x1D4AE, 0x1D4B9}, {0x1D4BB, 0x1D4BB},\n\t{0x1D4BD, 0x1D4C3}, {0x1D4C5, 0x1D505}, {0x1D507, 0x1D50A},\n\t{0x1D50D, 0x1D514}, {0x1D516, 0x1D51C}, {0x1D51E, 0x1D539},\n\t{0x1D53B, 0x1D53E}, {0x1D540, 0x1D544}, {0x1D546, 0x1D546},\n\t{0x1D54A, 0x1D550}, {0x1D552, 0x1D6A5}, {0x1D6A8, 0x1D6C0},\n\t{0x1D6C1, 0x1D6C1}, {0x1D6C2, 0x1D6DA}, {0x1D6DB, 0x1D6DB},\n\t{0x1D6DC, 0x1D6FA}, {0x1D6FB, 0x1D6FB}, {0x1D6FC, 0x1D714},\n\t{0x1D715, 0x1D715}, {0x1D716, 0x1D734}, {0x1D735, 0x1D735},\n\t{0x1D736, 0x1D74E}, {0x1D74F, 0x1D74F}, {0x1D750, 0x1D76E},\n\t{0x1D76F, 0x1D76F}, {0x1D770, 0x1D788}, {0x1D789, 0x1D789},\n\t{0x1D78A, 0x1D7A8}, {0x1D7A9, 0x1D7A9}, {0x1D7AA, 0x1D7C2},\n\t{0x1D7C3, 0x1D7C3}, {0x1D7C4, 0x1D7CB}, {0x1D7CE, 0x1D7FF},\n\t{0x1D800, 0x1D9FF}, {0x1DA00, 0x1DA36}, {0x1DA37, 0x1DA3A},\n\t{0x1DA3B, 0x1DA6C}, {0x1DA6D, 0x1DA74}, {0x1DA75, 0x1DA75},\n\t{0x1DA76, 0x1DA83}, {0x1DA84, 0x1DA84}, {0x1DA85, 0x1DA86},\n\t{0x1DA87, 0x1DA8B}, {0x1DA9B, 0x1DA9F}, {0x1DAA1, 0x1DAAF},\n\t{0x1E000, 0x1E006}, {0x1E008, 0x1E018}, {0x1E01B, 0x1E021},\n\t{0x1E023, 0x1E024}, {0x1E026, 0x1E02A}, {0x1E800, 0x1E8C4},\n\t{0x1E8C7, 0x1E8CF}, {0x1E8D0, 0x1E8D6}, {0x1E900, 0x1E943},\n\t{0x1E944, 0x1E94A}, {0x1E950, 0x1E959}, {0x1E95E, 0x1E95F},\n\t{0x1EE00, 0x1EE03}, {0x1EE05, 0x1EE1F}, {0x1EE21, 0x1EE22},\n\t{0x1EE24, 0x1EE24}, {0x1EE27, 0x1EE27}, {0x1EE29, 0x1EE32},\n\t{0x1EE34, 0x1EE37}, {0x1EE39, 0x1EE39}, {0x1EE3B, 0x1EE3B},\n\t{0x1EE42, 0x1EE42}, {0x1EE47, 0x1EE47}, {0x1EE49, 0x1EE49},\n\t{0x1EE4B, 0x1EE4B}, {0x1EE4D, 0x1EE4F}, {0x1EE51, 0x1EE52},\n\t{0x1EE54, 0x1EE54}, {0x1EE57, 0x1EE57}, {0x1EE59, 0x1EE59},\n\t{0x1EE5B, 0x1EE5B}, {0x1EE5D, 0x1EE5D}, {0x1EE5F, 0x1EE5F},\n\t{0x1EE61, 0x1EE62}, {0x1EE64, 0x1EE64}, {0x1EE67, 0x1EE6A},\n\t{0x1EE6C, 0x1EE72}, {0x1EE74, 0x1EE77}, {0x1EE79, 0x1EE7C},\n\t{0x1EE7E, 0x1EE7E}, {0x1EE80, 0x1EE89}, {0x1EE8B, 0x1EE9B},\n\t{0x1EEA1, 0x1EEA3}, {0x1EEA5, 0x1EEA9}, {0x1EEAB, 0x1EEBB},\n\t{0x1EEF0, 0x1EEF1}, {0x1F000, 0x1F003}, {0x1F005, 0x1F02B},\n\t{0x1F030, 0x1F093}, {0x1F0A0, 0x1F0AE}, {0x1F0B1, 0x1F0BF},\n\t{0x1F0C1, 0x1F0CE}, {0x1F0D1, 0x1F0F5}, {0x1F10B, 0x1F10C},\n\t{0x1F12E, 0x1F12E}, {0x1F16A, 0x1F16B}, {0x1F1E6, 0x1F1FF},\n\t{0x1F321, 0x1F32C}, {0x1F336, 0x1F336}, {0x1F37D, 0x1F37D},\n\t{0x1F394, 0x1F39F}, {0x1F3CB, 0x1F3CE}, {0x1F3D4, 0x1F3DF},\n\t{0x1F3F1, 0x1F3F3}, {0x1F3F5, 0x1F3F7}, {0x1F43F, 0x1F43F},\n\t{0x1F441, 0x1F441}, {0x1F4FD, 0x1F4FE}, {0x1F53E, 0x1F54A},\n\t{0x1F54F, 0x1F54F}, {0x1F568, 0x1F579}, {0x1F57B, 0x1F594},\n\t{0x1F597, 0x1F5A3}, {0x1F5A5, 0x1F5FA}, {0x1F650, 0x1F67F},\n\t{0x1F6C6, 0x1F6CB}, {0x1F6CD, 0x1F6CF}, {0x1F6E0, 0x1F6EA},\n\t{0x1F6F0, 0x1F6F3}, {0x1F700, 0x1F773}, {0x1F780, 0x1F7D4},\n\t{0x1F800, 0x1F80B}, {0x1F810, 0x1F847}, {0x1F850, 0x1F859},\n\t{0x1F860, 0x1F887}, {0x1F890, 0x1F8AD}, {0xE0001, 0xE0001},\n\t{0xE0020, 0xE007F},\n}\n\n// Condition have flag EastAsianWidth whether the current locale is CJK or not.\ntype Condition struct {\n\tEastAsianWidth bool\n}\n\n// NewCondition return new instance of Condition which is current locale.\nfunc NewCondition() *Condition {\n\treturn &Condition{EastAsianWidth}\n}\n\n// RuneWidth returns the number of cells in r.\n// See http://www.unicode.org/reports/tr11/\nfunc (c *Condition) RuneWidth(r rune) int {\n\tswitch {\n\tcase r < 0 || r > 0x10FFFF ||\n\t\tinTables(r, nonprint, combining, notassigned):\n\t\treturn 0\n\tcase (c.EastAsianWidth && IsAmbiguousWidth(r)) ||\n\t\tinTables(r, doublewidth, emoji):\n\t\treturn 2\n\tdefault:\n\t\treturn 1\n\t}\n}\n\n// StringWidth return width as you can see\nfunc (c *Condition) StringWidth(s string) (width int) {\n\tfor _, r := range []rune(s) {\n\t\twidth += c.RuneWidth(r)\n\t}\n\treturn width\n}\n\n// Truncate return string truncated with w cells\nfunc (c *Condition) Truncate(s string, w int, tail string) string {\n\tif c.StringWidth(s) <= w {\n\t\treturn s\n\t}\n\tr := []rune(s)\n\ttw := c.StringWidth(tail)\n\tw -= tw\n\twidth := 0\n\ti := 0\n\tfor ; i < len(r); i++ {\n\t\tcw := c.RuneWidth(r[i])\n\t\tif width+cw > w {\n\t\t\tbreak\n\t\t}\n\t\twidth += cw\n\t}\n\treturn string(r[0:i]) + tail\n}\n\n// Wrap return string wrapped with w cells\nfunc (c *Condition) Wrap(s string, w int) string {\n\twidth := 0\n\tout := \"\"\n\tfor _, r := range []rune(s) {\n\t\tcw := RuneWidth(r)\n\t\tif r == '\\n' {\n\t\t\tout += string(r)\n\t\t\twidth = 0\n\t\t\tcontinue\n\t\t} else if width+cw > w {\n\t\t\tout += \"\\n\"\n\t\t\twidth = 0\n\t\t\tout += string(r)\n\t\t\twidth += cw\n\t\t\tcontinue\n\t\t}\n\t\tout += string(r)\n\t\twidth += cw\n\t}\n\treturn out\n}\n\n// FillLeft return string filled in left by spaces in w cells\nfunc (c *Condition) FillLeft(s string, w int) string {\n\twidth := c.StringWidth(s)\n\tcount := w - width\n\tif count > 0 {\n\t\tb := make([]byte, count)\n\t\tfor i := range b {\n\t\t\tb[i] = ' '\n\t\t}\n\t\treturn string(b) + s\n\t}\n\treturn s\n}\n\n// FillRight return string filled in left by spaces in w cells\nfunc (c *Condition) FillRight(s string, w int) string {\n\twidth := c.StringWidth(s)\n\tcount := w - width\n\tif count > 0 {\n\t\tb := make([]byte, count)\n\t\tfor i := range b {\n\t\t\tb[i] = ' '\n\t\t}\n\t\treturn s + string(b)\n\t}\n\treturn s\n}\n\n// RuneWidth returns the number of cells in r.\n// See http://www.unicode.org/reports/tr11/\nfunc RuneWidth(r rune) int {\n\treturn DefaultCondition.RuneWidth(r)\n}\n\n// IsAmbiguousWidth returns whether is ambiguous width or not.\nfunc IsAmbiguousWidth(r rune) bool {\n\treturn inTables(r, private, ambiguous)\n}\n\n// IsNeutralWidth returns whether is neutral width or not.\nfunc IsNeutralWidth(r rune) bool {\n\treturn inTable(r, neutral)\n}\n\n// StringWidth return width as you can see\nfunc StringWidth(s string) (width int) {\n\treturn DefaultCondition.StringWidth(s)\n}\n\n// Truncate return string truncated with w cells\nfunc Truncate(s string, w int, tail string) string {\n\treturn DefaultCondition.Truncate(s, w, tail)\n}\n\n// Wrap return string wrapped with w cells\nfunc Wrap(s string, w int) string {\n\treturn DefaultCondition.Wrap(s, w)\n}\n\n// FillLeft return string filled in left by spaces in w cells\nfunc FillLeft(s string, w int) string {\n\treturn DefaultCondition.FillLeft(s, w)\n}\n\n// FillRight return string filled in left by spaces in w cells\nfunc FillRight(s string, w int) string {\n\treturn DefaultCondition.FillRight(s, w)\n}\n"
  },
  {
    "path": "vendor/github.com/mattn/go-runewidth/runewidth_js.go",
    "content": "// +build js\n\npackage runewidth\n\nfunc IsEastAsian() bool {\n\t// TODO: Implement this for the web. Detect east asian in a compatible way, and return true.\n\treturn false\n}\n"
  },
  {
    "path": "vendor/github.com/mattn/go-runewidth/runewidth_posix.go",
    "content": "// +build !windows,!js\n\npackage runewidth\n\nimport (\n\t\"os\"\n\t\"regexp\"\n\t\"strings\"\n)\n\nvar reLoc = regexp.MustCompile(`^[a-z][a-z][a-z]?(?:_[A-Z][A-Z])?\\.(.+)`)\n\nvar mblenTable = map[string]int{\n\t\"utf-8\":   6,\n\t\"utf8\":    6,\n\t\"jis\":     8,\n\t\"eucjp\":   3,\n\t\"euckr\":   2,\n\t\"euccn\":   2,\n\t\"sjis\":    2,\n\t\"cp932\":   2,\n\t\"cp51932\": 2,\n\t\"cp936\":   2,\n\t\"cp949\":   2,\n\t\"cp950\":   2,\n\t\"big5\":    2,\n\t\"gbk\":     2,\n\t\"gb2312\":  2,\n}\n\nfunc isEastAsian(locale string) bool {\n\tcharset := strings.ToLower(locale)\n\tr := reLoc.FindStringSubmatch(locale)\n\tif len(r) == 2 {\n\t\tcharset = strings.ToLower(r[1])\n\t}\n\n\tif strings.HasSuffix(charset, \"@cjk_narrow\") {\n\t\treturn false\n\t}\n\n\tfor pos, b := range []byte(charset) {\n\t\tif b == '@' {\n\t\t\tcharset = charset[:pos]\n\t\t\tbreak\n\t\t}\n\t}\n\tmax := 1\n\tif m, ok := mblenTable[charset]; ok {\n\t\tmax = m\n\t}\n\tif max > 1 && (charset[0] != 'u' ||\n\t\tstrings.HasPrefix(locale, \"ja\") ||\n\t\tstrings.HasPrefix(locale, \"ko\") ||\n\t\tstrings.HasPrefix(locale, \"zh\")) {\n\t\treturn true\n\t}\n\treturn false\n}\n\n// IsEastAsian return true if the current locale is CJK\nfunc IsEastAsian() bool {\n\tlocale := os.Getenv(\"LC_CTYPE\")\n\tif locale == \"\" {\n\t\tlocale = os.Getenv(\"LANG\")\n\t}\n\n\t// ignore C locale\n\tif locale == \"POSIX\" || locale == \"C\" {\n\t\treturn false\n\t}\n\tif len(locale) > 1 && locale[0] == 'C' && (locale[1] == '.' || locale[1] == '-') {\n\t\treturn false\n\t}\n\n\treturn isEastAsian(locale)\n}\n"
  },
  {
    "path": "vendor/github.com/mattn/go-runewidth/runewidth_test.go",
    "content": "package runewidth\n\nimport (\n\t\"sort\"\n\t\"testing\"\n)\n\nvar _ sort.Interface = (*table)(nil)\n\nfunc (t table) Len() int {\n\treturn len(t)\n}\n\nfunc (t table) Less(i, j int) bool {\n\treturn t[i].first < t[j].first\n}\n\nfunc (t *table) Swap(i, j int) {\n\t(*t)[i], (*t)[j] = (*t)[j], (*t)[i]\n}\n\nvar tables = []table{\n\tprivate,\n\tnonprint,\n\tcombining,\n\tdoublewidth,\n\tambiguous,\n\temoji,\n\tnotassigned,\n\tneutral,\n}\n\nfunc TestSorted(t *testing.T) {\n\tfor _, tbl := range tables {\n\t\tif !sort.IsSorted(&tbl) {\n\t\t\tt.Errorf(\"not sorted\")\n\t\t}\n\t}\n}\n\nvar runewidthtests = []struct {\n\tin    rune\n\tout   int\n\teaout int\n}{\n\t{'世', 2, 2},\n\t{'界', 2, 2},\n\t{'ｾ', 1, 1},\n\t{'ｶ', 1, 1},\n\t{'ｲ', 1, 1},\n\t{'☆', 1, 2}, // double width in ambiguous\n\t{'\\x00', 0, 0},\n\t{'\\x01', 0, 0},\n\t{'\\u0300', 0, 0},\n}\n\nfunc TestRuneWidth(t *testing.T) {\n\tc := NewCondition()\n\tfor _, tt := range runewidthtests {\n\t\tif out := c.RuneWidth(tt.in); out != tt.out {\n\t\t\tt.Errorf(\"RuneWidth(%q) = %d, want %d\", tt.in, out, tt.out)\n\t\t}\n\t}\n\tc.EastAsianWidth = true\n\tfor _, tt := range runewidthtests {\n\t\tif out := c.RuneWidth(tt.in); out != tt.eaout {\n\t\t\tt.Errorf(\"RuneWidth(%q) = %d, want %d\", tt.in, out, tt.eaout)\n\t\t}\n\t}\n}\n\nvar isambiguouswidthtests = []struct {\n\tin  rune\n\tout bool\n}{\n\t{'世', false},\n\t{'■', true},\n\t{'界', false},\n\t{'○', true},\n\t{'㈱', false},\n\t{'①', true},\n\t{'②', true},\n\t{'③', true},\n\t{'④', true},\n\t{'⑤', true},\n\t{'⑥', true},\n\t{'⑦', true},\n\t{'⑧', true},\n\t{'⑨', true},\n\t{'⑩', true},\n\t{'⑪', true},\n\t{'⑫', true},\n\t{'⑬', true},\n\t{'⑭', true},\n\t{'⑮', true},\n\t{'⑯', true},\n\t{'⑰', true},\n\t{'⑱', true},\n\t{'⑲', true},\n\t{'⑳', true},\n\t{'☆', true},\n}\n\nfunc TestIsAmbiguousWidth(t *testing.T) {\n\tfor _, tt := range isambiguouswidthtests {\n\t\tif out := IsAmbiguousWidth(tt.in); out != tt.out {\n\t\t\tt.Errorf(\"IsAmbiguousWidth(%q) = %v, want %v\", tt.in, out, tt.out)\n\t\t}\n\t}\n}\n\nvar stringwidthtests = []struct {\n\tin    string\n\tout   int\n\teaout int\n}{\n\t{\"■㈱の世界①\", 10, 12},\n\t{\"スター☆\", 7, 8},\n\t{\"つのだ☆HIRO\", 11, 12},\n}\n\nfunc TestStringWidth(t *testing.T) {\n\tc := NewCondition()\n\tfor _, tt := range stringwidthtests {\n\t\tif out := c.StringWidth(tt.in); out != tt.out {\n\t\t\tt.Errorf(\"StringWidth(%q) = %q, want %q\", tt.in, out, tt.out)\n\t\t}\n\t}\n\tc.EastAsianWidth = true\n\tfor _, tt := range stringwidthtests {\n\t\tif out := c.StringWidth(tt.in); out != tt.eaout {\n\t\t\tt.Errorf(\"StringWidth(%q) = %q, want %q\", tt.in, out, tt.eaout)\n\t\t}\n\t}\n}\n\nfunc TestStringWidthInvalid(t *testing.T) {\n\ts := \"こんにちわ\\x00世界\"\n\tif out := StringWidth(s); out != 14 {\n\t\tt.Errorf(\"StringWidth(%q) = %q, want %q\", s, out, 14)\n\t}\n}\n\nfunc TestTruncateSmaller(t *testing.T) {\n\ts := \"あいうえお\"\n\texpected := \"あいうえお\"\n\n\tif out := Truncate(s, 10, \"...\"); out != expected {\n\t\tt.Errorf(\"Truncate(%q) = %q, want %q\", s, out, expected)\n\t}\n}\n\nfunc TestTruncate(t *testing.T) {\n\ts := \"あいうえおあいうえおえおおおおおおおおおおおおおおおおおおおおおおおおおおおおおお\"\n\texpected := \"あいうえおあいうえおえおおおおおおおおおおおおおおおおおおおおおおおおおおお...\"\n\tout := Truncate(s, 80, \"...\")\n\tif out != expected {\n\t\tt.Errorf(\"Truncate(%q) = %q, want %q\", s, out, expected)\n\t}\n\twidth := StringWidth(out)\n\tif width != 79 {\n\t\tt.Errorf(\"width of Truncate(%q) should be %d, but %d\", s, 79, width)\n\t}\n}\n\nfunc TestTruncateFit(t *testing.T) {\n\ts := \"aあいうえおあいうえおえおおおおおおおおおおおおおおおおおおおおおおおおおおおおおお\"\n\texpected := \"aあいうえおあいうえおえおおおおおおおおおおおおおおおおおおおおおおおおおおお...\"\n\n\tout := Truncate(s, 80, \"...\")\n\tif out != expected {\n\t\tt.Errorf(\"Truncate(%q) = %q, want %q\", s, out, expected)\n\t}\n\twidth := StringWidth(out)\n\tif width != 80 {\n\t\tt.Errorf(\"width of Truncate(%q) should be %d, but %d\", s, 80, width)\n\t}\n}\n\nfunc TestTruncateJustFit(t *testing.T) {\n\ts := \"あいうえおあいうえおえおおおおおおおおおおおおおおおおおおおおおおおおおおおおお\"\n\texpected := \"あいうえおあいうえおえおおおおおおおおおおおおおおおおおおおおおおおおおおおおお\"\n\n\tout := Truncate(s, 80, \"...\")\n\tif out != expected {\n\t\tt.Errorf(\"Truncate(%q) = %q, want %q\", s, out, expected)\n\t}\n\twidth := StringWidth(out)\n\tif width != 80 {\n\t\tt.Errorf(\"width of Truncate(%q) should be %d, but %d\", s, 80, width)\n\t}\n}\n\nfunc TestWrap(t *testing.T) {\n\ts := `東京特許許可局局長はよく柿喰う客だ/東京特許許可局局長はよく柿喰う客だ\n123456789012345678901234567890\n\nEND`\n\texpected := `東京特許許可局局長はよく柿喰う\n客だ/東京特許許可局局長はよく\n柿喰う客だ\n123456789012345678901234567890\n\nEND`\n\n\tif out := Wrap(s, 30); out != expected {\n\t\tt.Errorf(\"Wrap(%q) = %q, want %q\", s, out, expected)\n\t}\n}\n\nfunc TestTruncateNoNeeded(t *testing.T) {\n\ts := \"あいうえおあい\"\n\texpected := \"あいうえおあい\"\n\n\tif out := Truncate(s, 80, \"...\"); out != expected {\n\t\tt.Errorf(\"Truncate(%q) = %q, want %q\", s, out, expected)\n\t}\n}\n\nvar isneutralwidthtests = []struct {\n\tin  rune\n\tout bool\n}{\n\t{'→', false},\n\t{'┊', false},\n\t{'┈', false},\n\t{'～', false},\n\t{'└', false},\n\t{'⣀', true},\n\t{'⣀', true},\n}\n\nfunc TestIsNeutralWidth(t *testing.T) {\n\tfor _, tt := range isneutralwidthtests {\n\t\tif out := IsNeutralWidth(tt.in); out != tt.out {\n\t\t\tt.Errorf(\"IsNeutralWidth(%q) = %v, want %v\", tt.in, out, tt.out)\n\t\t}\n\t}\n}\n\nfunc TestFillLeft(t *testing.T) {\n\ts := \"あxいうえお\"\n\texpected := \"    あxいうえお\"\n\n\tif out := FillLeft(s, 15); out != expected {\n\t\tt.Errorf(\"FillLeft(%q) = %q, want %q\", s, out, expected)\n\t}\n}\n\nfunc TestFillLeftFit(t *testing.T) {\n\ts := \"あいうえお\"\n\texpected := \"あいうえお\"\n\n\tif out := FillLeft(s, 10); out != expected {\n\t\tt.Errorf(\"FillLeft(%q) = %q, want %q\", s, out, expected)\n\t}\n}\n\nfunc TestFillRight(t *testing.T) {\n\ts := \"あxいうえお\"\n\texpected := \"あxいうえお    \"\n\n\tif out := FillRight(s, 15); out != expected {\n\t\tt.Errorf(\"FillRight(%q) = %q, want %q\", s, out, expected)\n\t}\n}\n\nfunc TestFillRightFit(t *testing.T) {\n\ts := \"あいうえお\"\n\texpected := \"あいうえお\"\n\n\tif out := FillRight(s, 10); out != expected {\n\t\tt.Errorf(\"FillRight(%q) = %q, want %q\", s, out, expected)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/mattn/go-runewidth/runewidth_windows.go",
    "content": "package runewidth\n\nimport (\n\t\"syscall\"\n)\n\nvar (\n\tkernel32               = syscall.NewLazyDLL(\"kernel32\")\n\tprocGetConsoleOutputCP = kernel32.NewProc(\"GetConsoleOutputCP\")\n)\n\n// IsEastAsian return true if the current locale is CJK\nfunc IsEastAsian() bool {\n\tr1, _, _ := procGetConsoleOutputCP.Call()\n\tif r1 == 0 {\n\t\treturn false\n\t}\n\n\tswitch int(r1) {\n\tcase 932, 51932, 936, 949, 950:\n\t\treturn true\n\t}\n\n\treturn false\n}\n"
  },
  {
    "path": "vendor/github.com/mitchellh/go-wordwrap/LICENSE.md",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2014 Mitchell Hashimoto\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "vendor/github.com/mitchellh/go-wordwrap/README.md",
    "content": "# go-wordwrap\n\n`go-wordwrap` (Golang package: `wordwrap`) is a package for Go that\nautomatically wraps words into multiple lines. The primary use case for this\nis in formatting CLI output, but of course word wrapping is a generally useful\nthing to do.\n\n## Installation and Usage\n\nInstall using `go get github.com/mitchellh/go-wordwrap`.\n\nFull documentation is available at\nhttp://godoc.org/github.com/mitchellh/go-wordwrap\n\nBelow is an example of its usage ignoring errors:\n\n```go\nwrapped := wordwrap.WrapString(\"foo bar baz\", 3)\nfmt.Println(wrapped)\n```\n\nWould output:\n\n```\nfoo\nbar\nbaz\n```\n\n## Word Wrap Algorithm\n\nThis library doesn't use any clever algorithm for word wrapping. The wrapping\nis actually very naive: whenever there is whitespace or an explicit linebreak.\nThe goal of this library is for word wrapping CLI output, so the input is\ntypically pretty well controlled human language. Because of this, the naive\napproach typically works just fine.\n\nIn the future, we'd like to make the algorithm more advanced. We would do\nso without breaking the API.\n"
  },
  {
    "path": "vendor/github.com/mitchellh/go-wordwrap/wordwrap.go",
    "content": "package wordwrap\n\nimport (\n\t\"bytes\"\n\t\"unicode\"\n)\n\n// WrapString wraps the given string within lim width in characters.\n//\n// Wrapping is currently naive and only happens at white-space. A future\n// version of the library will implement smarter wrapping. This means that\n// pathological cases can dramatically reach past the limit, such as a very\n// long word.\nfunc WrapString(s string, lim uint) string {\n\t// Initialize a buffer with a slightly larger size to account for breaks\n\tinit := make([]byte, 0, len(s))\n\tbuf := bytes.NewBuffer(init)\n\n\tvar current uint\n\tvar wordBuf, spaceBuf bytes.Buffer\n\n\tfor _, char := range s {\n\t\tif char == '\\n' {\n\t\t\tif wordBuf.Len() == 0 {\n\t\t\t\tif current+uint(spaceBuf.Len()) > lim {\n\t\t\t\t\tcurrent = 0\n\t\t\t\t} else {\n\t\t\t\t\tcurrent += uint(spaceBuf.Len())\n\t\t\t\t\tspaceBuf.WriteTo(buf)\n\t\t\t\t}\n\t\t\t\tspaceBuf.Reset()\n\t\t\t} else {\n\t\t\t\tcurrent += uint(spaceBuf.Len() + wordBuf.Len())\n\t\t\t\tspaceBuf.WriteTo(buf)\n\t\t\t\tspaceBuf.Reset()\n\t\t\t\twordBuf.WriteTo(buf)\n\t\t\t\twordBuf.Reset()\n\t\t\t}\n\t\t\tbuf.WriteRune(char)\n\t\t\tcurrent = 0\n\t\t} else if unicode.IsSpace(char) {\n\t\t\tif spaceBuf.Len() == 0 || wordBuf.Len() > 0 {\n\t\t\t\tcurrent += uint(spaceBuf.Len() + wordBuf.Len())\n\t\t\t\tspaceBuf.WriteTo(buf)\n\t\t\t\tspaceBuf.Reset()\n\t\t\t\twordBuf.WriteTo(buf)\n\t\t\t\twordBuf.Reset()\n\t\t\t}\n\n\t\t\tspaceBuf.WriteRune(char)\n\t\t} else {\n\n\t\t\twordBuf.WriteRune(char)\n\n\t\t\tif current+uint(spaceBuf.Len()+wordBuf.Len()) > lim && uint(wordBuf.Len()) < lim {\n\t\t\t\tbuf.WriteRune('\\n')\n\t\t\t\tcurrent = 0\n\t\t\t\tspaceBuf.Reset()\n\t\t\t}\n\t\t}\n\t}\n\n\tif wordBuf.Len() == 0 {\n\t\tif current+uint(spaceBuf.Len()) <= lim {\n\t\t\tspaceBuf.WriteTo(buf)\n\t\t}\n\t} else {\n\t\tspaceBuf.WriteTo(buf)\n\t\twordBuf.WriteTo(buf)\n\t}\n\n\treturn buf.String()\n}\n"
  },
  {
    "path": "vendor/github.com/mitchellh/go-wordwrap/wordwrap_test.go",
    "content": "package wordwrap\n\nimport (\n\t\"testing\"\n)\n\nfunc TestWrapString(t *testing.T) {\n\tcases := []struct {\n\t\tInput, Output string\n\t\tLim           uint\n\t}{\n\t\t// A simple word passes through.\n\t\t{\n\t\t\t\"foo\",\n\t\t\t\"foo\",\n\t\t\t4,\n\t\t},\n\t\t// A single word that is too long passes through.\n\t\t// We do not break words.\n\t\t{\n\t\t\t\"foobarbaz\",\n\t\t\t\"foobarbaz\",\n\t\t\t4,\n\t\t},\n\t\t// Lines are broken at whitespace.\n\t\t{\n\t\t\t\"foo bar baz\",\n\t\t\t\"foo\\nbar\\nbaz\",\n\t\t\t4,\n\t\t},\n\t\t// Lines are broken at whitespace, even if words\n\t\t// are too long. We do not break words.\n\t\t{\n\t\t\t\"foo bars bazzes\",\n\t\t\t\"foo\\nbars\\nbazzes\",\n\t\t\t4,\n\t\t},\n\t\t// A word that would run beyond the width is wrapped.\n\t\t{\n\t\t\t\"fo sop\",\n\t\t\t\"fo\\nsop\",\n\t\t\t4,\n\t\t},\n\t\t// Whitespace that trails a line and fits the width\n\t\t// passes through, as does whitespace prefixing an\n\t\t// explicit line break. A tab counts as one character.\n\t\t{\n\t\t\t\"foo\\nb\\t r\\n baz\",\n\t\t\t\"foo\\nb\\t r\\n baz\",\n\t\t\t4,\n\t\t},\n\t\t// Trailing whitespace is removed if it doesn't fit the width.\n\t\t// Runs of whitespace on which a line is broken are removed.\n\t\t{\n\t\t\t\"foo    \\nb   ar   \",\n\t\t\t\"foo\\nb\\nar\",\n\t\t\t4,\n\t\t},\n\t\t// An explicit line break at the end of the input is preserved.\n\t\t{\n\t\t\t\"foo bar baz\\n\",\n\t\t\t\"foo\\nbar\\nbaz\\n\",\n\t\t\t4,\n\t\t},\n\t\t// Explicit break are always preserved.\n\t\t{\n\t\t\t\"\\nfoo bar\\n\\n\\nbaz\\n\",\n\t\t\t\"\\nfoo\\nbar\\n\\n\\nbaz\\n\",\n\t\t\t4,\n\t\t},\n\t\t// Complete example:\n\t\t{\n\t\t\t\" This is a list: \\n\\n\\t* foo\\n\\t* bar\\n\\n\\n\\t* baz  \\nBAM    \",\n\t\t\t\" This\\nis a\\nlist: \\n\\n\\t* foo\\n\\t* bar\\n\\n\\n\\t* baz\\nBAM\",\n\t\t\t6,\n\t\t},\n\t}\n\n\tfor i, tc := range cases {\n\t\tactual := WrapString(tc.Input, tc.Lim)\n\t\tif actual != tc.Output {\n\t\t\tt.Fatalf(\"Case %d Input:\\n\\n`%s`\\n\\nActual Output:\\n\\n`%s`\", i, tc.Input, actual)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/AUTHORS",
    "content": "# Please keep this file sorted.\n\nGeorg Reinke <guelfey@googlemail.com>\nnsf <no.smile.face@gmail.com>\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/LICENSE",
    "content": "Copyright (C) 2012 termbox-go authors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/README.md",
    "content": "## Termbox\nTermbox is a library that provides a minimalistic API which allows the programmer to write text-based user interfaces. The library is crossplatform and has both terminal-based implementations on *nix operating systems and a winapi console based implementation for windows operating systems. The basic idea is an abstraction of the greatest common subset of features available on all major terminals and other terminal-like APIs in a minimalistic fashion. Small API means it is easy to implement, test, maintain and learn it, that's what makes the termbox a distinct library in its area.\n\n### Installation\nInstall and update this go package with `go get -u github.com/nsf/termbox-go`\n\n### Examples\nFor examples of what can be done take a look at demos in the _demos directory. You can try them with go run: `go run _demos/keyboard.go`\n\nThere are also some interesting projects using termbox-go:\n - [godit](https://github.com/nsf/godit) is an emacsish lightweight text editor written using termbox.\n - [gomatrix](https://github.com/GeertJohan/gomatrix) connects to The Matrix and displays its data streams in your terminal.\n - [gotetris](https://github.com/jjinux/gotetris) is an implementation of Tetris.\n - [sokoban-go](https://github.com/rn2dy/sokoban-go) is an implementation of sokoban game.\n - [hecate](https://github.com/evanmiller/hecate) is a hex editor designed by Satan.\n - [httopd](https://github.com/verdverm/httopd) is top for httpd logs.\n - [mop](https://github.com/mop-tracker/mop) is stock market tracker for hackers.\n - [termui](https://github.com/gizak/termui) is a terminal dashboard.\n - [termloop](https://github.com/JoelOtter/termloop) is a terminal game engine.\n - [xterm-color-chart](https://github.com/kutuluk/xterm-color-chart) is a XTerm 256 color chart.\n - [gocui](https://github.com/jroimartin/gocui) is a minimalist Go library aimed at creating console user interfaces.\n - [dry](https://github.com/moncho/dry) is an interactive cli to manage Docker containers.\n - [pxl](https://github.com/ichinaski/pxl) displays images in the terminal.\n - [snake-game](https://github.com/DyegoCosta/snake-game) is an implementation of the Snake game.\n - [gone](https://github.com/guillaumebreton/gone) is a CLI pomodoro® timer.\n - [Spoof.go](https://github.com/sabey/spoofgo) controllable movement spoofing from the cli\n - [lf](https://github.com/gokcehan/lf) is a terminal file manager\n - [rat](https://github.com/ericfreese/rat) lets you compose shell commands to build terminal applications.\n - [httplab](https://github.com/gchaincl/httplab) An interactive web server.\n - [tetris](https://github.com/MichaelS11/tetris) Go Tetris with AI option\n - [wot](https://github.com/kyu-suke/wot) Wait time during command is completed.\n - [2048-go](https://github.com/1984weed/2048-go) is 2048 in Go\n - [jv](https://github.com/maxzender/jv) helps you view JSON on the command-line.\n - [pinger](https://github.com/hirose31/pinger) helps you to monitor numerous hosts using ICMP ECHO_REQUEST.\n - [vixl44](https://github.com/sebashwa/vixl44) lets you create pixel art inside your terminal using vim movements\n\n### API reference\n[godoc.org/github.com/nsf/termbox-go](http://godoc.org/github.com/nsf/termbox-go)\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/api.go",
    "content": "// +build !windows\n\npackage termbox\n\nimport \"github.com/mattn/go-runewidth\"\nimport \"fmt\"\nimport \"os\"\nimport \"os/signal\"\nimport \"syscall\"\nimport \"runtime\"\n\n// public API\n\n// Initializes termbox library. This function should be called before any other functions.\n// After successful initialization, the library must be finalized using 'Close' function.\n//\n// Example usage:\n//      err := termbox.Init()\n//      if err != nil {\n//              panic(err)\n//      }\n//      defer termbox.Close()\nfunc Init() error {\n\tvar err error\n\n\tout, err = os.OpenFile(\"/dev/tty\", syscall.O_WRONLY, 0)\n\tif err != nil {\n\t\treturn err\n\t}\n\tin, err = syscall.Open(\"/dev/tty\", syscall.O_RDONLY, 0)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = setup_term()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"termbox: error while reading terminfo data: %v\", err)\n\t}\n\n\tsignal.Notify(sigwinch, syscall.SIGWINCH)\n\tsignal.Notify(sigio, syscall.SIGIO)\n\n\t_, err = fcntl(in, syscall.F_SETFL, syscall.O_ASYNC|syscall.O_NONBLOCK)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = fcntl(in, syscall.F_SETOWN, syscall.Getpid())\n\tif runtime.GOOS != \"darwin\" && err != nil {\n\t\treturn err\n\t}\n\terr = tcgetattr(out.Fd(), &orig_tios)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttios := orig_tios\n\ttios.Iflag &^= syscall_IGNBRK | syscall_BRKINT | syscall_PARMRK |\n\t\tsyscall_ISTRIP | syscall_INLCR | syscall_IGNCR |\n\t\tsyscall_ICRNL | syscall_IXON\n\ttios.Lflag &^= syscall_ECHO | syscall_ECHONL | syscall_ICANON |\n\t\tsyscall_ISIG | syscall_IEXTEN\n\ttios.Cflag &^= syscall_CSIZE | syscall_PARENB\n\ttios.Cflag |= syscall_CS8\n\ttios.Cc[syscall_VMIN] = 1\n\ttios.Cc[syscall_VTIME] = 0\n\n\terr = tcsetattr(out.Fd(), &tios)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tout.WriteString(funcs[t_enter_ca])\n\tout.WriteString(funcs[t_enter_keypad])\n\tout.WriteString(funcs[t_hide_cursor])\n\tout.WriteString(funcs[t_clear_screen])\n\n\ttermw, termh = get_term_size(out.Fd())\n\tback_buffer.init(termw, termh)\n\tfront_buffer.init(termw, termh)\n\tback_buffer.clear()\n\tfront_buffer.clear()\n\n\tgo func() {\n\t\tbuf := make([]byte, 128)\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-sigio:\n\t\t\t\tfor {\n\t\t\t\t\tn, err := syscall.Read(in, buf)\n\t\t\t\t\tif err == syscall.EAGAIN || err == syscall.EWOULDBLOCK {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tselect {\n\t\t\t\t\tcase input_comm <- input_event{buf[:n], err}:\n\t\t\t\t\t\tie := <-input_comm\n\t\t\t\t\t\tbuf = ie.data[:128]\n\t\t\t\t\tcase <-quit:\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase <-quit:\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n\n\tIsInit = true\n\treturn nil\n}\n\n// Interrupt an in-progress call to PollEvent by causing it to return\n// EventInterrupt.  Note that this function will block until the PollEvent\n// function has successfully been interrupted.\nfunc Interrupt() {\n\tinterrupt_comm <- struct{}{}\n}\n\n// Finalizes termbox library, should be called after successful initialization\n// when termbox's functionality isn't required anymore.\nfunc Close() {\n\tquit <- 1\n\tout.WriteString(funcs[t_show_cursor])\n\tout.WriteString(funcs[t_sgr0])\n\tout.WriteString(funcs[t_clear_screen])\n\tout.WriteString(funcs[t_exit_ca])\n\tout.WriteString(funcs[t_exit_keypad])\n\tout.WriteString(funcs[t_exit_mouse])\n\ttcsetattr(out.Fd(), &orig_tios)\n\n\tout.Close()\n\tsyscall.Close(in)\n\n\t// reset the state, so that on next Init() it will work again\n\ttermw = 0\n\ttermh = 0\n\tinput_mode = InputEsc\n\tout = nil\n\tin = 0\n\tlastfg = attr_invalid\n\tlastbg = attr_invalid\n\tlastx = coord_invalid\n\tlasty = coord_invalid\n\tcursor_x = cursor_hidden\n\tcursor_y = cursor_hidden\n\tforeground = ColorDefault\n\tbackground = ColorDefault\n\tIsInit = false\n}\n\n// Synchronizes the internal back buffer with the terminal.\nfunc Flush() error {\n\t// invalidate cursor position\n\tlastx = coord_invalid\n\tlasty = coord_invalid\n\n\tupdate_size_maybe()\n\n\tfor y := 0; y < front_buffer.height; y++ {\n\t\tline_offset := y * front_buffer.width\n\t\tfor x := 0; x < front_buffer.width; {\n\t\t\tcell_offset := line_offset + x\n\t\t\tback := &back_buffer.cells[cell_offset]\n\t\t\tfront := &front_buffer.cells[cell_offset]\n\t\t\tif back.Ch < ' ' {\n\t\t\t\tback.Ch = ' '\n\t\t\t}\n\t\t\tw := runewidth.RuneWidth(back.Ch)\n\t\t\tif w == 0 || w == 2 && runewidth.IsAmbiguousWidth(back.Ch) {\n\t\t\t\tw = 1\n\t\t\t}\n\t\t\tif *back == *front {\n\t\t\t\tx += w\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t*front = *back\n\t\t\tsend_attr(back.Fg, back.Bg)\n\n\t\t\tif w == 2 && x == front_buffer.width-1 {\n\t\t\t\t// there's not enough space for 2-cells rune,\n\t\t\t\t// let's just put a space in there\n\t\t\t\tsend_char(x, y, ' ')\n\t\t\t} else {\n\t\t\t\tsend_char(x, y, back.Ch)\n\t\t\t\tif w == 2 {\n\t\t\t\t\tnext := cell_offset + 1\n\t\t\t\t\tfront_buffer.cells[next] = Cell{\n\t\t\t\t\t\tCh: 0,\n\t\t\t\t\t\tFg: back.Fg,\n\t\t\t\t\t\tBg: back.Bg,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tx += w\n\t\t}\n\t}\n\tif !is_cursor_hidden(cursor_x, cursor_y) {\n\t\twrite_cursor(cursor_x, cursor_y)\n\t}\n\treturn flush()\n}\n\n// Sets the position of the cursor. See also HideCursor().\nfunc SetCursor(x, y int) {\n\tif is_cursor_hidden(cursor_x, cursor_y) && !is_cursor_hidden(x, y) {\n\t\toutbuf.WriteString(funcs[t_show_cursor])\n\t}\n\n\tif !is_cursor_hidden(cursor_x, cursor_y) && is_cursor_hidden(x, y) {\n\t\toutbuf.WriteString(funcs[t_hide_cursor])\n\t}\n\n\tcursor_x, cursor_y = x, y\n\tif !is_cursor_hidden(cursor_x, cursor_y) {\n\t\twrite_cursor(cursor_x, cursor_y)\n\t}\n}\n\n// The shortcut for SetCursor(-1, -1).\nfunc HideCursor() {\n\tSetCursor(cursor_hidden, cursor_hidden)\n}\n\n// Changes cell's parameters in the internal back buffer at the specified\n// position.\nfunc SetCell(x, y int, ch rune, fg, bg Attribute) {\n\tif x < 0 || x >= back_buffer.width {\n\t\treturn\n\t}\n\tif y < 0 || y >= back_buffer.height {\n\t\treturn\n\t}\n\n\tback_buffer.cells[y*back_buffer.width+x] = Cell{ch, fg, bg}\n}\n\n// Returns a slice into the termbox's back buffer. You can get its dimensions\n// using 'Size' function. The slice remains valid as long as no 'Clear' or\n// 'Flush' function calls were made after call to this function.\nfunc CellBuffer() []Cell {\n\treturn back_buffer.cells\n}\n\n// After getting a raw event from PollRawEvent function call, you can parse it\n// again into an ordinary one using termbox logic. That is parse an event as\n// termbox would do it. Returned event in addition to usual Event struct fields\n// sets N field to the amount of bytes used within 'data' slice. If the length\n// of 'data' slice is zero or event cannot be parsed for some other reason, the\n// function will return a special event type: EventNone.\n//\n// IMPORTANT: EventNone may contain a non-zero N, which means you should skip\n// these bytes, because termbox cannot recognize them.\n//\n// NOTE: This API is experimental and may change in future.\nfunc ParseEvent(data []byte) Event {\n\tevent := Event{Type: EventKey}\n\tok := extract_event(data, &event)\n\tif !ok {\n\t\treturn Event{Type: EventNone, N: event.N}\n\t}\n\treturn event\n}\n\n// Wait for an event and return it. This is a blocking function call. Instead\n// of EventKey and EventMouse it returns EventRaw events. Raw event is written\n// into `data` slice and Event's N field is set to the amount of bytes written.\n// The minimum required length of the 'data' slice is 1. This requirement may\n// vary on different platforms.\n//\n// NOTE: This API is experimental and may change in future.\nfunc PollRawEvent(data []byte) Event {\n\tif len(data) == 0 {\n\t\tpanic(\"len(data) >= 1 is a requirement\")\n\t}\n\n\tvar event Event\n\tif extract_raw_event(data, &event) {\n\t\treturn event\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase ev := <-input_comm:\n\t\t\tif ev.err != nil {\n\t\t\t\treturn Event{Type: EventError, Err: ev.err}\n\t\t\t}\n\n\t\t\tinbuf = append(inbuf, ev.data...)\n\t\t\tinput_comm <- ev\n\t\t\tif extract_raw_event(data, &event) {\n\t\t\t\treturn event\n\t\t\t}\n\t\tcase <-interrupt_comm:\n\t\t\tevent.Type = EventInterrupt\n\t\t\treturn event\n\n\t\tcase <-sigwinch:\n\t\t\tevent.Type = EventResize\n\t\t\tevent.Width, event.Height = get_term_size(out.Fd())\n\t\t\treturn event\n\t\t}\n\t}\n}\n\n// Wait for an event and return it. This is a blocking function call.\nfunc PollEvent() Event {\n\tvar event Event\n\n\t// try to extract event from input buffer, return on success\n\tevent.Type = EventKey\n\tok := extract_event(inbuf, &event)\n\tif event.N != 0 {\n\t\tcopy(inbuf, inbuf[event.N:])\n\t\tinbuf = inbuf[:len(inbuf)-event.N]\n\t}\n\tif ok {\n\t\treturn event\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase ev := <-input_comm:\n\t\t\tif ev.err != nil {\n\t\t\t\treturn Event{Type: EventError, Err: ev.err}\n\t\t\t}\n\n\t\t\tinbuf = append(inbuf, ev.data...)\n\t\t\tinput_comm <- ev\n\t\t\tok := extract_event(inbuf, &event)\n\t\t\tif event.N != 0 {\n\t\t\t\tcopy(inbuf, inbuf[event.N:])\n\t\t\t\tinbuf = inbuf[:len(inbuf)-event.N]\n\t\t\t}\n\t\t\tif ok {\n\t\t\t\treturn event\n\t\t\t}\n\t\tcase <-interrupt_comm:\n\t\t\tevent.Type = EventInterrupt\n\t\t\treturn event\n\n\t\tcase <-sigwinch:\n\t\t\tevent.Type = EventResize\n\t\t\tevent.Width, event.Height = get_term_size(out.Fd())\n\t\t\treturn event\n\t\t}\n\t}\n}\n\n// Returns the size of the internal back buffer (which is mostly the same as\n// terminal's window size in characters). But it doesn't always match the size\n// of the terminal window, after the terminal size has changed, the internal\n// back buffer will get in sync only after Clear or Flush function calls.\nfunc Size() (width int, height int) {\n\treturn termw, termh\n}\n\n// Clears the internal back buffer.\nfunc Clear(fg, bg Attribute) error {\n\tforeground, background = fg, bg\n\terr := update_size_maybe()\n\tback_buffer.clear()\n\treturn err\n}\n\n// Sets termbox input mode. Termbox has two input modes:\n//\n// 1. Esc input mode. When ESC sequence is in the buffer and it doesn't match\n// any known sequence. ESC means KeyEsc. This is the default input mode.\n//\n// 2. Alt input mode. When ESC sequence is in the buffer and it doesn't match\n// any known sequence. ESC enables ModAlt modifier for the next keyboard event.\n//\n// Both input modes can be OR'ed with Mouse mode. Setting Mouse mode bit up will\n// enable mouse button press/release and drag events.\n//\n// If 'mode' is InputCurrent, returns the current input mode. See also Input*\n// constants.\nfunc SetInputMode(mode InputMode) InputMode {\n\tif mode == InputCurrent {\n\t\treturn input_mode\n\t}\n\tif mode&(InputEsc|InputAlt) == 0 {\n\t\tmode |= InputEsc\n\t}\n\tif mode&(InputEsc|InputAlt) == InputEsc|InputAlt {\n\t\tmode &^= InputAlt\n\t}\n\tif mode&InputMouse != 0 {\n\t\tout.WriteString(funcs[t_enter_mouse])\n\t} else {\n\t\tout.WriteString(funcs[t_exit_mouse])\n\t}\n\n\tinput_mode = mode\n\treturn input_mode\n}\n\n// Sets the termbox output mode. Termbox has four output options:\n//\n// 1. OutputNormal => [1..8]\n//    This mode provides 8 different colors:\n//        black, red, green, yellow, blue, magenta, cyan, white\n//    Shortcut: ColorBlack, ColorRed, ...\n//    Attributes: AttrBold, AttrUnderline, AttrReverse\n//\n//    Example usage:\n//        SetCell(x, y, '@', ColorBlack | AttrBold, ColorRed);\n//\n// 2. Output256 => [1..256]\n//    In this mode you can leverage the 256 terminal mode:\n//    0x01 - 0x08: the 8 colors as in OutputNormal\n//    0x09 - 0x10: Color* | AttrBold\n//    0x11 - 0xe8: 216 different colors\n//    0xe9 - 0x1ff: 24 different shades of grey\n//\n//    Example usage:\n//        SetCell(x, y, '@', 184, 240);\n//        SetCell(x, y, '@', 0xb8, 0xf0);\n//\n// 3. Output216 => [1..216]\n//    This mode supports the 3rd range of the 256 mode only.\n//    But you don't need to provide an offset.\n//\n// 4. OutputGrayscale => [1..26]\n//    This mode supports the 4th range of the 256 mode\n//    and black and white colors from 3th range of the 256 mode\n//    But you don't need to provide an offset.\n//\n// In all modes, 0x00 represents the default color.\n//\n// `go run _demos/output.go` to see its impact on your terminal.\n//\n// If 'mode' is OutputCurrent, it returns the current output mode.\n//\n// Note that this may return a different OutputMode than the one requested,\n// as the requested mode may not be available on the target platform.\nfunc SetOutputMode(mode OutputMode) OutputMode {\n\tif mode == OutputCurrent {\n\t\treturn output_mode\n\t}\n\n\toutput_mode = mode\n\treturn output_mode\n}\n\n// Sync comes handy when something causes desync between termbox's understanding\n// of a terminal buffer and the reality. Such as a third party process. Sync\n// forces a complete resync between the termbox and a terminal, it may not be\n// visually pretty though.\nfunc Sync() error {\n\tfront_buffer.clear()\n\terr := send_clear()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn Flush()\n}\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/api_common.go",
    "content": "// termbox is a library for creating cross-platform text-based interfaces\npackage termbox\n\n// public API, common OS agnostic part\n\ntype (\n\tInputMode  int\n\tOutputMode int\n\tEventType  uint8\n\tModifier   uint8\n\tKey        uint16\n\tAttribute  uint16\n)\n\n// This type represents a termbox event. The 'Mod', 'Key' and 'Ch' fields are\n// valid if 'Type' is EventKey. The 'Width' and 'Height' fields are valid if\n// 'Type' is EventResize. The 'Err' field is valid if 'Type' is EventError.\ntype Event struct {\n\tType   EventType // one of Event* constants\n\tMod    Modifier  // one of Mod* constants or 0\n\tKey    Key       // one of Key* constants, invalid if 'Ch' is not 0\n\tCh     rune      // a unicode character\n\tWidth  int       // width of the screen\n\tHeight int       // height of the screen\n\tErr    error     // error in case if input failed\n\tMouseX int       // x coord of mouse\n\tMouseY int       // y coord of mouse\n\tN      int       // number of bytes written when getting a raw event\n}\n\n// A cell, single conceptual entity on the screen. The screen is basically a 2d\n// array of cells. 'Ch' is a unicode character, 'Fg' and 'Bg' are foreground\n// and background attributes respectively.\ntype Cell struct {\n\tCh rune\n\tFg Attribute\n\tBg Attribute\n}\n\n// To know if termbox has been initialized or not\nvar (\n\tIsInit bool = false\n)\n\n// Key constants, see Event.Key field.\nconst (\n\tKeyF1 Key = 0xFFFF - iota\n\tKeyF2\n\tKeyF3\n\tKeyF4\n\tKeyF5\n\tKeyF6\n\tKeyF7\n\tKeyF8\n\tKeyF9\n\tKeyF10\n\tKeyF11\n\tKeyF12\n\tKeyInsert\n\tKeyDelete\n\tKeyHome\n\tKeyEnd\n\tKeyPgup\n\tKeyPgdn\n\tKeyArrowUp\n\tKeyArrowDown\n\tKeyArrowLeft\n\tKeyArrowRight\n\tkey_min // see terminfo\n\tMouseLeft\n\tMouseMiddle\n\tMouseRight\n\tMouseRelease\n\tMouseWheelUp\n\tMouseWheelDown\n)\n\nconst (\n\tKeyCtrlTilde      Key = 0x00\n\tKeyCtrl2          Key = 0x00\n\tKeyCtrlSpace      Key = 0x00\n\tKeyCtrlA          Key = 0x01\n\tKeyCtrlB          Key = 0x02\n\tKeyCtrlC          Key = 0x03\n\tKeyCtrlD          Key = 0x04\n\tKeyCtrlE          Key = 0x05\n\tKeyCtrlF          Key = 0x06\n\tKeyCtrlG          Key = 0x07\n\tKeyBackspace      Key = 0x08\n\tKeyCtrlH          Key = 0x08\n\tKeyTab            Key = 0x09\n\tKeyCtrlI          Key = 0x09\n\tKeyCtrlJ          Key = 0x0A\n\tKeyCtrlK          Key = 0x0B\n\tKeyCtrlL          Key = 0x0C\n\tKeyEnter          Key = 0x0D\n\tKeyCtrlM          Key = 0x0D\n\tKeyCtrlN          Key = 0x0E\n\tKeyCtrlO          Key = 0x0F\n\tKeyCtrlP          Key = 0x10\n\tKeyCtrlQ          Key = 0x11\n\tKeyCtrlR          Key = 0x12\n\tKeyCtrlS          Key = 0x13\n\tKeyCtrlT          Key = 0x14\n\tKeyCtrlU          Key = 0x15\n\tKeyCtrlV          Key = 0x16\n\tKeyCtrlW          Key = 0x17\n\tKeyCtrlX          Key = 0x18\n\tKeyCtrlY          Key = 0x19\n\tKeyCtrlZ          Key = 0x1A\n\tKeyEsc            Key = 0x1B\n\tKeyCtrlLsqBracket Key = 0x1B\n\tKeyCtrl3          Key = 0x1B\n\tKeyCtrl4          Key = 0x1C\n\tKeyCtrlBackslash  Key = 0x1C\n\tKeyCtrl5          Key = 0x1D\n\tKeyCtrlRsqBracket Key = 0x1D\n\tKeyCtrl6          Key = 0x1E\n\tKeyCtrl7          Key = 0x1F\n\tKeyCtrlSlash      Key = 0x1F\n\tKeyCtrlUnderscore Key = 0x1F\n\tKeySpace          Key = 0x20\n\tKeyBackspace2     Key = 0x7F\n\tKeyCtrl8          Key = 0x7F\n)\n\n// Alt modifier constant, see Event.Mod field and SetInputMode function.\nconst (\n\tModAlt Modifier = 1 << iota\n\tModMotion\n)\n\n// Cell colors, you can combine a color with multiple attributes using bitwise\n// OR ('|').\nconst (\n\tColorDefault Attribute = iota\n\tColorBlack\n\tColorRed\n\tColorGreen\n\tColorYellow\n\tColorBlue\n\tColorMagenta\n\tColorCyan\n\tColorWhite\n)\n\n// Cell attributes, it is possible to use multiple attributes by combining them\n// using bitwise OR ('|'). Although, colors cannot be combined. But you can\n// combine attributes and a single color.\n//\n// It's worth mentioning that some platforms don't support certain attibutes.\n// For example windows console doesn't support AttrUnderline. And on some\n// terminals applying AttrBold to background may result in blinking text. Use\n// them with caution and test your code on various terminals.\nconst (\n\tAttrBold Attribute = 1 << (iota + 9)\n\tAttrUnderline\n\tAttrReverse\n)\n\n// Input mode. See SetInputMode function.\nconst (\n\tInputEsc InputMode = 1 << iota\n\tInputAlt\n\tInputMouse\n\tInputCurrent InputMode = 0\n)\n\n// Output mode. See SetOutputMode function.\nconst (\n\tOutputCurrent OutputMode = iota\n\tOutputNormal\n\tOutput256\n\tOutput216\n\tOutputGrayscale\n)\n\n// Event type. See Event.Type field.\nconst (\n\tEventKey EventType = iota\n\tEventResize\n\tEventMouse\n\tEventError\n\tEventInterrupt\n\tEventRaw\n\tEventNone\n)\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/api_windows.go",
    "content": "package termbox\n\nimport (\n\t\"syscall\"\n)\n\n// public API\n\n// Initializes termbox library. This function should be called before any other functions.\n// After successful initialization, the library must be finalized using 'Close' function.\n//\n// Example usage:\n//      err := termbox.Init()\n//      if err != nil {\n//              panic(err)\n//      }\n//      defer termbox.Close()\nfunc Init() error {\n\tvar err error\n\n\tinterrupt, err = create_event()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tin, err = syscall.Open(\"CONIN$\", syscall.O_RDWR, 0)\n\tif err != nil {\n\t\treturn err\n\t}\n\tout, err = syscall.Open(\"CONOUT$\", syscall.O_RDWR, 0)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = get_console_mode(in, &orig_mode)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = set_console_mode(in, enable_window_input)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\torig_size = get_term_size(out)\n\twin_size := get_win_size(out)\n\n\terr = set_console_screen_buffer_size(out, win_size)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = get_console_cursor_info(out, &orig_cursor_info)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tshow_cursor(false)\n\tterm_size = get_term_size(out)\n\tback_buffer.init(int(term_size.x), int(term_size.y))\n\tfront_buffer.init(int(term_size.x), int(term_size.y))\n\tback_buffer.clear()\n\tfront_buffer.clear()\n\tclear()\n\n\tdiffbuf = make([]diff_msg, 0, 32)\n\n\tgo input_event_producer()\n\tIsInit = true\n\treturn nil\n}\n\n// Finalizes termbox library, should be called after successful initialization\n// when termbox's functionality isn't required anymore.\nfunc Close() {\n\t// we ignore errors here, because we can't really do anything about them\n\tClear(0, 0)\n\tFlush()\n\n\t// stop event producer\n\tcancel_comm <- true\n\tset_event(interrupt)\n\tselect {\n\tcase <-input_comm:\n\tdefault:\n\t}\n\t<-cancel_done_comm\n\n\tset_console_cursor_info(out, &orig_cursor_info)\n\tset_console_cursor_position(out, coord{})\n\tset_console_screen_buffer_size(out, orig_size)\n\tset_console_mode(in, orig_mode)\n\tsyscall.Close(in)\n\tsyscall.Close(out)\n\tsyscall.Close(interrupt)\n\tIsInit = false\n}\n\n// Interrupt an in-progress call to PollEvent by causing it to return\n// EventInterrupt.  Note that this function will block until the PollEvent\n// function has successfully been interrupted.\nfunc Interrupt() {\n\tinterrupt_comm <- struct{}{}\n}\n\n// Synchronizes the internal back buffer with the terminal.\nfunc Flush() error {\n\tupdate_size_maybe()\n\tprepare_diff_messages()\n\tfor _, diff := range diffbuf {\n\t\tr := small_rect{\n\t\t\tleft:   0,\n\t\t\ttop:    diff.pos,\n\t\t\tright:  term_size.x - 1,\n\t\t\tbottom: diff.pos + diff.lines - 1,\n\t\t}\n\t\twrite_console_output(out, diff.chars, r)\n\t}\n\tif !is_cursor_hidden(cursor_x, cursor_y) {\n\t\tmove_cursor(cursor_x, cursor_y)\n\t}\n\treturn nil\n}\n\n// Sets the position of the cursor. See also HideCursor().\nfunc SetCursor(x, y int) {\n\tif is_cursor_hidden(cursor_x, cursor_y) && !is_cursor_hidden(x, y) {\n\t\tshow_cursor(true)\n\t}\n\n\tif !is_cursor_hidden(cursor_x, cursor_y) && is_cursor_hidden(x, y) {\n\t\tshow_cursor(false)\n\t}\n\n\tcursor_x, cursor_y = x, y\n\tif !is_cursor_hidden(cursor_x, cursor_y) {\n\t\tmove_cursor(cursor_x, cursor_y)\n\t}\n}\n\n// The shortcut for SetCursor(-1, -1).\nfunc HideCursor() {\n\tSetCursor(cursor_hidden, cursor_hidden)\n}\n\n// Changes cell's parameters in the internal back buffer at the specified\n// position.\nfunc SetCell(x, y int, ch rune, fg, bg Attribute) {\n\tif x < 0 || x >= back_buffer.width {\n\t\treturn\n\t}\n\tif y < 0 || y >= back_buffer.height {\n\t\treturn\n\t}\n\n\tback_buffer.cells[y*back_buffer.width+x] = Cell{ch, fg, bg}\n}\n\n// Returns a slice into the termbox's back buffer. You can get its dimensions\n// using 'Size' function. The slice remains valid as long as no 'Clear' or\n// 'Flush' function calls were made after call to this function.\nfunc CellBuffer() []Cell {\n\treturn back_buffer.cells\n}\n\n// Wait for an event and return it. This is a blocking function call.\nfunc PollEvent() Event {\n\tselect {\n\tcase ev := <-input_comm:\n\t\treturn ev\n\tcase <-interrupt_comm:\n\t\treturn Event{Type: EventInterrupt}\n\t}\n}\n\n// Returns the size of the internal back buffer (which is mostly the same as\n// console's window size in characters). But it doesn't always match the size\n// of the console window, after the console size has changed, the internal back\n// buffer will get in sync only after Clear or Flush function calls.\nfunc Size() (int, int) {\n\treturn int(term_size.x), int(term_size.y)\n}\n\n// Clears the internal back buffer.\nfunc Clear(fg, bg Attribute) error {\n\tforeground, background = fg, bg\n\tupdate_size_maybe()\n\tback_buffer.clear()\n\treturn nil\n}\n\n// Sets termbox input mode. Termbox has two input modes:\n//\n// 1. Esc input mode. When ESC sequence is in the buffer and it doesn't match\n// any known sequence. ESC means KeyEsc. This is the default input mode.\n//\n// 2. Alt input mode. When ESC sequence is in the buffer and it doesn't match\n// any known sequence. ESC enables ModAlt modifier for the next keyboard event.\n//\n// Both input modes can be OR'ed with Mouse mode. Setting Mouse mode bit up will\n// enable mouse button press/release and drag events.\n//\n// If 'mode' is InputCurrent, returns the current input mode. See also Input*\n// constants.\nfunc SetInputMode(mode InputMode) InputMode {\n\tif mode == InputCurrent {\n\t\treturn input_mode\n\t}\n\tif mode&InputMouse != 0 {\n\t\terr := set_console_mode(in, enable_window_input|enable_mouse_input|enable_extended_flags)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t} else {\n\t\terr := set_console_mode(in, enable_window_input)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n\tinput_mode = mode\n\treturn input_mode\n}\n\n// Sets the termbox output mode.\n//\n// Windows console does not support extra colour modes,\n// so this will always set and return OutputNormal.\nfunc SetOutputMode(mode OutputMode) OutputMode {\n\treturn OutputNormal\n}\n\n// Sync comes handy when something causes desync between termbox's understanding\n// of a terminal buffer and the reality. Such as a third party process. Sync\n// forces a complete resync between the termbox and a terminal, it may not be\n// visually pretty though. At the moment on Windows it does nothing.\nfunc Sync() error {\n\treturn nil\n}\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/collect_terminfo.py",
    "content": "#!/usr/bin/env python\n\nimport sys, os, subprocess\n\ndef escaped(s):\n\treturn repr(s)[1:-1]\n\ndef tput(term, name):\n\ttry:\n\t\treturn subprocess.check_output(['tput', '-T%s' % term, name]).decode()\n\texcept subprocess.CalledProcessError as e:\n\t\treturn e.output.decode()\n\n\ndef w(s):\n\tif s == None:\n\t\treturn\n\tsys.stdout.write(s)\n\nterminals = {\n\t'xterm' : 'xterm',\n\t'rxvt-256color' : 'rxvt_256color',\n\t'rxvt-unicode' : 'rxvt_unicode',\n\t'linux' : 'linux',\n\t'Eterm' : 'eterm',\n\t'screen' : 'screen'\n}\n\nkeys = [\n\t\"F1\",\t\t\"kf1\",\n\t\"F2\",\t\t\"kf2\",\n\t\"F3\",\t\t\"kf3\",\n\t\"F4\",\t\t\"kf4\",\n\t\"F5\",\t\t\"kf5\",\n\t\"F6\",\t\t\"kf6\",\n\t\"F7\",\t\t\"kf7\",\n\t\"F8\",\t\t\"kf8\",\n\t\"F9\",\t\t\"kf9\",\n\t\"F10\",\t\t\"kf10\",\n\t\"F11\",\t\t\"kf11\",\n\t\"F12\",\t\t\"kf12\",\n\t\"INSERT\",\t\"kich1\",\n\t\"DELETE\",\t\"kdch1\",\n\t\"HOME\",\t\t\"khome\",\n\t\"END\",\t\t\"kend\",\n\t\"PGUP\",\t\t\"kpp\",\n\t\"PGDN\",\t\t\"knp\",\n\t\"KEY_UP\",\t\"kcuu1\",\n\t\"KEY_DOWN\",\t\"kcud1\",\n\t\"KEY_LEFT\",\t\"kcub1\",\n\t\"KEY_RIGHT\",\t\"kcuf1\"\n]\n\nfuncs = [\n\t\"T_ENTER_CA\",\t\t\"smcup\",\n\t\"T_EXIT_CA\",\t\t\"rmcup\",\n\t\"T_SHOW_CURSOR\",\t\"cnorm\",\n\t\"T_HIDE_CURSOR\",\t\"civis\",\n\t\"T_CLEAR_SCREEN\",\t\"clear\",\n\t\"T_SGR0\",\t\t\"sgr0\",\n\t\"T_UNDERLINE\",\t\t\"smul\",\n\t\"T_BOLD\",\t\t\"bold\",\n\t\"T_BLINK\",\t\t\"blink\",\n\t\"T_REVERSE\",            \"rev\",\n\t\"T_ENTER_KEYPAD\",\t\"smkx\",\n\t\"T_EXIT_KEYPAD\",\t\"rmkx\"\n]\n\ndef iter_pairs(iterable):\n\titerable = iter(iterable)\n\twhile True:\n\t\tyield (next(iterable), next(iterable))\n\ndef do_term(term, nick):\n\tw(\"// %s\\n\" % term)\n\tw(\"var %s_keys = []string{\\n\\t\" % nick)\n\tfor k, v in iter_pairs(keys):\n\t\tw('\"')\n\t\tw(escaped(tput(term, v)))\n\t\tw('\",')\n\tw(\"\\n}\\n\")\n\tw(\"var %s_funcs = []string{\\n\\t\" % nick)\n\tfor k,v in iter_pairs(funcs):\n\t\tw('\"')\n\t\tif v == \"sgr\":\n\t\t\tw(\"\\\\033[3%d;4%dm\")\n\t\telif v == \"cup\":\n\t\t\tw(\"\\\\033[%d;%dH\")\n\t\telse:\n\t\t\tw(escaped(tput(term, v)))\n\t\tw('\", ')\n\tw(\"\\n}\\n\\n\")\n\ndef do_terms(d):\n\tw(\"var terms = []struct {\\n\")\n\tw(\"\\tname  string\\n\")\n\tw(\"\\tkeys  []string\\n\")\n\tw(\"\\tfuncs []string\\n\")\n\tw(\"}{\\n\")\n\tfor k, v in d.items():\n\t\tw('\\t{\"%s\", %s_keys, %s_funcs},\\n' % (k, v, v))\n\tw(\"}\\n\\n\")\n\nw(\"// +build !windows\\n\\npackage termbox\\n\\n\")\n\nfor k,v in terminals.items():\n\tdo_term(k, v)\n\ndo_terms(terminals)\n\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/syscalls.go",
    "content": "// +build ignore\n\npackage termbox\n\n/*\n#include <termios.h>\n#include <sys/ioctl.h>\n*/\nimport \"C\"\n\ntype syscall_Termios C.struct_termios\n\nconst (\n\tsyscall_IGNBRK = C.IGNBRK\n\tsyscall_BRKINT = C.BRKINT\n\tsyscall_PARMRK = C.PARMRK\n\tsyscall_ISTRIP = C.ISTRIP\n\tsyscall_INLCR  = C.INLCR\n\tsyscall_IGNCR  = C.IGNCR\n\tsyscall_ICRNL  = C.ICRNL\n\tsyscall_IXON   = C.IXON\n\tsyscall_OPOST  = C.OPOST\n\tsyscall_ECHO   = C.ECHO\n\tsyscall_ECHONL = C.ECHONL\n\tsyscall_ICANON = C.ICANON\n\tsyscall_ISIG   = C.ISIG\n\tsyscall_IEXTEN = C.IEXTEN\n\tsyscall_CSIZE  = C.CSIZE\n\tsyscall_PARENB = C.PARENB\n\tsyscall_CS8    = C.CS8\n\tsyscall_VMIN   = C.VMIN\n\tsyscall_VTIME  = C.VTIME\n\n\t// on darwin change these to (on *bsd too?):\n\t// C.TIOCGETA\n\t// C.TIOCSETA\n\tsyscall_TCGETS = C.TCGETS\n\tsyscall_TCSETS = C.TCSETS\n)\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/syscalls_darwin.go",
    "content": "// Created by cgo -godefs - DO NOT EDIT\n// cgo -godefs syscalls.go\n\n// +build !amd64\n\npackage termbox\n\ntype syscall_Termios struct {\n\tIflag  uint32\n\tOflag  uint32\n\tCflag  uint32\n\tLflag  uint32\n\tCc     [20]uint8\n\tIspeed uint32\n\tOspeed uint32\n}\n\nconst (\n\tsyscall_IGNBRK = 0x1\n\tsyscall_BRKINT = 0x2\n\tsyscall_PARMRK = 0x8\n\tsyscall_ISTRIP = 0x20\n\tsyscall_INLCR  = 0x40\n\tsyscall_IGNCR  = 0x80\n\tsyscall_ICRNL  = 0x100\n\tsyscall_IXON   = 0x200\n\tsyscall_OPOST  = 0x1\n\tsyscall_ECHO   = 0x8\n\tsyscall_ECHONL = 0x10\n\tsyscall_ICANON = 0x100\n\tsyscall_ISIG   = 0x80\n\tsyscall_IEXTEN = 0x400\n\tsyscall_CSIZE  = 0x300\n\tsyscall_PARENB = 0x1000\n\tsyscall_CS8    = 0x300\n\tsyscall_VMIN   = 0x10\n\tsyscall_VTIME  = 0x11\n\n\tsyscall_TCGETS = 0x402c7413\n\tsyscall_TCSETS = 0x802c7414\n)\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/syscalls_darwin_amd64.go",
    "content": "// Created by cgo -godefs - DO NOT EDIT\n// cgo -godefs syscalls.go\n\npackage termbox\n\ntype syscall_Termios struct {\n\tIflag     uint64\n\tOflag     uint64\n\tCflag     uint64\n\tLflag     uint64\n\tCc        [20]uint8\n\tPad_cgo_0 [4]byte\n\tIspeed    uint64\n\tOspeed    uint64\n}\n\nconst (\n\tsyscall_IGNBRK = 0x1\n\tsyscall_BRKINT = 0x2\n\tsyscall_PARMRK = 0x8\n\tsyscall_ISTRIP = 0x20\n\tsyscall_INLCR  = 0x40\n\tsyscall_IGNCR  = 0x80\n\tsyscall_ICRNL  = 0x100\n\tsyscall_IXON   = 0x200\n\tsyscall_OPOST  = 0x1\n\tsyscall_ECHO   = 0x8\n\tsyscall_ECHONL = 0x10\n\tsyscall_ICANON = 0x100\n\tsyscall_ISIG   = 0x80\n\tsyscall_IEXTEN = 0x400\n\tsyscall_CSIZE  = 0x300\n\tsyscall_PARENB = 0x1000\n\tsyscall_CS8    = 0x300\n\tsyscall_VMIN   = 0x10\n\tsyscall_VTIME  = 0x11\n\n\tsyscall_TCGETS = 0x40487413\n\tsyscall_TCSETS = 0x80487414\n)\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/syscalls_dragonfly.go",
    "content": "// Created by cgo -godefs - DO NOT EDIT\n// cgo -godefs syscalls.go\n\npackage termbox\n\ntype syscall_Termios struct {\n\tIflag  uint32\n\tOflag  uint32\n\tCflag  uint32\n\tLflag  uint32\n\tCc     [20]uint8\n\tIspeed uint32\n\tOspeed uint32\n}\n\nconst (\n\tsyscall_IGNBRK = 0x1\n\tsyscall_BRKINT = 0x2\n\tsyscall_PARMRK = 0x8\n\tsyscall_ISTRIP = 0x20\n\tsyscall_INLCR  = 0x40\n\tsyscall_IGNCR  = 0x80\n\tsyscall_ICRNL  = 0x100\n\tsyscall_IXON   = 0x200\n\tsyscall_OPOST  = 0x1\n\tsyscall_ECHO   = 0x8\n\tsyscall_ECHONL = 0x10\n\tsyscall_ICANON = 0x100\n\tsyscall_ISIG   = 0x80\n\tsyscall_IEXTEN = 0x400\n\tsyscall_CSIZE  = 0x300\n\tsyscall_PARENB = 0x1000\n\tsyscall_CS8    = 0x300\n\tsyscall_VMIN   = 0x10\n\tsyscall_VTIME  = 0x11\n\n\tsyscall_TCGETS = 0x402c7413\n\tsyscall_TCSETS = 0x802c7414\n)\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/syscalls_freebsd.go",
    "content": "// Created by cgo -godefs - DO NOT EDIT\n// cgo -godefs syscalls.go\n\npackage termbox\n\ntype syscall_Termios struct {\n\tIflag  uint32\n\tOflag  uint32\n\tCflag  uint32\n\tLflag  uint32\n\tCc     [20]uint8\n\tIspeed uint32\n\tOspeed uint32\n}\n\nconst (\n\tsyscall_IGNBRK = 0x1\n\tsyscall_BRKINT = 0x2\n\tsyscall_PARMRK = 0x8\n\tsyscall_ISTRIP = 0x20\n\tsyscall_INLCR  = 0x40\n\tsyscall_IGNCR  = 0x80\n\tsyscall_ICRNL  = 0x100\n\tsyscall_IXON   = 0x200\n\tsyscall_OPOST  = 0x1\n\tsyscall_ECHO   = 0x8\n\tsyscall_ECHONL = 0x10\n\tsyscall_ICANON = 0x100\n\tsyscall_ISIG   = 0x80\n\tsyscall_IEXTEN = 0x400\n\tsyscall_CSIZE  = 0x300\n\tsyscall_PARENB = 0x1000\n\tsyscall_CS8    = 0x300\n\tsyscall_VMIN   = 0x10\n\tsyscall_VTIME  = 0x11\n\n\tsyscall_TCGETS = 0x402c7413\n\tsyscall_TCSETS = 0x802c7414\n)\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/syscalls_linux.go",
    "content": "// Created by cgo -godefs - DO NOT EDIT\n// cgo -godefs syscalls.go\n\npackage termbox\n\nimport \"syscall\"\n\ntype syscall_Termios syscall.Termios\n\nconst (\n\tsyscall_IGNBRK = syscall.IGNBRK\n\tsyscall_BRKINT = syscall.BRKINT\n\tsyscall_PARMRK = syscall.PARMRK\n\tsyscall_ISTRIP = syscall.ISTRIP\n\tsyscall_INLCR  = syscall.INLCR\n\tsyscall_IGNCR  = syscall.IGNCR\n\tsyscall_ICRNL  = syscall.ICRNL\n\tsyscall_IXON   = syscall.IXON\n\tsyscall_OPOST  = syscall.OPOST\n\tsyscall_ECHO   = syscall.ECHO\n\tsyscall_ECHONL = syscall.ECHONL\n\tsyscall_ICANON = syscall.ICANON\n\tsyscall_ISIG   = syscall.ISIG\n\tsyscall_IEXTEN = syscall.IEXTEN\n\tsyscall_CSIZE  = syscall.CSIZE\n\tsyscall_PARENB = syscall.PARENB\n\tsyscall_CS8    = syscall.CS8\n\tsyscall_VMIN   = syscall.VMIN\n\tsyscall_VTIME  = syscall.VTIME\n\n\tsyscall_TCGETS = syscall.TCGETS\n\tsyscall_TCSETS = syscall.TCSETS\n)\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/syscalls_netbsd.go",
    "content": "// Created by cgo -godefs - DO NOT EDIT\n// cgo -godefs syscalls.go\n\npackage termbox\n\ntype syscall_Termios struct {\n\tIflag  uint32\n\tOflag  uint32\n\tCflag  uint32\n\tLflag  uint32\n\tCc     [20]uint8\n\tIspeed int32\n\tOspeed int32\n}\n\nconst (\n\tsyscall_IGNBRK = 0x1\n\tsyscall_BRKINT = 0x2\n\tsyscall_PARMRK = 0x8\n\tsyscall_ISTRIP = 0x20\n\tsyscall_INLCR  = 0x40\n\tsyscall_IGNCR  = 0x80\n\tsyscall_ICRNL  = 0x100\n\tsyscall_IXON   = 0x200\n\tsyscall_OPOST  = 0x1\n\tsyscall_ECHO   = 0x8\n\tsyscall_ECHONL = 0x10\n\tsyscall_ICANON = 0x100\n\tsyscall_ISIG   = 0x80\n\tsyscall_IEXTEN = 0x400\n\tsyscall_CSIZE  = 0x300\n\tsyscall_PARENB = 0x1000\n\tsyscall_CS8    = 0x300\n\tsyscall_VMIN   = 0x10\n\tsyscall_VTIME  = 0x11\n\n\tsyscall_TCGETS = 0x402c7413\n\tsyscall_TCSETS = 0x802c7414\n)\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/syscalls_openbsd.go",
    "content": "// Created by cgo -godefs - DO NOT EDIT\n// cgo -godefs syscalls.go\n\npackage termbox\n\ntype syscall_Termios struct {\n\tIflag  uint32\n\tOflag  uint32\n\tCflag  uint32\n\tLflag  uint32\n\tCc     [20]uint8\n\tIspeed int32\n\tOspeed int32\n}\n\nconst (\n\tsyscall_IGNBRK = 0x1\n\tsyscall_BRKINT = 0x2\n\tsyscall_PARMRK = 0x8\n\tsyscall_ISTRIP = 0x20\n\tsyscall_INLCR  = 0x40\n\tsyscall_IGNCR  = 0x80\n\tsyscall_ICRNL  = 0x100\n\tsyscall_IXON   = 0x200\n\tsyscall_OPOST  = 0x1\n\tsyscall_ECHO   = 0x8\n\tsyscall_ECHONL = 0x10\n\tsyscall_ICANON = 0x100\n\tsyscall_ISIG   = 0x80\n\tsyscall_IEXTEN = 0x400\n\tsyscall_CSIZE  = 0x300\n\tsyscall_PARENB = 0x1000\n\tsyscall_CS8    = 0x300\n\tsyscall_VMIN   = 0x10\n\tsyscall_VTIME  = 0x11\n\n\tsyscall_TCGETS = 0x402c7413\n\tsyscall_TCSETS = 0x802c7414\n)\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/syscalls_windows.go",
    "content": "// Created by cgo -godefs - DO NOT EDIT\n// cgo -godefs -- -DUNICODE syscalls.go\n\npackage termbox\n\nconst (\n\tforeground_blue          = 0x1\n\tforeground_green         = 0x2\n\tforeground_red           = 0x4\n\tforeground_intensity     = 0x8\n\tbackground_blue          = 0x10\n\tbackground_green         = 0x20\n\tbackground_red           = 0x40\n\tbackground_intensity     = 0x80\n\tstd_input_handle         = -0xa\n\tstd_output_handle        = -0xb\n\tkey_event                = 0x1\n\tmouse_event              = 0x2\n\twindow_buffer_size_event = 0x4\n\tenable_window_input      = 0x8\n\tenable_mouse_input       = 0x10\n\tenable_extended_flags    = 0x80\n\n\tvk_f1          = 0x70\n\tvk_f2          = 0x71\n\tvk_f3          = 0x72\n\tvk_f4          = 0x73\n\tvk_f5          = 0x74\n\tvk_f6          = 0x75\n\tvk_f7          = 0x76\n\tvk_f8          = 0x77\n\tvk_f9          = 0x78\n\tvk_f10         = 0x79\n\tvk_f11         = 0x7a\n\tvk_f12         = 0x7b\n\tvk_insert      = 0x2d\n\tvk_delete      = 0x2e\n\tvk_home        = 0x24\n\tvk_end         = 0x23\n\tvk_pgup        = 0x21\n\tvk_pgdn        = 0x22\n\tvk_arrow_up    = 0x26\n\tvk_arrow_down  = 0x28\n\tvk_arrow_left  = 0x25\n\tvk_arrow_right = 0x27\n\tvk_backspace   = 0x8\n\tvk_tab         = 0x9\n\tvk_enter       = 0xd\n\tvk_esc         = 0x1b\n\tvk_space       = 0x20\n\n\tleft_alt_pressed   = 0x2\n\tleft_ctrl_pressed  = 0x8\n\tright_alt_pressed  = 0x1\n\tright_ctrl_pressed = 0x4\n\tshift_pressed      = 0x10\n\n\tgeneric_read            = 0x80000000\n\tgeneric_write           = 0x40000000\n\tconsole_textmode_buffer = 0x1\n)\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/termbox.go",
    "content": "// +build !windows\n\npackage termbox\n\nimport \"unicode/utf8\"\nimport \"bytes\"\nimport \"syscall\"\nimport \"unsafe\"\nimport \"strings\"\nimport \"strconv\"\nimport \"os\"\nimport \"io\"\n\n// private API\n\nconst (\n\tt_enter_ca = iota\n\tt_exit_ca\n\tt_show_cursor\n\tt_hide_cursor\n\tt_clear_screen\n\tt_sgr0\n\tt_underline\n\tt_bold\n\tt_blink\n\tt_reverse\n\tt_enter_keypad\n\tt_exit_keypad\n\tt_enter_mouse\n\tt_exit_mouse\n\tt_max_funcs\n)\n\nconst (\n\tcoord_invalid = -2\n\tattr_invalid  = Attribute(0xFFFF)\n)\n\ntype input_event struct {\n\tdata []byte\n\terr  error\n}\n\nvar (\n\t// term specific sequences\n\tkeys  []string\n\tfuncs []string\n\n\t// termbox inner state\n\torig_tios      syscall_Termios\n\tback_buffer    cellbuf\n\tfront_buffer   cellbuf\n\ttermw          int\n\ttermh          int\n\tinput_mode     = InputEsc\n\toutput_mode    = OutputNormal\n\tout            *os.File\n\tin             int\n\tlastfg         = attr_invalid\n\tlastbg         = attr_invalid\n\tlastx          = coord_invalid\n\tlasty          = coord_invalid\n\tcursor_x       = cursor_hidden\n\tcursor_y       = cursor_hidden\n\tforeground     = ColorDefault\n\tbackground     = ColorDefault\n\tinbuf          = make([]byte, 0, 64)\n\toutbuf         bytes.Buffer\n\tsigwinch       = make(chan os.Signal, 1)\n\tsigio          = make(chan os.Signal, 1)\n\tquit           = make(chan int)\n\tinput_comm     = make(chan input_event)\n\tinterrupt_comm = make(chan struct{})\n\tintbuf         = make([]byte, 0, 16)\n\n\t// grayscale indexes\n\tgrayscale = []Attribute{\n\t\t0, 17, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244,\n\t\t245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 232,\n\t}\n)\n\nfunc write_cursor(x, y int) {\n\toutbuf.WriteString(\"\\033[\")\n\toutbuf.Write(strconv.AppendUint(intbuf, uint64(y+1), 10))\n\toutbuf.WriteString(\";\")\n\toutbuf.Write(strconv.AppendUint(intbuf, uint64(x+1), 10))\n\toutbuf.WriteString(\"H\")\n}\n\nfunc write_sgr_fg(a Attribute) {\n\tswitch output_mode {\n\tcase Output256, Output216, OutputGrayscale:\n\t\toutbuf.WriteString(\"\\033[38;5;\")\n\t\toutbuf.Write(strconv.AppendUint(intbuf, uint64(a-1), 10))\n\t\toutbuf.WriteString(\"m\")\n\tdefault:\n\t\toutbuf.WriteString(\"\\033[3\")\n\t\toutbuf.Write(strconv.AppendUint(intbuf, uint64(a-1), 10))\n\t\toutbuf.WriteString(\"m\")\n\t}\n}\n\nfunc write_sgr_bg(a Attribute) {\n\tswitch output_mode {\n\tcase Output256, Output216, OutputGrayscale:\n\t\toutbuf.WriteString(\"\\033[48;5;\")\n\t\toutbuf.Write(strconv.AppendUint(intbuf, uint64(a-1), 10))\n\t\toutbuf.WriteString(\"m\")\n\tdefault:\n\t\toutbuf.WriteString(\"\\033[4\")\n\t\toutbuf.Write(strconv.AppendUint(intbuf, uint64(a-1), 10))\n\t\toutbuf.WriteString(\"m\")\n\t}\n}\n\nfunc write_sgr(fg, bg Attribute) {\n\tswitch output_mode {\n\tcase Output256, Output216, OutputGrayscale:\n\t\toutbuf.WriteString(\"\\033[38;5;\")\n\t\toutbuf.Write(strconv.AppendUint(intbuf, uint64(fg-1), 10))\n\t\toutbuf.WriteString(\"m\")\n\t\toutbuf.WriteString(\"\\033[48;5;\")\n\t\toutbuf.Write(strconv.AppendUint(intbuf, uint64(bg-1), 10))\n\t\toutbuf.WriteString(\"m\")\n\tdefault:\n\t\toutbuf.WriteString(\"\\033[3\")\n\t\toutbuf.Write(strconv.AppendUint(intbuf, uint64(fg-1), 10))\n\t\toutbuf.WriteString(\";4\")\n\t\toutbuf.Write(strconv.AppendUint(intbuf, uint64(bg-1), 10))\n\t\toutbuf.WriteString(\"m\")\n\t}\n}\n\ntype winsize struct {\n\trows    uint16\n\tcols    uint16\n\txpixels uint16\n\typixels uint16\n}\n\nfunc get_term_size(fd uintptr) (int, int) {\n\tvar sz winsize\n\t_, _, _ = syscall.Syscall(syscall.SYS_IOCTL,\n\t\tfd, uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&sz)))\n\treturn int(sz.cols), int(sz.rows)\n}\n\nfunc send_attr(fg, bg Attribute) {\n\tif fg == lastfg && bg == lastbg {\n\t\treturn\n\t}\n\n\toutbuf.WriteString(funcs[t_sgr0])\n\n\tvar fgcol, bgcol Attribute\n\n\tswitch output_mode {\n\tcase Output256:\n\t\tfgcol = fg & 0x1FF\n\t\tbgcol = bg & 0x1FF\n\tcase Output216:\n\t\tfgcol = fg & 0xFF\n\t\tbgcol = bg & 0xFF\n\t\tif fgcol > 216 {\n\t\t\tfgcol = ColorDefault\n\t\t}\n\t\tif bgcol > 216 {\n\t\t\tbgcol = ColorDefault\n\t\t}\n\t\tif fgcol != ColorDefault {\n\t\t\tfgcol += 0x10\n\t\t}\n\t\tif bgcol != ColorDefault {\n\t\t\tbgcol += 0x10\n\t\t}\n\tcase OutputGrayscale:\n\t\tfgcol = fg & 0x1F\n\t\tbgcol = bg & 0x1F\n\t\tif fgcol > 26 {\n\t\t\tfgcol = ColorDefault\n\t\t}\n\t\tif bgcol > 26 {\n\t\t\tbgcol = ColorDefault\n\t\t}\n\t\tif fgcol != ColorDefault {\n\t\t\tfgcol = grayscale[fgcol]\n\t\t}\n\t\tif bgcol != ColorDefault {\n\t\t\tbgcol = grayscale[bgcol]\n\t\t}\n\tdefault:\n\t\tfgcol = fg & 0x0F\n\t\tbgcol = bg & 0x0F\n\t}\n\n\tif fgcol != ColorDefault {\n\t\tif bgcol != ColorDefault {\n\t\t\twrite_sgr(fgcol, bgcol)\n\t\t} else {\n\t\t\twrite_sgr_fg(fgcol)\n\t\t}\n\t} else if bgcol != ColorDefault {\n\t\twrite_sgr_bg(bgcol)\n\t}\n\n\tif fg&AttrBold != 0 {\n\t\toutbuf.WriteString(funcs[t_bold])\n\t}\n\tif bg&AttrBold != 0 {\n\t\toutbuf.WriteString(funcs[t_blink])\n\t}\n\tif fg&AttrUnderline != 0 {\n\t\toutbuf.WriteString(funcs[t_underline])\n\t}\n\tif fg&AttrReverse|bg&AttrReverse != 0 {\n\t\toutbuf.WriteString(funcs[t_reverse])\n\t}\n\n\tlastfg, lastbg = fg, bg\n}\n\nfunc send_char(x, y int, ch rune) {\n\tvar buf [8]byte\n\tn := utf8.EncodeRune(buf[:], ch)\n\tif x-1 != lastx || y != lasty {\n\t\twrite_cursor(x, y)\n\t}\n\tlastx, lasty = x, y\n\toutbuf.Write(buf[:n])\n}\n\nfunc flush() error {\n\t_, err := io.Copy(out, &outbuf)\n\toutbuf.Reset()\n\treturn err\n}\n\nfunc send_clear() error {\n\tsend_attr(foreground, background)\n\toutbuf.WriteString(funcs[t_clear_screen])\n\tif !is_cursor_hidden(cursor_x, cursor_y) {\n\t\twrite_cursor(cursor_x, cursor_y)\n\t}\n\n\t// we need to invalidate cursor position too and these two vars are\n\t// used only for simple cursor positioning optimization, cursor\n\t// actually may be in the correct place, but we simply discard\n\t// optimization once and it gives us simple solution for the case when\n\t// cursor moved\n\tlastx = coord_invalid\n\tlasty = coord_invalid\n\n\treturn flush()\n}\n\nfunc update_size_maybe() error {\n\tw, h := get_term_size(out.Fd())\n\tif w != termw || h != termh {\n\t\ttermw, termh = w, h\n\t\tback_buffer.resize(termw, termh)\n\t\tfront_buffer.resize(termw, termh)\n\t\tfront_buffer.clear()\n\t\treturn send_clear()\n\t}\n\treturn nil\n}\n\nfunc tcsetattr(fd uintptr, termios *syscall_Termios) error {\n\tr, _, e := syscall.Syscall(syscall.SYS_IOCTL,\n\t\tfd, uintptr(syscall_TCSETS), uintptr(unsafe.Pointer(termios)))\n\tif r != 0 {\n\t\treturn os.NewSyscallError(\"SYS_IOCTL\", e)\n\t}\n\treturn nil\n}\n\nfunc tcgetattr(fd uintptr, termios *syscall_Termios) error {\n\tr, _, e := syscall.Syscall(syscall.SYS_IOCTL,\n\t\tfd, uintptr(syscall_TCGETS), uintptr(unsafe.Pointer(termios)))\n\tif r != 0 {\n\t\treturn os.NewSyscallError(\"SYS_IOCTL\", e)\n\t}\n\treturn nil\n}\n\nfunc parse_mouse_event(event *Event, buf string) (int, bool) {\n\tif strings.HasPrefix(buf, \"\\033[M\") && len(buf) >= 6 {\n\t\t// X10 mouse encoding, the simplest one\n\t\t// \\033 [ M Cb Cx Cy\n\t\tb := buf[3] - 32\n\t\tswitch b & 3 {\n\t\tcase 0:\n\t\t\tif b&64 != 0 {\n\t\t\t\tevent.Key = MouseWheelUp\n\t\t\t} else {\n\t\t\t\tevent.Key = MouseLeft\n\t\t\t}\n\t\tcase 1:\n\t\t\tif b&64 != 0 {\n\t\t\t\tevent.Key = MouseWheelDown\n\t\t\t} else {\n\t\t\t\tevent.Key = MouseMiddle\n\t\t\t}\n\t\tcase 2:\n\t\t\tevent.Key = MouseRight\n\t\tcase 3:\n\t\t\tevent.Key = MouseRelease\n\t\tdefault:\n\t\t\treturn 6, false\n\t\t}\n\t\tevent.Type = EventMouse // KeyEvent by default\n\t\tif b&32 != 0 {\n\t\t\tevent.Mod |= ModMotion\n\t\t}\n\n\t\t// the coord is 1,1 for upper left\n\t\tevent.MouseX = int(buf[4]) - 1 - 32\n\t\tevent.MouseY = int(buf[5]) - 1 - 32\n\t\treturn 6, true\n\t} else if strings.HasPrefix(buf, \"\\033[<\") || strings.HasPrefix(buf, \"\\033[\") {\n\t\t// xterm 1006 extended mode or urxvt 1015 extended mode\n\t\t// xterm: \\033 [ < Cb ; Cx ; Cy (M or m)\n\t\t// urxvt: \\033 [ Cb ; Cx ; Cy M\n\n\t\t// find the first M or m, that's where we stop\n\t\tmi := strings.IndexAny(buf, \"Mm\")\n\t\tif mi == -1 {\n\t\t\treturn 0, false\n\t\t}\n\n\t\t// whether it's a capital M or not\n\t\tisM := buf[mi] == 'M'\n\n\t\t// whether it's urxvt or not\n\t\tisU := false\n\n\t\t// buf[2] is safe here, because having M or m found means we have at\n\t\t// least 3 bytes in a string\n\t\tif buf[2] == '<' {\n\t\t\tbuf = buf[3:mi]\n\t\t} else {\n\t\t\tisU = true\n\t\t\tbuf = buf[2:mi]\n\t\t}\n\n\t\ts1 := strings.Index(buf, \";\")\n\t\ts2 := strings.LastIndex(buf, \";\")\n\t\t// not found or only one ';'\n\t\tif s1 == -1 || s2 == -1 || s1 == s2 {\n\t\t\treturn 0, false\n\t\t}\n\n\t\tn1, err := strconv.ParseInt(buf[0:s1], 10, 64)\n\t\tif err != nil {\n\t\t\treturn 0, false\n\t\t}\n\t\tn2, err := strconv.ParseInt(buf[s1+1:s2], 10, 64)\n\t\tif err != nil {\n\t\t\treturn 0, false\n\t\t}\n\t\tn3, err := strconv.ParseInt(buf[s2+1:], 10, 64)\n\t\tif err != nil {\n\t\t\treturn 0, false\n\t\t}\n\n\t\t// on urxvt, first number is encoded exactly as in X10, but we need to\n\t\t// make it zero-based, on xterm it is zero-based already\n\t\tif isU {\n\t\t\tn1 -= 32\n\t\t}\n\t\tswitch n1 & 3 {\n\t\tcase 0:\n\t\t\tif n1&64 != 0 {\n\t\t\t\tevent.Key = MouseWheelUp\n\t\t\t} else {\n\t\t\t\tevent.Key = MouseLeft\n\t\t\t}\n\t\tcase 1:\n\t\t\tif n1&64 != 0 {\n\t\t\t\tevent.Key = MouseWheelDown\n\t\t\t} else {\n\t\t\t\tevent.Key = MouseMiddle\n\t\t\t}\n\t\tcase 2:\n\t\t\tevent.Key = MouseRight\n\t\tcase 3:\n\t\t\tevent.Key = MouseRelease\n\t\tdefault:\n\t\t\treturn mi + 1, false\n\t\t}\n\t\tif !isM {\n\t\t\t// on xterm mouse release is signaled by lowercase m\n\t\t\tevent.Key = MouseRelease\n\t\t}\n\n\t\tevent.Type = EventMouse // KeyEvent by default\n\t\tif n1&32 != 0 {\n\t\t\tevent.Mod |= ModMotion\n\t\t}\n\n\t\tevent.MouseX = int(n2) - 1\n\t\tevent.MouseY = int(n3) - 1\n\t\treturn mi + 1, true\n\t}\n\n\treturn 0, false\n}\n\nfunc parse_escape_sequence(event *Event, buf []byte) (int, bool) {\n\tbufstr := string(buf)\n\tfor i, key := range keys {\n\t\tif strings.HasPrefix(bufstr, key) {\n\t\t\tevent.Ch = 0\n\t\t\tevent.Key = Key(0xFFFF - i)\n\t\t\treturn len(key), true\n\t\t}\n\t}\n\n\t// if none of the keys match, let's try mouse seqences\n\treturn parse_mouse_event(event, bufstr)\n}\n\nfunc extract_raw_event(data []byte, event *Event) bool {\n\tif len(inbuf) == 0 {\n\t\treturn false\n\t}\n\n\tn := len(data)\n\tif n == 0 {\n\t\treturn false\n\t}\n\n\tn = copy(data, inbuf)\n\tcopy(inbuf, inbuf[n:])\n\tinbuf = inbuf[:len(inbuf)-n]\n\n\tevent.N = n\n\tevent.Type = EventRaw\n\treturn true\n}\n\nfunc extract_event(inbuf []byte, event *Event) bool {\n\tif len(inbuf) == 0 {\n\t\tevent.N = 0\n\t\treturn false\n\t}\n\n\tif inbuf[0] == '\\033' {\n\t\t// possible escape sequence\n\t\tif n, ok := parse_escape_sequence(event, inbuf); n != 0 {\n\t\t\tevent.N = n\n\t\t\treturn ok\n\t\t}\n\n\t\t// it's not escape sequence, then it's Alt or Esc, check input_mode\n\t\tswitch {\n\t\tcase input_mode&InputEsc != 0:\n\t\t\t// if we're in escape mode, fill Esc event, pop buffer, return success\n\t\t\tevent.Ch = 0\n\t\t\tevent.Key = KeyEsc\n\t\t\tevent.Mod = 0\n\t\t\tevent.N = 1\n\t\t\treturn true\n\t\tcase input_mode&InputAlt != 0:\n\t\t\t// if we're in alt mode, set Alt modifier to event and redo parsing\n\t\t\tevent.Mod = ModAlt\n\t\t\tok := extract_event(inbuf[1:], event)\n\t\t\tif ok {\n\t\t\t\tevent.N++\n\t\t\t} else {\n\t\t\t\tevent.N = 0\n\t\t\t}\n\t\t\treturn ok\n\t\tdefault:\n\t\t\tpanic(\"unreachable\")\n\t\t}\n\t}\n\n\t// if we're here, this is not an escape sequence and not an alt sequence\n\t// so, it's a FUNCTIONAL KEY or a UNICODE character\n\n\t// first of all check if it's a functional key\n\tif Key(inbuf[0]) <= KeySpace || Key(inbuf[0]) == KeyBackspace2 {\n\t\t// fill event, pop buffer, return success\n\t\tevent.Ch = 0\n\t\tevent.Key = Key(inbuf[0])\n\t\tevent.N = 1\n\t\treturn true\n\t}\n\n\t// the only possible option is utf8 rune\n\tif r, n := utf8.DecodeRune(inbuf); r != utf8.RuneError {\n\t\tevent.Ch = r\n\t\tevent.Key = 0\n\t\tevent.N = n\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc fcntl(fd int, cmd int, arg int) (val int, err error) {\n\tr, _, e := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), uintptr(cmd),\n\t\tuintptr(arg))\n\tval = int(r)\n\tif e != 0 {\n\t\terr = e\n\t}\n\treturn\n}\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/termbox_common.go",
    "content": "package termbox\n\n// private API, common OS agnostic part\n\ntype cellbuf struct {\n\twidth  int\n\theight int\n\tcells  []Cell\n}\n\nfunc (this *cellbuf) init(width, height int) {\n\tthis.width = width\n\tthis.height = height\n\tthis.cells = make([]Cell, width*height)\n}\n\nfunc (this *cellbuf) resize(width, height int) {\n\tif this.width == width && this.height == height {\n\t\treturn\n\t}\n\n\toldw := this.width\n\toldh := this.height\n\toldcells := this.cells\n\n\tthis.init(width, height)\n\tthis.clear()\n\n\tminw, minh := oldw, oldh\n\n\tif width < minw {\n\t\tminw = width\n\t}\n\tif height < minh {\n\t\tminh = height\n\t}\n\n\tfor i := 0; i < minh; i++ {\n\t\tsrco, dsto := i*oldw, i*width\n\t\tsrc := oldcells[srco : srco+minw]\n\t\tdst := this.cells[dsto : dsto+minw]\n\t\tcopy(dst, src)\n\t}\n}\n\nfunc (this *cellbuf) clear() {\n\tfor i := range this.cells {\n\t\tc := &this.cells[i]\n\t\tc.Ch = ' '\n\t\tc.Fg = foreground\n\t\tc.Bg = background\n\t}\n}\n\nconst cursor_hidden = -1\n\nfunc is_cursor_hidden(x, y int) bool {\n\treturn x == cursor_hidden || y == cursor_hidden\n}\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/termbox_windows.go",
    "content": "package termbox\n\nimport \"syscall\"\nimport \"unsafe\"\nimport \"unicode/utf16\"\nimport \"github.com/mattn/go-runewidth\"\n\ntype (\n\twchar     uint16\n\tshort     int16\n\tdword     uint32\n\tword      uint16\n\tchar_info struct {\n\t\tchar wchar\n\t\tattr word\n\t}\n\tcoord struct {\n\t\tx short\n\t\ty short\n\t}\n\tsmall_rect struct {\n\t\tleft   short\n\t\ttop    short\n\t\tright  short\n\t\tbottom short\n\t}\n\tconsole_screen_buffer_info struct {\n\t\tsize                coord\n\t\tcursor_position     coord\n\t\tattributes          word\n\t\twindow              small_rect\n\t\tmaximum_window_size coord\n\t}\n\tconsole_cursor_info struct {\n\t\tsize    dword\n\t\tvisible int32\n\t}\n\tinput_record struct {\n\t\tevent_type word\n\t\t_          [2]byte\n\t\tevent      [16]byte\n\t}\n\tkey_event_record struct {\n\t\tkey_down          int32\n\t\trepeat_count      word\n\t\tvirtual_key_code  word\n\t\tvirtual_scan_code word\n\t\tunicode_char      wchar\n\t\tcontrol_key_state dword\n\t}\n\twindow_buffer_size_record struct {\n\t\tsize coord\n\t}\n\tmouse_event_record struct {\n\t\tmouse_pos         coord\n\t\tbutton_state      dword\n\t\tcontrol_key_state dword\n\t\tevent_flags       dword\n\t}\n)\n\nconst (\n\tmouse_lmb = 0x1\n\tmouse_rmb = 0x2\n\tmouse_mmb = 0x4 | 0x8 | 0x10\n\tSM_CXMIN  = 28\n\tSM_CYMIN  = 29\n)\n\nfunc (this coord) uintptr() uintptr {\n\treturn uintptr(*(*int32)(unsafe.Pointer(&this)))\n}\n\nvar kernel32 = syscall.NewLazyDLL(\"kernel32.dll\")\nvar moduser32 = syscall.NewLazyDLL(\"user32.dll\")\nvar is_cjk = runewidth.IsEastAsian()\n\nvar (\n\tproc_set_console_active_screen_buffer = kernel32.NewProc(\"SetConsoleActiveScreenBuffer\")\n\tproc_set_console_screen_buffer_size   = kernel32.NewProc(\"SetConsoleScreenBufferSize\")\n\tproc_create_console_screen_buffer     = kernel32.NewProc(\"CreateConsoleScreenBuffer\")\n\tproc_get_console_screen_buffer_info   = kernel32.NewProc(\"GetConsoleScreenBufferInfo\")\n\tproc_write_console_output             = kernel32.NewProc(\"WriteConsoleOutputW\")\n\tproc_write_console_output_character   = kernel32.NewProc(\"WriteConsoleOutputCharacterW\")\n\tproc_write_console_output_attribute   = kernel32.NewProc(\"WriteConsoleOutputAttribute\")\n\tproc_set_console_cursor_info          = kernel32.NewProc(\"SetConsoleCursorInfo\")\n\tproc_set_console_cursor_position      = kernel32.NewProc(\"SetConsoleCursorPosition\")\n\tproc_get_console_cursor_info          = kernel32.NewProc(\"GetConsoleCursorInfo\")\n\tproc_read_console_input               = kernel32.NewProc(\"ReadConsoleInputW\")\n\tproc_get_console_mode                 = kernel32.NewProc(\"GetConsoleMode\")\n\tproc_set_console_mode                 = kernel32.NewProc(\"SetConsoleMode\")\n\tproc_fill_console_output_character    = kernel32.NewProc(\"FillConsoleOutputCharacterW\")\n\tproc_fill_console_output_attribute    = kernel32.NewProc(\"FillConsoleOutputAttribute\")\n\tproc_create_event                     = kernel32.NewProc(\"CreateEventW\")\n\tproc_wait_for_multiple_objects        = kernel32.NewProc(\"WaitForMultipleObjects\")\n\tproc_set_event                        = kernel32.NewProc(\"SetEvent\")\n\tget_system_metrics                    = moduser32.NewProc(\"GetSystemMetrics\")\n)\n\nfunc set_console_active_screen_buffer(h syscall.Handle) (err error) {\n\tr0, _, e1 := syscall.Syscall(proc_set_console_active_screen_buffer.Addr(),\n\t\t1, uintptr(h), 0, 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc set_console_screen_buffer_size(h syscall.Handle, size coord) (err error) {\n\tr0, _, e1 := syscall.Syscall(proc_set_console_screen_buffer_size.Addr(),\n\t\t2, uintptr(h), size.uintptr(), 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc create_console_screen_buffer() (h syscall.Handle, err error) {\n\tr0, _, e1 := syscall.Syscall6(proc_create_console_screen_buffer.Addr(),\n\t\t5, uintptr(generic_read|generic_write), 0, 0, console_textmode_buffer, 0, 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn syscall.Handle(r0), err\n}\n\nfunc get_console_screen_buffer_info(h syscall.Handle, info *console_screen_buffer_info) (err error) {\n\tr0, _, e1 := syscall.Syscall(proc_get_console_screen_buffer_info.Addr(),\n\t\t2, uintptr(h), uintptr(unsafe.Pointer(info)), 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc write_console_output(h syscall.Handle, chars []char_info, dst small_rect) (err error) {\n\ttmp_coord = coord{dst.right - dst.left + 1, dst.bottom - dst.top + 1}\n\ttmp_rect = dst\n\tr0, _, e1 := syscall.Syscall6(proc_write_console_output.Addr(),\n\t\t5, uintptr(h), uintptr(unsafe.Pointer(&chars[0])), tmp_coord.uintptr(),\n\t\ttmp_coord0.uintptr(), uintptr(unsafe.Pointer(&tmp_rect)), 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc write_console_output_character(h syscall.Handle, chars []wchar, pos coord) (err error) {\n\tr0, _, e1 := syscall.Syscall6(proc_write_console_output_character.Addr(),\n\t\t5, uintptr(h), uintptr(unsafe.Pointer(&chars[0])), uintptr(len(chars)),\n\t\tpos.uintptr(), uintptr(unsafe.Pointer(&tmp_arg)), 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc write_console_output_attribute(h syscall.Handle, attrs []word, pos coord) (err error) {\n\tr0, _, e1 := syscall.Syscall6(proc_write_console_output_attribute.Addr(),\n\t\t5, uintptr(h), uintptr(unsafe.Pointer(&attrs[0])), uintptr(len(attrs)),\n\t\tpos.uintptr(), uintptr(unsafe.Pointer(&tmp_arg)), 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc set_console_cursor_info(h syscall.Handle, info *console_cursor_info) (err error) {\n\tr0, _, e1 := syscall.Syscall(proc_set_console_cursor_info.Addr(),\n\t\t2, uintptr(h), uintptr(unsafe.Pointer(info)), 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc get_console_cursor_info(h syscall.Handle, info *console_cursor_info) (err error) {\n\tr0, _, e1 := syscall.Syscall(proc_get_console_cursor_info.Addr(),\n\t\t2, uintptr(h), uintptr(unsafe.Pointer(info)), 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc set_console_cursor_position(h syscall.Handle, pos coord) (err error) {\n\tr0, _, e1 := syscall.Syscall(proc_set_console_cursor_position.Addr(),\n\t\t2, uintptr(h), pos.uintptr(), 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc read_console_input(h syscall.Handle, record *input_record) (err error) {\n\tr0, _, e1 := syscall.Syscall6(proc_read_console_input.Addr(),\n\t\t4, uintptr(h), uintptr(unsafe.Pointer(record)), 1, uintptr(unsafe.Pointer(&tmp_arg)), 0, 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc get_console_mode(h syscall.Handle, mode *dword) (err error) {\n\tr0, _, e1 := syscall.Syscall(proc_get_console_mode.Addr(),\n\t\t2, uintptr(h), uintptr(unsafe.Pointer(mode)), 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc set_console_mode(h syscall.Handle, mode dword) (err error) {\n\tr0, _, e1 := syscall.Syscall(proc_set_console_mode.Addr(),\n\t\t2, uintptr(h), uintptr(mode), 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc fill_console_output_character(h syscall.Handle, char wchar, n int) (err error) {\n\tr0, _, e1 := syscall.Syscall6(proc_fill_console_output_character.Addr(),\n\t\t5, uintptr(h), uintptr(char), uintptr(n), tmp_coord.uintptr(),\n\t\tuintptr(unsafe.Pointer(&tmp_arg)), 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc fill_console_output_attribute(h syscall.Handle, attr word, n int) (err error) {\n\tr0, _, e1 := syscall.Syscall6(proc_fill_console_output_attribute.Addr(),\n\t\t5, uintptr(h), uintptr(attr), uintptr(n), tmp_coord.uintptr(),\n\t\tuintptr(unsafe.Pointer(&tmp_arg)), 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc create_event() (out syscall.Handle, err error) {\n\tr0, _, e1 := syscall.Syscall6(proc_create_event.Addr(),\n\t\t4, 0, 0, 0, 0, 0, 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn syscall.Handle(r0), err\n}\n\nfunc wait_for_multiple_objects(objects []syscall.Handle) (err error) {\n\tr0, _, e1 := syscall.Syscall6(proc_wait_for_multiple_objects.Addr(),\n\t\t4, uintptr(len(objects)), uintptr(unsafe.Pointer(&objects[0])),\n\t\t0, 0xFFFFFFFF, 0, 0)\n\tif uint32(r0) == 0xFFFFFFFF {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\nfunc set_event(ev syscall.Handle) (err error) {\n\tr0, _, e1 := syscall.Syscall(proc_set_event.Addr(),\n\t\t1, uintptr(ev), 0, 0)\n\tif int(r0) == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}\n\ntype diff_msg struct {\n\tpos   short\n\tlines short\n\tchars []char_info\n}\n\ntype input_event struct {\n\tevent Event\n\terr   error\n}\n\nvar (\n\torig_cursor_info console_cursor_info\n\torig_size        coord\n\torig_mode        dword\n\torig_screen      syscall.Handle\n\tback_buffer      cellbuf\n\tfront_buffer     cellbuf\n\tterm_size        coord\n\tinput_mode       = InputEsc\n\tcursor_x         = cursor_hidden\n\tcursor_y         = cursor_hidden\n\tforeground       = ColorDefault\n\tbackground       = ColorDefault\n\tin               syscall.Handle\n\tout              syscall.Handle\n\tinterrupt        syscall.Handle\n\tcharbuf          []char_info\n\tdiffbuf          []diff_msg\n\tbeg_x            = -1\n\tbeg_y            = -1\n\tbeg_i            = -1\n\tinput_comm       = make(chan Event)\n\tinterrupt_comm   = make(chan struct{})\n\tcancel_comm      = make(chan bool, 1)\n\tcancel_done_comm = make(chan bool)\n\talt_mode_esc     = false\n\n\t// these ones just to prevent heap allocs at all costs\n\ttmp_info   console_screen_buffer_info\n\ttmp_arg    dword\n\ttmp_coord0 = coord{0, 0}\n\ttmp_coord  = coord{0, 0}\n\ttmp_rect   = small_rect{0, 0, 0, 0}\n)\n\nfunc get_cursor_position(out syscall.Handle) coord {\n\terr := get_console_screen_buffer_info(out, &tmp_info)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn tmp_info.cursor_position\n}\n\nfunc get_term_size(out syscall.Handle) coord {\n\terr := get_console_screen_buffer_info(out, &tmp_info)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn tmp_info.size\n}\n\nfunc get_win_min_size(out syscall.Handle) coord {\n\tx, _, err := get_system_metrics.Call(SM_CXMIN)\n\ty, _, err := get_system_metrics.Call(SM_CYMIN)\n\n\tif x == 0 || y == 0 {\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n\treturn coord{\n\t\tx: short(x),\n\t\ty: short(y),\n\t}\n}\n\nfunc get_win_size(out syscall.Handle) coord {\n\terr := get_console_screen_buffer_info(out, &tmp_info)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tmin_size := get_win_min_size(out)\n\n\tsize := coord{\n\t\tx: tmp_info.window.right - tmp_info.window.left + 1,\n\t\ty: tmp_info.window.bottom - tmp_info.window.top + 1,\n\t}\n\n\tif size.x < min_size.x {\n\t\tsize.x = min_size.x\n\t}\n\n\tif size.y < min_size.y {\n\t\tsize.y = min_size.y\n\t}\n\n\treturn size\n}\n\nfunc update_size_maybe() {\n\tsize := get_term_size(out)\n\tif size.x != term_size.x || size.y != term_size.y {\n\t\tterm_size = size\n\t\tback_buffer.resize(int(size.x), int(size.y))\n\t\tfront_buffer.resize(int(size.x), int(size.y))\n\t\tfront_buffer.clear()\n\t\tclear()\n\n\t\tarea := int(size.x) * int(size.y)\n\t\tif cap(charbuf) < area {\n\t\t\tcharbuf = make([]char_info, 0, area)\n\t\t}\n\t}\n}\n\nvar color_table_bg = []word{\n\t0, // default (black)\n\t0, // black\n\tbackground_red,\n\tbackground_green,\n\tbackground_red | background_green, // yellow\n\tbackground_blue,\n\tbackground_red | background_blue,                    // magenta\n\tbackground_green | background_blue,                  // cyan\n\tbackground_red | background_blue | background_green, // white\n}\n\nvar color_table_fg = []word{\n\tforeground_red | foreground_blue | foreground_green, // default (white)\n\t0,\n\tforeground_red,\n\tforeground_green,\n\tforeground_red | foreground_green, // yellow\n\tforeground_blue,\n\tforeground_red | foreground_blue,                    // magenta\n\tforeground_green | foreground_blue,                  // cyan\n\tforeground_red | foreground_blue | foreground_green, // white\n}\n\nconst (\n\treplacement_char = '\\uFFFD'\n\tmax_rune         = '\\U0010FFFF'\n\tsurr1            = 0xd800\n\tsurr2            = 0xdc00\n\tsurr3            = 0xe000\n\tsurr_self        = 0x10000\n)\n\nfunc append_diff_line(y int) int {\n\tn := 0\n\tfor x := 0; x < front_buffer.width; {\n\t\tcell_offset := y*front_buffer.width + x\n\t\tback := &back_buffer.cells[cell_offset]\n\t\tfront := &front_buffer.cells[cell_offset]\n\t\tattr, char := cell_to_char_info(*back)\n\t\tcharbuf = append(charbuf, char_info{attr: attr, char: char[0]})\n\t\t*front = *back\n\t\tn++\n\t\tw := runewidth.RuneWidth(back.Ch)\n\t\tif w == 0 || w == 2 && runewidth.IsAmbiguousWidth(back.Ch) {\n\t\t\tw = 1\n\t\t}\n\t\tx += w\n\t\t// If not CJK, fill trailing space with whitespace\n\t\tif !is_cjk && w == 2 {\n\t\t\tcharbuf = append(charbuf, char_info{attr: attr, char: ' '})\n\t\t}\n\t}\n\treturn n\n}\n\n// compares 'back_buffer' with 'front_buffer' and prepares all changes in the form of\n// 'diff_msg's in the 'diff_buf'\nfunc prepare_diff_messages() {\n\t// clear buffers\n\tdiffbuf = diffbuf[:0]\n\tcharbuf = charbuf[:0]\n\n\tvar diff diff_msg\n\tgbeg := 0\n\tfor y := 0; y < front_buffer.height; y++ {\n\t\tsame := true\n\t\tline_offset := y * front_buffer.width\n\t\tfor x := 0; x < front_buffer.width; x++ {\n\t\t\tcell_offset := line_offset + x\n\t\t\tback := &back_buffer.cells[cell_offset]\n\t\t\tfront := &front_buffer.cells[cell_offset]\n\t\t\tif *back != *front {\n\t\t\t\tsame = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif same && diff.lines > 0 {\n\t\t\tdiffbuf = append(diffbuf, diff)\n\t\t\tdiff = diff_msg{}\n\t\t}\n\t\tif !same {\n\t\t\tbeg := len(charbuf)\n\t\t\tend := beg + append_diff_line(y)\n\t\t\tif diff.lines == 0 {\n\t\t\t\tdiff.pos = short(y)\n\t\t\t\tgbeg = beg\n\t\t\t}\n\t\t\tdiff.lines++\n\t\t\tdiff.chars = charbuf[gbeg:end]\n\t\t}\n\t}\n\tif diff.lines > 0 {\n\t\tdiffbuf = append(diffbuf, diff)\n\t\tdiff = diff_msg{}\n\t}\n}\n\nfunc get_ct(table []word, idx int) word {\n\tidx = idx & 0x0F\n\tif idx >= len(table) {\n\t\tidx = len(table) - 1\n\t}\n\treturn table[idx]\n}\n\nfunc cell_to_char_info(c Cell) (attr word, wc [2]wchar) {\n\tattr = get_ct(color_table_fg, int(c.Fg)) | get_ct(color_table_bg, int(c.Bg))\n\tif c.Fg&AttrReverse|c.Bg&AttrReverse != 0 {\n\t\tattr = (attr&0xF0)>>4 | (attr&0x0F)<<4\n\t}\n\tif c.Fg&AttrBold != 0 {\n\t\tattr |= foreground_intensity\n\t}\n\tif c.Bg&AttrBold != 0 {\n\t\tattr |= background_intensity\n\t}\n\n\tr0, r1 := utf16.EncodeRune(c.Ch)\n\tif r0 == 0xFFFD {\n\t\twc[0] = wchar(c.Ch)\n\t\twc[1] = ' '\n\t} else {\n\t\twc[0] = wchar(r0)\n\t\twc[1] = wchar(r1)\n\t}\n\treturn\n}\n\nfunc move_cursor(x, y int) {\n\terr := set_console_cursor_position(out, coord{short(x), short(y)})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc show_cursor(visible bool) {\n\tvar v int32\n\tif visible {\n\t\tv = 1\n\t}\n\n\tvar info console_cursor_info\n\tinfo.size = 100\n\tinfo.visible = v\n\terr := set_console_cursor_info(out, &info)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc clear() {\n\tvar err error\n\tattr, char := cell_to_char_info(Cell{\n\t\t' ',\n\t\tforeground,\n\t\tbackground,\n\t})\n\n\tarea := int(term_size.x) * int(term_size.y)\n\terr = fill_console_output_attribute(out, attr, area)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\terr = fill_console_output_character(out, char[0], area)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif !is_cursor_hidden(cursor_x, cursor_y) {\n\t\tmove_cursor(cursor_x, cursor_y)\n\t}\n}\n\nfunc key_event_record_to_event(r *key_event_record) (Event, bool) {\n\tif r.key_down == 0 {\n\t\treturn Event{}, false\n\t}\n\n\te := Event{Type: EventKey}\n\tif input_mode&InputAlt != 0 {\n\t\tif alt_mode_esc {\n\t\t\te.Mod = ModAlt\n\t\t\talt_mode_esc = false\n\t\t}\n\t\tif r.control_key_state&(left_alt_pressed|right_alt_pressed) != 0 {\n\t\t\te.Mod = ModAlt\n\t\t}\n\t}\n\n\tctrlpressed := r.control_key_state&(left_ctrl_pressed|right_ctrl_pressed) != 0\n\n\tif r.virtual_key_code >= vk_f1 && r.virtual_key_code <= vk_f12 {\n\t\tswitch r.virtual_key_code {\n\t\tcase vk_f1:\n\t\t\te.Key = KeyF1\n\t\tcase vk_f2:\n\t\t\te.Key = KeyF2\n\t\tcase vk_f3:\n\t\t\te.Key = KeyF3\n\t\tcase vk_f4:\n\t\t\te.Key = KeyF4\n\t\tcase vk_f5:\n\t\t\te.Key = KeyF5\n\t\tcase vk_f6:\n\t\t\te.Key = KeyF6\n\t\tcase vk_f7:\n\t\t\te.Key = KeyF7\n\t\tcase vk_f8:\n\t\t\te.Key = KeyF8\n\t\tcase vk_f9:\n\t\t\te.Key = KeyF9\n\t\tcase vk_f10:\n\t\t\te.Key = KeyF10\n\t\tcase vk_f11:\n\t\t\te.Key = KeyF11\n\t\tcase vk_f12:\n\t\t\te.Key = KeyF12\n\t\tdefault:\n\t\t\tpanic(\"unreachable\")\n\t\t}\n\n\t\treturn e, true\n\t}\n\n\tif r.virtual_key_code <= vk_delete {\n\t\tswitch r.virtual_key_code {\n\t\tcase vk_insert:\n\t\t\te.Key = KeyInsert\n\t\tcase vk_delete:\n\t\t\te.Key = KeyDelete\n\t\tcase vk_home:\n\t\t\te.Key = KeyHome\n\t\tcase vk_end:\n\t\t\te.Key = KeyEnd\n\t\tcase vk_pgup:\n\t\t\te.Key = KeyPgup\n\t\tcase vk_pgdn:\n\t\t\te.Key = KeyPgdn\n\t\tcase vk_arrow_up:\n\t\t\te.Key = KeyArrowUp\n\t\tcase vk_arrow_down:\n\t\t\te.Key = KeyArrowDown\n\t\tcase vk_arrow_left:\n\t\t\te.Key = KeyArrowLeft\n\t\tcase vk_arrow_right:\n\t\t\te.Key = KeyArrowRight\n\t\tcase vk_backspace:\n\t\t\tif ctrlpressed {\n\t\t\t\te.Key = KeyBackspace2\n\t\t\t} else {\n\t\t\t\te.Key = KeyBackspace\n\t\t\t}\n\t\tcase vk_tab:\n\t\t\te.Key = KeyTab\n\t\tcase vk_enter:\n\t\t\te.Key = KeyEnter\n\t\tcase vk_esc:\n\t\t\tswitch {\n\t\t\tcase input_mode&InputEsc != 0:\n\t\t\t\te.Key = KeyEsc\n\t\t\tcase input_mode&InputAlt != 0:\n\t\t\t\talt_mode_esc = true\n\t\t\t\treturn Event{}, false\n\t\t\t}\n\t\tcase vk_space:\n\t\t\tif ctrlpressed {\n\t\t\t\t// manual return here, because KeyCtrlSpace is zero\n\t\t\t\te.Key = KeyCtrlSpace\n\t\t\t\treturn e, true\n\t\t\t} else {\n\t\t\t\te.Key = KeySpace\n\t\t\t}\n\t\t}\n\n\t\tif e.Key != 0 {\n\t\t\treturn e, true\n\t\t}\n\t}\n\n\tif ctrlpressed {\n\t\tif Key(r.unicode_char) >= KeyCtrlA && Key(r.unicode_char) <= KeyCtrlRsqBracket {\n\t\t\te.Key = Key(r.unicode_char)\n\t\t\tif input_mode&InputAlt != 0 && e.Key == KeyEsc {\n\t\t\t\talt_mode_esc = true\n\t\t\t\treturn Event{}, false\n\t\t\t}\n\t\t\treturn e, true\n\t\t}\n\t\tswitch r.virtual_key_code {\n\t\tcase 192, 50:\n\t\t\t// manual return here, because KeyCtrl2 is zero\n\t\t\te.Key = KeyCtrl2\n\t\t\treturn e, true\n\t\tcase 51:\n\t\t\tif input_mode&InputAlt != 0 {\n\t\t\t\talt_mode_esc = true\n\t\t\t\treturn Event{}, false\n\t\t\t}\n\t\t\te.Key = KeyCtrl3\n\t\tcase 52:\n\t\t\te.Key = KeyCtrl4\n\t\tcase 53:\n\t\t\te.Key = KeyCtrl5\n\t\tcase 54:\n\t\t\te.Key = KeyCtrl6\n\t\tcase 189, 191, 55:\n\t\t\te.Key = KeyCtrl7\n\t\tcase 8, 56:\n\t\t\te.Key = KeyCtrl8\n\t\t}\n\n\t\tif e.Key != 0 {\n\t\t\treturn e, true\n\t\t}\n\t}\n\n\tif r.unicode_char != 0 {\n\t\te.Ch = rune(r.unicode_char)\n\t\treturn e, true\n\t}\n\n\treturn Event{}, false\n}\n\nfunc input_event_producer() {\n\tvar r input_record\n\tvar err error\n\tvar last_button Key\n\tvar last_button_pressed Key\n\tvar last_state = dword(0)\n\tvar last_x, last_y = -1, -1\n\thandles := []syscall.Handle{in, interrupt}\n\tfor {\n\t\terr = wait_for_multiple_objects(handles)\n\t\tif err != nil {\n\t\t\tinput_comm <- Event{Type: EventError, Err: err}\n\t\t}\n\n\t\tselect {\n\t\tcase <-cancel_comm:\n\t\t\tcancel_done_comm <- true\n\t\t\treturn\n\t\tdefault:\n\t\t}\n\n\t\terr = read_console_input(in, &r)\n\t\tif err != nil {\n\t\t\tinput_comm <- Event{Type: EventError, Err: err}\n\t\t}\n\n\t\tswitch r.event_type {\n\t\tcase key_event:\n\t\t\tkr := (*key_event_record)(unsafe.Pointer(&r.event))\n\t\t\tev, ok := key_event_record_to_event(kr)\n\t\t\tif ok {\n\t\t\t\tfor i := 0; i < int(kr.repeat_count); i++ {\n\t\t\t\t\tinput_comm <- ev\n\t\t\t\t}\n\t\t\t}\n\t\tcase window_buffer_size_event:\n\t\t\tsr := *(*window_buffer_size_record)(unsafe.Pointer(&r.event))\n\t\t\tinput_comm <- Event{\n\t\t\t\tType:   EventResize,\n\t\t\t\tWidth:  int(sr.size.x),\n\t\t\t\tHeight: int(sr.size.y),\n\t\t\t}\n\t\tcase mouse_event:\n\t\t\tmr := *(*mouse_event_record)(unsafe.Pointer(&r.event))\n\t\t\tev := Event{Type: EventMouse}\n\t\t\tswitch mr.event_flags {\n\t\t\tcase 0, 2:\n\t\t\t\t// single or double click\n\t\t\t\tcur_state := mr.button_state\n\t\t\t\tswitch {\n\t\t\t\tcase last_state&mouse_lmb == 0 && cur_state&mouse_lmb != 0:\n\t\t\t\t\tlast_button = MouseLeft\n\t\t\t\t\tlast_button_pressed = last_button\n\t\t\t\tcase last_state&mouse_rmb == 0 && cur_state&mouse_rmb != 0:\n\t\t\t\t\tlast_button = MouseRight\n\t\t\t\t\tlast_button_pressed = last_button\n\t\t\t\tcase last_state&mouse_mmb == 0 && cur_state&mouse_mmb != 0:\n\t\t\t\t\tlast_button = MouseMiddle\n\t\t\t\t\tlast_button_pressed = last_button\n\t\t\t\tcase last_state&mouse_lmb != 0 && cur_state&mouse_lmb == 0:\n\t\t\t\t\tlast_button = MouseRelease\n\t\t\t\tcase last_state&mouse_rmb != 0 && cur_state&mouse_rmb == 0:\n\t\t\t\t\tlast_button = MouseRelease\n\t\t\t\tcase last_state&mouse_mmb != 0 && cur_state&mouse_mmb == 0:\n\t\t\t\t\tlast_button = MouseRelease\n\t\t\t\tdefault:\n\t\t\t\t\tlast_state = cur_state\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tlast_state = cur_state\n\t\t\t\tev.Key = last_button\n\t\t\t\tlast_x, last_y = int(mr.mouse_pos.x), int(mr.mouse_pos.y)\n\t\t\t\tev.MouseX = last_x\n\t\t\t\tev.MouseY = last_y\n\t\t\tcase 1:\n\t\t\t\t// mouse motion\n\t\t\t\tx, y := int(mr.mouse_pos.x), int(mr.mouse_pos.y)\n\t\t\t\tif last_state != 0 && (last_x != x || last_y != y) {\n\t\t\t\t\tev.Key = last_button_pressed\n\t\t\t\t\tev.Mod = ModMotion\n\t\t\t\t\tev.MouseX = x\n\t\t\t\t\tev.MouseY = y\n\t\t\t\t\tlast_x, last_y = x, y\n\t\t\t\t} else {\n\t\t\t\t\tev.Type = EventNone\n\t\t\t\t}\n\t\t\tcase 4:\n\t\t\t\t// mouse wheel\n\t\t\t\tn := int16(mr.button_state >> 16)\n\t\t\t\tif n > 0 {\n\t\t\t\t\tev.Key = MouseWheelUp\n\t\t\t\t} else {\n\t\t\t\t\tev.Key = MouseWheelDown\n\t\t\t\t}\n\t\t\t\tlast_x, last_y = int(mr.mouse_pos.x), int(mr.mouse_pos.y)\n\t\t\t\tev.MouseX = last_x\n\t\t\t\tev.MouseY = last_y\n\t\t\tdefault:\n\t\t\t\tev.Type = EventNone\n\t\t\t}\n\t\t\tif ev.Type != EventNone {\n\t\t\t\tinput_comm <- ev\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/terminfo.go",
    "content": "// +build !windows\n// This file contains a simple and incomplete implementation of the terminfo\n// database. Information was taken from the ncurses manpages term(5) and\n// terminfo(5). Currently, only the string capabilities for special keys and for\n// functions without parameters are actually used. Colors are still done with\n// ANSI escape sequences. Other special features that are not (yet?) supported\n// are reading from ~/.terminfo, the TERMINFO_DIRS variable, Berkeley database\n// format and extended capabilities.\n\npackage termbox\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"encoding/hex\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"strings\"\n)\n\nconst (\n\tti_magic         = 0432\n\tti_header_length = 12\n\tti_mouse_enter   = \"\\x1b[?1000h\\x1b[?1002h\\x1b[?1015h\\x1b[?1006h\"\n\tti_mouse_leave   = \"\\x1b[?1006l\\x1b[?1015l\\x1b[?1002l\\x1b[?1000l\"\n)\n\nfunc load_terminfo() ([]byte, error) {\n\tvar data []byte\n\tvar err error\n\n\tterm := os.Getenv(\"TERM\")\n\tif term == \"\" {\n\t\treturn nil, fmt.Errorf(\"termbox: TERM not set\")\n\t}\n\n\t// The following behaviour follows the one described in terminfo(5) as\n\t// distributed by ncurses.\n\n\tterminfo := os.Getenv(\"TERMINFO\")\n\tif terminfo != \"\" {\n\t\t// if TERMINFO is set, no other directory should be searched\n\t\treturn ti_try_path(terminfo)\n\t}\n\n\t// next, consider ~/.terminfo\n\thome := os.Getenv(\"HOME\")\n\tif home != \"\" {\n\t\tdata, err = ti_try_path(home + \"/.terminfo\")\n\t\tif err == nil {\n\t\t\treturn data, nil\n\t\t}\n\t}\n\n\t// next, TERMINFO_DIRS\n\tdirs := os.Getenv(\"TERMINFO_DIRS\")\n\tif dirs != \"\" {\n\t\tfor _, dir := range strings.Split(dirs, \":\") {\n\t\t\tif dir == \"\" {\n\t\t\t\t// \"\" -> \"/usr/share/terminfo\"\n\t\t\t\tdir = \"/usr/share/terminfo\"\n\t\t\t}\n\t\t\tdata, err = ti_try_path(dir)\n\t\t\tif err == nil {\n\t\t\t\treturn data, nil\n\t\t\t}\n\t\t}\n\t}\n\n\t// fall back to /usr/share/terminfo\n\treturn ti_try_path(\"/usr/share/terminfo\")\n}\n\nfunc ti_try_path(path string) (data []byte, err error) {\n\t// load_terminfo already made sure it is set\n\tterm := os.Getenv(\"TERM\")\n\n\t// first try, the typical *nix path\n\tterminfo := path + \"/\" + term[0:1] + \"/\" + term\n\tdata, err = ioutil.ReadFile(terminfo)\n\tif err == nil {\n\t\treturn\n\t}\n\n\t// fallback to darwin specific dirs structure\n\tterminfo = path + \"/\" + hex.EncodeToString([]byte(term[:1])) + \"/\" + term\n\tdata, err = ioutil.ReadFile(terminfo)\n\treturn\n}\n\nfunc setup_term_builtin() error {\n\tname := os.Getenv(\"TERM\")\n\tif name == \"\" {\n\t\treturn errors.New(\"termbox: TERM environment variable not set\")\n\t}\n\n\tfor _, t := range terms {\n\t\tif t.name == name {\n\t\t\tkeys = t.keys\n\t\t\tfuncs = t.funcs\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tcompat_table := []struct {\n\t\tpartial string\n\t\tkeys    []string\n\t\tfuncs   []string\n\t}{\n\t\t{\"xterm\", xterm_keys, xterm_funcs},\n\t\t{\"rxvt\", rxvt_unicode_keys, rxvt_unicode_funcs},\n\t\t{\"linux\", linux_keys, linux_funcs},\n\t\t{\"Eterm\", eterm_keys, eterm_funcs},\n\t\t{\"screen\", screen_keys, screen_funcs},\n\t\t// let's assume that 'cygwin' is xterm compatible\n\t\t{\"cygwin\", xterm_keys, xterm_funcs},\n\t\t{\"st\", xterm_keys, xterm_funcs},\n\t}\n\n\t// try compatibility variants\n\tfor _, it := range compat_table {\n\t\tif strings.Contains(name, it.partial) {\n\t\t\tkeys = it.keys\n\t\t\tfuncs = it.funcs\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn errors.New(\"termbox: unsupported terminal\")\n}\n\nfunc setup_term() (err error) {\n\tvar data []byte\n\tvar header [6]int16\n\tvar str_offset, table_offset int16\n\n\tdata, err = load_terminfo()\n\tif err != nil {\n\t\treturn setup_term_builtin()\n\t}\n\n\trd := bytes.NewReader(data)\n\t// 0: magic number, 1: size of names section, 2: size of boolean section, 3:\n\t// size of numbers section (in integers), 4: size of the strings section (in\n\t// integers), 5: size of the string table\n\n\terr = binary.Read(rd, binary.LittleEndian, header[:])\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif (header[1]+header[2])%2 != 0 {\n\t\t// old quirk to align everything on word boundaries\n\t\theader[2] += 1\n\t}\n\tstr_offset = ti_header_length + header[1] + header[2] + 2*header[3]\n\ttable_offset = str_offset + 2*header[4]\n\n\tkeys = make([]string, 0xFFFF-key_min)\n\tfor i, _ := range keys {\n\t\tkeys[i], err = ti_read_string(rd, str_offset+2*ti_keys[i], table_offset)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\tfuncs = make([]string, t_max_funcs)\n\t// the last two entries are reserved for mouse. because the table offset is\n\t// not there, the two entries have to fill in manually\n\tfor i, _ := range funcs[:len(funcs)-2] {\n\t\tfuncs[i], err = ti_read_string(rd, str_offset+2*ti_funcs[i], table_offset)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\tfuncs[t_max_funcs-2] = ti_mouse_enter\n\tfuncs[t_max_funcs-1] = ti_mouse_leave\n\treturn nil\n}\n\nfunc ti_read_string(rd *bytes.Reader, str_off, table int16) (string, error) {\n\tvar off int16\n\n\t_, err := rd.Seek(int64(str_off), 0)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\terr = binary.Read(rd, binary.LittleEndian, &off)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\t_, err = rd.Seek(int64(table+off), 0)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tvar bs []byte\n\tfor {\n\t\tb, err := rd.ReadByte()\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif b == byte(0x00) {\n\t\t\tbreak\n\t\t}\n\t\tbs = append(bs, b)\n\t}\n\treturn string(bs), nil\n}\n\n// \"Maps\" the function constants from termbox.go to the number of the respective\n// string capability in the terminfo file. Taken from (ncurses) term.h.\nvar ti_funcs = []int16{\n\t28, 40, 16, 13, 5, 39, 36, 27, 26, 34, 89, 88,\n}\n\n// Same as above for the special keys.\nvar ti_keys = []int16{\n\t66, 68 /* apparently not a typo; 67 is F10 for whatever reason */, 69, 70,\n\t71, 72, 73, 74, 75, 67, 216, 217, 77, 59, 76, 164, 82, 81, 87, 61, 79, 83,\n}\n"
  },
  {
    "path": "vendor/github.com/nsf/termbox-go/terminfo_builtin.go",
    "content": "// +build !windows\n\npackage termbox\n\n// Eterm\nvar eterm_keys = []string{\n\t\"\\x1b[11~\", \"\\x1b[12~\", \"\\x1b[13~\", \"\\x1b[14~\", \"\\x1b[15~\", \"\\x1b[17~\", \"\\x1b[18~\", \"\\x1b[19~\", \"\\x1b[20~\", \"\\x1b[21~\", \"\\x1b[23~\", \"\\x1b[24~\", \"\\x1b[2~\", \"\\x1b[3~\", \"\\x1b[7~\", \"\\x1b[8~\", \"\\x1b[5~\", \"\\x1b[6~\", \"\\x1b[A\", \"\\x1b[B\", \"\\x1b[D\", \"\\x1b[C\",\n}\nvar eterm_funcs = []string{\n\t\"\\x1b7\\x1b[?47h\", \"\\x1b[2J\\x1b[?47l\\x1b8\", \"\\x1b[?25h\", \"\\x1b[?25l\", \"\\x1b[H\\x1b[2J\", \"\\x1b[m\\x0f\", \"\\x1b[4m\", \"\\x1b[1m\", \"\\x1b[5m\", \"\\x1b[7m\", \"\", \"\", \"\", \"\",\n}\n\n// screen\nvar screen_keys = []string{\n\t\"\\x1bOP\", \"\\x1bOQ\", \"\\x1bOR\", \"\\x1bOS\", \"\\x1b[15~\", \"\\x1b[17~\", \"\\x1b[18~\", \"\\x1b[19~\", \"\\x1b[20~\", \"\\x1b[21~\", \"\\x1b[23~\", \"\\x1b[24~\", \"\\x1b[2~\", \"\\x1b[3~\", \"\\x1b[1~\", \"\\x1b[4~\", \"\\x1b[5~\", \"\\x1b[6~\", \"\\x1bOA\", \"\\x1bOB\", \"\\x1bOD\", \"\\x1bOC\",\n}\nvar screen_funcs = []string{\n\t\"\\x1b[?1049h\", \"\\x1b[?1049l\", \"\\x1b[34h\\x1b[?25h\", \"\\x1b[?25l\", \"\\x1b[H\\x1b[J\", \"\\x1b[m\\x0f\", \"\\x1b[4m\", \"\\x1b[1m\", \"\\x1b[5m\", \"\\x1b[7m\", \"\\x1b[?1h\\x1b=\", \"\\x1b[?1l\\x1b>\", ti_mouse_enter, ti_mouse_leave,\n}\n\n// xterm\nvar xterm_keys = []string{\n\t\"\\x1bOP\", \"\\x1bOQ\", \"\\x1bOR\", \"\\x1bOS\", \"\\x1b[15~\", \"\\x1b[17~\", \"\\x1b[18~\", \"\\x1b[19~\", \"\\x1b[20~\", \"\\x1b[21~\", \"\\x1b[23~\", \"\\x1b[24~\", \"\\x1b[2~\", \"\\x1b[3~\", \"\\x1bOH\", \"\\x1bOF\", \"\\x1b[5~\", \"\\x1b[6~\", \"\\x1bOA\", \"\\x1bOB\", \"\\x1bOD\", \"\\x1bOC\",\n}\nvar xterm_funcs = []string{\n\t\"\\x1b[?1049h\", \"\\x1b[?1049l\", \"\\x1b[?12l\\x1b[?25h\", \"\\x1b[?25l\", \"\\x1b[H\\x1b[2J\", \"\\x1b(B\\x1b[m\", \"\\x1b[4m\", \"\\x1b[1m\", \"\\x1b[5m\", \"\\x1b[7m\", \"\\x1b[?1h\\x1b=\", \"\\x1b[?1l\\x1b>\", ti_mouse_enter, ti_mouse_leave,\n}\n\n// rxvt-unicode\nvar rxvt_unicode_keys = []string{\n\t\"\\x1b[11~\", \"\\x1b[12~\", \"\\x1b[13~\", \"\\x1b[14~\", \"\\x1b[15~\", \"\\x1b[17~\", \"\\x1b[18~\", \"\\x1b[19~\", \"\\x1b[20~\", \"\\x1b[21~\", \"\\x1b[23~\", \"\\x1b[24~\", \"\\x1b[2~\", \"\\x1b[3~\", \"\\x1b[7~\", \"\\x1b[8~\", \"\\x1b[5~\", \"\\x1b[6~\", \"\\x1b[A\", \"\\x1b[B\", \"\\x1b[D\", \"\\x1b[C\",\n}\nvar rxvt_unicode_funcs = []string{\n\t\"\\x1b[?1049h\", \"\\x1b[r\\x1b[?1049l\", \"\\x1b[?25h\", \"\\x1b[?25l\", \"\\x1b[H\\x1b[2J\", \"\\x1b[m\\x1b(B\", \"\\x1b[4m\", \"\\x1b[1m\", \"\\x1b[5m\", \"\\x1b[7m\", \"\\x1b=\", \"\\x1b>\", ti_mouse_enter, ti_mouse_leave,\n}\n\n// linux\nvar linux_keys = []string{\n\t\"\\x1b[[A\", \"\\x1b[[B\", \"\\x1b[[C\", \"\\x1b[[D\", \"\\x1b[[E\", \"\\x1b[17~\", \"\\x1b[18~\", \"\\x1b[19~\", \"\\x1b[20~\", \"\\x1b[21~\", \"\\x1b[23~\", \"\\x1b[24~\", \"\\x1b[2~\", \"\\x1b[3~\", \"\\x1b[1~\", \"\\x1b[4~\", \"\\x1b[5~\", \"\\x1b[6~\", \"\\x1b[A\", \"\\x1b[B\", \"\\x1b[D\", \"\\x1b[C\",\n}\nvar linux_funcs = []string{\n\t\"\", \"\", \"\\x1b[?25h\\x1b[?0c\", \"\\x1b[?25l\\x1b[?1c\", \"\\x1b[H\\x1b[J\", \"\\x1b[0;10m\", \"\\x1b[4m\", \"\\x1b[1m\", \"\\x1b[5m\", \"\\x1b[7m\", \"\", \"\", \"\", \"\",\n}\n\n// rxvt-256color\nvar rxvt_256color_keys = []string{\n\t\"\\x1b[11~\", \"\\x1b[12~\", \"\\x1b[13~\", \"\\x1b[14~\", \"\\x1b[15~\", \"\\x1b[17~\", \"\\x1b[18~\", \"\\x1b[19~\", \"\\x1b[20~\", \"\\x1b[21~\", \"\\x1b[23~\", \"\\x1b[24~\", \"\\x1b[2~\", \"\\x1b[3~\", \"\\x1b[7~\", \"\\x1b[8~\", \"\\x1b[5~\", \"\\x1b[6~\", \"\\x1b[A\", \"\\x1b[B\", \"\\x1b[D\", \"\\x1b[C\",\n}\nvar rxvt_256color_funcs = []string{\n\t\"\\x1b7\\x1b[?47h\", \"\\x1b[2J\\x1b[?47l\\x1b8\", \"\\x1b[?25h\", \"\\x1b[?25l\", \"\\x1b[H\\x1b[2J\", \"\\x1b[m\\x0f\", \"\\x1b[4m\", \"\\x1b[1m\", \"\\x1b[5m\", \"\\x1b[7m\", \"\\x1b=\", \"\\x1b>\", ti_mouse_enter, ti_mouse_leave,\n}\n\nvar terms = []struct {\n\tname  string\n\tkeys  []string\n\tfuncs []string\n}{\n\t{\"Eterm\", eterm_keys, eterm_funcs},\n\t{\"screen\", screen_keys, screen_funcs},\n\t{\"xterm\", xterm_keys, xterm_funcs},\n\t{\"rxvt-unicode\", rxvt_unicode_keys, rxvt_unicode_funcs},\n\t{\"linux\", linux_keys, linux_funcs},\n\t{\"rxvt-256color\", rxvt_256color_keys, rxvt_256color_funcs},\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/.gitignore",
    "content": "# Compiled Object files, Static and Dynamic libs (Shared Objects)\n*.o\n*.a\n*.so\n\n# Folders\n_obj\n_test\n\n# Architecture specific extensions/prefixes\n*.[568vq]\n[568vq].out\n\n*.cgo1.go\n*.cgo2.c\n_cgo_defun.c\n_cgo_gotypes.go\n_cgo_export.*\n\n_testmain.go\n\n# Vim files https://github.com/github/gitignore/blob/master/Global/Vim.gitignore\n# swap\n[._]*.s[a-w][a-z]\n[._]s[a-w][a-z]\n# session\nSession.vim\n# temporary\n.netrwhist\n*~\n# auto-generated tag files\ntags\n\n*.exe\n\ncobra.test\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/.mailmap",
    "content": "Steve Francia <steve.francia@gmail.com>\nBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>\nFabiano Franz <ffranz@redhat.com>                   <contact@fabianofranz.com>\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/.travis.yml",
    "content": "language: go\n\nmatrix:\n  include:\n    - go: 1.7.6\n    - go: 1.8.3\n    - go: tip\n  allow_failures:\n    - go: tip\n\nbefore_install:\n  - mkdir -p bin\n  - curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.3/shellcheck\n  - chmod +x bin/shellcheck\nscript:\n  - PATH=$PATH:$PWD/bin go test -v ./...\n  - go build\n  - diff -u <(echo -n) <(gofmt -d -s .)\n  - if [ -z $NOVET ]; then\n      diff -u <(echo -n) <(go tool vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint');\n    fi\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/LICENSE.txt",
    "content": "                                Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/README.md",
    "content": "![cobra logo](https://cloud.githubusercontent.com/assets/173412/10886352/ad566232-814f-11e5-9cd0-aa101788c117.png)\n\nCobra is both a library for creating powerful modern CLI applications as well as a program to generate applications and command files.\n\nMany of the most widely used Go projects are built using Cobra including:\n\n* [Kubernetes](http://kubernetes.io/)\n* [Hugo](http://gohugo.io)\n* [rkt](https://github.com/coreos/rkt)\n* [etcd](https://github.com/coreos/etcd)\n* [Moby (former Docker)](https://github.com/moby/moby)\n* [Docker (distribution)](https://github.com/docker/distribution)\n* [OpenShift](https://www.openshift.com/)\n* [Delve](https://github.com/derekparker/delve)\n* [GopherJS](http://www.gopherjs.org/)\n* [CockroachDB](http://www.cockroachlabs.com/)\n* [Bleve](http://www.blevesearch.com/)\n* [ProjectAtomic (enterprise)](http://www.projectatomic.io/)\n* [GiantSwarm's swarm](https://github.com/giantswarm/cli)\n* [Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack)\n* [rclone](http://rclone.org/)\n* [nehm](https://github.com/bogem/nehm)\n* [Pouch](https://github.com/alibaba/pouch)\n\n[![Build Status](https://travis-ci.org/spf13/cobra.svg \"Travis CI status\")](https://travis-ci.org/spf13/cobra)\n[![CircleCI status](https://circleci.com/gh/spf13/cobra.png?circle-token=:circle-token \"CircleCI status\")](https://circleci.com/gh/spf13/cobra)\n[![GoDoc](https://godoc.org/github.com/spf13/cobra?status.svg)](https://godoc.org/github.com/spf13/cobra)\n\n# Table of Contents\n\n- [Overview](#overview)\n- [Concepts](#concepts)\n  * [Commands](#commands)\n  * [Flags](#flags)\n- [Installing](#installing)\n- [Getting Started](#getting-started)\n  * [Using the Cobra Generator](#using-the-cobra-generator)\n  * [Using the Cobra Library](#using-the-cobra-library)\n  * [Working with Flags](#working-with-flags)\n  * [Positional and Custom Arguments](#positional-and-custom-arguments)\n  * [Example](#example)\n  * [Help Command](#help-command)\n  * [Usage Message](#usage-message)\n  * [PreRun and PostRun Hooks](#prerun-and-postrun-hooks)\n  * [Suggestions when \"unknown command\" happens](#suggestions-when-unknown-command-happens)\n  * [Generating documentation for your command](#generating-documentation-for-your-command)\n  * [Generating bash completions](#generating-bash-completions)\n- [Contributing](#contributing)\n- [License](#license)\n\n# Overview\n\nCobra is a library providing a simple interface to create powerful modern CLI\ninterfaces similar to git & go tools.\n\nCobra is also an application that will generate your application scaffolding to rapidly\ndevelop a Cobra-based application.\n\nCobra provides:\n* Easy subcommand-based CLIs: `app server`, `app fetch`, etc.\n* Fully POSIX-compliant flags (including short & long versions)\n* Nested subcommands\n* Global, local and cascading flags\n* Easy generation of applications & commands with `cobra init appname` & `cobra add cmdname`\n* Intelligent suggestions (`app srver`... did you mean `app server`?)\n* Automatic help generation for commands and flags\n* Automatic help flag recognition of `-h`, `--help`, etc.\n* Automatically generated bash autocomplete for your application\n* Automatically generated man pages for your application\n* Command aliases so you can change things without breaking them\n* The flexibility to define your own help, usage, etc.\n* Optional tight integration with [viper](http://github.com/spf13/viper) for 12-factor apps\n\n# Concepts\n\nCobra is built on a structure of commands, arguments & flags.\n\n**Commands** represent actions, **Args** are things and **Flags** are modifiers for those actions.\n\nThe best applications will read like sentences when used. Users will know how\nto use the application because they will natively understand how to use it.\n\nThe pattern to follow is\n`APPNAME VERB NOUN --ADJECTIVE.`\n    or\n`APPNAME COMMAND ARG --FLAG`\n\nA few good real world examples may better illustrate this point.\n\nIn the following example, 'server' is a command, and 'port' is a flag:\n\n    hugo server --port=1313\n\nIn this command we are telling Git to clone the url bare.\n\n    git clone URL --bare\n\n## Commands\n\nCommand is the central point of the application. Each interaction that\nthe application supports will be contained in a Command. A command can\nhave children commands and optionally run an action.\n\nIn the example above, 'server' is the command.\n\n[More about cobra.Command](https://godoc.org/github.com/spf13/cobra#Command)\n\n## Flags\n\nA flag is a way to modify the behavior of a command. Cobra supports\nfully POSIX-compliant flags as well as the Go [flag package](https://golang.org/pkg/flag/).\nA Cobra command can define flags that persist through to children commands\nand flags that are only available to that command.\n\nIn the example above, 'port' is the flag.\n\nFlag functionality is provided by the [pflag\nlibrary](https://github.com/spf13/pflag), a fork of the flag standard library\nwhich maintains the same interface while adding POSIX compliance.\n\n# Installing\nUsing Cobra is easy. First, use `go get` to install the latest version\nof the library. This command will install the `cobra` generator executable\nalong with the library and its dependencies:\n\n    go get -u github.com/spf13/cobra/cobra\n\nNext, include Cobra in your application:\n\n```go\nimport \"github.com/spf13/cobra\"\n```\n\n# Getting Started\n\nWhile you are welcome to provide your own organization, typically a Cobra-based\napplication will follow the following organizational structure:\n\n```\n  ▾ appName/\n    ▾ cmd/\n        add.go\n        your.go\n        commands.go\n        here.go\n      main.go\n```\n\nIn a Cobra app, typically the main.go file is very bare. It serves one purpose: initializing Cobra.\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"os\"\n\n  \"{pathToYourApp}/cmd\"\n)\n\nfunc main() {\n  cmd.Execute()\n}\n```\n\n## Using the Cobra Generator\n\nCobra provides its own program that will create your application and add any\ncommands you want. It's the easiest way to incorporate Cobra into your application.\n\n[Here](https://github.com/spf13/cobra/blob/master/cobra/README.md) you can find more information about it.\n\n## Using the Cobra Library\n\nTo manually implement Cobra you need to create a bare main.go file and a rootCmd file.\nYou will optionally provide additional commands as you see fit.\n\n### Create rootCmd\n\nCobra doesn't require any special constructors. Simply create your commands.\n\nIdeally you place this in app/cmd/root.go:\n\n```go\nvar rootCmd = &cobra.Command{\n  Use:   \"hugo\",\n  Short: \"Hugo is a very fast static site generator\",\n  Long: `A Fast and Flexible Static Site Generator built with\n                love by spf13 and friends in Go.\n                Complete documentation is available at http://hugo.spf13.com`,\n  Run: func(cmd *cobra.Command, args []string) {\n    // Do Stuff Here\n  },\n}\n```\n\nYou will additionally define flags and handle configuration in your init() function.\n\nFor example cmd/root.go:\n\n```go\nimport (\n  \"fmt\"\n  \"os\"\n\n  homedir \"github.com/mitchellh/go-homedir\"\n  \"github.com/spf13/cobra\"\n  \"github.com/spf13/viper\"\n)\n\nfunc init() {\n  cobra.OnInitialize(initConfig)\n  rootCmd.PersistentFlags().StringVar(&cfgFile, \"config\", \"\", \"config file (default is $HOME/.cobra.yaml)\")\n  rootCmd.PersistentFlags().StringVarP(&projectBase, \"projectbase\", \"b\", \"\", \"base project directory eg. github.com/spf13/\")\n  rootCmd.PersistentFlags().StringP(\"author\", \"a\", \"YOUR NAME\", \"Author name for copyright attribution\")\n  rootCmd.PersistentFlags().StringVarP(&userLicense, \"license\", \"l\", \"\", \"Name of license for the project (can provide `licensetext` in config)\")\n  rootCmd.PersistentFlags().Bool(\"viper\", true, \"Use Viper for configuration\")\n  viper.BindPFlag(\"author\", rootCmd.PersistentFlags().Lookup(\"author\"))\n  viper.BindPFlag(\"projectbase\", rootCmd.PersistentFlags().Lookup(\"projectbase\"))\n  viper.BindPFlag(\"useViper\", rootCmd.PersistentFlags().Lookup(\"viper\"))\n  viper.SetDefault(\"author\", \"NAME HERE <EMAIL ADDRESS>\")\n  viper.SetDefault(\"license\", \"apache\")\n}\n\nfunc initConfig() {\n  // Don't forget to read config either from cfgFile or from home directory!\n  if cfgFile != \"\" {\n    // Use config file from the flag.\n    viper.SetConfigFile(cfgFile)\n  } else {\n    // Find home directory.\n    home, err := homedir.Dir()\n    if err != nil {\n      fmt.Println(err)\n      os.Exit(1)\n    }\n\n    // Search config in home directory with name \".cobra\" (without extension).\n    viper.AddConfigPath(home)\n    viper.SetConfigName(\".cobra\")\n  }\n\n  if err := viper.ReadInConfig(); err != nil {\n    fmt.Println(\"Can't read config:\", err)\n    os.Exit(1)\n  }\n}\n```\n\n### Create your main.go\n\nWith the root command you need to have your main function execute it.\nExecute should be run on the root for clarity, though it can be called on any command.\n\nIn a Cobra app, typically the main.go file is very bare. It serves, one purpose, to initialize Cobra.\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"os\"\n\n  \"{pathToYourApp}/cmd\"\n)\n\nfunc main() {\n  cmd.Execute()\n}\n```\n\n### Create additional commands\n\nAdditional commands can be defined and typically are each given their own file\ninside of the cmd/ directory.\n\nIf you wanted to create a version command you would create cmd/version.go and\npopulate it with the following:\n\n```go\npackage cmd\n\nimport (\n  \"fmt\"\n\n  \"github.com/spf13/cobra\"\n)\n\nfunc init() {\n  rootCmd.AddCommand(versionCmd)\n}\n\nvar versionCmd = &cobra.Command{\n  Use:   \"version\",\n  Short: \"Print the version number of Hugo\",\n  Long:  `All software has versions. This is Hugo's`,\n  Run: func(cmd *cobra.Command, args []string) {\n    fmt.Println(\"Hugo Static Site Generator v0.9 -- HEAD\")\n  },\n}\n```\n\n## Working with Flags\n\nFlags provide modifiers to control how the action command operates.\n\n### Assign flags to a command\n\nSince the flags are defined and used in different locations, we need to\ndefine a variable outside with the correct scope to assign the flag to\nwork with.\n\n```go\nvar Verbose bool\nvar Source string\n```\n\nThere are two different approaches to assign a flag.\n\n### Persistent Flags\n\nA flag can be 'persistent' meaning that this flag will be available to the\ncommand it's assigned to as well as every command under that command. For\nglobal flags, assign a flag as a persistent flag on the root.\n\n```go\nrootCmd.PersistentFlags().BoolVarP(&Verbose, \"verbose\", \"v\", false, \"verbose output\")\n```\n\n### Local Flags\n\nA flag can also be assigned locally which will only apply to that specific command.\n\n```go\nrootCmd.Flags().StringVarP(&Source, \"source\", \"s\", \"\", \"Source directory to read from\")\n```\n\n### Local Flag on Parent Commands\n\nBy default Cobra only parses local flags on the target command, any local flags on \nparent commands are ignored. By enabling `Command.TraverseChildren` Cobra will \nparse local flags on each command before executing the target command.\n\n```go\ncommand := cobra.Command{\n  Use: \"print [OPTIONS] [COMMANDS]\",\n  TraverseChildren: true,\n}\n```\n\n### Bind Flags with Config\n\nYou can also bind your flags with [viper](https://github.com/spf13/viper):\n```go\nvar author string\n\nfunc init() {\n  rootCmd.PersistentFlags().StringVar(&author, \"author\", \"YOUR NAME\", \"Author name for copyright attribution\")\n  viper.BindPFlag(\"author\", rootCmd.PersistentFlags().Lookup(\"author\"))\n}\n```\n\nIn this example the persistent flag `author` is bound with `viper`.\n**Note**, that the variable `author` will not be set to the value from config,\nwhen the `--author` flag is not provided by user.\n\nMore in [viper documentation](https://github.com/spf13/viper#working-with-flags).\n\n## Positional and Custom Arguments\n\nValidation of positional arguments can be specified using the `Args` field\nof `Command`.\n\nThe following validators are built in:\n\n- `NoArgs` - the command will report an error if there are any positional args.\n- `ArbitraryArgs` - the command will accept any args.\n- `OnlyValidArgs` - the command will report an error if there are any positional args that are not in the `ValidArgs` field of `Command`.\n- `MinimumNArgs(int)` - the command will report an error if there are not at least N positional args.\n- `MaximumNArgs(int)` - the command will report an error if there are more than N positional args.\n- `ExactArgs(int)` - the command will report an error if there are not exactly N positional args.\n- `RangeArgs(min, max)` - the command will report an error if the number of args is not between the minimum and maximum number of expected args.\n\nAn example of setting the custom validator:\n\n```go\nvar cmd = &cobra.Command{\n  Short: \"hello\",\n  Args: func(cmd *cobra.Command, args []string) error {\n    if len(args) < 1 {\n      return errors.New(\"requires at least one arg\")\n    }\n    if myapp.IsValidColor(args[0]) {\n      return nil\n    }\n    return fmt.Errorf(\"invalid color specified: %s\", args[0])\n  },\n  Run: func(cmd *cobra.Command, args []string) {\n    fmt.Println(\"Hello, World!\")\n  },\n}\n```\n\n## Example\n\nIn the example below, we have defined three commands. Two are at the top level\nand one (cmdTimes) is a child of one of the top commands. In this case the root\nis not executable meaning that a subcommand is required. This is accomplished\nby not providing a 'Run' for the 'rootCmd'.\n\nWe have only defined one flag for a single command.\n\nMore documentation about flags is available at https://github.com/spf13/pflag\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"strings\"\n\n  \"github.com/spf13/cobra\"\n)\n\nfunc main() {\n  var echoTimes int\n\n  var cmdPrint = &cobra.Command{\n    Use:   \"print [string to print]\",\n    Short: \"Print anything to the screen\",\n    Long: `print is for printing anything back to the screen.\nFor many years people have printed back to the screen.`,\n    Args: cobra.MinimumNArgs(1),\n    Run: func(cmd *cobra.Command, args []string) {\n      fmt.Println(\"Print: \" + strings.Join(args, \" \"))\n    },\n  }\n\n  var cmdEcho = &cobra.Command{\n    Use:   \"echo [string to echo]\",\n    Short: \"Echo anything to the screen\",\n    Long: `echo is for echoing anything back.\nEcho works a lot like print, except it has a child command.`,\n    Args: cobra.MinimumNArgs(1),\n    Run: func(cmd *cobra.Command, args []string) {\n      fmt.Println(\"Print: \" + strings.Join(args, \" \"))\n    },\n  }\n\n  var cmdTimes = &cobra.Command{\n    Use:   \"times [# times] [string to echo]\",\n    Short: \"Echo anything to the screen more times\",\n    Long: `echo things multiple times back to the user by providing\na count and a string.`,\n    Args: cobra.MinimumNArgs(1),\n    Run: func(cmd *cobra.Command, args []string) {\n      for i := 0; i < echoTimes; i++ {\n        fmt.Println(\"Echo: \" + strings.Join(args, \" \"))\n      }\n    },\n  }\n\n  cmdTimes.Flags().IntVarP(&echoTimes, \"times\", \"t\", 1, \"times to echo the input\")\n\n  var rootCmd = &cobra.Command{Use: \"app\"}\n  rootCmd.AddCommand(cmdPrint, cmdEcho)\n  cmdEcho.AddCommand(cmdTimes)\n  rootCmd.Execute()\n}\n```\n\nFor a more complete example of a larger application, please checkout [Hugo](http://gohugo.io/).\n\n## Help Command\n\nCobra automatically adds a help command to your application when you have subcommands.\nThis will be called when a user runs 'app help'. Additionally, help will also\nsupport all other commands as input. Say, for instance, you have a command called\n'create' without any additional configuration; Cobra will work when 'app help\ncreate' is called.  Every command will automatically have the '--help' flag added.\n\n### Example\n\nThe following output is automatically generated by Cobra. Nothing beyond the\ncommand and flag definitions are needed.\n\n    $ cobra help\n\n    Cobra is a CLI library for Go that empowers applications.\n    This application is a tool to generate the needed files\n    to quickly create a Cobra application.\n\n    Usage:\n      cobra [command]\n\n    Available Commands:\n      add         Add a command to a Cobra Application\n      help        Help about any command\n      init        Initialize a Cobra Application\n\n    Flags:\n      -a, --author string    author name for copyright attribution (default \"YOUR NAME\")\n          --config string    config file (default is $HOME/.cobra.yaml)\n      -h, --help             help for cobra\n      -l, --license string   name of license for the project\n          --viper            use Viper for configuration (default true)\n\n    Use \"cobra [command] --help\" for more information about a command.\n\n\nHelp is just a command like any other. There is no special logic or behavior\naround it. In fact, you can provide your own if you want.\n\n### Defining your own help\n\nYou can provide your own Help command or your own template for the default command to use\nwith following functions:\n\n```go\ncmd.SetHelpCommand(cmd *Command)\ncmd.SetHelpFunc(f func(*Command, []string))\ncmd.SetHelpTemplate(s string)\n```\n\nThe latter two will also apply to any children commands.\n\n## Usage Message\n\nWhen the user provides an invalid flag or invalid command, Cobra responds by\nshowing the user the 'usage'.\n\n### Example\nYou may recognize this from the help above. That's because the default help\nembeds the usage as part of its output.\n\n    $ cobra --invalid\n    Error: unknown flag: --invalid\n    Usage:\n      cobra [command]\n\n    Available Commands:\n      add         Add a command to a Cobra Application\n      help        Help about any command\n      init        Initialize a Cobra Application\n\n    Flags:\n      -a, --author string    author name for copyright attribution (default \"YOUR NAME\")\n          --config string    config file (default is $HOME/.cobra.yaml)\n      -h, --help             help for cobra\n      -l, --license string   name of license for the project\n          --viper            use Viper for configuration (default true)\n\n    Use \"cobra [command] --help\" for more information about a command.\n\n### Defining your own usage\nYou can provide your own usage function or template for Cobra to use.\nLike help, the function and template are overridable through public methods:\n\n```go\ncmd.SetUsageFunc(f func(*Command) error)\ncmd.SetUsageTemplate(s string)\n```\n\n## Version Flag\n\nCobra adds a top-level '--version' flag if the Version field is set on the root command.\nRunning an application with the '--version' flag will print the version to stdout using\nthe version template. The template can be customized using the\n`cmd.SetVersionTemplate(s string)` function.\n\n## PreRun and PostRun Hooks\n\nIt is possible to run functions before or after the main `Run` function of your command. The `PersistentPreRun` and `PreRun` functions will be executed before `Run`. `PersistentPostRun` and `PostRun` will be executed after `Run`.  The `Persistent*Run` functions will be inherited by children if they do not declare their own.  These functions are run in the following order:\n\n- `PersistentPreRun`\n- `PreRun`\n- `Run`\n- `PostRun`\n- `PersistentPostRun`\n\nAn example of two commands which use all of these features is below.  When the subcommand is executed, it will run the root command's `PersistentPreRun` but not the root command's `PersistentPostRun`:\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n\n  \"github.com/spf13/cobra\"\n)\n\nfunc main() {\n\n  var rootCmd = &cobra.Command{\n    Use:   \"root [sub]\",\n    Short: \"My root command\",\n    PersistentPreRun: func(cmd *cobra.Command, args []string) {\n      fmt.Printf(\"Inside rootCmd PersistentPreRun with args: %v\\n\", args)\n    },\n    PreRun: func(cmd *cobra.Command, args []string) {\n      fmt.Printf(\"Inside rootCmd PreRun with args: %v\\n\", args)\n    },\n    Run: func(cmd *cobra.Command, args []string) {\n      fmt.Printf(\"Inside rootCmd Run with args: %v\\n\", args)\n    },\n    PostRun: func(cmd *cobra.Command, args []string) {\n      fmt.Printf(\"Inside rootCmd PostRun with args: %v\\n\", args)\n    },\n    PersistentPostRun: func(cmd *cobra.Command, args []string) {\n      fmt.Printf(\"Inside rootCmd PersistentPostRun with args: %v\\n\", args)\n    },\n  }\n\n  var subCmd = &cobra.Command{\n    Use:   \"sub [no options!]\",\n    Short: \"My subcommand\",\n    PreRun: func(cmd *cobra.Command, args []string) {\n      fmt.Printf(\"Inside subCmd PreRun with args: %v\\n\", args)\n    },\n    Run: func(cmd *cobra.Command, args []string) {\n      fmt.Printf(\"Inside subCmd Run with args: %v\\n\", args)\n    },\n    PostRun: func(cmd *cobra.Command, args []string) {\n      fmt.Printf(\"Inside subCmd PostRun with args: %v\\n\", args)\n    },\n    PersistentPostRun: func(cmd *cobra.Command, args []string) {\n      fmt.Printf(\"Inside subCmd PersistentPostRun with args: %v\\n\", args)\n    },\n  }\n\n  rootCmd.AddCommand(subCmd)\n\n  rootCmd.SetArgs([]string{\"\"})\n  rootCmd.Execute()\n  fmt.Println()\n  rootCmd.SetArgs([]string{\"sub\", \"arg1\", \"arg2\"})\n  rootCmd.Execute()\n}\n```\n\nOutput:\n```\nInside rootCmd PersistentPreRun with args: []\nInside rootCmd PreRun with args: []\nInside rootCmd Run with args: []\nInside rootCmd PostRun with args: []\nInside rootCmd PersistentPostRun with args: []\n\nInside rootCmd PersistentPreRun with args: [arg1 arg2]\nInside subCmd PreRun with args: [arg1 arg2]\nInside subCmd Run with args: [arg1 arg2]\nInside subCmd PostRun with args: [arg1 arg2]\nInside subCmd PersistentPostRun with args: [arg1 arg2]\n```\n\n## Suggestions when \"unknown command\" happens\n\nCobra will print automatic suggestions when \"unknown command\" errors happen. This allows Cobra to behave similarly to the `git` command when a typo happens. For example:\n\n```\n$ hugo srever\nError: unknown command \"srever\" for \"hugo\"\n\nDid you mean this?\n        server\n\nRun 'hugo --help' for usage.\n```\n\nSuggestions are automatic based on every subcommand registered and use an implementation of [Levenshtein distance](http://en.wikipedia.org/wiki/Levenshtein_distance). Every registered command that matches a minimum distance of 2 (ignoring case) will be displayed as a suggestion.\n\nIf you need to disable suggestions or tweak the string distance in your command, use:\n\n```go\ncommand.DisableSuggestions = true\n```\n\nor\n\n```go\ncommand.SuggestionsMinimumDistance = 1\n```\n\nYou can also explicitly set names for which a given command will be suggested using the `SuggestFor` attribute. This allows suggestions for strings that are not close in terms of string distance, but makes sense in your set of commands and for some which you don't want aliases. Example:\n\n```\n$ kubectl remove\nError: unknown command \"remove\" for \"kubectl\"\n\nDid you mean this?\n        delete\n\nRun 'kubectl help' for usage.\n```\n\n## Generating documentation for your command\n\nCobra can generate documentation based on subcommands, flags, etc. in the following formats:\n\n- [Markdown](doc/md_docs.md)\n- [ReStructured Text](doc/rest_docs.md)\n- [Man Page](doc/man_docs.md)\n\n## Generating bash completions\n\nCobra can generate a bash-completion file. If you add more information to your command, these completions can be amazingly powerful and flexible.  Read more about it in [Bash Completions](bash_completions.md).\n\n# Contributing\n\n1. Fork it\n2. Download your fork to your PC (`git clone https://github.com/your_username/cobra && cd cobra`)\n3. Create your feature branch (`git checkout -b my-new-feature`)\n4. Make changes and add them (`git add .`)\n5. Commit your changes (`git commit -m 'Add some feature'`)\n6. Push to the branch (`git push origin my-new-feature`)\n7. Create new pull request\n\n# License\n\nCobra is released under the Apache 2.0 license. See [LICENSE.txt](https://github.com/spf13/cobra/blob/master/LICENSE.txt)\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/args.go",
    "content": "package cobra\n\nimport (\n\t\"fmt\"\n)\n\ntype PositionalArgs func(cmd *Command, args []string) error\n\n// Legacy arg validation has the following behaviour:\n// - root commands with no subcommands can take arbitrary arguments\n// - root commands with subcommands will do subcommand validity checking\n// - subcommands will always accept arbitrary arguments\nfunc legacyArgs(cmd *Command, args []string) error {\n\t// no subcommand, always take args\n\tif !cmd.HasSubCommands() {\n\t\treturn nil\n\t}\n\n\t// root command with subcommands, do subcommand checking.\n\tif !cmd.HasParent() && len(args) > 0 {\n\t\treturn fmt.Errorf(\"unknown command %q for %q%s\", args[0], cmd.CommandPath(), cmd.findSuggestions(args[0]))\n\t}\n\treturn nil\n}\n\n// NoArgs returns an error if any args are included.\nfunc NoArgs(cmd *Command, args []string) error {\n\tif len(args) > 0 {\n\t\treturn fmt.Errorf(\"unknown command %q for %q\", args[0], cmd.CommandPath())\n\t}\n\treturn nil\n}\n\n// OnlyValidArgs returns an error if any args are not in the list of ValidArgs.\nfunc OnlyValidArgs(cmd *Command, args []string) error {\n\tif len(cmd.ValidArgs) > 0 {\n\t\tfor _, v := range args {\n\t\t\tif !stringInSlice(v, cmd.ValidArgs) {\n\t\t\t\treturn fmt.Errorf(\"invalid argument %q for %q%s\", v, cmd.CommandPath(), cmd.findSuggestions(args[0]))\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// ArbitraryArgs never returns an error.\nfunc ArbitraryArgs(cmd *Command, args []string) error {\n\treturn nil\n}\n\n// MinimumNArgs returns an error if there is not at least N args.\nfunc MinimumNArgs(n int) PositionalArgs {\n\treturn func(cmd *Command, args []string) error {\n\t\tif len(args) < n {\n\t\t\treturn fmt.Errorf(\"requires at least %d arg(s), only received %d\", n, len(args))\n\t\t}\n\t\treturn nil\n\t}\n}\n\n// MaximumNArgs returns an error if there are more than N args.\nfunc MaximumNArgs(n int) PositionalArgs {\n\treturn func(cmd *Command, args []string) error {\n\t\tif len(args) > n {\n\t\t\treturn fmt.Errorf(\"accepts at most %d arg(s), received %d\", n, len(args))\n\t\t}\n\t\treturn nil\n\t}\n}\n\n// ExactArgs returns an error if there are not exactly n args.\nfunc ExactArgs(n int) PositionalArgs {\n\treturn func(cmd *Command, args []string) error {\n\t\tif len(args) != n {\n\t\t\treturn fmt.Errorf(\"accepts %d arg(s), received %d\", n, len(args))\n\t\t}\n\t\treturn nil\n\t}\n}\n\n// RangeArgs returns an error if the number of args is not within the expected range.\nfunc RangeArgs(min int, max int) PositionalArgs {\n\treturn func(cmd *Command, args []string) error {\n\t\tif len(args) < min || len(args) > max {\n\t\t\treturn fmt.Errorf(\"accepts between %d and %d arg(s), received %d\", min, max, len(args))\n\t\t}\n\t\treturn nil\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/args_test.go",
    "content": "package cobra\n\nimport (\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc TestNoArgs(t *testing.T) {\n\tc := &Command{Use: \"c\", Args: NoArgs, Run: emptyRun}\n\n\toutput, err := executeCommand(c)\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected string: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Fatalf(\"Unexpected error: %v\", err)\n\t}\n}\n\nfunc TestNoArgsWithArgs(t *testing.T) {\n\tc := &Command{Use: \"c\", Args: NoArgs, Run: emptyRun}\n\n\t_, err := executeCommand(c, \"illegal\")\n\tif err == nil {\n\t\tt.Fatal(\"Expected an error\")\n\t}\n\n\tgot := err.Error()\n\texpected := `unknown command \"illegal\" for \"c\"`\n\tif got != expected {\n\t\tt.Errorf(\"Expected: %q, got: %q\", expected, got)\n\t}\n}\n\nfunc TestOnlyValidArgs(t *testing.T) {\n\tc := &Command{\n\t\tUse:       \"c\",\n\t\tArgs:      OnlyValidArgs,\n\t\tValidArgs: []string{\"one\", \"two\"},\n\t\tRun:       emptyRun,\n\t}\n\n\toutput, err := executeCommand(c, \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Fatalf(\"Unexpected error: %v\", err)\n\t}\n}\n\nfunc TestOnlyValidArgsWithInvalidArgs(t *testing.T) {\n\tc := &Command{\n\t\tUse:       \"c\",\n\t\tArgs:      OnlyValidArgs,\n\t\tValidArgs: []string{\"one\", \"two\"},\n\t\tRun:       emptyRun,\n\t}\n\n\t_, err := executeCommand(c, \"three\")\n\tif err == nil {\n\t\tt.Fatal(\"Expected an error\")\n\t}\n\n\tgot := err.Error()\n\texpected := `invalid argument \"three\" for \"c\"`\n\tif got != expected {\n\t\tt.Errorf(\"Expected: %q, got: %q\", expected, got)\n\t}\n}\n\nfunc TestArbitraryArgs(t *testing.T) {\n\tc := &Command{Use: \"c\", Args: ArbitraryArgs, Run: emptyRun}\n\toutput, err := executeCommand(c, \"a\", \"b\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n}\n\nfunc TestMinimumNArgs(t *testing.T) {\n\tc := &Command{Use: \"c\", Args: MinimumNArgs(2), Run: emptyRun}\n\toutput, err := executeCommand(c, \"a\", \"b\", \"c\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n}\n\nfunc TestMinimumNArgsWithLessArgs(t *testing.T) {\n\tc := &Command{Use: \"c\", Args: MinimumNArgs(2), Run: emptyRun}\n\t_, err := executeCommand(c, \"a\")\n\n\tif err == nil {\n\t\tt.Fatal(\"Expected an error\")\n\t}\n\n\tgot := err.Error()\n\texpected := \"requires at least 2 arg(s), only received 1\"\n\tif got != expected {\n\t\tt.Fatalf(\"Expected %q, got %q\", expected, got)\n\t}\n}\n\nfunc TestMaximumNArgs(t *testing.T) {\n\tc := &Command{Use: \"c\", Args: MaximumNArgs(3), Run: emptyRun}\n\toutput, err := executeCommand(c, \"a\", \"b\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n}\n\nfunc TestMaximumNArgsWithMoreArgs(t *testing.T) {\n\tc := &Command{Use: \"c\", Args: MaximumNArgs(2), Run: emptyRun}\n\t_, err := executeCommand(c, \"a\", \"b\", \"c\")\n\n\tif err == nil {\n\t\tt.Fatal(\"Expected an error\")\n\t}\n\n\tgot := err.Error()\n\texpected := \"accepts at most 2 arg(s), received 3\"\n\tif got != expected {\n\t\tt.Fatalf(\"Expected %q, got %q\", expected, got)\n\t}\n}\n\nfunc TestExactArgs(t *testing.T) {\n\tc := &Command{Use: \"c\", Args: ExactArgs(3), Run: emptyRun}\n\toutput, err := executeCommand(c, \"a\", \"b\", \"c\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n}\n\nfunc TestExactArgsWithInvalidCount(t *testing.T) {\n\tc := &Command{Use: \"c\", Args: ExactArgs(2), Run: emptyRun}\n\t_, err := executeCommand(c, \"a\", \"b\", \"c\")\n\n\tif err == nil {\n\t\tt.Fatal(\"Expected an error\")\n\t}\n\n\tgot := err.Error()\n\texpected := \"accepts 2 arg(s), received 3\"\n\tif got != expected {\n\t\tt.Fatalf(\"Expected %q, got %q\", expected, got)\n\t}\n}\n\nfunc TestRangeArgs(t *testing.T) {\n\tc := &Command{Use: \"c\", Args: RangeArgs(2, 4), Run: emptyRun}\n\toutput, err := executeCommand(c, \"a\", \"b\", \"c\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n}\n\nfunc TestRangeArgsWithInvalidCount(t *testing.T) {\n\tc := &Command{Use: \"c\", Args: RangeArgs(2, 4), Run: emptyRun}\n\t_, err := executeCommand(c, \"a\")\n\n\tif err == nil {\n\t\tt.Fatal(\"Expected an error\")\n\t}\n\n\tgot := err.Error()\n\texpected := \"accepts between 2 and 4 arg(s), received 1\"\n\tif got != expected {\n\t\tt.Fatalf(\"Expected %q, got %q\", expected, got)\n\t}\n}\n\nfunc TestRootTakesNoArgs(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tchildCmd := &Command{Use: \"child\", Run: emptyRun}\n\trootCmd.AddCommand(childCmd)\n\n\t_, err := executeCommand(rootCmd, \"illegal\", \"args\")\n\tif err == nil {\n\t\tt.Fatal(\"Expected an error\")\n\t}\n\n\tgot := err.Error()\n\texpected := `unknown command \"illegal\" for \"root\"`\n\tif !strings.Contains(got, expected) {\n\t\tt.Errorf(\"expected %q, got %q\", expected, got)\n\t}\n}\n\nfunc TestRootTakesArgs(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Args: ArbitraryArgs, Run: emptyRun}\n\tchildCmd := &Command{Use: \"child\", Run: emptyRun}\n\trootCmd.AddCommand(childCmd)\n\n\t_, err := executeCommand(rootCmd, \"legal\", \"args\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n}\n\nfunc TestChildTakesNoArgs(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tchildCmd := &Command{Use: \"child\", Args: NoArgs, Run: emptyRun}\n\trootCmd.AddCommand(childCmd)\n\n\t_, err := executeCommand(rootCmd, \"child\", \"illegal\", \"args\")\n\tif err == nil {\n\t\tt.Fatal(\"Expected an error\")\n\t}\n\n\tgot := err.Error()\n\texpected := `unknown command \"illegal\" for \"root child\"`\n\tif !strings.Contains(got, expected) {\n\t\tt.Errorf(\"expected %q, got %q\", expected, got)\n\t}\n}\n\nfunc TestChildTakesArgs(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tchildCmd := &Command{Use: \"child\", Args: ArbitraryArgs, Run: emptyRun}\n\trootCmd.AddCommand(childCmd)\n\n\t_, err := executeCommand(rootCmd, \"child\", \"legal\", \"args\")\n\tif err != nil {\n\t\tt.Fatalf(\"Unexpected error: %v\", err)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/bash_completions.go",
    "content": "package cobra\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n\t\"strings\"\n\n\t\"github.com/spf13/pflag\"\n)\n\n// Annotations for Bash completion.\nconst (\n\tBashCompFilenameExt     = \"cobra_annotation_bash_completion_filename_extensions\"\n\tBashCompCustom          = \"cobra_annotation_bash_completion_custom\"\n\tBashCompOneRequiredFlag = \"cobra_annotation_bash_completion_one_required_flag\"\n\tBashCompSubdirsInDir    = \"cobra_annotation_bash_completion_subdirs_in_dir\"\n)\n\nfunc writePreamble(buf *bytes.Buffer, name string) {\n\tbuf.WriteString(fmt.Sprintf(\"# bash completion for %-36s -*- shell-script -*-\\n\", name))\n\tbuf.WriteString(`\n__debug()\n{\n    if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then\n        echo \"$*\" >> \"${BASH_COMP_DEBUG_FILE}\"\n    fi\n}\n\n# Homebrew on Macs have version 1.3 of bash-completion which doesn't include\n# _init_completion. This is a very minimal version of that function.\n__my_init_completion()\n{\n    COMPREPLY=()\n    _get_comp_words_by_ref \"$@\" cur prev words cword\n}\n\n__index_of_word()\n{\n    local w word=$1\n    shift\n    index=0\n    for w in \"$@\"; do\n        [[ $w = \"$word\" ]] && return\n        index=$((index+1))\n    done\n    index=-1\n}\n\n__contains_word()\n{\n    local w word=$1; shift\n    for w in \"$@\"; do\n        [[ $w = \"$word\" ]] && return\n    done\n    return 1\n}\n\n__handle_reply()\n{\n    __debug \"${FUNCNAME[0]}\"\n    case $cur in\n        -*)\n            if [[ $(type -t compopt) = \"builtin\" ]]; then\n                compopt -o nospace\n            fi\n            local allflags\n            if [ ${#must_have_one_flag[@]} -ne 0 ]; then\n                allflags=(\"${must_have_one_flag[@]}\")\n            else\n                allflags=(\"${flags[*]} ${two_word_flags[*]}\")\n            fi\n            COMPREPLY=( $(compgen -W \"${allflags[*]}\" -- \"$cur\") )\n            if [[ $(type -t compopt) = \"builtin\" ]]; then\n                [[ \"${COMPREPLY[0]}\" == *= ]] || compopt +o nospace\n            fi\n\n            # complete after --flag=abc\n            if [[ $cur == *=* ]]; then\n                if [[ $(type -t compopt) = \"builtin\" ]]; then\n                    compopt +o nospace\n                fi\n\n                local index flag\n                flag=\"${cur%%=*}\"\n                __index_of_word \"${flag}\" \"${flags_with_completion[@]}\"\n                COMPREPLY=()\n                if [[ ${index} -ge 0 ]]; then\n                    PREFIX=\"\"\n                    cur=\"${cur#*=}\"\n                    ${flags_completion[${index}]}\n                    if [ -n \"${ZSH_VERSION}\" ]; then\n                        # zsh completion needs --flag= prefix\n                        eval \"COMPREPLY=( \\\"\\${COMPREPLY[@]/#/${flag}=}\\\" )\"\n                    fi\n                fi\n            fi\n            return 0;\n            ;;\n    esac\n\n    # check if we are handling a flag with special work handling\n    local index\n    __index_of_word \"${prev}\" \"${flags_with_completion[@]}\"\n    if [[ ${index} -ge 0 ]]; then\n        ${flags_completion[${index}]}\n        return\n    fi\n\n    # we are parsing a flag and don't have a special handler, no completion\n    if [[ ${cur} != \"${words[cword]}\" ]]; then\n        return\n    fi\n\n    local completions\n    completions=(\"${commands[@]}\")\n    if [[ ${#must_have_one_noun[@]} -ne 0 ]]; then\n        completions=(\"${must_have_one_noun[@]}\")\n    fi\n    if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then\n        completions+=(\"${must_have_one_flag[@]}\")\n    fi\n    COMPREPLY=( $(compgen -W \"${completions[*]}\" -- \"$cur\") )\n\n    if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]]; then\n        COMPREPLY=( $(compgen -W \"${noun_aliases[*]}\" -- \"$cur\") )\n    fi\n\n    if [[ ${#COMPREPLY[@]} -eq 0 ]]; then\n        declare -F __custom_func >/dev/null && __custom_func\n    fi\n\n    # available in bash-completion >= 2, not always present on macOS\n    if declare -F __ltrim_colon_completions >/dev/null; then\n        __ltrim_colon_completions \"$cur\"\n    fi\n}\n\n# The arguments should be in the form \"ext1|ext2|extn\"\n__handle_filename_extension_flag()\n{\n    local ext=\"$1\"\n    _filedir \"@(${ext})\"\n}\n\n__handle_subdirs_in_dir_flag()\n{\n    local dir=\"$1\"\n    pushd \"${dir}\" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1\n}\n\n__handle_flag()\n{\n    __debug \"${FUNCNAME[0]}: c is $c words[c] is ${words[c]}\"\n\n    # if a command required a flag, and we found it, unset must_have_one_flag()\n    local flagname=${words[c]}\n    local flagvalue\n    # if the word contained an =\n    if [[ ${words[c]} == *\"=\"* ]]; then\n        flagvalue=${flagname#*=} # take in as flagvalue after the =\n        flagname=${flagname%%=*} # strip everything after the =\n        flagname=\"${flagname}=\" # but put the = back\n    fi\n    __debug \"${FUNCNAME[0]}: looking for ${flagname}\"\n    if __contains_word \"${flagname}\" \"${must_have_one_flag[@]}\"; then\n        must_have_one_flag=()\n    fi\n\n    # if you set a flag which only applies to this command, don't show subcommands\n    if __contains_word \"${flagname}\" \"${local_nonpersistent_flags[@]}\"; then\n      commands=()\n    fi\n\n    # keep flag value with flagname as flaghash\n    if [ -n \"${flagvalue}\" ] ; then\n        flaghash[${flagname}]=${flagvalue}\n    elif [ -n \"${words[ $((c+1)) ]}\" ] ; then\n        flaghash[${flagname}]=${words[ $((c+1)) ]}\n    else\n        flaghash[${flagname}]=\"true\" # pad \"true\" for bool flag\n    fi\n\n    # skip the argument to a two word flag\n    if __contains_word \"${words[c]}\" \"${two_word_flags[@]}\"; then\n        c=$((c+1))\n        # if we are looking for a flags value, don't show commands\n        if [[ $c -eq $cword ]]; then\n            commands=()\n        fi\n    fi\n\n    c=$((c+1))\n\n}\n\n__handle_noun()\n{\n    __debug \"${FUNCNAME[0]}: c is $c words[c] is ${words[c]}\"\n\n    if __contains_word \"${words[c]}\" \"${must_have_one_noun[@]}\"; then\n        must_have_one_noun=()\n    elif __contains_word \"${words[c]}\" \"${noun_aliases[@]}\"; then\n        must_have_one_noun=()\n    fi\n\n    nouns+=(\"${words[c]}\")\n    c=$((c+1))\n}\n\n__handle_command()\n{\n    __debug \"${FUNCNAME[0]}: c is $c words[c] is ${words[c]}\"\n\n    local next_command\n    if [[ -n ${last_command} ]]; then\n        next_command=\"_${last_command}_${words[c]//:/__}\"\n    else\n        if [[ $c -eq 0 ]]; then\n            next_command=\"_$(basename \"${words[c]//:/__}\")\"\n        else\n            next_command=\"_${words[c]//:/__}\"\n        fi\n    fi\n    c=$((c+1))\n    __debug \"${FUNCNAME[0]}: looking for ${next_command}\"\n    declare -F \"$next_command\" >/dev/null && $next_command\n}\n\n__handle_word()\n{\n    if [[ $c -ge $cword ]]; then\n        __handle_reply\n        return\n    fi\n    __debug \"${FUNCNAME[0]}: c is $c words[c] is ${words[c]}\"\n    if [[ \"${words[c]}\" == -* ]]; then\n        __handle_flag\n    elif __contains_word \"${words[c]}\" \"${commands[@]}\"; then\n        __handle_command\n    elif [[ $c -eq 0 ]] && __contains_word \"$(basename \"${words[c]}\")\" \"${commands[@]}\"; then\n        __handle_command\n    else\n        __handle_noun\n    fi\n    __handle_word\n}\n\n`)\n}\n\nfunc writePostscript(buf *bytes.Buffer, name string) {\n\tname = strings.Replace(name, \":\", \"__\", -1)\n\tbuf.WriteString(fmt.Sprintf(\"__start_%s()\\n\", name))\n\tbuf.WriteString(fmt.Sprintf(`{\n    local cur prev words cword\n    declare -A flaghash 2>/dev/null || :\n    if declare -F _init_completion >/dev/null 2>&1; then\n        _init_completion -s || return\n    else\n        __my_init_completion -n \"=\" || return\n    fi\n\n    local c=0\n    local flags=()\n    local two_word_flags=()\n    local local_nonpersistent_flags=()\n    local flags_with_completion=()\n    local flags_completion=()\n    local commands=(\"%s\")\n    local must_have_one_flag=()\n    local must_have_one_noun=()\n    local last_command\n    local nouns=()\n\n    __handle_word\n}\n\n`, name))\n\tbuf.WriteString(fmt.Sprintf(`if [[ $(type -t compopt) = \"builtin\" ]]; then\n    complete -o default -F __start_%s %s\nelse\n    complete -o default -o nospace -F __start_%s %s\nfi\n\n`, name, name, name, name))\n\tbuf.WriteString(\"# ex: ts=4 sw=4 et filetype=sh\\n\")\n}\n\nfunc writeCommands(buf *bytes.Buffer, cmd *Command) {\n\tbuf.WriteString(\"    commands=()\\n\")\n\tfor _, c := range cmd.Commands() {\n\t\tif !c.IsAvailableCommand() || c == cmd.helpCommand {\n\t\t\tcontinue\n\t\t}\n\t\tbuf.WriteString(fmt.Sprintf(\"    commands+=(%q)\\n\", c.Name()))\n\t}\n\tbuf.WriteString(\"\\n\")\n}\n\nfunc writeFlagHandler(buf *bytes.Buffer, name string, annotations map[string][]string) {\n\tfor key, value := range annotations {\n\t\tswitch key {\n\t\tcase BashCompFilenameExt:\n\t\t\tbuf.WriteString(fmt.Sprintf(\"    flags_with_completion+=(%q)\\n\", name))\n\n\t\t\tvar ext string\n\t\t\tif len(value) > 0 {\n\t\t\t\text = \"__handle_filename_extension_flag \" + strings.Join(value, \"|\")\n\t\t\t} else {\n\t\t\t\text = \"_filedir\"\n\t\t\t}\n\t\t\tbuf.WriteString(fmt.Sprintf(\"    flags_completion+=(%q)\\n\", ext))\n\t\tcase BashCompCustom:\n\t\t\tbuf.WriteString(fmt.Sprintf(\"    flags_with_completion+=(%q)\\n\", name))\n\t\t\tif len(value) > 0 {\n\t\t\t\thandlers := strings.Join(value, \"; \")\n\t\t\t\tbuf.WriteString(fmt.Sprintf(\"    flags_completion+=(%q)\\n\", handlers))\n\t\t\t} else {\n\t\t\t\tbuf.WriteString(\"    flags_completion+=(:)\\n\")\n\t\t\t}\n\t\tcase BashCompSubdirsInDir:\n\t\t\tbuf.WriteString(fmt.Sprintf(\"    flags_with_completion+=(%q)\\n\", name))\n\n\t\t\tvar ext string\n\t\t\tif len(value) == 1 {\n\t\t\t\text = \"__handle_subdirs_in_dir_flag \" + value[0]\n\t\t\t} else {\n\t\t\t\text = \"_filedir -d\"\n\t\t\t}\n\t\t\tbuf.WriteString(fmt.Sprintf(\"    flags_completion+=(%q)\\n\", ext))\n\t\t}\n\t}\n}\n\nfunc writeShortFlag(buf *bytes.Buffer, flag *pflag.Flag) {\n\tname := flag.Shorthand\n\tformat := \"    \"\n\tif len(flag.NoOptDefVal) == 0 {\n\t\tformat += \"two_word_\"\n\t}\n\tformat += \"flags+=(\\\"-%s\\\")\\n\"\n\tbuf.WriteString(fmt.Sprintf(format, name))\n\twriteFlagHandler(buf, \"-\"+name, flag.Annotations)\n}\n\nfunc writeFlag(buf *bytes.Buffer, flag *pflag.Flag) {\n\tname := flag.Name\n\tformat := \"    flags+=(\\\"--%s\"\n\tif len(flag.NoOptDefVal) == 0 {\n\t\tformat += \"=\"\n\t}\n\tformat += \"\\\")\\n\"\n\tbuf.WriteString(fmt.Sprintf(format, name))\n\twriteFlagHandler(buf, \"--\"+name, flag.Annotations)\n}\n\nfunc writeLocalNonPersistentFlag(buf *bytes.Buffer, flag *pflag.Flag) {\n\tname := flag.Name\n\tformat := \"    local_nonpersistent_flags+=(\\\"--%s\"\n\tif len(flag.NoOptDefVal) == 0 {\n\t\tformat += \"=\"\n\t}\n\tformat += \"\\\")\\n\"\n\tbuf.WriteString(fmt.Sprintf(format, name))\n}\n\nfunc writeFlags(buf *bytes.Buffer, cmd *Command) {\n\tbuf.WriteString(`    flags=()\n    two_word_flags=()\n    local_nonpersistent_flags=()\n    flags_with_completion=()\n    flags_completion=()\n\n`)\n\tlocalNonPersistentFlags := cmd.LocalNonPersistentFlags()\n\tcmd.NonInheritedFlags().VisitAll(func(flag *pflag.Flag) {\n\t\tif nonCompletableFlag(flag) {\n\t\t\treturn\n\t\t}\n\t\twriteFlag(buf, flag)\n\t\tif len(flag.Shorthand) > 0 {\n\t\t\twriteShortFlag(buf, flag)\n\t\t}\n\t\tif localNonPersistentFlags.Lookup(flag.Name) != nil {\n\t\t\twriteLocalNonPersistentFlag(buf, flag)\n\t\t}\n\t})\n\tcmd.InheritedFlags().VisitAll(func(flag *pflag.Flag) {\n\t\tif nonCompletableFlag(flag) {\n\t\t\treturn\n\t\t}\n\t\twriteFlag(buf, flag)\n\t\tif len(flag.Shorthand) > 0 {\n\t\t\twriteShortFlag(buf, flag)\n\t\t}\n\t})\n\n\tbuf.WriteString(\"\\n\")\n}\n\nfunc writeRequiredFlag(buf *bytes.Buffer, cmd *Command) {\n\tbuf.WriteString(\"    must_have_one_flag=()\\n\")\n\tflags := cmd.NonInheritedFlags()\n\tflags.VisitAll(func(flag *pflag.Flag) {\n\t\tif nonCompletableFlag(flag) {\n\t\t\treturn\n\t\t}\n\t\tfor key := range flag.Annotations {\n\t\t\tswitch key {\n\t\t\tcase BashCompOneRequiredFlag:\n\t\t\t\tformat := \"    must_have_one_flag+=(\\\"--%s\"\n\t\t\t\tif flag.Value.Type() != \"bool\" {\n\t\t\t\t\tformat += \"=\"\n\t\t\t\t}\n\t\t\t\tformat += \"\\\")\\n\"\n\t\t\t\tbuf.WriteString(fmt.Sprintf(format, flag.Name))\n\n\t\t\t\tif len(flag.Shorthand) > 0 {\n\t\t\t\t\tbuf.WriteString(fmt.Sprintf(\"    must_have_one_flag+=(\\\"-%s\\\")\\n\", flag.Shorthand))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunc writeRequiredNouns(buf *bytes.Buffer, cmd *Command) {\n\tbuf.WriteString(\"    must_have_one_noun=()\\n\")\n\tsort.Sort(sort.StringSlice(cmd.ValidArgs))\n\tfor _, value := range cmd.ValidArgs {\n\t\tbuf.WriteString(fmt.Sprintf(\"    must_have_one_noun+=(%q)\\n\", value))\n\t}\n}\n\nfunc writeArgAliases(buf *bytes.Buffer, cmd *Command) {\n\tbuf.WriteString(\"    noun_aliases=()\\n\")\n\tsort.Sort(sort.StringSlice(cmd.ArgAliases))\n\tfor _, value := range cmd.ArgAliases {\n\t\tbuf.WriteString(fmt.Sprintf(\"    noun_aliases+=(%q)\\n\", value))\n\t}\n}\n\nfunc gen(buf *bytes.Buffer, cmd *Command) {\n\tfor _, c := range cmd.Commands() {\n\t\tif !c.IsAvailableCommand() || c == cmd.helpCommand {\n\t\t\tcontinue\n\t\t}\n\t\tgen(buf, c)\n\t}\n\tcommandName := cmd.CommandPath()\n\tcommandName = strings.Replace(commandName, \" \", \"_\", -1)\n\tcommandName = strings.Replace(commandName, \":\", \"__\", -1)\n\tbuf.WriteString(fmt.Sprintf(\"_%s()\\n{\\n\", commandName))\n\tbuf.WriteString(fmt.Sprintf(\"    last_command=%q\\n\", commandName))\n\twriteCommands(buf, cmd)\n\twriteFlags(buf, cmd)\n\twriteRequiredFlag(buf, cmd)\n\twriteRequiredNouns(buf, cmd)\n\twriteArgAliases(buf, cmd)\n\tbuf.WriteString(\"}\\n\\n\")\n}\n\n// GenBashCompletion generates bash completion file and writes to the passed writer.\nfunc (c *Command) GenBashCompletion(w io.Writer) error {\n\tbuf := new(bytes.Buffer)\n\twritePreamble(buf, c.Name())\n\tif len(c.BashCompletionFunction) > 0 {\n\t\tbuf.WriteString(c.BashCompletionFunction + \"\\n\")\n\t}\n\tgen(buf, c)\n\twritePostscript(buf, c.Name())\n\n\t_, err := buf.WriteTo(w)\n\treturn err\n}\n\nfunc nonCompletableFlag(flag *pflag.Flag) bool {\n\treturn flag.Hidden || len(flag.Deprecated) > 0\n}\n\n// GenBashCompletionFile generates bash completion file.\nfunc (c *Command) GenBashCompletionFile(filename string) error {\n\toutFile, err := os.Create(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer outFile.Close()\n\n\treturn c.GenBashCompletion(outFile)\n}\n\n// MarkFlagRequired adds the BashCompOneRequiredFlag annotation to the named flag, if it exists.\nfunc (c *Command) MarkFlagRequired(name string) error {\n\treturn MarkFlagRequired(c.Flags(), name)\n}\n\n// MarkPersistentFlagRequired adds the BashCompOneRequiredFlag annotation to the named persistent flag, if it exists.\nfunc (c *Command) MarkPersistentFlagRequired(name string) error {\n\treturn MarkFlagRequired(c.PersistentFlags(), name)\n}\n\n// MarkFlagRequired adds the BashCompOneRequiredFlag annotation to the named flag in the flag set, if it exists.\nfunc MarkFlagRequired(flags *pflag.FlagSet, name string) error {\n\treturn flags.SetAnnotation(name, BashCompOneRequiredFlag, []string{\"true\"})\n}\n\n// MarkFlagFilename adds the BashCompFilenameExt annotation to the named flag, if it exists.\n// Generated bash autocompletion will select filenames for the flag, limiting to named extensions if provided.\nfunc (c *Command) MarkFlagFilename(name string, extensions ...string) error {\n\treturn MarkFlagFilename(c.Flags(), name, extensions...)\n}\n\n// MarkFlagCustom adds the BashCompCustom annotation to the named flag, if it exists.\n// Generated bash autocompletion will call the bash function f for the flag.\nfunc (c *Command) MarkFlagCustom(name string, f string) error {\n\treturn MarkFlagCustom(c.Flags(), name, f)\n}\n\n// MarkPersistentFlagFilename adds the BashCompFilenameExt annotation to the named persistent flag, if it exists.\n// Generated bash autocompletion will select filenames for the flag, limiting to named extensions if provided.\nfunc (c *Command) MarkPersistentFlagFilename(name string, extensions ...string) error {\n\treturn MarkFlagFilename(c.PersistentFlags(), name, extensions...)\n}\n\n// MarkFlagFilename adds the BashCompFilenameExt annotation to the named flag in the flag set, if it exists.\n// Generated bash autocompletion will select filenames for the flag, limiting to named extensions if provided.\nfunc MarkFlagFilename(flags *pflag.FlagSet, name string, extensions ...string) error {\n\treturn flags.SetAnnotation(name, BashCompFilenameExt, extensions)\n}\n\n// MarkFlagCustom adds the BashCompCustom annotation to the named flag in the flag set, if it exists.\n// Generated bash autocompletion will call the bash function f for the flag.\nfunc MarkFlagCustom(flags *pflag.FlagSet, name string, f string) error {\n\treturn flags.SetAnnotation(name, BashCompCustom, []string{f})\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/bash_completions.md",
    "content": "# Generating Bash Completions For Your Own cobra.Command\n\nGenerating bash completions from a cobra command is incredibly easy. An actual program which does so for the kubernetes kubectl binary is as follows:\n\n```go\npackage main\n\nimport (\n        \"io/ioutil\"\n        \"os\"\n\n        \"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd\"\n)\n\nfunc main() {\n        kubectl := cmd.NewFactory(nil).NewKubectlCommand(os.Stdin, ioutil.Discard, ioutil.Discard)\n        kubectl.GenBashCompletionFile(\"out.sh\")\n}\n```\n\n`out.sh` will get you completions of subcommands and flags. Copy it to `/etc/bash_completion.d/` as described [here](https://debian-administration.org/article/316/An_introduction_to_bash_completion_part_1) and reset your terminal to use autocompletion. If you make additional annotations to your code, you can get even more intelligent and flexible behavior.\n\n## Creating your own custom functions\n\nSome more actual code that works in kubernetes:\n\n```bash\nconst (\n        bash_completion_func = `__kubectl_parse_get()\n{\n    local kubectl_output out\n    if kubectl_output=$(kubectl get --no-headers \"$1\" 2>/dev/null); then\n        out=($(echo \"${kubectl_output}\" | awk '{print $1}'))\n        COMPREPLY=( $( compgen -W \"${out[*]}\" -- \"$cur\" ) )\n    fi\n}\n\n__kubectl_get_resource()\n{\n    if [[ ${#nouns[@]} -eq 0 ]]; then\n        return 1\n    fi\n    __kubectl_parse_get ${nouns[${#nouns[@]} -1]}\n    if [[ $? -eq 0 ]]; then\n        return 0\n    fi\n}\n\n__custom_func() {\n    case ${last_command} in\n        kubectl_get | kubectl_describe | kubectl_delete | kubectl_stop)\n            __kubectl_get_resource\n            return\n            ;;\n        *)\n            ;;\n    esac\n}\n`)\n```\n\nAnd then I set that in my command definition:\n\n```go\ncmds := &cobra.Command{\n\tUse:   \"kubectl\",\n\tShort: \"kubectl controls the Kubernetes cluster manager\",\n\tLong: `kubectl controls the Kubernetes cluster manager.\n\nFind more information at https://github.com/GoogleCloudPlatform/kubernetes.`,\n\tRun: runHelp,\n\tBashCompletionFunction: bash_completion_func,\n}\n```\n\nThe `BashCompletionFunction` option is really only valid/useful on the root command. Doing the above will cause `__custom_func()` to be called when the built in processor was unable to find a solution. In the case of kubernetes a valid command might look something like `kubectl get pod [mypod]`. If you type `kubectl get pod [tab][tab]` the `__customc_func()` will run because the cobra.Command only understood \"kubectl\" and \"get.\" `__custom_func()` will see that the cobra.Command is \"kubectl_get\" and will thus call another helper `__kubectl_get_resource()`.  `__kubectl_get_resource` will look at the 'nouns' collected. In our example the only noun will be `pod`.  So it will call `__kubectl_parse_get pod`.  `__kubectl_parse_get` will actually call out to kubernetes and get any pods.  It will then set `COMPREPLY` to valid pods!\n\n## Have the completions code complete your 'nouns'\n\nIn the above example \"pod\" was assumed to already be typed. But if you want `kubectl get [tab][tab]` to show a list of valid \"nouns\" you have to set them. Simplified code from `kubectl get` looks like:\n\n```go\nvalidArgs []string = { \"pod\", \"node\", \"service\", \"replicationcontroller\" }\n\ncmd := &cobra.Command{\n\tUse:     \"get [(-o|--output=)json|yaml|template|...] (RESOURCE [NAME] | RESOURCE/NAME ...)\",\n\tShort:   \"Display one or many resources\",\n\tLong:    get_long,\n\tExample: get_example,\n\tRun: func(cmd *cobra.Command, args []string) {\n\t\terr := RunGet(f, out, cmd, args)\n\t\tutil.CheckErr(err)\n\t},\n\tValidArgs: validArgs,\n}\n```\n\nNotice we put the \"ValidArgs\" on the \"get\" subcommand. Doing so will give results like\n\n```bash\n# kubectl get [tab][tab]\nnode                 pod                    replicationcontroller  service\n```\n\n## Plural form and shortcuts for nouns\n\nIf your nouns have a number of aliases, you can define them alongside `ValidArgs` using `ArgAliases`:\n\n```go\nargAliases []string = { \"pods\", \"nodes\", \"services\", \"svc\", \"replicationcontrollers\", \"rc\" }\n\ncmd := &cobra.Command{\n    ...\n\tValidArgs:  validArgs,\n\tArgAliases: argAliases\n}\n```\n\nThe aliases are not shown to the user on tab completion, but they are accepted as valid nouns by\nthe completion algorithm if entered manually, e.g. in:\n\n```bash\n# kubectl get rc [tab][tab]\nbackend        frontend       database \n```\n\nNote that without declaring `rc` as an alias, the completion algorithm would show the list of nouns\nin this example again instead of the replication controllers.\n\n## Mark flags as required\n\nMost of the time completions will only show subcommands. But if a flag is required to make a subcommand work, you probably want it to show up when the user types [tab][tab].  Marking a flag as 'Required' is incredibly easy.\n\n```go\ncmd.MarkFlagRequired(\"pod\")\ncmd.MarkFlagRequired(\"container\")\n```\n\nand you'll get something like\n\n```bash\n# kubectl exec [tab][tab][tab]\n-c            --container=  -p            --pod=  \n```\n\n# Specify valid filename extensions for flags that take a filename\n\nIn this example we use --filename= and expect to get a json or yaml file as the argument. To make this easier we annotate the --filename flag with valid filename extensions.\n\n```go\n\tannotations := []string{\"json\", \"yaml\", \"yml\"}\n\tannotation := make(map[string][]string)\n\tannotation[cobra.BashCompFilenameExt] = annotations\n\n\tflag := &pflag.Flag{\n\t\tName:        \"filename\",\n\t\tShorthand:   \"f\",\n\t\tUsage:       usage,\n\t\tValue:       value,\n\t\tDefValue:    value.String(),\n\t\tAnnotations: annotation,\n\t}\n\tcmd.Flags().AddFlag(flag)\n```\n\nNow when you run a command with this filename flag you'll get something like\n\n```bash\n# kubectl create -f \ntest/                         example/                      rpmbuild/\nhello.yml                     test.json\n```\n\nSo while there are many other files in the CWD it only shows me subdirs and those with valid extensions.\n\n# Specifiy custom flag completion\n\nSimilar to the filename completion and filtering using cobra.BashCompFilenameExt, you can specifiy\na custom flag completion function with cobra.BashCompCustom:\n\n```go\n\tannotation := make(map[string][]string)\n\tannotation[cobra.BashCompFilenameExt] = []string{\"__kubectl_get_namespaces\"}\n\n\tflag := &pflag.Flag{\n\t\tName:        \"namespace\",\n\t\tUsage:       usage,\n\t\tAnnotations: annotation,\n\t}\n\tcmd.Flags().AddFlag(flag)\n```\n\nIn addition add the `__handle_namespace_flag` implementation in the `BashCompletionFunction`\nvalue, e.g.:\n\n```bash\n__kubectl_get_namespaces()\n{\n    local template\n    template=\"{{ range .items  }}{{ .metadata.name }} {{ end }}\"\n    local kubectl_out\n    if kubectl_out=$(kubectl get -o template --template=\"${template}\" namespace 2>/dev/null); then\n        COMPREPLY=( $( compgen -W \"${kubectl_out}[*]\" -- \"$cur\" ) )\n    fi\n}\n```\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/bash_completions_test.go",
    "content": "package cobra\n\nimport (\n\t\"bytes\"\n\t\"os\"\n\t\"os/exec\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc checkOmit(t *testing.T, found, unexpected string) {\n\tif strings.Contains(found, unexpected) {\n\t\tt.Errorf(\"Got: %q\\nBut should not have!\\n\", unexpected)\n\t}\n}\n\nfunc check(t *testing.T, found, expected string) {\n\tif !strings.Contains(found, expected) {\n\t\tt.Errorf(\"Expecting to contain: \\n %q\\nGot:\\n %q\\n\", expected, found)\n\t}\n}\n\nfunc runShellCheck(s string) error {\n\texcluded := []string{\n\t\t\"SC2034\", // PREFIX appears unused. Verify it or export it.\n\t}\n\tcmd := exec.Command(\"shellcheck\", \"-s\", \"bash\", \"-\", \"-e\", strings.Join(excluded, \",\"))\n\tcmd.Stderr = os.Stderr\n\tcmd.Stdout = os.Stdout\n\n\tstdin, err := cmd.StdinPipe()\n\tif err != nil {\n\t\treturn err\n\t}\n\tgo func() {\n\t\tstdin.Write([]byte(s))\n\t\tstdin.Close()\n\t}()\n\n\treturn cmd.Run()\n}\n\n// World worst custom function, just keep telling you to enter hello!\nconst bashCompletionFunc = `__custom_func() {\n\tCOMPREPLY=( \"hello\" )\n}\n`\n\nfunc TestBashCompletions(t *testing.T) {\n\trootCmd := &Command{\n\t\tUse:                    \"root\",\n\t\tArgAliases:             []string{\"pods\", \"nodes\", \"services\", \"replicationcontrollers\", \"po\", \"no\", \"svc\", \"rc\"},\n\t\tValidArgs:              []string{\"pod\", \"node\", \"service\", \"replicationcontroller\"},\n\t\tBashCompletionFunction: bashCompletionFunc,\n\t\tRun: emptyRun,\n\t}\n\trootCmd.Flags().IntP(\"introot\", \"i\", -1, \"help message for flag introot\")\n\trootCmd.MarkFlagRequired(\"introot\")\n\n\t// Filename.\n\trootCmd.Flags().String(\"filename\", \"\", \"Enter a filename\")\n\trootCmd.MarkFlagFilename(\"filename\", \"json\", \"yaml\", \"yml\")\n\n\t// Persistent filename.\n\trootCmd.PersistentFlags().String(\"persistent-filename\", \"\", \"Enter a filename\")\n\trootCmd.MarkPersistentFlagFilename(\"persistent-filename\")\n\trootCmd.MarkPersistentFlagRequired(\"persistent-filename\")\n\n\t// Filename extensions.\n\trootCmd.Flags().String(\"filename-ext\", \"\", \"Enter a filename (extension limited)\")\n\trootCmd.MarkFlagFilename(\"filename-ext\")\n\trootCmd.Flags().String(\"custom\", \"\", \"Enter a filename (extension limited)\")\n\trootCmd.MarkFlagCustom(\"custom\", \"__complete_custom\")\n\n\t// Subdirectories in a given directory.\n\trootCmd.Flags().String(\"theme\", \"\", \"theme to use (located in /themes/THEMENAME/)\")\n\trootCmd.Flags().SetAnnotation(\"theme\", BashCompSubdirsInDir, []string{\"themes\"})\n\n\techoCmd := &Command{\n\t\tUse:     \"echo [string to echo]\",\n\t\tAliases: []string{\"say\"},\n\t\tShort:   \"Echo anything to the screen\",\n\t\tLong:    \"an utterly useless command for testing.\",\n\t\tExample: \"Just run cobra-test echo\",\n\t\tRun:     emptyRun,\n\t}\n\n\tprintCmd := &Command{\n\t\tUse:   \"print [string to print]\",\n\t\tArgs:  MinimumNArgs(1),\n\t\tShort: \"Print anything to the screen\",\n\t\tLong:  \"an absolutely utterly useless command for testing.\",\n\t\tRun:   emptyRun,\n\t}\n\n\tdeprecatedCmd := &Command{\n\t\tUse:        \"deprecated [can't do anything here]\",\n\t\tArgs:       NoArgs,\n\t\tShort:      \"A command which is deprecated\",\n\t\tLong:       \"an absolutely utterly useless command for testing deprecation!.\",\n\t\tDeprecated: \"Please use echo instead\",\n\t\tRun:        emptyRun,\n\t}\n\n\tcolonCmd := &Command{\n\t\tUse: \"cmd:colon\",\n\t\tRun: emptyRun,\n\t}\n\n\ttimesCmd := &Command{\n\t\tUse:        \"times [# times] [string to echo]\",\n\t\tSuggestFor: []string{\"counts\"},\n\t\tArgs:       OnlyValidArgs,\n\t\tValidArgs:  []string{\"one\", \"two\", \"three\", \"four\"},\n\t\tShort:      \"Echo anything to the screen more times\",\n\t\tLong:       \"a slightly useless command for testing.\",\n\t\tRun:        emptyRun,\n\t}\n\n\techoCmd.AddCommand(timesCmd)\n\trootCmd.AddCommand(echoCmd, printCmd, deprecatedCmd, colonCmd)\n\n\tbuf := new(bytes.Buffer)\n\trootCmd.GenBashCompletion(buf)\n\toutput := buf.String()\n\n\tcheck(t, output, \"_root\")\n\tcheck(t, output, \"_root_echo\")\n\tcheck(t, output, \"_root_echo_times\")\n\tcheck(t, output, \"_root_print\")\n\tcheck(t, output, \"_root_cmd__colon\")\n\n\t// check for required flags\n\tcheck(t, output, `must_have_one_flag+=(\"--introot=\")`)\n\tcheck(t, output, `must_have_one_flag+=(\"--persistent-filename=\")`)\n\t// check for custom completion function\n\tcheck(t, output, `COMPREPLY=( \"hello\" )`)\n\t// check for required nouns\n\tcheck(t, output, `must_have_one_noun+=(\"pod\")`)\n\t// check for noun aliases\n\tcheck(t, output, `noun_aliases+=(\"pods\")`)\n\tcheck(t, output, `noun_aliases+=(\"rc\")`)\n\tcheckOmit(t, output, `must_have_one_noun+=(\"pods\")`)\n\t// check for filename extension flags\n\tcheck(t, output, `flags_completion+=(\"_filedir\")`)\n\t// check for filename extension flags\n\tcheck(t, output, `must_have_one_noun+=(\"three\")`)\n\t// check for filename extension flags\n\tcheck(t, output, `flags_completion+=(\"__handle_filename_extension_flag json|yaml|yml\")`)\n\t// check for custom flags\n\tcheck(t, output, `flags_completion+=(\"__complete_custom\")`)\n\t// check for subdirs_in_dir flags\n\tcheck(t, output, `flags_completion+=(\"__handle_subdirs_in_dir_flag themes\")`)\n\n\tcheckOmit(t, output, deprecatedCmd.Name())\n\n\t// If available, run shellcheck against the script.\n\tif err := exec.Command(\"which\", \"shellcheck\").Run(); err != nil {\n\t\treturn\n\t}\n\tif err := runShellCheck(output); err != nil {\n\t\tt.Fatalf(\"shellcheck failed: %v\", err)\n\t}\n}\n\nfunc TestBashCompletionHiddenFlag(t *testing.T) {\n\tc := &Command{Use: \"c\", Run: emptyRun}\n\n\tconst flagName = \"hiddenFlag\"\n\tc.Flags().Bool(flagName, false, \"\")\n\tc.Flags().MarkHidden(flagName)\n\n\tbuf := new(bytes.Buffer)\n\tc.GenBashCompletion(buf)\n\toutput := buf.String()\n\n\tif strings.Contains(output, flagName) {\n\t\tt.Errorf(\"Expected completion to not include %q flag: Got %v\", flagName, output)\n\t}\n}\n\nfunc TestBashCompletionDeprecatedFlag(t *testing.T) {\n\tc := &Command{Use: \"c\", Run: emptyRun}\n\n\tconst flagName = \"deprecated-flag\"\n\tc.Flags().Bool(flagName, false, \"\")\n\tc.Flags().MarkDeprecated(flagName, \"use --not-deprecated instead\")\n\n\tbuf := new(bytes.Buffer)\n\tc.GenBashCompletion(buf)\n\toutput := buf.String()\n\n\tif strings.Contains(output, flagName) {\n\t\tt.Errorf(\"expected completion to not include %q flag: Got %v\", flagName, output)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/cobra.go",
    "content": "// Copyright © 2013 Steve Francia <spf@spf13.com>.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Commands similar to git, go tools and other modern CLI tools\n// inspired by go, go-Commander, gh and subcommand\n\npackage cobra\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"reflect\"\n\t\"strconv\"\n\t\"strings\"\n\t\"text/template\"\n\t\"unicode\"\n)\n\nvar templateFuncs = template.FuncMap{\n\t\"trim\":                    strings.TrimSpace,\n\t\"trimRightSpace\":          trimRightSpace,\n\t\"trimTrailingWhitespaces\": trimRightSpace,\n\t\"appendIfNotPresent\":      appendIfNotPresent,\n\t\"rpad\":                    rpad,\n\t\"gt\":                      Gt,\n\t\"eq\":                      Eq,\n}\n\nvar initializers []func()\n\n// EnablePrefixMatching allows to set automatic prefix matching. Automatic prefix matching can be a dangerous thing\n// to automatically enable in CLI tools.\n// Set this to true to enable it.\nvar EnablePrefixMatching = false\n\n// EnableCommandSorting controls sorting of the slice of commands, which is turned on by default.\n// To disable sorting, set it to false.\nvar EnableCommandSorting = true\n\n// MousetrapHelpText enables an information splash screen on Windows\n// if the CLI is started from explorer.exe.\n// To disable the mousetrap, just set this variable to blank string (\"\").\n// Works only on Microsoft Windows.\nvar MousetrapHelpText string = `This is a command line tool.\n\nYou need to open cmd.exe and run it from there.\n`\n\n// AddTemplateFunc adds a template function that's available to Usage and Help\n// template generation.\nfunc AddTemplateFunc(name string, tmplFunc interface{}) {\n\ttemplateFuncs[name] = tmplFunc\n}\n\n// AddTemplateFuncs adds multiple template functions that are available to Usage and\n// Help template generation.\nfunc AddTemplateFuncs(tmplFuncs template.FuncMap) {\n\tfor k, v := range tmplFuncs {\n\t\ttemplateFuncs[k] = v\n\t}\n}\n\n// OnInitialize sets the passed functions to be run when each command's\n// Execute method is called.\nfunc OnInitialize(y ...func()) {\n\tinitializers = append(initializers, y...)\n}\n\n// FIXME Gt is unused by cobra and should be removed in a version 2. It exists only for compatibility with users of cobra.\n\n// Gt takes two types and checks whether the first type is greater than the second. In case of types Arrays, Chans,\n// Maps and Slices, Gt will compare their lengths. Ints are compared directly while strings are first parsed as\n// ints and then compared.\nfunc Gt(a interface{}, b interface{}) bool {\n\tvar left, right int64\n\tav := reflect.ValueOf(a)\n\n\tswitch av.Kind() {\n\tcase reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:\n\t\tleft = int64(av.Len())\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\tleft = av.Int()\n\tcase reflect.String:\n\t\tleft, _ = strconv.ParseInt(av.String(), 10, 64)\n\t}\n\n\tbv := reflect.ValueOf(b)\n\n\tswitch bv.Kind() {\n\tcase reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:\n\t\tright = int64(bv.Len())\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\tright = bv.Int()\n\tcase reflect.String:\n\t\tright, _ = strconv.ParseInt(bv.String(), 10, 64)\n\t}\n\n\treturn left > right\n}\n\n// FIXME Eq is unused by cobra and should be removed in a version 2. It exists only for compatibility with users of cobra.\n\n// Eq takes two types and checks whether they are equal. Supported types are int and string. Unsupported types will panic.\nfunc Eq(a interface{}, b interface{}) bool {\n\tav := reflect.ValueOf(a)\n\tbv := reflect.ValueOf(b)\n\n\tswitch av.Kind() {\n\tcase reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:\n\t\tpanic(\"Eq called on unsupported type\")\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn av.Int() == bv.Int()\n\tcase reflect.String:\n\t\treturn av.String() == bv.String()\n\t}\n\treturn false\n}\n\nfunc trimRightSpace(s string) string {\n\treturn strings.TrimRightFunc(s, unicode.IsSpace)\n}\n\n// FIXME appendIfNotPresent is unused by cobra and should be removed in a version 2. It exists only for compatibility with users of cobra.\n\n// appendIfNotPresent will append stringToAppend to the end of s, but only if it's not yet present in s.\nfunc appendIfNotPresent(s, stringToAppend string) string {\n\tif strings.Contains(s, stringToAppend) {\n\t\treturn s\n\t}\n\treturn s + \" \" + stringToAppend\n}\n\n// rpad adds padding to the right of a string.\nfunc rpad(s string, padding int) string {\n\ttemplate := fmt.Sprintf(\"%%-%ds\", padding)\n\treturn fmt.Sprintf(template, s)\n}\n\n// tmpl executes the given template text on data, writing the result to w.\nfunc tmpl(w io.Writer, text string, data interface{}) error {\n\tt := template.New(\"top\")\n\tt.Funcs(templateFuncs)\n\ttemplate.Must(t.Parse(text))\n\treturn t.Execute(w, data)\n}\n\n// ld compares two strings and returns the levenshtein distance between them.\nfunc ld(s, t string, ignoreCase bool) int {\n\tif ignoreCase {\n\t\ts = strings.ToLower(s)\n\t\tt = strings.ToLower(t)\n\t}\n\td := make([][]int, len(s)+1)\n\tfor i := range d {\n\t\td[i] = make([]int, len(t)+1)\n\t}\n\tfor i := range d {\n\t\td[i][0] = i\n\t}\n\tfor j := range d[0] {\n\t\td[0][j] = j\n\t}\n\tfor j := 1; j <= len(t); j++ {\n\t\tfor i := 1; i <= len(s); i++ {\n\t\t\tif s[i-1] == t[j-1] {\n\t\t\t\td[i][j] = d[i-1][j-1]\n\t\t\t} else {\n\t\t\t\tmin := d[i-1][j]\n\t\t\t\tif d[i][j-1] < min {\n\t\t\t\t\tmin = d[i][j-1]\n\t\t\t\t}\n\t\t\t\tif d[i-1][j-1] < min {\n\t\t\t\t\tmin = d[i-1][j-1]\n\t\t\t\t}\n\t\t\t\td[i][j] = min + 1\n\t\t\t}\n\t\t}\n\n\t}\n\treturn d[len(s)][len(t)]\n}\n\nfunc stringInSlice(a string, list []string) bool {\n\tfor _, b := range list {\n\t\tif b == a {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/cobra_test.go",
    "content": "package cobra\n\nimport (\n\t\"testing\"\n\t\"text/template\"\n)\n\nfunc TestAddTemplateFunctions(t *testing.T) {\n\tAddTemplateFunc(\"t\", func() bool { return true })\n\tAddTemplateFuncs(template.FuncMap{\n\t\t\"f\": func() bool { return false },\n\t\t\"h\": func() string { return \"Hello,\" },\n\t\t\"w\": func() string { return \"world.\" }})\n\n\tc := &Command{}\n\tc.SetUsageTemplate(`{{if t}}{{h}}{{end}}{{if f}}{{h}}{{end}} {{w}}`)\n\n\tconst expected = \"Hello, world.\"\n\tif got := c.UsageString(); got != expected {\n\t\tt.Errorf(\"Expected UsageString: %v\\nGot: %v\", expected, got)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/command.go",
    "content": "// Copyright © 2013 Steve Francia <spf@spf13.com>.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Package cobra is a commander providing a simple interface to create powerful modern CLI interfaces.\n// In addition to providing an interface, Cobra simultaneously provides a controller to organize your application code.\npackage cobra\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"sort\"\n\t\"strings\"\n\n\tflag \"github.com/spf13/pflag\"\n)\n\n// Command is just that, a command for your application.\n// E.g.  'go run ...' - 'run' is the command. Cobra requires\n// you to define the usage and description as part of your command\n// definition to ensure usability.\ntype Command struct {\n\t// Use is the one-line usage message.\n\tUse string\n\n\t// Aliases is an array of aliases that can be used instead of the first word in Use.\n\tAliases []string\n\n\t// SuggestFor is an array of command names for which this command will be suggested -\n\t// similar to aliases but only suggests.\n\tSuggestFor []string\n\n\t// Short is the short description shown in the 'help' output.\n\tShort string\n\n\t// Long is the long message shown in the 'help <this-command>' output.\n\tLong string\n\n\t// Example is examples of how to use the command.\n\tExample string\n\n\t// ValidArgs is list of all valid non-flag arguments that are accepted in bash completions\n\tValidArgs []string\n\n\t// Expected arguments\n\tArgs PositionalArgs\n\n\t// ArgAliases is List of aliases for ValidArgs.\n\t// These are not suggested to the user in the bash completion,\n\t// but accepted if entered manually.\n\tArgAliases []string\n\n\t// BashCompletionFunction is custom functions used by the bash autocompletion generator.\n\tBashCompletionFunction string\n\n\t// Deprecated defines, if this command is deprecated and should print this string when used.\n\tDeprecated string\n\n\t// Hidden defines, if this command is hidden and should NOT show up in the list of available commands.\n\tHidden bool\n\n\t// Annotations are key/value pairs that can be used by applications to identify or\n\t// group commands.\n\tAnnotations map[string]string\n\n\t// Version defines the version for this command. If this value is non-empty and the command does not\n\t// define a \"version\" flag, a \"version\" boolean flag will be added to the command and, if specified,\n\t// will print content of the \"Version\" variable.\n\tVersion string\n\n\t// The *Run functions are executed in the following order:\n\t//   * PersistentPreRun()\n\t//   * PreRun()\n\t//   * Run()\n\t//   * PostRun()\n\t//   * PersistentPostRun()\n\t// All functions get the same args, the arguments after the command name.\n\t//\n\t// PersistentPreRun: children of this command will inherit and execute.\n\tPersistentPreRun func(cmd *Command, args []string)\n\t// PersistentPreRunE: PersistentPreRun but returns an error.\n\tPersistentPreRunE func(cmd *Command, args []string) error\n\t// PreRun: children of this command will not inherit.\n\tPreRun func(cmd *Command, args []string)\n\t// PreRunE: PreRun but returns an error.\n\tPreRunE func(cmd *Command, args []string) error\n\t// Run: Typically the actual work function. Most commands will only implement this.\n\tRun func(cmd *Command, args []string)\n\t// RunE: Run but returns an error.\n\tRunE func(cmd *Command, args []string) error\n\t// PostRun: run after the Run command.\n\tPostRun func(cmd *Command, args []string)\n\t// PostRunE: PostRun but returns an error.\n\tPostRunE func(cmd *Command, args []string) error\n\t// PersistentPostRun: children of this command will inherit and execute after PostRun.\n\tPersistentPostRun func(cmd *Command, args []string)\n\t// PersistentPostRunE: PersistentPostRun but returns an error.\n\tPersistentPostRunE func(cmd *Command, args []string) error\n\n\t// SilenceErrors is an option to quiet errors down stream.\n\tSilenceErrors bool\n\n\t// SilenceUsage is an option to silence usage when an error occurs.\n\tSilenceUsage bool\n\n\t// DisableFlagParsing disables the flag parsing.\n\t// If this is true all flags will be passed to the command as arguments.\n\tDisableFlagParsing bool\n\n\t// DisableAutoGenTag defines, if gen tag (\"Auto generated by spf13/cobra...\")\n\t// will be printed by generating docs for this command.\n\tDisableAutoGenTag bool\n\n\t// DisableFlagsInUseLine will disable the addition of [flags] to the usage\n\t// line of a command when printing help or generating docs\n\tDisableFlagsInUseLine bool\n\n\t// DisableSuggestions disables the suggestions based on Levenshtein distance\n\t// that go along with 'unknown command' messages.\n\tDisableSuggestions bool\n\t// SuggestionsMinimumDistance defines minimum levenshtein distance to display suggestions.\n\t// Must be > 0.\n\tSuggestionsMinimumDistance int\n\n\t// TraverseChildren parses flags on all parents before executing child command.\n\tTraverseChildren bool\n\n\t// commands is the list of commands supported by this program.\n\tcommands []*Command\n\t// parent is a parent command for this command.\n\tparent *Command\n\t// Max lengths of commands' string lengths for use in padding.\n\tcommandsMaxUseLen         int\n\tcommandsMaxCommandPathLen int\n\tcommandsMaxNameLen        int\n\t// commandsAreSorted defines, if command slice are sorted or not.\n\tcommandsAreSorted bool\n\n\t// args is actual args parsed from flags.\n\targs []string\n\t// flagErrorBuf contains all error messages from pflag.\n\tflagErrorBuf *bytes.Buffer\n\t// flags is full set of flags.\n\tflags *flag.FlagSet\n\t// pflags contains persistent flags.\n\tpflags *flag.FlagSet\n\t// lflags contains local flags.\n\tlflags *flag.FlagSet\n\t// iflags contains inherited flags.\n\tiflags *flag.FlagSet\n\t// parentsPflags is all persistent flags of cmd's parents.\n\tparentsPflags *flag.FlagSet\n\t// globNormFunc is the global normalization function\n\t// that we can use on every pflag set and children commands\n\tglobNormFunc func(f *flag.FlagSet, name string) flag.NormalizedName\n\n\t// output is an output writer defined by user.\n\toutput io.Writer\n\t// usageFunc is usage func defined by user.\n\tusageFunc func(*Command) error\n\t// usageTemplate is usage template defined by user.\n\tusageTemplate string\n\t// flagErrorFunc is func defined by user and it's called when the parsing of\n\t// flags returns an error.\n\tflagErrorFunc func(*Command, error) error\n\t// helpTemplate is help template defined by user.\n\thelpTemplate string\n\t// helpFunc is help func defined by user.\n\thelpFunc func(*Command, []string)\n\t// helpCommand is command with usage 'help'. If it's not defined by user,\n\t// cobra uses default help command.\n\thelpCommand *Command\n\t// versionTemplate is the version template defined by user.\n\tversionTemplate string\n}\n\n// SetArgs sets arguments for the command. It is set to os.Args[1:] by default, if desired, can be overridden\n// particularly useful when testing.\nfunc (c *Command) SetArgs(a []string) {\n\tc.args = a\n}\n\n// SetOutput sets the destination for usage and error messages.\n// If output is nil, os.Stderr is used.\nfunc (c *Command) SetOutput(output io.Writer) {\n\tc.output = output\n}\n\n// SetUsageFunc sets usage function. Usage can be defined by application.\nfunc (c *Command) SetUsageFunc(f func(*Command) error) {\n\tc.usageFunc = f\n}\n\n// SetUsageTemplate sets usage template. Can be defined by Application.\nfunc (c *Command) SetUsageTemplate(s string) {\n\tc.usageTemplate = s\n}\n\n// SetFlagErrorFunc sets a function to generate an error when flag parsing\n// fails.\nfunc (c *Command) SetFlagErrorFunc(f func(*Command, error) error) {\n\tc.flagErrorFunc = f\n}\n\n// SetHelpFunc sets help function. Can be defined by Application.\nfunc (c *Command) SetHelpFunc(f func(*Command, []string)) {\n\tc.helpFunc = f\n}\n\n// SetHelpCommand sets help command.\nfunc (c *Command) SetHelpCommand(cmd *Command) {\n\tc.helpCommand = cmd\n}\n\n// SetHelpTemplate sets help template to be used. Application can use it to set custom template.\nfunc (c *Command) SetHelpTemplate(s string) {\n\tc.helpTemplate = s\n}\n\n// SetVersionTemplate sets version template to be used. Application can use it to set custom template.\nfunc (c *Command) SetVersionTemplate(s string) {\n\tc.versionTemplate = s\n}\n\n// SetGlobalNormalizationFunc sets a normalization function to all flag sets and also to child commands.\n// The user should not have a cyclic dependency on commands.\nfunc (c *Command) SetGlobalNormalizationFunc(n func(f *flag.FlagSet, name string) flag.NormalizedName) {\n\tc.Flags().SetNormalizeFunc(n)\n\tc.PersistentFlags().SetNormalizeFunc(n)\n\tc.globNormFunc = n\n\n\tfor _, command := range c.commands {\n\t\tcommand.SetGlobalNormalizationFunc(n)\n\t}\n}\n\n// OutOrStdout returns output to stdout.\nfunc (c *Command) OutOrStdout() io.Writer {\n\treturn c.getOut(os.Stdout)\n}\n\n// OutOrStderr returns output to stderr\nfunc (c *Command) OutOrStderr() io.Writer {\n\treturn c.getOut(os.Stderr)\n}\n\nfunc (c *Command) getOut(def io.Writer) io.Writer {\n\tif c.output != nil {\n\t\treturn c.output\n\t}\n\tif c.HasParent() {\n\t\treturn c.parent.getOut(def)\n\t}\n\treturn def\n}\n\n// UsageFunc returns either the function set by SetUsageFunc for this command\n// or a parent, or it returns a default usage function.\nfunc (c *Command) UsageFunc() (f func(*Command) error) {\n\tif c.usageFunc != nil {\n\t\treturn c.usageFunc\n\t}\n\tif c.HasParent() {\n\t\treturn c.Parent().UsageFunc()\n\t}\n\treturn func(c *Command) error {\n\t\tc.mergePersistentFlags()\n\t\terr := tmpl(c.OutOrStderr(), c.UsageTemplate(), c)\n\t\tif err != nil {\n\t\t\tc.Println(err)\n\t\t}\n\t\treturn err\n\t}\n}\n\n// Usage puts out the usage for the command.\n// Used when a user provides invalid input.\n// Can be defined by user by overriding UsageFunc.\nfunc (c *Command) Usage() error {\n\treturn c.UsageFunc()(c)\n}\n\n// HelpFunc returns either the function set by SetHelpFunc for this command\n// or a parent, or it returns a function with default help behavior.\nfunc (c *Command) HelpFunc() func(*Command, []string) {\n\tif c.helpFunc != nil {\n\t\treturn c.helpFunc\n\t}\n\tif c.HasParent() {\n\t\treturn c.Parent().HelpFunc()\n\t}\n\treturn func(c *Command, a []string) {\n\t\tc.mergePersistentFlags()\n\t\terr := tmpl(c.OutOrStdout(), c.HelpTemplate(), c)\n\t\tif err != nil {\n\t\t\tc.Println(err)\n\t\t}\n\t}\n}\n\n// Help puts out the help for the command.\n// Used when a user calls help [command].\n// Can be defined by user by overriding HelpFunc.\nfunc (c *Command) Help() error {\n\tc.HelpFunc()(c, []string{})\n\treturn nil\n}\n\n// UsageString return usage string.\nfunc (c *Command) UsageString() string {\n\ttmpOutput := c.output\n\tbb := new(bytes.Buffer)\n\tc.SetOutput(bb)\n\tc.Usage()\n\tc.output = tmpOutput\n\treturn bb.String()\n}\n\n// FlagErrorFunc returns either the function set by SetFlagErrorFunc for this\n// command or a parent, or it returns a function which returns the original\n// error.\nfunc (c *Command) FlagErrorFunc() (f func(*Command, error) error) {\n\tif c.flagErrorFunc != nil {\n\t\treturn c.flagErrorFunc\n\t}\n\n\tif c.HasParent() {\n\t\treturn c.parent.FlagErrorFunc()\n\t}\n\treturn func(c *Command, err error) error {\n\t\treturn err\n\t}\n}\n\nvar minUsagePadding = 25\n\n// UsagePadding return padding for the usage.\nfunc (c *Command) UsagePadding() int {\n\tif c.parent == nil || minUsagePadding > c.parent.commandsMaxUseLen {\n\t\treturn minUsagePadding\n\t}\n\treturn c.parent.commandsMaxUseLen\n}\n\nvar minCommandPathPadding = 11\n\n// CommandPathPadding return padding for the command path.\nfunc (c *Command) CommandPathPadding() int {\n\tif c.parent == nil || minCommandPathPadding > c.parent.commandsMaxCommandPathLen {\n\t\treturn minCommandPathPadding\n\t}\n\treturn c.parent.commandsMaxCommandPathLen\n}\n\nvar minNamePadding = 11\n\n// NamePadding returns padding for the name.\nfunc (c *Command) NamePadding() int {\n\tif c.parent == nil || minNamePadding > c.parent.commandsMaxNameLen {\n\t\treturn minNamePadding\n\t}\n\treturn c.parent.commandsMaxNameLen\n}\n\n// UsageTemplate returns usage template for the command.\nfunc (c *Command) UsageTemplate() string {\n\tif c.usageTemplate != \"\" {\n\t\treturn c.usageTemplate\n\t}\n\n\tif c.HasParent() {\n\t\treturn c.parent.UsageTemplate()\n\t}\n\treturn `Usage:{{if .Runnable}}\n  {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}\n  {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}\n\nAliases:\n  {{.NameAndAliases}}{{end}}{{if .HasExample}}\n\nExamples:\n{{.Example}}{{end}}{{if .HasAvailableSubCommands}}\n\nAvailable Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name \"help\"))}}\n  {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}\n\nFlags:\n{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}\n\nGlobal Flags:\n{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}\n\nAdditional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}\n  {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}\n\nUse \"{{.CommandPath}} [command] --help\" for more information about a command.{{end}}\n`\n}\n\n// HelpTemplate return help template for the command.\nfunc (c *Command) HelpTemplate() string {\n\tif c.helpTemplate != \"\" {\n\t\treturn c.helpTemplate\n\t}\n\n\tif c.HasParent() {\n\t\treturn c.parent.HelpTemplate()\n\t}\n\treturn `{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}}\n\n{{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}`\n}\n\n// VersionTemplate return version template for the command.\nfunc (c *Command) VersionTemplate() string {\n\tif c.versionTemplate != \"\" {\n\t\treturn c.versionTemplate\n\t}\n\n\tif c.HasParent() {\n\t\treturn c.parent.VersionTemplate()\n\t}\n\treturn `{{with .Name}}{{printf \"%s \" .}}{{end}}{{printf \"version %s\" .Version}}\n`\n}\n\nfunc hasNoOptDefVal(name string, fs *flag.FlagSet) bool {\n\tflag := fs.Lookup(name)\n\tif flag == nil {\n\t\treturn false\n\t}\n\treturn flag.NoOptDefVal != \"\"\n}\n\nfunc shortHasNoOptDefVal(name string, fs *flag.FlagSet) bool {\n\tif len(name) == 0 {\n\t\treturn false\n\t}\n\n\tflag := fs.ShorthandLookup(name[:1])\n\tif flag == nil {\n\t\treturn false\n\t}\n\treturn flag.NoOptDefVal != \"\"\n}\n\nfunc stripFlags(args []string, c *Command) []string {\n\tif len(args) == 0 {\n\t\treturn args\n\t}\n\tc.mergePersistentFlags()\n\n\tcommands := []string{}\n\tflags := c.Flags()\n\nLoop:\n\tfor len(args) > 0 {\n\t\ts := args[0]\n\t\targs = args[1:]\n\t\tswitch {\n\t\tcase strings.HasPrefix(s, \"--\") && !strings.Contains(s, \"=\") && !hasNoOptDefVal(s[2:], flags):\n\t\t\t// If '--flag arg' then\n\t\t\t// delete arg from args.\n\t\t\tfallthrough // (do the same as below)\n\t\tcase strings.HasPrefix(s, \"-\") && !strings.Contains(s, \"=\") && len(s) == 2 && !shortHasNoOptDefVal(s[1:], flags):\n\t\t\t// If '-f arg' then\n\t\t\t// delete 'arg' from args or break the loop if len(args) <= 1.\n\t\t\tif len(args) <= 1 {\n\t\t\t\tbreak Loop\n\t\t\t} else {\n\t\t\t\targs = args[1:]\n\t\t\t\tcontinue\n\t\t\t}\n\t\tcase s != \"\" && !strings.HasPrefix(s, \"-\"):\n\t\t\tcommands = append(commands, s)\n\t\t}\n\t}\n\n\treturn commands\n}\n\n// argsMinusFirstX removes only the first x from args.  Otherwise, commands that look like\n// openshift admin policy add-role-to-user admin my-user, lose the admin argument (arg[4]).\nfunc argsMinusFirstX(args []string, x string) []string {\n\tfor i, y := range args {\n\t\tif x == y {\n\t\t\tret := []string{}\n\t\t\tret = append(ret, args[:i]...)\n\t\t\tret = append(ret, args[i+1:]...)\n\t\t\treturn ret\n\t\t}\n\t}\n\treturn args\n}\n\nfunc isFlagArg(arg string) bool {\n\treturn ((len(arg) >= 3 && arg[1] == '-') ||\n\t\t(len(arg) >= 2 && arg[0] == '-' && arg[1] != '-'))\n}\n\n// Find the target command given the args and command tree\n// Meant to be run on the highest node. Only searches down.\nfunc (c *Command) Find(args []string) (*Command, []string, error) {\n\tvar innerfind func(*Command, []string) (*Command, []string)\n\n\tinnerfind = func(c *Command, innerArgs []string) (*Command, []string) {\n\t\targsWOflags := stripFlags(innerArgs, c)\n\t\tif len(argsWOflags) == 0 {\n\t\t\treturn c, innerArgs\n\t\t}\n\t\tnextSubCmd := argsWOflags[0]\n\n\t\tcmd := c.findNext(nextSubCmd)\n\t\tif cmd != nil {\n\t\t\treturn innerfind(cmd, argsMinusFirstX(innerArgs, nextSubCmd))\n\t\t}\n\t\treturn c, innerArgs\n\t}\n\n\tcommandFound, a := innerfind(c, args)\n\tif commandFound.Args == nil {\n\t\treturn commandFound, a, legacyArgs(commandFound, stripFlags(a, commandFound))\n\t}\n\treturn commandFound, a, nil\n}\n\nfunc (c *Command) findSuggestions(arg string) string {\n\tif c.DisableSuggestions {\n\t\treturn \"\"\n\t}\n\tif c.SuggestionsMinimumDistance <= 0 {\n\t\tc.SuggestionsMinimumDistance = 2\n\t}\n\tsuggestionsString := \"\"\n\tif suggestions := c.SuggestionsFor(arg); len(suggestions) > 0 {\n\t\tsuggestionsString += \"\\n\\nDid you mean this?\\n\"\n\t\tfor _, s := range suggestions {\n\t\t\tsuggestionsString += fmt.Sprintf(\"\\t%v\\n\", s)\n\t\t}\n\t}\n\treturn suggestionsString\n}\n\nfunc (c *Command) findNext(next string) *Command {\n\tmatches := make([]*Command, 0)\n\tfor _, cmd := range c.commands {\n\t\tif cmd.Name() == next || cmd.HasAlias(next) {\n\t\t\treturn cmd\n\t\t}\n\t\tif EnablePrefixMatching && cmd.hasNameOrAliasPrefix(next) {\n\t\t\tmatches = append(matches, cmd)\n\t\t}\n\t}\n\n\tif len(matches) == 1 {\n\t\treturn matches[0]\n\t}\n\treturn nil\n}\n\n// Traverse the command tree to find the command, and parse args for\n// each parent.\nfunc (c *Command) Traverse(args []string) (*Command, []string, error) {\n\tflags := []string{}\n\tinFlag := false\n\n\tfor i, arg := range args {\n\t\tswitch {\n\t\t// A long flag with a space separated value\n\t\tcase strings.HasPrefix(arg, \"--\") && !strings.Contains(arg, \"=\"):\n\t\t\t// TODO: this isn't quite right, we should really check ahead for 'true' or 'false'\n\t\t\tinFlag = !hasNoOptDefVal(arg[2:], c.Flags())\n\t\t\tflags = append(flags, arg)\n\t\t\tcontinue\n\t\t// A short flag with a space separated value\n\t\tcase strings.HasPrefix(arg, \"-\") && !strings.Contains(arg, \"=\") && len(arg) == 2 && !shortHasNoOptDefVal(arg[1:], c.Flags()):\n\t\t\tinFlag = true\n\t\t\tflags = append(flags, arg)\n\t\t\tcontinue\n\t\t// The value for a flag\n\t\tcase inFlag:\n\t\t\tinFlag = false\n\t\t\tflags = append(flags, arg)\n\t\t\tcontinue\n\t\t// A flag without a value, or with an `=` separated value\n\t\tcase isFlagArg(arg):\n\t\t\tflags = append(flags, arg)\n\t\t\tcontinue\n\t\t}\n\n\t\tcmd := c.findNext(arg)\n\t\tif cmd == nil {\n\t\t\treturn c, args, nil\n\t\t}\n\n\t\tif err := c.ParseFlags(flags); err != nil {\n\t\t\treturn nil, args, err\n\t\t}\n\t\treturn cmd.Traverse(args[i+1:])\n\t}\n\treturn c, args, nil\n}\n\n// SuggestionsFor provides suggestions for the typedName.\nfunc (c *Command) SuggestionsFor(typedName string) []string {\n\tsuggestions := []string{}\n\tfor _, cmd := range c.commands {\n\t\tif cmd.IsAvailableCommand() {\n\t\t\tlevenshteinDistance := ld(typedName, cmd.Name(), true)\n\t\t\tsuggestByLevenshtein := levenshteinDistance <= c.SuggestionsMinimumDistance\n\t\t\tsuggestByPrefix := strings.HasPrefix(strings.ToLower(cmd.Name()), strings.ToLower(typedName))\n\t\t\tif suggestByLevenshtein || suggestByPrefix {\n\t\t\t\tsuggestions = append(suggestions, cmd.Name())\n\t\t\t}\n\t\t\tfor _, explicitSuggestion := range cmd.SuggestFor {\n\t\t\t\tif strings.EqualFold(typedName, explicitSuggestion) {\n\t\t\t\t\tsuggestions = append(suggestions, cmd.Name())\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn suggestions\n}\n\n// VisitParents visits all parents of the command and invokes fn on each parent.\nfunc (c *Command) VisitParents(fn func(*Command)) {\n\tif c.HasParent() {\n\t\tfn(c.Parent())\n\t\tc.Parent().VisitParents(fn)\n\t}\n}\n\n// Root finds root command.\nfunc (c *Command) Root() *Command {\n\tif c.HasParent() {\n\t\treturn c.Parent().Root()\n\t}\n\treturn c\n}\n\n// ArgsLenAtDash will return the length of c.Flags().Args at the moment\n// when a -- was found during args parsing.\nfunc (c *Command) ArgsLenAtDash() int {\n\treturn c.Flags().ArgsLenAtDash()\n}\n\nfunc (c *Command) execute(a []string) (err error) {\n\tif c == nil {\n\t\treturn fmt.Errorf(\"Called Execute() on a nil Command\")\n\t}\n\n\tif len(c.Deprecated) > 0 {\n\t\tc.Printf(\"Command %q is deprecated, %s\\n\", c.Name(), c.Deprecated)\n\t}\n\n\t// initialize help and version flag at the last point possible to allow for user\n\t// overriding\n\tc.InitDefaultHelpFlag()\n\tc.InitDefaultVersionFlag()\n\n\terr = c.ParseFlags(a)\n\tif err != nil {\n\t\treturn c.FlagErrorFunc()(c, err)\n\t}\n\n\t// If help is called, regardless of other flags, return we want help.\n\t// Also say we need help if the command isn't runnable.\n\thelpVal, err := c.Flags().GetBool(\"help\")\n\tif err != nil {\n\t\t// should be impossible to get here as we always declare a help\n\t\t// flag in InitDefaultHelpFlag()\n\t\tc.Println(\"\\\"help\\\" flag declared as non-bool. Please correct your code\")\n\t\treturn err\n\t}\n\n\tif helpVal {\n\t\treturn flag.ErrHelp\n\t}\n\n\t// for back-compat, only add version flag behavior if version is defined\n\tif c.Version != \"\" {\n\t\tversionVal, err := c.Flags().GetBool(\"version\")\n\t\tif err != nil {\n\t\t\tc.Println(\"\\\"version\\\" flag declared as non-bool. Please correct your code\")\n\t\t\treturn err\n\t\t}\n\t\tif versionVal {\n\t\t\terr := tmpl(c.OutOrStdout(), c.VersionTemplate(), c)\n\t\t\tif err != nil {\n\t\t\t\tc.Println(err)\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif !c.Runnable() {\n\t\treturn flag.ErrHelp\n\t}\n\n\tc.preRun()\n\n\targWoFlags := c.Flags().Args()\n\tif c.DisableFlagParsing {\n\t\targWoFlags = a\n\t}\n\n\tif err := c.ValidateArgs(argWoFlags); err != nil {\n\t\treturn err\n\t}\n\n\tfor p := c; p != nil; p = p.Parent() {\n\t\tif p.PersistentPreRunE != nil {\n\t\t\tif err := p.PersistentPreRunE(c, argWoFlags); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tbreak\n\t\t} else if p.PersistentPreRun != nil {\n\t\t\tp.PersistentPreRun(c, argWoFlags)\n\t\t\tbreak\n\t\t}\n\t}\n\tif c.PreRunE != nil {\n\t\tif err := c.PreRunE(c, argWoFlags); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else if c.PreRun != nil {\n\t\tc.PreRun(c, argWoFlags)\n\t}\n\n\tif err := c.validateRequiredFlags(); err != nil {\n\t\treturn err\n\t}\n\tif c.RunE != nil {\n\t\tif err := c.RunE(c, argWoFlags); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tc.Run(c, argWoFlags)\n\t}\n\tif c.PostRunE != nil {\n\t\tif err := c.PostRunE(c, argWoFlags); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else if c.PostRun != nil {\n\t\tc.PostRun(c, argWoFlags)\n\t}\n\tfor p := c; p != nil; p = p.Parent() {\n\t\tif p.PersistentPostRunE != nil {\n\t\t\tif err := p.PersistentPostRunE(c, argWoFlags); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tbreak\n\t\t} else if p.PersistentPostRun != nil {\n\t\t\tp.PersistentPostRun(c, argWoFlags)\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (c *Command) preRun() {\n\tfor _, x := range initializers {\n\t\tx()\n\t}\n}\n\n// Execute uses the args (os.Args[1:] by default)\n// and run through the command tree finding appropriate matches\n// for commands and then corresponding flags.\nfunc (c *Command) Execute() error {\n\t_, err := c.ExecuteC()\n\treturn err\n}\n\n// ExecuteC executes the command.\nfunc (c *Command) ExecuteC() (cmd *Command, err error) {\n\t// Regardless of what command execute is called on, run on Root only\n\tif c.HasParent() {\n\t\treturn c.Root().ExecuteC()\n\t}\n\n\t// windows hook\n\tif preExecHookFn != nil {\n\t\tpreExecHookFn(c)\n\t}\n\n\t// initialize help as the last point possible to allow for user\n\t// overriding\n\tc.InitDefaultHelpCmd()\n\n\tvar args []string\n\n\t// Workaround FAIL with \"go test -v\" or \"cobra.test -test.v\", see #155\n\tif c.args == nil && filepath.Base(os.Args[0]) != \"cobra.test\" {\n\t\targs = os.Args[1:]\n\t} else {\n\t\targs = c.args\n\t}\n\n\tvar flags []string\n\tif c.TraverseChildren {\n\t\tcmd, flags, err = c.Traverse(args)\n\t} else {\n\t\tcmd, flags, err = c.Find(args)\n\t}\n\tif err != nil {\n\t\t// If found parse to a subcommand and then failed, talk about the subcommand\n\t\tif cmd != nil {\n\t\t\tc = cmd\n\t\t}\n\t\tif !c.SilenceErrors {\n\t\t\tc.Println(\"Error:\", err.Error())\n\t\t\tc.Printf(\"Run '%v --help' for usage.\\n\", c.CommandPath())\n\t\t}\n\t\treturn c, err\n\t}\n\n\terr = cmd.execute(flags)\n\tif err != nil {\n\t\t// Always show help if requested, even if SilenceErrors is in\n\t\t// effect\n\t\tif err == flag.ErrHelp {\n\t\t\tcmd.HelpFunc()(cmd, args)\n\t\t\treturn cmd, nil\n\t\t}\n\n\t\t// If root command has SilentErrors flagged,\n\t\t// all subcommands should respect it\n\t\tif !cmd.SilenceErrors && !c.SilenceErrors {\n\t\t\tc.Println(\"Error:\", err.Error())\n\t\t}\n\n\t\t// If root command has SilentUsage flagged,\n\t\t// all subcommands should respect it\n\t\tif !cmd.SilenceUsage && !c.SilenceUsage {\n\t\t\tc.Println(cmd.UsageString())\n\t\t}\n\t}\n\treturn cmd, err\n}\n\nfunc (c *Command) ValidateArgs(args []string) error {\n\tif c.Args == nil {\n\t\treturn nil\n\t}\n\treturn c.Args(c, args)\n}\n\nfunc (c *Command) validateRequiredFlags() error {\n\tflags := c.Flags()\n\tmissingFlagNames := []string{}\n\tflags.VisitAll(func(pflag *flag.Flag) {\n\t\trequiredAnnotation, found := pflag.Annotations[BashCompOneRequiredFlag]\n\t\tif !found {\n\t\t\treturn\n\t\t}\n\t\tif (requiredAnnotation[0] == \"true\") && !pflag.Changed {\n\t\t\tmissingFlagNames = append(missingFlagNames, pflag.Name)\n\t\t}\n\t})\n\n\tif len(missingFlagNames) > 0 {\n\t\treturn fmt.Errorf(`required flag(s) \"%s\" not set`, strings.Join(missingFlagNames, `\", \"`))\n\t}\n\treturn nil\n}\n\n// InitDefaultHelpFlag adds default help flag to c.\n// It is called automatically by executing the c or by calling help and usage.\n// If c already has help flag, it will do nothing.\nfunc (c *Command) InitDefaultHelpFlag() {\n\tc.mergePersistentFlags()\n\tif c.Flags().Lookup(\"help\") == nil {\n\t\tusage := \"help for \"\n\t\tif c.Name() == \"\" {\n\t\t\tusage += \"this command\"\n\t\t} else {\n\t\t\tusage += c.Name()\n\t\t}\n\t\tc.Flags().BoolP(\"help\", \"h\", false, usage)\n\t}\n}\n\n// InitDefaultVersionFlag adds default version flag to c.\n// It is called automatically by executing the c.\n// If c already has a version flag, it will do nothing.\n// If c.Version is empty, it will do nothing.\nfunc (c *Command) InitDefaultVersionFlag() {\n\tif c.Version == \"\" {\n\t\treturn\n\t}\n\n\tc.mergePersistentFlags()\n\tif c.Flags().Lookup(\"version\") == nil {\n\t\tusage := \"version for \"\n\t\tif c.Name() == \"\" {\n\t\t\tusage += \"this command\"\n\t\t} else {\n\t\t\tusage += c.Name()\n\t\t}\n\t\tc.Flags().Bool(\"version\", false, usage)\n\t}\n}\n\n// InitDefaultHelpCmd adds default help command to c.\n// It is called automatically by executing the c or by calling help and usage.\n// If c already has help command or c has no subcommands, it will do nothing.\nfunc (c *Command) InitDefaultHelpCmd() {\n\tif !c.HasSubCommands() {\n\t\treturn\n\t}\n\n\tif c.helpCommand == nil {\n\t\tc.helpCommand = &Command{\n\t\t\tUse:   \"help [command]\",\n\t\t\tShort: \"Help about any command\",\n\t\t\tLong: `Help provides help for any command in the application.\nSimply type ` + c.Name() + ` help [path to command] for full details.`,\n\n\t\t\tRun: func(c *Command, args []string) {\n\t\t\t\tcmd, _, e := c.Root().Find(args)\n\t\t\t\tif cmd == nil || e != nil {\n\t\t\t\t\tc.Printf(\"Unknown help topic %#q\\n\", args)\n\t\t\t\t\tc.Root().Usage()\n\t\t\t\t} else {\n\t\t\t\t\tcmd.InitDefaultHelpFlag() // make possible 'help' flag to be shown\n\t\t\t\t\tcmd.Help()\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t}\n\tc.RemoveCommand(c.helpCommand)\n\tc.AddCommand(c.helpCommand)\n}\n\n// ResetCommands delete parent, subcommand and help command from c.\nfunc (c *Command) ResetCommands() {\n\tc.parent = nil\n\tc.commands = nil\n\tc.helpCommand = nil\n\tc.parentsPflags = nil\n}\n\n// Sorts commands by their names.\ntype commandSorterByName []*Command\n\nfunc (c commandSorterByName) Len() int           { return len(c) }\nfunc (c commandSorterByName) Swap(i, j int)      { c[i], c[j] = c[j], c[i] }\nfunc (c commandSorterByName) Less(i, j int) bool { return c[i].Name() < c[j].Name() }\n\n// Commands returns a sorted slice of child commands.\nfunc (c *Command) Commands() []*Command {\n\t// do not sort commands if it already sorted or sorting was disabled\n\tif EnableCommandSorting && !c.commandsAreSorted {\n\t\tsort.Sort(commandSorterByName(c.commands))\n\t\tc.commandsAreSorted = true\n\t}\n\treturn c.commands\n}\n\n// AddCommand adds one or more commands to this parent command.\nfunc (c *Command) AddCommand(cmds ...*Command) {\n\tfor i, x := range cmds {\n\t\tif cmds[i] == c {\n\t\t\tpanic(\"Command can't be a child of itself\")\n\t\t}\n\t\tcmds[i].parent = c\n\t\t// update max lengths\n\t\tusageLen := len(x.Use)\n\t\tif usageLen > c.commandsMaxUseLen {\n\t\t\tc.commandsMaxUseLen = usageLen\n\t\t}\n\t\tcommandPathLen := len(x.CommandPath())\n\t\tif commandPathLen > c.commandsMaxCommandPathLen {\n\t\t\tc.commandsMaxCommandPathLen = commandPathLen\n\t\t}\n\t\tnameLen := len(x.Name())\n\t\tif nameLen > c.commandsMaxNameLen {\n\t\t\tc.commandsMaxNameLen = nameLen\n\t\t}\n\t\t// If global normalization function exists, update all children\n\t\tif c.globNormFunc != nil {\n\t\t\tx.SetGlobalNormalizationFunc(c.globNormFunc)\n\t\t}\n\t\tc.commands = append(c.commands, x)\n\t\tc.commandsAreSorted = false\n\t}\n}\n\n// RemoveCommand removes one or more commands from a parent command.\nfunc (c *Command) RemoveCommand(cmds ...*Command) {\n\tcommands := []*Command{}\nmain:\n\tfor _, command := range c.commands {\n\t\tfor _, cmd := range cmds {\n\t\t\tif command == cmd {\n\t\t\t\tcommand.parent = nil\n\t\t\t\tcontinue main\n\t\t\t}\n\t\t}\n\t\tcommands = append(commands, command)\n\t}\n\tc.commands = commands\n\t// recompute all lengths\n\tc.commandsMaxUseLen = 0\n\tc.commandsMaxCommandPathLen = 0\n\tc.commandsMaxNameLen = 0\n\tfor _, command := range c.commands {\n\t\tusageLen := len(command.Use)\n\t\tif usageLen > c.commandsMaxUseLen {\n\t\t\tc.commandsMaxUseLen = usageLen\n\t\t}\n\t\tcommandPathLen := len(command.CommandPath())\n\t\tif commandPathLen > c.commandsMaxCommandPathLen {\n\t\t\tc.commandsMaxCommandPathLen = commandPathLen\n\t\t}\n\t\tnameLen := len(command.Name())\n\t\tif nameLen > c.commandsMaxNameLen {\n\t\t\tc.commandsMaxNameLen = nameLen\n\t\t}\n\t}\n}\n\n// Print is a convenience method to Print to the defined output, fallback to Stderr if not set.\nfunc (c *Command) Print(i ...interface{}) {\n\tfmt.Fprint(c.OutOrStderr(), i...)\n}\n\n// Println is a convenience method to Println to the defined output, fallback to Stderr if not set.\nfunc (c *Command) Println(i ...interface{}) {\n\tc.Print(fmt.Sprintln(i...))\n}\n\n// Printf is a convenience method to Printf to the defined output, fallback to Stderr if not set.\nfunc (c *Command) Printf(format string, i ...interface{}) {\n\tc.Print(fmt.Sprintf(format, i...))\n}\n\n// CommandPath returns the full path to this command.\nfunc (c *Command) CommandPath() string {\n\tif c.HasParent() {\n\t\treturn c.Parent().CommandPath() + \" \" + c.Name()\n\t}\n\treturn c.Name()\n}\n\n// UseLine puts out the full usage for a given command (including parents).\nfunc (c *Command) UseLine() string {\n\tvar useline string\n\tif c.HasParent() {\n\t\tuseline = c.parent.CommandPath() + \" \" + c.Use\n\t} else {\n\t\tuseline = c.Use\n\t}\n\tif c.DisableFlagsInUseLine {\n\t\treturn useline\n\t}\n\tif c.HasAvailableFlags() && !strings.Contains(useline, \"[flags]\") {\n\t\tuseline += \" [flags]\"\n\t}\n\treturn useline\n}\n\n// DebugFlags used to determine which flags have been assigned to which commands\n// and which persist.\nfunc (c *Command) DebugFlags() {\n\tc.Println(\"DebugFlags called on\", c.Name())\n\tvar debugflags func(*Command)\n\n\tdebugflags = func(x *Command) {\n\t\tif x.HasFlags() || x.HasPersistentFlags() {\n\t\t\tc.Println(x.Name())\n\t\t}\n\t\tif x.HasFlags() {\n\t\t\tx.flags.VisitAll(func(f *flag.Flag) {\n\t\t\t\tif x.HasPersistentFlags() && x.persistentFlag(f.Name) != nil {\n\t\t\t\t\tc.Println(\"  -\"+f.Shorthand+\",\", \"--\"+f.Name, \"[\"+f.DefValue+\"]\", \"\", f.Value, \"  [LP]\")\n\t\t\t\t} else {\n\t\t\t\t\tc.Println(\"  -\"+f.Shorthand+\",\", \"--\"+f.Name, \"[\"+f.DefValue+\"]\", \"\", f.Value, \"  [L]\")\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tif x.HasPersistentFlags() {\n\t\t\tx.pflags.VisitAll(func(f *flag.Flag) {\n\t\t\t\tif x.HasFlags() {\n\t\t\t\t\tif x.flags.Lookup(f.Name) == nil {\n\t\t\t\t\t\tc.Println(\"  -\"+f.Shorthand+\",\", \"--\"+f.Name, \"[\"+f.DefValue+\"]\", \"\", f.Value, \"  [P]\")\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tc.Println(\"  -\"+f.Shorthand+\",\", \"--\"+f.Name, \"[\"+f.DefValue+\"]\", \"\", f.Value, \"  [P]\")\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tc.Println(x.flagErrorBuf)\n\t\tif x.HasSubCommands() {\n\t\t\tfor _, y := range x.commands {\n\t\t\t\tdebugflags(y)\n\t\t\t}\n\t\t}\n\t}\n\n\tdebugflags(c)\n}\n\n// Name returns the command's name: the first word in the use line.\nfunc (c *Command) Name() string {\n\tname := c.Use\n\ti := strings.Index(name, \" \")\n\tif i >= 0 {\n\t\tname = name[:i]\n\t}\n\treturn name\n}\n\n// HasAlias determines if a given string is an alias of the command.\nfunc (c *Command) HasAlias(s string) bool {\n\tfor _, a := range c.Aliases {\n\t\tif a == s {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// hasNameOrAliasPrefix returns true if the Name or any of aliases start\n// with prefix\nfunc (c *Command) hasNameOrAliasPrefix(prefix string) bool {\n\tif strings.HasPrefix(c.Name(), prefix) {\n\t\treturn true\n\t}\n\tfor _, alias := range c.Aliases {\n\t\tif strings.HasPrefix(alias, prefix) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// NameAndAliases returns a list of the command name and all aliases\nfunc (c *Command) NameAndAliases() string {\n\treturn strings.Join(append([]string{c.Name()}, c.Aliases...), \", \")\n}\n\n// HasExample determines if the command has example.\nfunc (c *Command) HasExample() bool {\n\treturn len(c.Example) > 0\n}\n\n// Runnable determines if the command is itself runnable.\nfunc (c *Command) Runnable() bool {\n\treturn c.Run != nil || c.RunE != nil\n}\n\n// HasSubCommands determines if the command has children commands.\nfunc (c *Command) HasSubCommands() bool {\n\treturn len(c.commands) > 0\n}\n\n// IsAvailableCommand determines if a command is available as a non-help command\n// (this includes all non deprecated/hidden commands).\nfunc (c *Command) IsAvailableCommand() bool {\n\tif len(c.Deprecated) != 0 || c.Hidden {\n\t\treturn false\n\t}\n\n\tif c.HasParent() && c.Parent().helpCommand == c {\n\t\treturn false\n\t}\n\n\tif c.Runnable() || c.HasAvailableSubCommands() {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n// IsAdditionalHelpTopicCommand determines if a command is an additional\n// help topic command; additional help topic command is determined by the\n// fact that it is NOT runnable/hidden/deprecated, and has no sub commands that\n// are runnable/hidden/deprecated.\n// Concrete example: https://github.com/spf13/cobra/issues/393#issuecomment-282741924.\nfunc (c *Command) IsAdditionalHelpTopicCommand() bool {\n\t// if a command is runnable, deprecated, or hidden it is not a 'help' command\n\tif c.Runnable() || len(c.Deprecated) != 0 || c.Hidden {\n\t\treturn false\n\t}\n\n\t// if any non-help sub commands are found, the command is not a 'help' command\n\tfor _, sub := range c.commands {\n\t\tif !sub.IsAdditionalHelpTopicCommand() {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// the command either has no sub commands, or no non-help sub commands\n\treturn true\n}\n\n// HasHelpSubCommands determines if a command has any available 'help' sub commands\n// that need to be shown in the usage/help default template under 'additional help\n// topics'.\nfunc (c *Command) HasHelpSubCommands() bool {\n\t// return true on the first found available 'help' sub command\n\tfor _, sub := range c.commands {\n\t\tif sub.IsAdditionalHelpTopicCommand() {\n\t\t\treturn true\n\t\t}\n\t}\n\n\t// the command either has no sub commands, or no available 'help' sub commands\n\treturn false\n}\n\n// HasAvailableSubCommands determines if a command has available sub commands that\n// need to be shown in the usage/help default template under 'available commands'.\nfunc (c *Command) HasAvailableSubCommands() bool {\n\t// return true on the first found available (non deprecated/help/hidden)\n\t// sub command\n\tfor _, sub := range c.commands {\n\t\tif sub.IsAvailableCommand() {\n\t\t\treturn true\n\t\t}\n\t}\n\n\t// the command either has no sub commands, or no available (non deprecated/help/hidden)\n\t// sub commands\n\treturn false\n}\n\n// HasParent determines if the command is a child command.\nfunc (c *Command) HasParent() bool {\n\treturn c.parent != nil\n}\n\n// GlobalNormalizationFunc returns the global normalization function or nil if doesn't exists.\nfunc (c *Command) GlobalNormalizationFunc() func(f *flag.FlagSet, name string) flag.NormalizedName {\n\treturn c.globNormFunc\n}\n\n// Flags returns the complete FlagSet that applies\n// to this command (local and persistent declared here and by all parents).\nfunc (c *Command) Flags() *flag.FlagSet {\n\tif c.flags == nil {\n\t\tc.flags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)\n\t\tif c.flagErrorBuf == nil {\n\t\t\tc.flagErrorBuf = new(bytes.Buffer)\n\t\t}\n\t\tc.flags.SetOutput(c.flagErrorBuf)\n\t}\n\n\treturn c.flags\n}\n\n// LocalNonPersistentFlags are flags specific to this command which will NOT persist to subcommands.\nfunc (c *Command) LocalNonPersistentFlags() *flag.FlagSet {\n\tpersistentFlags := c.PersistentFlags()\n\n\tout := flag.NewFlagSet(c.Name(), flag.ContinueOnError)\n\tc.LocalFlags().VisitAll(func(f *flag.Flag) {\n\t\tif persistentFlags.Lookup(f.Name) == nil {\n\t\t\tout.AddFlag(f)\n\t\t}\n\t})\n\treturn out\n}\n\n// LocalFlags returns the local FlagSet specifically set in the current command.\nfunc (c *Command) LocalFlags() *flag.FlagSet {\n\tc.mergePersistentFlags()\n\n\tif c.lflags == nil {\n\t\tc.lflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)\n\t\tif c.flagErrorBuf == nil {\n\t\t\tc.flagErrorBuf = new(bytes.Buffer)\n\t\t}\n\t\tc.lflags.SetOutput(c.flagErrorBuf)\n\t}\n\tc.lflags.SortFlags = c.Flags().SortFlags\n\tif c.globNormFunc != nil {\n\t\tc.lflags.SetNormalizeFunc(c.globNormFunc)\n\t}\n\n\taddToLocal := func(f *flag.Flag) {\n\t\tif c.lflags.Lookup(f.Name) == nil && c.parentsPflags.Lookup(f.Name) == nil {\n\t\t\tc.lflags.AddFlag(f)\n\t\t}\n\t}\n\tc.Flags().VisitAll(addToLocal)\n\tc.PersistentFlags().VisitAll(addToLocal)\n\treturn c.lflags\n}\n\n// InheritedFlags returns all flags which were inherited from parents commands.\nfunc (c *Command) InheritedFlags() *flag.FlagSet {\n\tc.mergePersistentFlags()\n\n\tif c.iflags == nil {\n\t\tc.iflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)\n\t\tif c.flagErrorBuf == nil {\n\t\t\tc.flagErrorBuf = new(bytes.Buffer)\n\t\t}\n\t\tc.iflags.SetOutput(c.flagErrorBuf)\n\t}\n\n\tlocal := c.LocalFlags()\n\tif c.globNormFunc != nil {\n\t\tc.iflags.SetNormalizeFunc(c.globNormFunc)\n\t}\n\n\tc.parentsPflags.VisitAll(func(f *flag.Flag) {\n\t\tif c.iflags.Lookup(f.Name) == nil && local.Lookup(f.Name) == nil {\n\t\t\tc.iflags.AddFlag(f)\n\t\t}\n\t})\n\treturn c.iflags\n}\n\n// NonInheritedFlags returns all flags which were not inherited from parent commands.\nfunc (c *Command) NonInheritedFlags() *flag.FlagSet {\n\treturn c.LocalFlags()\n}\n\n// PersistentFlags returns the persistent FlagSet specifically set in the current command.\nfunc (c *Command) PersistentFlags() *flag.FlagSet {\n\tif c.pflags == nil {\n\t\tc.pflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)\n\t\tif c.flagErrorBuf == nil {\n\t\t\tc.flagErrorBuf = new(bytes.Buffer)\n\t\t}\n\t\tc.pflags.SetOutput(c.flagErrorBuf)\n\t}\n\treturn c.pflags\n}\n\n// ResetFlags deletes all flags from command.\nfunc (c *Command) ResetFlags() {\n\tc.flagErrorBuf = new(bytes.Buffer)\n\tc.flagErrorBuf.Reset()\n\tc.flags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)\n\tc.flags.SetOutput(c.flagErrorBuf)\n\tc.pflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)\n\tc.pflags.SetOutput(c.flagErrorBuf)\n\n\tc.lflags = nil\n\tc.iflags = nil\n\tc.parentsPflags = nil\n}\n\n// HasFlags checks if the command contains any flags (local plus persistent from the entire structure).\nfunc (c *Command) HasFlags() bool {\n\treturn c.Flags().HasFlags()\n}\n\n// HasPersistentFlags checks if the command contains persistent flags.\nfunc (c *Command) HasPersistentFlags() bool {\n\treturn c.PersistentFlags().HasFlags()\n}\n\n// HasLocalFlags checks if the command has flags specifically declared locally.\nfunc (c *Command) HasLocalFlags() bool {\n\treturn c.LocalFlags().HasFlags()\n}\n\n// HasInheritedFlags checks if the command has flags inherited from its parent command.\nfunc (c *Command) HasInheritedFlags() bool {\n\treturn c.InheritedFlags().HasFlags()\n}\n\n// HasAvailableFlags checks if the command contains any flags (local plus persistent from the entire\n// structure) which are not hidden or deprecated.\nfunc (c *Command) HasAvailableFlags() bool {\n\treturn c.Flags().HasAvailableFlags()\n}\n\n// HasAvailablePersistentFlags checks if the command contains persistent flags which are not hidden or deprecated.\nfunc (c *Command) HasAvailablePersistentFlags() bool {\n\treturn c.PersistentFlags().HasAvailableFlags()\n}\n\n// HasAvailableLocalFlags checks if the command has flags specifically declared locally which are not hidden\n// or deprecated.\nfunc (c *Command) HasAvailableLocalFlags() bool {\n\treturn c.LocalFlags().HasAvailableFlags()\n}\n\n// HasAvailableInheritedFlags checks if the command has flags inherited from its parent command which are\n// not hidden or deprecated.\nfunc (c *Command) HasAvailableInheritedFlags() bool {\n\treturn c.InheritedFlags().HasAvailableFlags()\n}\n\n// Flag climbs up the command tree looking for matching flag.\nfunc (c *Command) Flag(name string) (flag *flag.Flag) {\n\tflag = c.Flags().Lookup(name)\n\n\tif flag == nil {\n\t\tflag = c.persistentFlag(name)\n\t}\n\n\treturn\n}\n\n// Recursively find matching persistent flag.\nfunc (c *Command) persistentFlag(name string) (flag *flag.Flag) {\n\tif c.HasPersistentFlags() {\n\t\tflag = c.PersistentFlags().Lookup(name)\n\t}\n\n\tif flag == nil {\n\t\tc.updateParentsPflags()\n\t\tflag = c.parentsPflags.Lookup(name)\n\t}\n\treturn\n}\n\n// ParseFlags parses persistent flag tree and local flags.\nfunc (c *Command) ParseFlags(args []string) error {\n\tif c.DisableFlagParsing {\n\t\treturn nil\n\t}\n\n\tif c.flagErrorBuf == nil {\n\t\tc.flagErrorBuf = new(bytes.Buffer)\n\t}\n\tbeforeErrorBufLen := c.flagErrorBuf.Len()\n\tc.mergePersistentFlags()\n\terr := c.Flags().Parse(args)\n\t// Print warnings if they occurred (e.g. deprecated flag messages).\n\tif c.flagErrorBuf.Len()-beforeErrorBufLen > 0 && err == nil {\n\t\tc.Print(c.flagErrorBuf.String())\n\t}\n\n\treturn err\n}\n\n// Parent returns a commands parent command.\nfunc (c *Command) Parent() *Command {\n\treturn c.parent\n}\n\n// mergePersistentFlags merges c.PersistentFlags() to c.Flags()\n// and adds missing persistent flags of all parents.\nfunc (c *Command) mergePersistentFlags() {\n\tc.updateParentsPflags()\n\tc.Flags().AddFlagSet(c.PersistentFlags())\n\tc.Flags().AddFlagSet(c.parentsPflags)\n}\n\n// updateParentsPflags updates c.parentsPflags by adding\n// new persistent flags of all parents.\n// If c.parentsPflags == nil, it makes new.\nfunc (c *Command) updateParentsPflags() {\n\tif c.parentsPflags == nil {\n\t\tc.parentsPflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)\n\t\tc.parentsPflags.SetOutput(c.flagErrorBuf)\n\t\tc.parentsPflags.SortFlags = false\n\t}\n\n\tif c.globNormFunc != nil {\n\t\tc.parentsPflags.SetNormalizeFunc(c.globNormFunc)\n\t}\n\n\tc.Root().PersistentFlags().AddFlagSet(flag.CommandLine)\n\n\tc.VisitParents(func(parent *Command) {\n\t\tc.parentsPflags.AddFlagSet(parent.PersistentFlags())\n\t})\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/command_notwin.go",
    "content": "// +build !windows\n\npackage cobra\n\nvar preExecHookFn func(*Command)\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/command_test.go",
    "content": "package cobra\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n\t\"reflect\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/spf13/pflag\"\n)\n\nfunc emptyRun(*Command, []string) {}\n\nfunc executeCommand(root *Command, args ...string) (output string, err error) {\n\t_, output, err = executeCommandC(root, args...)\n\treturn output, err\n}\n\nfunc executeCommandC(root *Command, args ...string) (c *Command, output string, err error) {\n\tbuf := new(bytes.Buffer)\n\troot.SetOutput(buf)\n\troot.SetArgs(args)\n\n\tc, err = root.ExecuteC()\n\n\treturn c, buf.String(), err\n}\n\nfunc resetCommandLineFlagSet() {\n\tpflag.CommandLine = pflag.NewFlagSet(os.Args[0], pflag.ExitOnError)\n}\n\nfunc checkStringContains(t *testing.T, got, expected string) {\n\tif !strings.Contains(got, expected) {\n\t\tt.Errorf(\"Expected to contain: \\n %v\\nGot:\\n %v\\n\", expected, got)\n\t}\n}\n\nfunc checkStringOmits(t *testing.T, got, expected string) {\n\tif strings.Contains(got, expected) {\n\t\tt.Errorf(\"Expected to not contain: \\n %v\\nGot: %v\", expected, got)\n\t}\n}\n\nfunc TestSingleCommand(t *testing.T) {\n\tvar rootCmdArgs []string\n\trootCmd := &Command{\n\t\tUse:  \"root\",\n\t\tArgs: ExactArgs(2),\n\t\tRun:  func(_ *Command, args []string) { rootCmdArgs = args },\n\t}\n\taCmd := &Command{Use: \"a\", Args: NoArgs, Run: emptyRun}\n\tbCmd := &Command{Use: \"b\", Args: NoArgs, Run: emptyRun}\n\trootCmd.AddCommand(aCmd, bCmd)\n\n\toutput, err := executeCommand(rootCmd, \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tgot := strings.Join(rootCmdArgs, \" \")\n\texpected := \"one two\"\n\tif got != expected {\n\t\tt.Errorf(\"rootCmdArgs expected: %q, got: %q\", expected, got)\n\t}\n}\n\nfunc TestChildCommand(t *testing.T) {\n\tvar child1CmdArgs []string\n\trootCmd := &Command{Use: \"root\", Args: NoArgs, Run: emptyRun}\n\tchild1Cmd := &Command{\n\t\tUse:  \"child1\",\n\t\tArgs: ExactArgs(2),\n\t\tRun:  func(_ *Command, args []string) { child1CmdArgs = args },\n\t}\n\tchild2Cmd := &Command{Use: \"child2\", Args: NoArgs, Run: emptyRun}\n\trootCmd.AddCommand(child1Cmd, child2Cmd)\n\n\toutput, err := executeCommand(rootCmd, \"child1\", \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tgot := strings.Join(child1CmdArgs, \" \")\n\texpected := \"one two\"\n\tif got != expected {\n\t\tt.Errorf(\"child1CmdArgs expected: %q, got: %q\", expected, got)\n\t}\n}\n\nfunc TestCallCommandWithoutSubcommands(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Args: NoArgs, Run: emptyRun}\n\t_, err := executeCommand(rootCmd)\n\tif err != nil {\n\t\tt.Errorf(\"Calling command without subcommands should not have error: %v\", err)\n\t}\n}\n\nfunc TestRootExecuteUnknownCommand(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\trootCmd.AddCommand(&Command{Use: \"child\", Run: emptyRun})\n\n\toutput, _ := executeCommand(rootCmd, \"unknown\")\n\n\texpected := \"Error: unknown command \\\"unknown\\\" for \\\"root\\\"\\nRun 'root --help' for usage.\\n\"\n\n\tif output != expected {\n\t\tt.Errorf(\"Expected:\\n %q\\nGot:\\n %q\\n\", expected, output)\n\t}\n}\n\nfunc TestSubcommandExecuteC(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tchildCmd := &Command{Use: \"child\", Run: emptyRun}\n\trootCmd.AddCommand(childCmd)\n\n\tc, output, err := executeCommandC(rootCmd, \"child\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tif c.Name() != \"child\" {\n\t\tt.Errorf(`invalid command returned from ExecuteC: expected \"child\"', got %q`, c.Name())\n\t}\n}\n\nfunc TestRootUnknownCommandSilenced(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\trootCmd.SilenceErrors = true\n\trootCmd.SilenceUsage = true\n\trootCmd.AddCommand(&Command{Use: \"child\", Run: emptyRun})\n\n\toutput, _ := executeCommand(rootCmd, \"unknown\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Expected blank output, because of silenced usage.\\nGot:\\n %q\\n\", output)\n\t}\n}\n\nfunc TestCommandAlias(t *testing.T) {\n\tvar timesCmdArgs []string\n\trootCmd := &Command{Use: \"root\", Args: NoArgs, Run: emptyRun}\n\techoCmd := &Command{\n\t\tUse:     \"echo\",\n\t\tAliases: []string{\"say\", \"tell\"},\n\t\tArgs:    NoArgs,\n\t\tRun:     emptyRun,\n\t}\n\ttimesCmd := &Command{\n\t\tUse:  \"times\",\n\t\tArgs: ExactArgs(2),\n\t\tRun:  func(_ *Command, args []string) { timesCmdArgs = args },\n\t}\n\techoCmd.AddCommand(timesCmd)\n\trootCmd.AddCommand(echoCmd)\n\n\toutput, err := executeCommand(rootCmd, \"tell\", \"times\", \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tgot := strings.Join(timesCmdArgs, \" \")\n\texpected := \"one two\"\n\tif got != expected {\n\t\tt.Errorf(\"timesCmdArgs expected: %v, got: %v\", expected, got)\n\t}\n}\n\nfunc TestEnablePrefixMatching(t *testing.T) {\n\tEnablePrefixMatching = true\n\n\tvar aCmdArgs []string\n\trootCmd := &Command{Use: \"root\", Args: NoArgs, Run: emptyRun}\n\taCmd := &Command{\n\t\tUse:  \"aCmd\",\n\t\tArgs: ExactArgs(2),\n\t\tRun:  func(_ *Command, args []string) { aCmdArgs = args },\n\t}\n\tbCmd := &Command{Use: \"bCmd\", Args: NoArgs, Run: emptyRun}\n\trootCmd.AddCommand(aCmd, bCmd)\n\n\toutput, err := executeCommand(rootCmd, \"a\", \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tgot := strings.Join(aCmdArgs, \" \")\n\texpected := \"one two\"\n\tif got != expected {\n\t\tt.Errorf(\"aCmdArgs expected: %q, got: %q\", expected, got)\n\t}\n\n\tEnablePrefixMatching = false\n}\n\nfunc TestAliasPrefixMatching(t *testing.T) {\n\tEnablePrefixMatching = true\n\n\tvar timesCmdArgs []string\n\trootCmd := &Command{Use: \"root\", Args: NoArgs, Run: emptyRun}\n\techoCmd := &Command{\n\t\tUse:     \"echo\",\n\t\tAliases: []string{\"say\", \"tell\"},\n\t\tArgs:    NoArgs,\n\t\tRun:     emptyRun,\n\t}\n\ttimesCmd := &Command{\n\t\tUse:  \"times\",\n\t\tArgs: ExactArgs(2),\n\t\tRun:  func(_ *Command, args []string) { timesCmdArgs = args },\n\t}\n\techoCmd.AddCommand(timesCmd)\n\trootCmd.AddCommand(echoCmd)\n\n\toutput, err := executeCommand(rootCmd, \"sa\", \"times\", \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tgot := strings.Join(timesCmdArgs, \" \")\n\texpected := \"one two\"\n\tif got != expected {\n\t\tt.Errorf(\"timesCmdArgs expected: %v, got: %v\", expected, got)\n\t}\n\n\tEnablePrefixMatching = false\n}\n\n// TestChildSameName checks the correct behaviour of cobra in cases,\n// when an application with name \"foo\" and with subcommand \"foo\"\n// is executed with args \"foo foo\".\nfunc TestChildSameName(t *testing.T) {\n\tvar fooCmdArgs []string\n\trootCmd := &Command{Use: \"foo\", Args: NoArgs, Run: emptyRun}\n\tfooCmd := &Command{\n\t\tUse:  \"foo\",\n\t\tArgs: ExactArgs(2),\n\t\tRun:  func(_ *Command, args []string) { fooCmdArgs = args },\n\t}\n\tbarCmd := &Command{Use: \"bar\", Args: NoArgs, Run: emptyRun}\n\trootCmd.AddCommand(fooCmd, barCmd)\n\n\toutput, err := executeCommand(rootCmd, \"foo\", \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tgot := strings.Join(fooCmdArgs, \" \")\n\texpected := \"one two\"\n\tif got != expected {\n\t\tt.Errorf(\"fooCmdArgs expected: %v, got: %v\", expected, got)\n\t}\n}\n\n// TestGrandChildSameName checks the correct behaviour of cobra in cases,\n// when user has a root command and a grand child\n// with the same name.\nfunc TestGrandChildSameName(t *testing.T) {\n\tvar fooCmdArgs []string\n\trootCmd := &Command{Use: \"foo\", Args: NoArgs, Run: emptyRun}\n\tbarCmd := &Command{Use: \"bar\", Args: NoArgs, Run: emptyRun}\n\tfooCmd := &Command{\n\t\tUse:  \"foo\",\n\t\tArgs: ExactArgs(2),\n\t\tRun:  func(_ *Command, args []string) { fooCmdArgs = args },\n\t}\n\tbarCmd.AddCommand(fooCmd)\n\trootCmd.AddCommand(barCmd)\n\n\toutput, err := executeCommand(rootCmd, \"bar\", \"foo\", \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tgot := strings.Join(fooCmdArgs, \" \")\n\texpected := \"one two\"\n\tif got != expected {\n\t\tt.Errorf(\"fooCmdArgs expected: %v, got: %v\", expected, got)\n\t}\n}\n\nfunc TestFlagLong(t *testing.T) {\n\tvar cArgs []string\n\tc := &Command{\n\t\tUse:  \"c\",\n\t\tArgs: ArbitraryArgs,\n\t\tRun:  func(_ *Command, args []string) { cArgs = args },\n\t}\n\n\tvar intFlagValue int\n\tvar stringFlagValue string\n\tc.Flags().IntVar(&intFlagValue, \"intf\", -1, \"\")\n\tc.Flags().StringVar(&stringFlagValue, \"sf\", \"\", \"\")\n\n\toutput, err := executeCommand(c, \"--intf=7\", \"--sf=abc\", \"one\", \"--\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", err)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tif c.ArgsLenAtDash() != 1 {\n\t\tt.Errorf(\"Expected ArgsLenAtDash: %v but got %v\", 1, c.ArgsLenAtDash())\n\t}\n\tif intFlagValue != 7 {\n\t\tt.Errorf(\"Expected intFlagValue: %v, got %v\", 7, intFlagValue)\n\t}\n\tif stringFlagValue != \"abc\" {\n\t\tt.Errorf(\"Expected stringFlagValue: %q, got %q\", \"abc\", stringFlagValue)\n\t}\n\n\tgot := strings.Join(cArgs, \" \")\n\texpected := \"one two\"\n\tif got != expected {\n\t\tt.Errorf(\"Expected arguments: %q, got %q\", expected, got)\n\t}\n}\n\nfunc TestFlagShort(t *testing.T) {\n\tvar cArgs []string\n\tc := &Command{\n\t\tUse:  \"c\",\n\t\tArgs: ArbitraryArgs,\n\t\tRun:  func(_ *Command, args []string) { cArgs = args },\n\t}\n\n\tvar intFlagValue int\n\tvar stringFlagValue string\n\tc.Flags().IntVarP(&intFlagValue, \"intf\", \"i\", -1, \"\")\n\tc.Flags().StringVarP(&stringFlagValue, \"sf\", \"s\", \"\", \"\")\n\n\toutput, err := executeCommand(c, \"-i\", \"7\", \"-sabc\", \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", err)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tif intFlagValue != 7 {\n\t\tt.Errorf(\"Expected flag value: %v, got %v\", 7, intFlagValue)\n\t}\n\tif stringFlagValue != \"abc\" {\n\t\tt.Errorf(\"Expected stringFlagValue: %q, got %q\", \"abc\", stringFlagValue)\n\t}\n\n\tgot := strings.Join(cArgs, \" \")\n\texpected := \"one two\"\n\tif got != expected {\n\t\tt.Errorf(\"Expected arguments: %q, got %q\", expected, got)\n\t}\n}\n\nfunc TestChildFlag(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tchildCmd := &Command{Use: \"child\", Run: emptyRun}\n\trootCmd.AddCommand(childCmd)\n\n\tvar intFlagValue int\n\tchildCmd.Flags().IntVarP(&intFlagValue, \"intf\", \"i\", -1, \"\")\n\n\toutput, err := executeCommand(rootCmd, \"child\", \"-i7\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", err)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tif intFlagValue != 7 {\n\t\tt.Errorf(\"Expected flag value: %v, got %v\", 7, intFlagValue)\n\t}\n}\n\nfunc TestChildFlagWithParentLocalFlag(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tchildCmd := &Command{Use: \"child\", Run: emptyRun}\n\trootCmd.AddCommand(childCmd)\n\n\tvar intFlagValue int\n\trootCmd.Flags().StringP(\"sf\", \"s\", \"\", \"\")\n\tchildCmd.Flags().IntVarP(&intFlagValue, \"intf\", \"i\", -1, \"\")\n\n\t_, err := executeCommand(rootCmd, \"child\", \"-i7\", \"-sabc\")\n\tif err == nil {\n\t\tt.Errorf(\"Invalid flag should generate error\")\n\t}\n\n\tcheckStringContains(t, err.Error(), \"unknown shorthand\")\n\n\tif intFlagValue != 7 {\n\t\tt.Errorf(\"Expected flag value: %v, got %v\", 7, intFlagValue)\n\t}\n}\n\nfunc TestFlagInvalidInput(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\trootCmd.Flags().IntP(\"intf\", \"i\", -1, \"\")\n\n\t_, err := executeCommand(rootCmd, \"-iabc\")\n\tif err == nil {\n\t\tt.Errorf(\"Invalid flag value should generate error\")\n\t}\n\n\tcheckStringContains(t, err.Error(), \"invalid syntax\")\n}\n\nfunc TestFlagBeforeCommand(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tchildCmd := &Command{Use: \"child\", Run: emptyRun}\n\trootCmd.AddCommand(childCmd)\n\n\tvar flagValue int\n\tchildCmd.Flags().IntVarP(&flagValue, \"intf\", \"i\", -1, \"\")\n\n\t// With short flag.\n\t_, err := executeCommand(rootCmd, \"-i7\", \"child\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\tif flagValue != 7 {\n\t\tt.Errorf(\"Expected flag value: %v, got %v\", 7, flagValue)\n\t}\n\n\t// With long flag.\n\t_, err = executeCommand(rootCmd, \"--intf=8\", \"child\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\tif flagValue != 8 {\n\t\tt.Errorf(\"Expected flag value: %v, got %v\", 9, flagValue)\n\t}\n}\n\nfunc TestStripFlags(t *testing.T) {\n\ttests := []struct {\n\t\tinput  []string\n\t\toutput []string\n\t}{\n\t\t{\n\t\t\t[]string{\"foo\", \"bar\"},\n\t\t\t[]string{\"foo\", \"bar\"},\n\t\t},\n\t\t{\n\t\t\t[]string{\"foo\", \"--str\", \"-s\"},\n\t\t\t[]string{\"foo\"},\n\t\t},\n\t\t{\n\t\t\t[]string{\"-s\", \"foo\", \"--str\", \"bar\"},\n\t\t\t[]string{},\n\t\t},\n\t\t{\n\t\t\t[]string{\"-i10\", \"echo\"},\n\t\t\t[]string{\"echo\"},\n\t\t},\n\t\t{\n\t\t\t[]string{\"-i=10\", \"echo\"},\n\t\t\t[]string{\"echo\"},\n\t\t},\n\t\t{\n\t\t\t[]string{\"--int=100\", \"echo\"},\n\t\t\t[]string{\"echo\"},\n\t\t},\n\t\t{\n\t\t\t[]string{\"-ib\", \"echo\", \"-sfoo\", \"baz\"},\n\t\t\t[]string{\"echo\", \"baz\"},\n\t\t},\n\t\t{\n\t\t\t[]string{\"-i=baz\", \"bar\", \"-i\", \"foo\", \"blah\"},\n\t\t\t[]string{\"bar\", \"blah\"},\n\t\t},\n\t\t{\n\t\t\t[]string{\"--int=baz\", \"-sbar\", \"-i\", \"foo\", \"blah\"},\n\t\t\t[]string{\"blah\"},\n\t\t},\n\t\t{\n\t\t\t[]string{\"--bool\", \"bar\", \"-i\", \"foo\", \"blah\"},\n\t\t\t[]string{\"bar\", \"blah\"},\n\t\t},\n\t\t{\n\t\t\t[]string{\"-b\", \"bar\", \"-i\", \"foo\", \"blah\"},\n\t\t\t[]string{\"bar\", \"blah\"},\n\t\t},\n\t\t{\n\t\t\t[]string{\"--persist\", \"bar\"},\n\t\t\t[]string{\"bar\"},\n\t\t},\n\t\t{\n\t\t\t[]string{\"-p\", \"bar\"},\n\t\t\t[]string{\"bar\"},\n\t\t},\n\t}\n\n\tc := &Command{Use: \"c\", Run: emptyRun}\n\tc.PersistentFlags().BoolP(\"persist\", \"p\", false, \"\")\n\tc.Flags().IntP(\"int\", \"i\", -1, \"\")\n\tc.Flags().StringP(\"str\", \"s\", \"\", \"\")\n\tc.Flags().BoolP(\"bool\", \"b\", false, \"\")\n\n\tfor i, test := range tests {\n\t\tgot := stripFlags(test.input, c)\n\t\tif !reflect.DeepEqual(test.output, got) {\n\t\t\tt.Errorf(\"(%v) Expected: %v, got: %v\", i, test.output, got)\n\t\t}\n\t}\n}\n\nfunc TestDisableFlagParsing(t *testing.T) {\n\tvar cArgs []string\n\tc := &Command{\n\t\tUse:                \"c\",\n\t\tDisableFlagParsing: true,\n\t\tRun: func(_ *Command, args []string) {\n\t\t\tcArgs = args\n\t\t},\n\t}\n\n\targs := []string{\"cmd\", \"-v\", \"-race\", \"-file\", \"foo.go\"}\n\toutput, err := executeCommand(c, args...)\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tif !reflect.DeepEqual(args, cArgs) {\n\t\tt.Errorf(\"Expected: %v, got: %v\", args, cArgs)\n\t}\n}\n\nfunc TestPersistentFlagsOnSameCommand(t *testing.T) {\n\tvar rootCmdArgs []string\n\trootCmd := &Command{\n\t\tUse:  \"root\",\n\t\tArgs: ArbitraryArgs,\n\t\tRun:  func(_ *Command, args []string) { rootCmdArgs = args },\n\t}\n\n\tvar flagValue int\n\trootCmd.PersistentFlags().IntVarP(&flagValue, \"intf\", \"i\", -1, \"\")\n\n\toutput, err := executeCommand(rootCmd, \"-i7\", \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tgot := strings.Join(rootCmdArgs, \" \")\n\texpected := \"one two\"\n\tif got != expected {\n\t\tt.Errorf(\"rootCmdArgs expected: %q, got %q\", expected, got)\n\t}\n\tif flagValue != 7 {\n\t\tt.Errorf(\"flagValue expected: %v, got %v\", 7, flagValue)\n\t}\n}\n\n// TestEmptyInputs checks,\n// if flags correctly parsed with blank strings in args.\nfunc TestEmptyInputs(t *testing.T) {\n\tc := &Command{Use: \"c\", Run: emptyRun}\n\n\tvar flagValue int\n\tc.Flags().IntVarP(&flagValue, \"intf\", \"i\", -1, \"\")\n\n\toutput, err := executeCommand(c, \"\", \"-i7\", \"\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tif flagValue != 7 {\n\t\tt.Errorf(\"flagValue expected: %v, got %v\", 7, flagValue)\n\t}\n}\n\nfunc TestOverwrittenFlag(t *testing.T) {\n\t// TODO: This test fails, but should work.\n\tt.Skip()\n\n\tparent := &Command{Use: \"parent\", Run: emptyRun}\n\tchild := &Command{Use: \"child\", Run: emptyRun}\n\n\tparent.PersistentFlags().Bool(\"boolf\", false, \"\")\n\tparent.PersistentFlags().Int(\"intf\", -1, \"\")\n\tchild.Flags().String(\"strf\", \"\", \"\")\n\tchild.Flags().Int(\"intf\", -1, \"\")\n\n\tparent.AddCommand(child)\n\n\tchildInherited := child.InheritedFlags()\n\tchildLocal := child.LocalFlags()\n\n\tif childLocal.Lookup(\"strf\") == nil {\n\t\tt.Error(`LocalFlags expected to contain \"strf\", got \"nil\"`)\n\t}\n\tif childInherited.Lookup(\"boolf\") == nil {\n\t\tt.Error(`InheritedFlags expected to contain \"boolf\", got \"nil\"`)\n\t}\n\n\tif childInherited.Lookup(\"intf\") != nil {\n\t\tt.Errorf(`InheritedFlags should not contain overwritten flag \"intf\"`)\n\t}\n\tif childLocal.Lookup(\"intf\") == nil {\n\t\tt.Error(`LocalFlags expected to contain \"intf\", got \"nil\"`)\n\t}\n}\n\nfunc TestPersistentFlagsOnChild(t *testing.T) {\n\tvar childCmdArgs []string\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tchildCmd := &Command{\n\t\tUse:  \"child\",\n\t\tArgs: ArbitraryArgs,\n\t\tRun:  func(_ *Command, args []string) { childCmdArgs = args },\n\t}\n\trootCmd.AddCommand(childCmd)\n\n\tvar parentFlagValue int\n\tvar childFlagValue int\n\trootCmd.PersistentFlags().IntVarP(&parentFlagValue, \"parentf\", \"p\", -1, \"\")\n\tchildCmd.Flags().IntVarP(&childFlagValue, \"childf\", \"c\", -1, \"\")\n\n\toutput, err := executeCommand(rootCmd, \"child\", \"-c7\", \"-p8\", \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tgot := strings.Join(childCmdArgs, \" \")\n\texpected := \"one two\"\n\tif got != expected {\n\t\tt.Errorf(\"childCmdArgs expected: %q, got %q\", expected, got)\n\t}\n\tif parentFlagValue != 8 {\n\t\tt.Errorf(\"parentFlagValue expected: %v, got %v\", 8, parentFlagValue)\n\t}\n\tif childFlagValue != 7 {\n\t\tt.Errorf(\"childFlagValue expected: %v, got %v\", 7, childFlagValue)\n\t}\n}\n\nfunc TestRequiredFlags(t *testing.T) {\n\tc := &Command{Use: \"c\", Run: emptyRun}\n\tc.Flags().String(\"foo1\", \"\", \"\")\n\tc.MarkFlagRequired(\"foo1\")\n\tc.Flags().String(\"foo2\", \"\", \"\")\n\tc.MarkFlagRequired(\"foo2\")\n\tc.Flags().String(\"bar\", \"\", \"\")\n\n\texpected := fmt.Sprintf(\"required flag(s) %q, %q not set\", \"foo1\", \"foo2\")\n\n\t_, err := executeCommand(c)\n\tgot := err.Error()\n\n\tif got != expected {\n\t\tt.Errorf(\"Expected error: %q, got: %q\", expected, got)\n\t}\n}\n\nfunc TestPersistentRequiredFlags(t *testing.T) {\n\tparent := &Command{Use: \"parent\", Run: emptyRun}\n\tparent.PersistentFlags().String(\"foo1\", \"\", \"\")\n\tparent.MarkPersistentFlagRequired(\"foo1\")\n\tparent.PersistentFlags().String(\"foo2\", \"\", \"\")\n\tparent.MarkPersistentFlagRequired(\"foo2\")\n\tparent.Flags().String(\"foo3\", \"\", \"\")\n\n\tchild := &Command{Use: \"child\", Run: emptyRun}\n\tchild.Flags().String(\"bar1\", \"\", \"\")\n\tchild.MarkFlagRequired(\"bar1\")\n\tchild.Flags().String(\"bar2\", \"\", \"\")\n\tchild.MarkFlagRequired(\"bar2\")\n\tchild.Flags().String(\"bar3\", \"\", \"\")\n\n\tparent.AddCommand(child)\n\n\texpected := fmt.Sprintf(\"required flag(s) %q, %q, %q, %q not set\", \"bar1\", \"bar2\", \"foo1\", \"foo2\")\n\n\t_, err := executeCommand(parent, \"child\")\n\tif err.Error() != expected {\n\t\tt.Errorf(\"Expected %q, got %q\", expected, err.Error())\n\t}\n}\n\nfunc TestInitHelpFlagMergesFlags(t *testing.T) {\n\tusage := \"custom flag\"\n\trootCmd := &Command{Use: \"root\"}\n\trootCmd.PersistentFlags().Bool(\"help\", false, \"custom flag\")\n\tchildCmd := &Command{Use: \"child\"}\n\trootCmd.AddCommand(childCmd)\n\n\tchildCmd.InitDefaultHelpFlag()\n\tgot := childCmd.Flags().Lookup(\"help\").Usage\n\tif got != usage {\n\t\tt.Errorf(\"Expected the help flag from the root command with usage: %v\\nGot the default with usage: %v\", usage, got)\n\t}\n}\n\nfunc TestHelpCommandExecuted(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Long: \"Long description\", Run: emptyRun}\n\trootCmd.AddCommand(&Command{Use: \"child\", Run: emptyRun})\n\n\toutput, err := executeCommand(rootCmd, \"help\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tcheckStringContains(t, output, rootCmd.Long)\n}\n\nfunc TestHelpCommandExecutedOnChild(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tchildCmd := &Command{Use: \"child\", Long: \"Long description\", Run: emptyRun}\n\trootCmd.AddCommand(childCmd)\n\n\toutput, err := executeCommand(rootCmd, \"help\", \"child\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tcheckStringContains(t, output, childCmd.Long)\n}\n\nfunc TestSetHelpCommand(t *testing.T) {\n\tc := &Command{Use: \"c\", Run: emptyRun}\n\tc.AddCommand(&Command{Use: \"empty\", Run: emptyRun})\n\n\texpected := \"WORKS\"\n\tc.SetHelpCommand(&Command{\n\t\tUse:   \"help [command]\",\n\t\tShort: \"Help about any command\",\n\t\tLong: `Help provides help for any command in the application.\n\tSimply type ` + c.Name() + ` help [path to command] for full details.`,\n\t\tRun: func(c *Command, _ []string) { c.Print(expected) },\n\t})\n\n\tgot, err := executeCommand(c, \"help\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tif got != expected {\n\t\tt.Errorf(\"Expected to contain %q, got %q\", expected, got)\n\t}\n}\n\nfunc TestHelpFlagExecuted(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Long: \"Long description\", Run: emptyRun}\n\n\toutput, err := executeCommand(rootCmd, \"--help\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tcheckStringContains(t, output, rootCmd.Long)\n}\n\nfunc TestHelpFlagExecutedOnChild(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tchildCmd := &Command{Use: \"child\", Long: \"Long description\", Run: emptyRun}\n\trootCmd.AddCommand(childCmd)\n\n\toutput, err := executeCommand(rootCmd, \"child\", \"--help\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tcheckStringContains(t, output, childCmd.Long)\n}\n\n// TestHelpFlagInHelp checks,\n// if '--help' flag is shown in help for child (executing `parent help child`),\n// that has no other flags.\n// Related to https://github.com/spf13/cobra/issues/302.\nfunc TestHelpFlagInHelp(t *testing.T) {\n\tparentCmd := &Command{Use: \"parent\", Run: func(*Command, []string) {}}\n\n\tchildCmd := &Command{Use: \"child\", Run: func(*Command, []string) {}}\n\tparentCmd.AddCommand(childCmd)\n\n\toutput, err := executeCommand(parentCmd, \"help\", \"child\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tcheckStringContains(t, output, \"[flags]\")\n}\n\nfunc TestFlagsInUsage(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Args: NoArgs, Run: func(*Command, []string) {}}\n\toutput, err := executeCommand(rootCmd, \"--help\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tcheckStringContains(t, output, \"[flags]\")\n}\n\nfunc TestHelpExecutedOnNonRunnableChild(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tchildCmd := &Command{Use: \"child\", Long: \"Long description\"}\n\trootCmd.AddCommand(childCmd)\n\n\toutput, err := executeCommand(rootCmd, \"child\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tcheckStringContains(t, output, childCmd.Long)\n}\n\nfunc TestVersionFlagExecuted(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Version: \"1.0.0\", Run: emptyRun}\n\n\toutput, err := executeCommand(rootCmd, \"--version\", \"arg1\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tcheckStringContains(t, output, \"root version 1.0.0\")\n}\n\nfunc TestVersionTemplate(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Version: \"1.0.0\", Run: emptyRun}\n\trootCmd.SetVersionTemplate(`customized version: {{.Version}}`)\n\n\toutput, err := executeCommand(rootCmd, \"--version\", \"arg1\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tcheckStringContains(t, output, \"customized version: 1.0.0\")\n}\n\nfunc TestVersionFlagExecutedOnSubcommand(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Version: \"1.0.0\"}\n\trootCmd.AddCommand(&Command{Use: \"sub\", Run: emptyRun})\n\n\toutput, err := executeCommand(rootCmd, \"--version\", \"sub\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tcheckStringContains(t, output, \"root version 1.0.0\")\n}\n\nfunc TestVersionFlagOnlyAddedToRoot(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Version: \"1.0.0\", Run: emptyRun}\n\trootCmd.AddCommand(&Command{Use: \"sub\", Run: emptyRun})\n\n\t_, err := executeCommand(rootCmd, \"sub\", \"--version\")\n\tif err == nil {\n\t\tt.Errorf(\"Expected error\")\n\t}\n\n\tcheckStringContains(t, err.Error(), \"unknown flag: --version\")\n}\n\nfunc TestVersionFlagOnlyExistsIfVersionNonEmpty(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\n\t_, err := executeCommand(rootCmd, \"--version\")\n\tif err == nil {\n\t\tt.Errorf(\"Expected error\")\n\t}\n\tcheckStringContains(t, err.Error(), \"unknown flag: --version\")\n}\n\nfunc TestUsageIsNotPrintedTwice(t *testing.T) {\n\tvar cmd = &Command{Use: \"root\"}\n\tvar sub = &Command{Use: \"sub\"}\n\tcmd.AddCommand(sub)\n\n\toutput, _ := executeCommand(cmd, \"\")\n\tif strings.Count(output, \"Usage:\") != 1 {\n\t\tt.Error(\"Usage output is not printed exactly once\")\n\t}\n}\n\nfunc TestVisitParents(t *testing.T) {\n\tc := &Command{Use: \"app\"}\n\tsub := &Command{Use: \"sub\"}\n\tdsub := &Command{Use: \"dsub\"}\n\tsub.AddCommand(dsub)\n\tc.AddCommand(sub)\n\n\ttotal := 0\n\tadd := func(x *Command) {\n\t\ttotal++\n\t}\n\tsub.VisitParents(add)\n\tif total != 1 {\n\t\tt.Errorf(\"Should have visited 1 parent but visited %d\", total)\n\t}\n\n\ttotal = 0\n\tdsub.VisitParents(add)\n\tif total != 2 {\n\t\tt.Errorf(\"Should have visited 2 parents but visited %d\", total)\n\t}\n\n\ttotal = 0\n\tc.VisitParents(add)\n\tif total != 0 {\n\t\tt.Errorf(\"Should have visited no parents but visited %d\", total)\n\t}\n}\n\nfunc TestSuggestions(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\ttimesCmd := &Command{\n\t\tUse:        \"times\",\n\t\tSuggestFor: []string{\"counts\"},\n\t\tRun:        emptyRun,\n\t}\n\trootCmd.AddCommand(timesCmd)\n\n\ttemplateWithSuggestions := \"Error: unknown command \\\"%s\\\" for \\\"root\\\"\\n\\nDid you mean this?\\n\\t%s\\n\\nRun 'root --help' for usage.\\n\"\n\ttemplateWithoutSuggestions := \"Error: unknown command \\\"%s\\\" for \\\"root\\\"\\nRun 'root --help' for usage.\\n\"\n\n\ttests := map[string]string{\n\t\t\"time\":     \"times\",\n\t\t\"tiems\":    \"times\",\n\t\t\"tims\":     \"times\",\n\t\t\"timeS\":    \"times\",\n\t\t\"rimes\":    \"times\",\n\t\t\"ti\":       \"times\",\n\t\t\"t\":        \"times\",\n\t\t\"timely\":   \"times\",\n\t\t\"ri\":       \"\",\n\t\t\"timezone\": \"\",\n\t\t\"foo\":      \"\",\n\t\t\"counts\":   \"times\",\n\t}\n\n\tfor typo, suggestion := range tests {\n\t\tfor _, suggestionsDisabled := range []bool{true, false} {\n\t\t\trootCmd.DisableSuggestions = suggestionsDisabled\n\n\t\t\tvar expected string\n\t\t\toutput, _ := executeCommand(rootCmd, typo)\n\n\t\t\tif suggestion == \"\" || suggestionsDisabled {\n\t\t\t\texpected = fmt.Sprintf(templateWithoutSuggestions, typo)\n\t\t\t} else {\n\t\t\t\texpected = fmt.Sprintf(templateWithSuggestions, typo, suggestion)\n\t\t\t}\n\n\t\t\tif output != expected {\n\t\t\t\tt.Errorf(\"Unexpected response.\\nExpected:\\n %q\\nGot:\\n %q\\n\", expected, output)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc TestRemoveCommand(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Args: NoArgs, Run: emptyRun}\n\tchildCmd := &Command{Use: \"child\", Run: emptyRun}\n\trootCmd.AddCommand(childCmd)\n\trootCmd.RemoveCommand(childCmd)\n\n\t_, err := executeCommand(rootCmd, \"child\")\n\tif err == nil {\n\t\tt.Error(\"Expected error on calling removed command. Got nil.\")\n\t}\n}\n\nfunc TestReplaceCommandWithRemove(t *testing.T) {\n\tchildUsed := 0\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tchild1Cmd := &Command{\n\t\tUse: \"child\",\n\t\tRun: func(*Command, []string) { childUsed = 1 },\n\t}\n\tchild2Cmd := &Command{\n\t\tUse: \"child\",\n\t\tRun: func(*Command, []string) { childUsed = 2 },\n\t}\n\trootCmd.AddCommand(child1Cmd)\n\trootCmd.RemoveCommand(child1Cmd)\n\trootCmd.AddCommand(child2Cmd)\n\n\toutput, err := executeCommand(rootCmd, \"child\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tif childUsed == 1 {\n\t\tt.Error(\"Removed command shouldn't be called\")\n\t}\n\tif childUsed != 2 {\n\t\tt.Error(\"Replacing command should have been called but didn't\")\n\t}\n}\n\nfunc TestDeprecatedCommand(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tdeprecatedCmd := &Command{\n\t\tUse:        \"deprecated\",\n\t\tDeprecated: \"This command is deprecated\",\n\t\tRun:        emptyRun,\n\t}\n\trootCmd.AddCommand(deprecatedCmd)\n\n\toutput, err := executeCommand(rootCmd, \"deprecated\")\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tcheckStringContains(t, output, deprecatedCmd.Deprecated)\n}\n\nfunc TestHooks(t *testing.T) {\n\tvar (\n\t\tpersPreArgs  string\n\t\tpreArgs      string\n\t\trunArgs      string\n\t\tpostArgs     string\n\t\tpersPostArgs string\n\t)\n\n\tc := &Command{\n\t\tUse: \"c\",\n\t\tPersistentPreRun: func(_ *Command, args []string) {\n\t\t\tpersPreArgs = strings.Join(args, \" \")\n\t\t},\n\t\tPreRun: func(_ *Command, args []string) {\n\t\t\tpreArgs = strings.Join(args, \" \")\n\t\t},\n\t\tRun: func(_ *Command, args []string) {\n\t\t\trunArgs = strings.Join(args, \" \")\n\t\t},\n\t\tPostRun: func(_ *Command, args []string) {\n\t\t\tpostArgs = strings.Join(args, \" \")\n\t\t},\n\t\tPersistentPostRun: func(_ *Command, args []string) {\n\t\t\tpersPostArgs = strings.Join(args, \" \")\n\t\t},\n\t}\n\n\toutput, err := executeCommand(c, \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tif persPreArgs != \"one two\" {\n\t\tt.Errorf(\"Expected persPreArgs %q, got %q\", \"one two\", persPreArgs)\n\t}\n\tif preArgs != \"one two\" {\n\t\tt.Errorf(\"Expected preArgs %q, got %q\", \"one two\", preArgs)\n\t}\n\tif runArgs != \"one two\" {\n\t\tt.Errorf(\"Expected runArgs %q, got %q\", \"one two\", runArgs)\n\t}\n\tif postArgs != \"one two\" {\n\t\tt.Errorf(\"Expected postArgs %q, got %q\", \"one two\", postArgs)\n\t}\n\tif persPostArgs != \"one two\" {\n\t\tt.Errorf(\"Expected persPostArgs %q, got %q\", \"one two\", persPostArgs)\n\t}\n}\n\nfunc TestPersistentHooks(t *testing.T) {\n\tvar (\n\t\tparentPersPreArgs  string\n\t\tparentPreArgs      string\n\t\tparentRunArgs      string\n\t\tparentPostArgs     string\n\t\tparentPersPostArgs string\n\t)\n\n\tvar (\n\t\tchildPersPreArgs  string\n\t\tchildPreArgs      string\n\t\tchildRunArgs      string\n\t\tchildPostArgs     string\n\t\tchildPersPostArgs string\n\t)\n\n\tparentCmd := &Command{\n\t\tUse: \"parent\",\n\t\tPersistentPreRun: func(_ *Command, args []string) {\n\t\t\tparentPersPreArgs = strings.Join(args, \" \")\n\t\t},\n\t\tPreRun: func(_ *Command, args []string) {\n\t\t\tparentPreArgs = strings.Join(args, \" \")\n\t\t},\n\t\tRun: func(_ *Command, args []string) {\n\t\t\tparentRunArgs = strings.Join(args, \" \")\n\t\t},\n\t\tPostRun: func(_ *Command, args []string) {\n\t\t\tparentPostArgs = strings.Join(args, \" \")\n\t\t},\n\t\tPersistentPostRun: func(_ *Command, args []string) {\n\t\t\tparentPersPostArgs = strings.Join(args, \" \")\n\t\t},\n\t}\n\n\tchildCmd := &Command{\n\t\tUse: \"child\",\n\t\tPersistentPreRun: func(_ *Command, args []string) {\n\t\t\tchildPersPreArgs = strings.Join(args, \" \")\n\t\t},\n\t\tPreRun: func(_ *Command, args []string) {\n\t\t\tchildPreArgs = strings.Join(args, \" \")\n\t\t},\n\t\tRun: func(_ *Command, args []string) {\n\t\t\tchildRunArgs = strings.Join(args, \" \")\n\t\t},\n\t\tPostRun: func(_ *Command, args []string) {\n\t\t\tchildPostArgs = strings.Join(args, \" \")\n\t\t},\n\t\tPersistentPostRun: func(_ *Command, args []string) {\n\t\t\tchildPersPostArgs = strings.Join(args, \" \")\n\t\t},\n\t}\n\tparentCmd.AddCommand(childCmd)\n\n\toutput, err := executeCommand(parentCmd, \"child\", \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\t// TODO: This test fails, but should not.\n\t// Related to https://github.com/spf13/cobra/issues/252.\n\t//\n\t// if parentPersPreArgs != \"one two\" {\n\t// \tt.Errorf(\"Expected parentPersPreArgs %q, got %q\", \"one two\", parentPersPreArgs)\n\t// }\n\tif parentPreArgs != \"\" {\n\t\tt.Errorf(\"Expected blank parentPreArgs, got %q\", parentPreArgs)\n\t}\n\tif parentRunArgs != \"\" {\n\t\tt.Errorf(\"Expected blank parentRunArgs, got %q\", parentRunArgs)\n\t}\n\tif parentPostArgs != \"\" {\n\t\tt.Errorf(\"Expected blank parentPostArgs, got %q\", parentPostArgs)\n\t}\n\t// TODO: This test fails, but should not.\n\t// Related to https://github.com/spf13/cobra/issues/252.\n\t//\n\t// if parentPersPostArgs != \"one two\" {\n\t// \tt.Errorf(\"Expected parentPersPostArgs %q, got %q\", \"one two\", parentPersPostArgs)\n\t// }\n\n\tif childPersPreArgs != \"one two\" {\n\t\tt.Errorf(\"Expected childPersPreArgs %q, got %q\", \"one two\", childPersPreArgs)\n\t}\n\tif childPreArgs != \"one two\" {\n\t\tt.Errorf(\"Expected childPreArgs %q, got %q\", \"one two\", childPreArgs)\n\t}\n\tif childRunArgs != \"one two\" {\n\t\tt.Errorf(\"Expected childRunArgs %q, got %q\", \"one two\", childRunArgs)\n\t}\n\tif childPostArgs != \"one two\" {\n\t\tt.Errorf(\"Expected childPostArgs %q, got %q\", \"one two\", childPostArgs)\n\t}\n\tif childPersPostArgs != \"one two\" {\n\t\tt.Errorf(\"Expected childPersPostArgs %q, got %q\", \"one two\", childPersPostArgs)\n\t}\n}\n\n// Related to https://github.com/spf13/cobra/issues/521.\nfunc TestGlobalNormFuncPropagation(t *testing.T) {\n\tnormFunc := func(f *pflag.FlagSet, name string) pflag.NormalizedName {\n\t\treturn pflag.NormalizedName(name)\n\t}\n\n\trootCmd := &Command{Use: \"root\", Run: emptyRun}\n\tchildCmd := &Command{Use: \"child\", Run: emptyRun}\n\trootCmd.AddCommand(childCmd)\n\n\trootCmd.SetGlobalNormalizationFunc(normFunc)\n\tif reflect.ValueOf(normFunc).Pointer() != reflect.ValueOf(rootCmd.GlobalNormalizationFunc()).Pointer() {\n\t\tt.Error(\"rootCmd seems to have a wrong normalization function\")\n\t}\n\n\tif reflect.ValueOf(normFunc).Pointer() != reflect.ValueOf(childCmd.GlobalNormalizationFunc()).Pointer() {\n\t\tt.Error(\"childCmd should have had the normalization function of rootCmd\")\n\t}\n}\n\n// Related to https://github.com/spf13/cobra/issues/521.\nfunc TestNormPassedOnLocal(t *testing.T) {\n\ttoUpper := func(f *pflag.FlagSet, name string) pflag.NormalizedName {\n\t\treturn pflag.NormalizedName(strings.ToUpper(name))\n\t}\n\n\tc := &Command{}\n\tc.Flags().Bool(\"flagname\", true, \"this is a dummy flag\")\n\tc.SetGlobalNormalizationFunc(toUpper)\n\tif c.LocalFlags().Lookup(\"flagname\") != c.LocalFlags().Lookup(\"FLAGNAME\") {\n\t\tt.Error(\"Normalization function should be passed on to Local flag set\")\n\t}\n}\n\n// Related to https://github.com/spf13/cobra/issues/521.\nfunc TestNormPassedOnInherited(t *testing.T) {\n\ttoUpper := func(f *pflag.FlagSet, name string) pflag.NormalizedName {\n\t\treturn pflag.NormalizedName(strings.ToUpper(name))\n\t}\n\n\tc := &Command{}\n\tc.SetGlobalNormalizationFunc(toUpper)\n\n\tchild1 := &Command{}\n\tc.AddCommand(child1)\n\n\tc.PersistentFlags().Bool(\"flagname\", true, \"\")\n\n\tchild2 := &Command{}\n\tc.AddCommand(child2)\n\n\tinherited := child1.InheritedFlags()\n\tif inherited.Lookup(\"flagname\") == nil || inherited.Lookup(\"flagname\") != inherited.Lookup(\"FLAGNAME\") {\n\t\tt.Error(\"Normalization function should be passed on to inherited flag set in command added before flag\")\n\t}\n\n\tinherited = child2.InheritedFlags()\n\tif inherited.Lookup(\"flagname\") == nil || inherited.Lookup(\"flagname\") != inherited.Lookup(\"FLAGNAME\") {\n\t\tt.Error(\"Normalization function should be passed on to inherited flag set in command added after flag\")\n\t}\n}\n\n// Related to https://github.com/spf13/cobra/issues/521.\nfunc TestConsistentNormalizedName(t *testing.T) {\n\ttoUpper := func(f *pflag.FlagSet, name string) pflag.NormalizedName {\n\t\treturn pflag.NormalizedName(strings.ToUpper(name))\n\t}\n\tn := func(f *pflag.FlagSet, name string) pflag.NormalizedName {\n\t\treturn pflag.NormalizedName(name)\n\t}\n\n\tc := &Command{}\n\tc.Flags().Bool(\"flagname\", true, \"\")\n\tc.SetGlobalNormalizationFunc(toUpper)\n\tc.SetGlobalNormalizationFunc(n)\n\n\tif c.LocalFlags().Lookup(\"flagname\") == c.LocalFlags().Lookup(\"FLAGNAME\") {\n\t\tt.Error(\"Normalizing flag names should not result in duplicate flags\")\n\t}\n}\n\nfunc TestFlagOnPflagCommandLine(t *testing.T) {\n\tflagName := \"flagOnCommandLine\"\n\tpflag.String(flagName, \"\", \"about my flag\")\n\n\tc := &Command{Use: \"c\", Run: emptyRun}\n\tc.AddCommand(&Command{Use: \"child\", Run: emptyRun})\n\n\toutput, _ := executeCommand(c, \"--help\")\n\tcheckStringContains(t, output, flagName)\n\n\tresetCommandLineFlagSet()\n}\n\n// TestHiddenCommandExecutes checks,\n// if hidden commands run as intended.\nfunc TestHiddenCommandExecutes(t *testing.T) {\n\texecuted := false\n\tc := &Command{\n\t\tUse:    \"c\",\n\t\tHidden: true,\n\t\tRun:    func(*Command, []string) { executed = true },\n\t}\n\n\toutput, err := executeCommand(c)\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tif !executed {\n\t\tt.Error(\"Hidden command should have been executed\")\n\t}\n}\n\n// test to ensure hidden commands do not show up in usage/help text\nfunc TestHiddenCommandIsHidden(t *testing.T) {\n\tc := &Command{Use: \"c\", Hidden: true, Run: emptyRun}\n\tif c.IsAvailableCommand() {\n\t\tt.Errorf(\"Hidden command should be unavailable\")\n\t}\n}\n\nfunc TestCommandsAreSorted(t *testing.T) {\n\tEnableCommandSorting = true\n\n\toriginalNames := []string{\"middle\", \"zlast\", \"afirst\"}\n\texpectedNames := []string{\"afirst\", \"middle\", \"zlast\"}\n\n\tvar rootCmd = &Command{Use: \"root\"}\n\n\tfor _, name := range originalNames {\n\t\trootCmd.AddCommand(&Command{Use: name})\n\t}\n\n\tfor i, c := range rootCmd.Commands() {\n\t\tgot := c.Name()\n\t\tif expectedNames[i] != got {\n\t\t\tt.Errorf(\"Expected: %s, got: %s\", expectedNames[i], got)\n\t\t}\n\t}\n\n\tEnableCommandSorting = true\n}\n\nfunc TestEnableCommandSortingIsDisabled(t *testing.T) {\n\tEnableCommandSorting = false\n\n\toriginalNames := []string{\"middle\", \"zlast\", \"afirst\"}\n\n\tvar rootCmd = &Command{Use: \"root\"}\n\n\tfor _, name := range originalNames {\n\t\trootCmd.AddCommand(&Command{Use: name})\n\t}\n\n\tfor i, c := range rootCmd.Commands() {\n\t\tgot := c.Name()\n\t\tif originalNames[i] != got {\n\t\t\tt.Errorf(\"expected: %s, got: %s\", originalNames[i], got)\n\t\t}\n\t}\n\n\tEnableCommandSorting = true\n}\n\nfunc TestSetOutput(t *testing.T) {\n\tc := &Command{}\n\tc.SetOutput(nil)\n\tif out := c.OutOrStdout(); out != os.Stdout {\n\t\tt.Errorf(\"Expected setting output to nil to revert back to stdout\")\n\t}\n}\n\nfunc TestFlagErrorFunc(t *testing.T) {\n\tc := &Command{Use: \"c\", Run: emptyRun}\n\n\texpectedFmt := \"This is expected: %v\"\n\tc.SetFlagErrorFunc(func(_ *Command, err error) error {\n\t\treturn fmt.Errorf(expectedFmt, err)\n\t})\n\n\t_, err := executeCommand(c, \"--unknown-flag\")\n\n\tgot := err.Error()\n\texpected := fmt.Sprintf(expectedFmt, \"unknown flag: --unknown-flag\")\n\tif got != expected {\n\t\tt.Errorf(\"Expected %v, got %v\", expected, got)\n\t}\n}\n\n// TestSortedFlags checks,\n// if cmd.LocalFlags() is unsorted when cmd.Flags().SortFlags set to false.\n// Related to https://github.com/spf13/cobra/issues/404.\nfunc TestSortedFlags(t *testing.T) {\n\tc := &Command{}\n\tc.Flags().SortFlags = false\n\tnames := []string{\"C\", \"B\", \"A\", \"D\"}\n\tfor _, name := range names {\n\t\tc.Flags().Bool(name, false, \"\")\n\t}\n\n\ti := 0\n\tc.LocalFlags().VisitAll(func(f *pflag.Flag) {\n\t\tif i == len(names) {\n\t\t\treturn\n\t\t}\n\t\tif stringInSlice(f.Name, names) {\n\t\t\tif names[i] != f.Name {\n\t\t\t\tt.Errorf(\"Incorrect order. Expected %v, got %v\", names[i], f.Name)\n\t\t\t}\n\t\t\ti++\n\t\t}\n\t})\n}\n\n// TestMergeCommandLineToFlags checks,\n// if pflag.CommandLine is correctly merged to c.Flags() after first call\n// of c.mergePersistentFlags.\n// Related to https://github.com/spf13/cobra/issues/443.\nfunc TestMergeCommandLineToFlags(t *testing.T) {\n\tpflag.Bool(\"boolflag\", false, \"\")\n\tc := &Command{Use: \"c\", Run: emptyRun}\n\tc.mergePersistentFlags()\n\tif c.Flags().Lookup(\"boolflag\") == nil {\n\t\tt.Fatal(\"Expecting to have flag from CommandLine in c.Flags()\")\n\t}\n\n\tresetCommandLineFlagSet()\n}\n\n// TestUseDeprecatedFlags checks,\n// if cobra.Execute() prints a message, if a deprecated flag is used.\n// Related to https://github.com/spf13/cobra/issues/463.\nfunc TestUseDeprecatedFlags(t *testing.T) {\n\tc := &Command{Use: \"c\", Run: emptyRun}\n\tc.Flags().BoolP(\"deprecated\", \"d\", false, \"deprecated flag\")\n\tc.Flags().MarkDeprecated(\"deprecated\", \"This flag is deprecated\")\n\n\toutput, err := executeCommand(c, \"c\", \"-d\")\n\tif err != nil {\n\t\tt.Error(\"Unexpected error:\", err)\n\t}\n\tcheckStringContains(t, output, \"This flag is deprecated\")\n}\n\nfunc TestTraverseWithParentFlags(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", TraverseChildren: true}\n\trootCmd.Flags().String(\"str\", \"\", \"\")\n\trootCmd.Flags().BoolP(\"bool\", \"b\", false, \"\")\n\n\tchildCmd := &Command{Use: \"child\"}\n\tchildCmd.Flags().Int(\"int\", -1, \"\")\n\n\trootCmd.AddCommand(childCmd)\n\n\tc, args, err := rootCmd.Traverse([]string{\"-b\", \"--str\", \"ok\", \"child\", \"--int\"})\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\tif len(args) != 1 && args[0] != \"--add\" {\n\t\tt.Errorf(\"Wrong args: %v\", args)\n\t}\n\tif c.Name() != childCmd.Name() {\n\t\tt.Errorf(\"Expected command: %q, got: %q\", childCmd.Name(), c.Name())\n\t}\n}\n\nfunc TestTraverseNoParentFlags(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", TraverseChildren: true}\n\trootCmd.Flags().String(\"foo\", \"\", \"foo things\")\n\n\tchildCmd := &Command{Use: \"child\"}\n\tchildCmd.Flags().String(\"str\", \"\", \"\")\n\trootCmd.AddCommand(childCmd)\n\n\tc, args, err := rootCmd.Traverse([]string{\"child\"})\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\tif len(args) != 0 {\n\t\tt.Errorf(\"Wrong args %v\", args)\n\t}\n\tif c.Name() != childCmd.Name() {\n\t\tt.Errorf(\"Expected command: %q, got: %q\", childCmd.Name(), c.Name())\n\t}\n}\n\nfunc TestTraverseWithBadParentFlags(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", TraverseChildren: true}\n\n\tchildCmd := &Command{Use: \"child\"}\n\tchildCmd.Flags().String(\"str\", \"\", \"\")\n\trootCmd.AddCommand(childCmd)\n\n\texpected := \"unknown flag: --str\"\n\n\tc, _, err := rootCmd.Traverse([]string{\"--str\", \"ok\", \"child\"})\n\tif err == nil || !strings.Contains(err.Error(), expected) {\n\t\tt.Errorf(\"Expected error, %q, got %q\", expected, err)\n\t}\n\tif c != nil {\n\t\tt.Errorf(\"Expected nil command\")\n\t}\n}\n\nfunc TestTraverseWithBadChildFlag(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", TraverseChildren: true}\n\trootCmd.Flags().String(\"str\", \"\", \"\")\n\n\tchildCmd := &Command{Use: \"child\"}\n\trootCmd.AddCommand(childCmd)\n\n\t// Expect no error because the last commands args shouldn't be parsed in\n\t// Traverse.\n\tc, args, err := rootCmd.Traverse([]string{\"child\", \"--str\"})\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\tif len(args) != 1 && args[0] != \"--str\" {\n\t\tt.Errorf(\"Wrong args: %v\", args)\n\t}\n\tif c.Name() != childCmd.Name() {\n\t\tt.Errorf(\"Expected command %q, got: %q\", childCmd.Name(), c.Name())\n\t}\n}\n\nfunc TestTraverseWithTwoSubcommands(t *testing.T) {\n\trootCmd := &Command{Use: \"root\", TraverseChildren: true}\n\n\tsubCmd := &Command{Use: \"sub\", TraverseChildren: true}\n\trootCmd.AddCommand(subCmd)\n\n\tsubsubCmd := &Command{\n\t\tUse: \"subsub\",\n\t}\n\tsubCmd.AddCommand(subsubCmd)\n\n\tc, _, err := rootCmd.Traverse([]string{\"sub\", \"subsub\"})\n\tif err != nil {\n\t\tt.Fatalf(\"Unexpected error: %v\", err)\n\t}\n\tif c.Name() != subsubCmd.Name() {\n\t\tt.Fatalf(\"Expected command: %q, got %q\", subsubCmd.Name(), c.Name())\n\t}\n}\n\n// TestUpdateName checks if c.Name() updates on changed c.Use.\n// Related to https://github.com/spf13/cobra/pull/422#discussion_r143918343.\nfunc TestUpdateName(t *testing.T) {\n\tc := &Command{Use: \"name xyz\"}\n\toriginalName := c.Name()\n\n\tc.Use = \"changedName abc\"\n\tif originalName == c.Name() || c.Name() != \"changedName\" {\n\t\tt.Error(\"c.Name() should be updated on changed c.Use\")\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/command_win.go",
    "content": "// +build windows\n\npackage cobra\n\nimport (\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/inconshreveable/mousetrap\"\n)\n\nvar preExecHookFn = preExecHook\n\nfunc preExecHook(c *Command) {\n\tif MousetrapHelpText != \"\" && mousetrap.StartedByExplorer() {\n\t\tc.Print(MousetrapHelpText)\n\t\ttime.Sleep(5 * time.Second)\n\t\tos.Exit(1)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/zsh_completions.go",
    "content": "package cobra\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strings\"\n)\n\n// GenZshCompletionFile generates zsh completion file.\nfunc (c *Command) GenZshCompletionFile(filename string) error {\n\toutFile, err := os.Create(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer outFile.Close()\n\n\treturn c.GenZshCompletion(outFile)\n}\n\n// GenZshCompletion generates a zsh completion file and writes to the passed writer.\nfunc (c *Command) GenZshCompletion(w io.Writer) error {\n\tbuf := new(bytes.Buffer)\n\n\twriteHeader(buf, c)\n\tmaxDepth := maxDepth(c)\n\twriteLevelMapping(buf, maxDepth)\n\twriteLevelCases(buf, maxDepth, c)\n\n\t_, err := buf.WriteTo(w)\n\treturn err\n}\n\nfunc writeHeader(w io.Writer, cmd *Command) {\n\tfmt.Fprintf(w, \"#compdef %s\\n\\n\", cmd.Name())\n}\n\nfunc maxDepth(c *Command) int {\n\tif len(c.Commands()) == 0 {\n\t\treturn 0\n\t}\n\tmaxDepthSub := 0\n\tfor _, s := range c.Commands() {\n\t\tsubDepth := maxDepth(s)\n\t\tif subDepth > maxDepthSub {\n\t\t\tmaxDepthSub = subDepth\n\t\t}\n\t}\n\treturn 1 + maxDepthSub\n}\n\nfunc writeLevelMapping(w io.Writer, numLevels int) {\n\tfmt.Fprintln(w, `_arguments \\`)\n\tfor i := 1; i <= numLevels; i++ {\n\t\tfmt.Fprintf(w, `  '%d: :->level%d' \\`, i, i)\n\t\tfmt.Fprintln(w)\n\t}\n\tfmt.Fprintf(w, `  '%d: :%s'`, numLevels+1, \"_files\")\n\tfmt.Fprintln(w)\n}\n\nfunc writeLevelCases(w io.Writer, maxDepth int, root *Command) {\n\tfmt.Fprintln(w, \"case $state in\")\n\tdefer fmt.Fprintln(w, \"esac\")\n\n\tfor i := 1; i <= maxDepth; i++ {\n\t\tfmt.Fprintf(w, \"  level%d)\\n\", i)\n\t\twriteLevel(w, root, i)\n\t\tfmt.Fprintln(w, \"  ;;\")\n\t}\n\tfmt.Fprintln(w, \"  *)\")\n\tfmt.Fprintln(w, \"    _arguments '*: :_files'\")\n\tfmt.Fprintln(w, \"  ;;\")\n}\n\nfunc writeLevel(w io.Writer, root *Command, i int) {\n\tfmt.Fprintf(w, \"    case $words[%d] in\\n\", i)\n\tdefer fmt.Fprintln(w, \"    esac\")\n\n\tcommands := filterByLevel(root, i)\n\tbyParent := groupByParent(commands)\n\n\tfor p, c := range byParent {\n\t\tnames := names(c)\n\t\tfmt.Fprintf(w, \"      %s)\\n\", p)\n\t\tfmt.Fprintf(w, \"        _arguments '%d: :(%s)'\\n\", i, strings.Join(names, \" \"))\n\t\tfmt.Fprintln(w, \"      ;;\")\n\t}\n\tfmt.Fprintln(w, \"      *)\")\n\tfmt.Fprintln(w, \"        _arguments '*: :_files'\")\n\tfmt.Fprintln(w, \"      ;;\")\n\n}\n\nfunc filterByLevel(c *Command, l int) []*Command {\n\tcs := make([]*Command, 0)\n\tif l == 0 {\n\t\tcs = append(cs, c)\n\t\treturn cs\n\t}\n\tfor _, s := range c.Commands() {\n\t\tcs = append(cs, filterByLevel(s, l-1)...)\n\t}\n\treturn cs\n}\n\nfunc groupByParent(commands []*Command) map[string][]*Command {\n\tm := make(map[string][]*Command)\n\tfor _, c := range commands {\n\t\tparent := c.Parent()\n\t\tif parent == nil {\n\t\t\tcontinue\n\t\t}\n\t\tm[parent.Name()] = append(m[parent.Name()], c)\n\t}\n\treturn m\n}\n\nfunc names(commands []*Command) []string {\n\tns := make([]string, len(commands))\n\tfor i, c := range commands {\n\t\tns[i] = c.Name()\n\t}\n\treturn ns\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/cobra/zsh_completions_test.go",
    "content": "package cobra\n\nimport (\n\t\"bytes\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc TestZshCompletion(t *testing.T) {\n\ttcs := []struct {\n\t\tname                string\n\t\troot                *Command\n\t\texpectedExpressions []string\n\t}{\n\t\t{\n\t\t\tname:                \"trivial\",\n\t\t\troot:                &Command{Use: \"trivialapp\"},\n\t\t\texpectedExpressions: []string{\"#compdef trivial\"},\n\t\t},\n\t\t{\n\t\t\tname: \"linear\",\n\t\t\troot: func() *Command {\n\t\t\t\tr := &Command{Use: \"linear\"}\n\n\t\t\t\tsub1 := &Command{Use: \"sub1\"}\n\t\t\t\tr.AddCommand(sub1)\n\n\t\t\t\tsub2 := &Command{Use: \"sub2\"}\n\t\t\t\tsub1.AddCommand(sub2)\n\n\t\t\t\tsub3 := &Command{Use: \"sub3\"}\n\t\t\t\tsub2.AddCommand(sub3)\n\t\t\t\treturn r\n\t\t\t}(),\n\t\t\texpectedExpressions: []string{\"sub1\", \"sub2\", \"sub3\"},\n\t\t},\n\t\t{\n\t\t\tname: \"flat\",\n\t\t\troot: func() *Command {\n\t\t\t\tr := &Command{Use: \"flat\"}\n\t\t\t\tr.AddCommand(&Command{Use: \"c1\"})\n\t\t\t\tr.AddCommand(&Command{Use: \"c2\"})\n\t\t\t\treturn r\n\t\t\t}(),\n\t\t\texpectedExpressions: []string{\"(c1 c2)\"},\n\t\t},\n\t\t{\n\t\t\tname: \"tree\",\n\t\t\troot: func() *Command {\n\t\t\t\tr := &Command{Use: \"tree\"}\n\n\t\t\t\tsub1 := &Command{Use: \"sub1\"}\n\t\t\t\tr.AddCommand(sub1)\n\n\t\t\t\tsub11 := &Command{Use: \"sub11\"}\n\t\t\t\tsub12 := &Command{Use: \"sub12\"}\n\n\t\t\t\tsub1.AddCommand(sub11)\n\t\t\t\tsub1.AddCommand(sub12)\n\n\t\t\t\tsub2 := &Command{Use: \"sub2\"}\n\t\t\t\tr.AddCommand(sub2)\n\n\t\t\t\tsub21 := &Command{Use: \"sub21\"}\n\t\t\t\tsub22 := &Command{Use: \"sub22\"}\n\n\t\t\t\tsub2.AddCommand(sub21)\n\t\t\t\tsub2.AddCommand(sub22)\n\n\t\t\t\treturn r\n\t\t\t}(),\n\t\t\texpectedExpressions: []string{\"(sub11 sub12)\", \"(sub21 sub22)\"},\n\t\t},\n\t}\n\n\tfor _, tc := range tcs {\n\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\tbuf := new(bytes.Buffer)\n\t\t\ttc.root.GenZshCompletion(buf)\n\t\t\toutput := buf.String()\n\n\t\t\tfor _, expectedExpression := range tc.expectedExpressions {\n\t\t\t\tif !strings.Contains(output, expectedExpression) {\n\t\t\t\t\tt.Errorf(\"Expected completion to contain %q somewhere; got %q\", expectedExpression, output)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/.gitignore",
    "content": ".idea/*\n\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/.travis.yml",
    "content": "sudo: false\n\nlanguage: go\n\ngo:\n  - 1.7.3\n  - 1.8.1\n  - tip\n\nmatrix:\n  allow_failures:\n    - go: tip\n\ninstall:\n  - go get github.com/golang/lint/golint\n  - export PATH=$GOPATH/bin:$PATH\n  - go install ./...\n\nscript:\n  - verify/all.sh -v\n  - go test ./...\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/LICENSE",
    "content": "Copyright (c) 2012 Alex Ogier. All rights reserved.\nCopyright (c) 2012 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/github.com/spf13/pflag/README.md",
    "content": "[![Build Status](https://travis-ci.org/spf13/pflag.svg?branch=master)](https://travis-ci.org/spf13/pflag)\n[![Go Report Card](https://goreportcard.com/badge/github.com/spf13/pflag)](https://goreportcard.com/report/github.com/spf13/pflag)\n[![GoDoc](https://godoc.org/github.com/spf13/pflag?status.svg)](https://godoc.org/github.com/spf13/pflag)\n\n## Description\n\npflag is a drop-in replacement for Go's flag package, implementing\nPOSIX/GNU-style --flags.\n\npflag is compatible with the [GNU extensions to the POSIX recommendations\nfor command-line options][1]. For a more precise description, see the\n\"Command-line flag syntax\" section below.\n\n[1]: http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html\n\npflag is available under the same style of BSD license as the Go language,\nwhich can be found in the LICENSE file.\n\n## Installation\n\npflag is available using the standard `go get` command.\n\nInstall by running:\n\n    go get github.com/spf13/pflag\n\nRun tests by running:\n\n    go test github.com/spf13/pflag\n\n## Usage\n\npflag is a drop-in replacement of Go's native flag package. If you import\npflag under the name \"flag\" then all code should continue to function\nwith no changes.\n\n``` go\nimport flag \"github.com/spf13/pflag\"\n```\n\nThere is one exception to this: if you directly instantiate the Flag struct\nthere is one more field \"Shorthand\" that you will need to set.\nMost code never instantiates this struct directly, and instead uses\nfunctions such as String(), BoolVar(), and Var(), and is therefore\nunaffected.\n\nDefine flags using flag.String(), Bool(), Int(), etc.\n\nThis declares an integer flag, -flagname, stored in the pointer ip, with type *int.\n\n``` go\nvar ip *int = flag.Int(\"flagname\", 1234, \"help message for flagname\")\n```\n\nIf you like, you can bind the flag to a variable using the Var() functions.\n\n``` go\nvar flagvar int\nfunc init() {\n    flag.IntVar(&flagvar, \"flagname\", 1234, \"help message for flagname\")\n}\n```\n\nOr you can create custom flags that satisfy the Value interface (with\npointer receivers) and couple them to flag parsing by\n\n``` go\nflag.Var(&flagVal, \"name\", \"help message for flagname\")\n```\n\nFor such flags, the default value is just the initial value of the variable.\n\nAfter all flags are defined, call\n\n``` go\nflag.Parse()\n```\n\nto parse the command line into the defined flags.\n\nFlags may then be used directly. If you're using the flags themselves,\nthey are all pointers; if you bind to variables, they're values.\n\n``` go\nfmt.Println(\"ip has value \", *ip)\nfmt.Println(\"flagvar has value \", flagvar)\n```\n\nThere are helpers function to get values later if you have the FlagSet but\nit was difficult to keep up with all of the flag pointers in your code.\nIf you have a pflag.FlagSet with a flag called 'flagname' of type int you\ncan use GetInt() to get the int value. But notice that 'flagname' must exist\nand it must be an int. GetString(\"flagname\") will fail.\n\n``` go\ni, err := flagset.GetInt(\"flagname\")\n```\n\nAfter parsing, the arguments after the flag are available as the\nslice flag.Args() or individually as flag.Arg(i).\nThe arguments are indexed from 0 through flag.NArg()-1.\n\nThe pflag package also defines some new functions that are not in flag,\nthat give one-letter shorthands for flags. You can use these by appending\n'P' to the name of any function that defines a flag.\n\n``` go\nvar ip = flag.IntP(\"flagname\", \"f\", 1234, \"help message\")\nvar flagvar bool\nfunc init() {\n\tflag.BoolVarP(&flagvar, \"boolname\", \"b\", true, \"help message\")\n}\nflag.VarP(&flagVal, \"varname\", \"v\", \"help message\")\n```\n\nShorthand letters can be used with single dashes on the command line.\nBoolean shorthand flags can be combined with other shorthand flags.\n\nThe default set of command-line flags is controlled by\ntop-level functions.  The FlagSet type allows one to define\nindependent sets of flags, such as to implement subcommands\nin a command-line interface. The methods of FlagSet are\nanalogous to the top-level functions for the command-line\nflag set.\n\n## Setting no option default values for flags\n\nAfter you create a flag it is possible to set the pflag.NoOptDefVal for\nthe given flag. Doing this changes the meaning of the flag slightly. If\na flag has a NoOptDefVal and the flag is set on the command line without\nan option the flag will be set to the NoOptDefVal. For example given:\n\n``` go\nvar ip = flag.IntP(\"flagname\", \"f\", 1234, \"help message\")\nflag.Lookup(\"flagname\").NoOptDefVal = \"4321\"\n```\n\nWould result in something like\n\n| Parsed Arguments | Resulting Value |\n| -------------    | -------------   |\n| --flagname=1357  | ip=1357         |\n| --flagname       | ip=4321         |\n| [nothing]        | ip=1234         |\n\n## Command line flag syntax\n\n```\n--flag    // boolean flags, or flags with no option default values\n--flag x  // only on flags without a default value\n--flag=x\n```\n\nUnlike the flag package, a single dash before an option means something\ndifferent than a double dash. Single dashes signify a series of shorthand\nletters for flags. All but the last shorthand letter must be boolean flags\nor a flag with a default value\n\n```\n// boolean or flags where the 'no option default value' is set\n-f\n-f=true\n-abc\nbut\n-b true is INVALID\n\n// non-boolean and flags without a 'no option default value'\n-n 1234\n-n=1234\n-n1234\n\n// mixed\n-abcs \"hello\"\n-absd=\"hello\"\n-abcs1234\n```\n\nFlag parsing stops after the terminator \"--\". Unlike the flag package,\nflags can be interspersed with arguments anywhere on the command line\nbefore this terminator.\n\nInteger flags accept 1234, 0664, 0x1234 and may be negative.\nBoolean flags (in their long form) accept 1, 0, t, f, true, false,\nTRUE, FALSE, True, False.\nDuration flags accept any input valid for time.ParseDuration.\n\n## Mutating or \"Normalizing\" Flag names\n\nIt is possible to set a custom flag name 'normalization function.' It allows flag names to be mutated both when created in the code and when used on the command line to some 'normalized' form. The 'normalized' form is used for comparison. Two examples of using the custom normalization func follow.\n\n**Example #1**: You want -, _, and . in flags to compare the same. aka --my-flag == --my_flag == --my.flag\n\n``` go\nfunc wordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {\n\tfrom := []string{\"-\", \"_\"}\n\tto := \".\"\n\tfor _, sep := range from {\n\t\tname = strings.Replace(name, sep, to, -1)\n\t}\n\treturn pflag.NormalizedName(name)\n}\n\nmyFlagSet.SetNormalizeFunc(wordSepNormalizeFunc)\n```\n\n**Example #2**: You want to alias two flags. aka --old-flag-name == --new-flag-name\n\n``` go\nfunc aliasNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {\n\tswitch name {\n\tcase \"old-flag-name\":\n\t\tname = \"new-flag-name\"\n\t\tbreak\n\t}\n\treturn pflag.NormalizedName(name)\n}\n\nmyFlagSet.SetNormalizeFunc(aliasNormalizeFunc)\n```\n\n## Deprecating a flag or its shorthand\nIt is possible to deprecate a flag, or just its shorthand. Deprecating a flag/shorthand hides it from help text and prints a usage message when the deprecated flag/shorthand is used.\n\n**Example #1**: You want to deprecate a flag named \"badflag\" as well as inform the users what flag they should use instead.\n```go\n// deprecate a flag by specifying its name and a usage message\nflags.MarkDeprecated(\"badflag\", \"please use --good-flag instead\")\n```\nThis hides \"badflag\" from help text, and prints `Flag --badflag has been deprecated, please use --good-flag instead` when \"badflag\" is used.\n\n**Example #2**: You want to keep a flag name \"noshorthandflag\" but deprecate its shortname \"n\".\n```go\n// deprecate a flag shorthand by specifying its flag name and a usage message\nflags.MarkShorthandDeprecated(\"noshorthandflag\", \"please use --noshorthandflag only\")\n```\nThis hides the shortname \"n\" from help text, and prints `Flag shorthand -n has been deprecated, please use --noshorthandflag only` when the shorthand \"n\" is used.\n\nNote that usage message is essential here, and it should not be empty.\n\n## Hidden flags\nIt is possible to mark a flag as hidden, meaning it will still function as normal, however will not show up in usage/help text.\n\n**Example**: You have a flag named \"secretFlag\" that you need for internal use only and don't want it showing up in help text, or for its usage text to be available.\n```go\n// hide a flag by specifying its name\nflags.MarkHidden(\"secretFlag\")\n```\n\n## Disable sorting of flags\n`pflag` allows you to disable sorting of flags for help and usage message.\n\n**Example**:\n```go\nflags.BoolP(\"verbose\", \"v\", false, \"verbose output\")\nflags.String(\"coolflag\", \"yeaah\", \"it's really cool flag\")\nflags.Int(\"usefulflag\", 777, \"sometimes it's very useful\")\nflags.SortFlags = false\nflags.PrintDefaults()\n```\n**Output**:\n```\n  -v, --verbose           verbose output\n      --coolflag string   it's really cool flag (default \"yeaah\")\n      --usefulflag int    sometimes it's very useful (default 777)\n```\n\n\n## Supporting Go flags when using pflag\nIn order to support flags defined using Go's `flag` package, they must be added to the `pflag` flagset. This is usually necessary\nto support flags defined by third-party dependencies (e.g. `golang/glog`).\n\n**Example**: You want to add the Go flags to the `CommandLine` flagset\n```go\nimport (\n\tgoflag \"flag\"\n\tflag \"github.com/spf13/pflag\"\n)\n\nvar ip *int = flag.Int(\"flagname\", 1234, \"help message for flagname\")\n\nfunc main() {\n\tflag.CommandLine.AddGoFlagSet(goflag.CommandLine)\n\tflag.Parse()\n}\n```\n\n## More info\n\nYou can see the full reference documentation of the pflag package\n[at godoc.org][3], or through go's standard documentation system by\nrunning `godoc -http=:6060` and browsing to\n[http://localhost:6060/pkg/github.com/spf13/pflag][2] after\ninstallation.\n\n[2]: http://localhost:6060/pkg/github.com/spf13/pflag\n[3]: http://godoc.org/github.com/spf13/pflag\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/bool.go",
    "content": "package pflag\n\nimport \"strconv\"\n\n// optional interface to indicate boolean flags that can be\n// supplied without \"=value\" text\ntype boolFlag interface {\n\tValue\n\tIsBoolFlag() bool\n}\n\n// -- bool Value\ntype boolValue bool\n\nfunc newBoolValue(val bool, p *bool) *boolValue {\n\t*p = val\n\treturn (*boolValue)(p)\n}\n\nfunc (b *boolValue) Set(s string) error {\n\tv, err := strconv.ParseBool(s)\n\t*b = boolValue(v)\n\treturn err\n}\n\nfunc (b *boolValue) Type() string {\n\treturn \"bool\"\n}\n\nfunc (b *boolValue) String() string { return strconv.FormatBool(bool(*b)) }\n\nfunc (b *boolValue) IsBoolFlag() bool { return true }\n\nfunc boolConv(sval string) (interface{}, error) {\n\treturn strconv.ParseBool(sval)\n}\n\n// GetBool return the bool value of a flag with the given name\nfunc (f *FlagSet) GetBool(name string) (bool, error) {\n\tval, err := f.getFlagType(name, \"bool\", boolConv)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn val.(bool), nil\n}\n\n// BoolVar defines a bool flag with specified name, default value, and usage string.\n// The argument p points to a bool variable in which to store the value of the flag.\nfunc (f *FlagSet) BoolVar(p *bool, name string, value bool, usage string) {\n\tf.BoolVarP(p, name, \"\", value, usage)\n}\n\n// BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) BoolVarP(p *bool, name, shorthand string, value bool, usage string) {\n\tflag := f.VarPF(newBoolValue(value, p), name, shorthand, usage)\n\tflag.NoOptDefVal = \"true\"\n}\n\n// BoolVar defines a bool flag with specified name, default value, and usage string.\n// The argument p points to a bool variable in which to store the value of the flag.\nfunc BoolVar(p *bool, name string, value bool, usage string) {\n\tBoolVarP(p, name, \"\", value, usage)\n}\n\n// BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash.\nfunc BoolVarP(p *bool, name, shorthand string, value bool, usage string) {\n\tflag := CommandLine.VarPF(newBoolValue(value, p), name, shorthand, usage)\n\tflag.NoOptDefVal = \"true\"\n}\n\n// Bool defines a bool flag with specified name, default value, and usage string.\n// The return value is the address of a bool variable that stores the value of the flag.\nfunc (f *FlagSet) Bool(name string, value bool, usage string) *bool {\n\treturn f.BoolP(name, \"\", value, usage)\n}\n\n// BoolP is like Bool, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) BoolP(name, shorthand string, value bool, usage string) *bool {\n\tp := new(bool)\n\tf.BoolVarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// Bool defines a bool flag with specified name, default value, and usage string.\n// The return value is the address of a bool variable that stores the value of the flag.\nfunc Bool(name string, value bool, usage string) *bool {\n\treturn BoolP(name, \"\", value, usage)\n}\n\n// BoolP is like Bool, but accepts a shorthand letter that can be used after a single dash.\nfunc BoolP(name, shorthand string, value bool, usage string) *bool {\n\tb := CommandLine.BoolP(name, shorthand, value, usage)\n\treturn b\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/bool_slice.go",
    "content": "package pflag\n\nimport (\n\t\"io\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// -- boolSlice Value\ntype boolSliceValue struct {\n\tvalue   *[]bool\n\tchanged bool\n}\n\nfunc newBoolSliceValue(val []bool, p *[]bool) *boolSliceValue {\n\tbsv := new(boolSliceValue)\n\tbsv.value = p\n\t*bsv.value = val\n\treturn bsv\n}\n\n// Set converts, and assigns, the comma-separated boolean argument string representation as the []bool value of this flag.\n// If Set is called on a flag that already has a []bool assigned, the newly converted values will be appended.\nfunc (s *boolSliceValue) Set(val string) error {\n\n\t// remove all quote characters\n\trmQuote := strings.NewReplacer(`\"`, \"\", `'`, \"\", \"`\", \"\")\n\n\t// read flag arguments with CSV parser\n\tboolStrSlice, err := readAsCSV(rmQuote.Replace(val))\n\tif err != nil && err != io.EOF {\n\t\treturn err\n\t}\n\n\t// parse boolean values into slice\n\tout := make([]bool, 0, len(boolStrSlice))\n\tfor _, boolStr := range boolStrSlice {\n\t\tb, err := strconv.ParseBool(strings.TrimSpace(boolStr))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tout = append(out, b)\n\t}\n\n\tif !s.changed {\n\t\t*s.value = out\n\t} else {\n\t\t*s.value = append(*s.value, out...)\n\t}\n\n\ts.changed = true\n\n\treturn nil\n}\n\n// Type returns a string that uniquely represents this flag's type.\nfunc (s *boolSliceValue) Type() string {\n\treturn \"boolSlice\"\n}\n\n// String defines a \"native\" format for this boolean slice flag value.\nfunc (s *boolSliceValue) String() string {\n\n\tboolStrSlice := make([]string, len(*s.value))\n\tfor i, b := range *s.value {\n\t\tboolStrSlice[i] = strconv.FormatBool(b)\n\t}\n\n\tout, _ := writeAsCSV(boolStrSlice)\n\n\treturn \"[\" + out + \"]\"\n}\n\nfunc boolSliceConv(val string) (interface{}, error) {\n\tval = strings.Trim(val, \"[]\")\n\t// Empty string would cause a slice with one (empty) entry\n\tif len(val) == 0 {\n\t\treturn []bool{}, nil\n\t}\n\tss := strings.Split(val, \",\")\n\tout := make([]bool, len(ss))\n\tfor i, t := range ss {\n\t\tvar err error\n\t\tout[i], err = strconv.ParseBool(t)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn out, nil\n}\n\n// GetBoolSlice returns the []bool value of a flag with the given name.\nfunc (f *FlagSet) GetBoolSlice(name string) ([]bool, error) {\n\tval, err := f.getFlagType(name, \"boolSlice\", boolSliceConv)\n\tif err != nil {\n\t\treturn []bool{}, err\n\t}\n\treturn val.([]bool), nil\n}\n\n// BoolSliceVar defines a boolSlice flag with specified name, default value, and usage string.\n// The argument p points to a []bool variable in which to store the value of the flag.\nfunc (f *FlagSet) BoolSliceVar(p *[]bool, name string, value []bool, usage string) {\n\tf.VarP(newBoolSliceValue(value, p), name, \"\", usage)\n}\n\n// BoolSliceVarP is like BoolSliceVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) BoolSliceVarP(p *[]bool, name, shorthand string, value []bool, usage string) {\n\tf.VarP(newBoolSliceValue(value, p), name, shorthand, usage)\n}\n\n// BoolSliceVar defines a []bool flag with specified name, default value, and usage string.\n// The argument p points to a []bool variable in which to store the value of the flag.\nfunc BoolSliceVar(p *[]bool, name string, value []bool, usage string) {\n\tCommandLine.VarP(newBoolSliceValue(value, p), name, \"\", usage)\n}\n\n// BoolSliceVarP is like BoolSliceVar, but accepts a shorthand letter that can be used after a single dash.\nfunc BoolSliceVarP(p *[]bool, name, shorthand string, value []bool, usage string) {\n\tCommandLine.VarP(newBoolSliceValue(value, p), name, shorthand, usage)\n}\n\n// BoolSlice defines a []bool flag with specified name, default value, and usage string.\n// The return value is the address of a []bool variable that stores the value of the flag.\nfunc (f *FlagSet) BoolSlice(name string, value []bool, usage string) *[]bool {\n\tp := []bool{}\n\tf.BoolSliceVarP(&p, name, \"\", value, usage)\n\treturn &p\n}\n\n// BoolSliceP is like BoolSlice, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) BoolSliceP(name, shorthand string, value []bool, usage string) *[]bool {\n\tp := []bool{}\n\tf.BoolSliceVarP(&p, name, shorthand, value, usage)\n\treturn &p\n}\n\n// BoolSlice defines a []bool flag with specified name, default value, and usage string.\n// The return value is the address of a []bool variable that stores the value of the flag.\nfunc BoolSlice(name string, value []bool, usage string) *[]bool {\n\treturn CommandLine.BoolSliceP(name, \"\", value, usage)\n}\n\n// BoolSliceP is like BoolSlice, but accepts a shorthand letter that can be used after a single dash.\nfunc BoolSliceP(name, shorthand string, value []bool, usage string) *[]bool {\n\treturn CommandLine.BoolSliceP(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/bool_slice_test.go",
    "content": "package pflag\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc setUpBSFlagSet(bsp *[]bool) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.BoolSliceVar(bsp, \"bs\", []bool{}, \"Command separated list!\")\n\treturn f\n}\n\nfunc setUpBSFlagSetWithDefault(bsp *[]bool) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.BoolSliceVar(bsp, \"bs\", []bool{false, true}, \"Command separated list!\")\n\treturn f\n}\n\nfunc TestEmptyBS(t *testing.T) {\n\tvar bs []bool\n\tf := setUpBSFlagSet(&bs)\n\terr := f.Parse([]string{})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tgetBS, err := f.GetBoolSlice(\"bs\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetBoolSlice():\", err)\n\t}\n\tif len(getBS) != 0 {\n\t\tt.Fatalf(\"got bs %v with len=%d but expected length=0\", getBS, len(getBS))\n\t}\n}\n\nfunc TestBS(t *testing.T) {\n\tvar bs []bool\n\tf := setUpBSFlagSet(&bs)\n\n\tvals := []string{\"1\", \"F\", \"TRUE\", \"0\"}\n\targ := fmt.Sprintf(\"--bs=%s\", strings.Join(vals, \",\"))\n\terr := f.Parse([]string{arg})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range bs {\n\t\tb, err := strconv.ParseBool(vals[i])\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif b != v {\n\t\t\tt.Fatalf(\"expected is[%d] to be %s but got: %t\", i, vals[i], v)\n\t\t}\n\t}\n\tgetBS, err := f.GetBoolSlice(\"bs\")\n\tif err != nil {\n\t\tt.Fatalf(\"got error: %v\", err)\n\t}\n\tfor i, v := range getBS {\n\t\tb, err := strconv.ParseBool(vals[i])\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif b != v {\n\t\t\tt.Fatalf(\"expected bs[%d] to be %s but got: %t from GetBoolSlice\", i, vals[i], v)\n\t\t}\n\t}\n}\n\nfunc TestBSDefault(t *testing.T) {\n\tvar bs []bool\n\tf := setUpBSFlagSetWithDefault(&bs)\n\n\tvals := []string{\"false\", \"T\"}\n\n\terr := f.Parse([]string{})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range bs {\n\t\tb, err := strconv.ParseBool(vals[i])\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif b != v {\n\t\t\tt.Fatalf(\"expected bs[%d] to be %t from GetBoolSlice but got: %t\", i, b, v)\n\t\t}\n\t}\n\n\tgetBS, err := f.GetBoolSlice(\"bs\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetBoolSlice():\", err)\n\t}\n\tfor i, v := range getBS {\n\t\tb, err := strconv.ParseBool(vals[i])\n\t\tif err != nil {\n\t\t\tt.Fatal(\"got an error from GetBoolSlice():\", err)\n\t\t}\n\t\tif b != v {\n\t\t\tt.Fatalf(\"expected bs[%d] to be %t from GetBoolSlice but got: %t\", i, b, v)\n\t\t}\n\t}\n}\n\nfunc TestBSWithDefault(t *testing.T) {\n\tvar bs []bool\n\tf := setUpBSFlagSetWithDefault(&bs)\n\n\tvals := []string{\"FALSE\", \"1\"}\n\targ := fmt.Sprintf(\"--bs=%s\", strings.Join(vals, \",\"))\n\terr := f.Parse([]string{arg})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range bs {\n\t\tb, err := strconv.ParseBool(vals[i])\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif b != v {\n\t\t\tt.Fatalf(\"expected bs[%d] to be %t but got: %t\", i, b, v)\n\t\t}\n\t}\n\n\tgetBS, err := f.GetBoolSlice(\"bs\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetBoolSlice():\", err)\n\t}\n\tfor i, v := range getBS {\n\t\tb, err := strconv.ParseBool(vals[i])\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif b != v {\n\t\t\tt.Fatalf(\"expected bs[%d] to be %t from GetBoolSlice but got: %t\", i, b, v)\n\t\t}\n\t}\n}\n\nfunc TestBSCalledTwice(t *testing.T) {\n\tvar bs []bool\n\tf := setUpBSFlagSet(&bs)\n\n\tin := []string{\"T,F\", \"T\"}\n\texpected := []bool{true, false, true}\n\targfmt := \"--bs=%s\"\n\targ1 := fmt.Sprintf(argfmt, in[0])\n\targ2 := fmt.Sprintf(argfmt, in[1])\n\terr := f.Parse([]string{arg1, arg2})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range bs {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected bs[%d] to be %t but got %t\", i, expected[i], v)\n\t\t}\n\t}\n}\n\nfunc TestBSBadQuoting(t *testing.T) {\n\n\ttests := []struct {\n\t\tWant    []bool\n\t\tFlagArg []string\n\t}{\n\t\t{\n\t\t\tWant:    []bool{true, false, true},\n\t\t\tFlagArg: []string{\"1\", \"0\", \"true\"},\n\t\t},\n\t\t{\n\t\t\tWant:    []bool{true, false},\n\t\t\tFlagArg: []string{\"True\", \"F\"},\n\t\t},\n\t\t{\n\t\t\tWant:    []bool{true, false},\n\t\t\tFlagArg: []string{\"T\", \"0\"},\n\t\t},\n\t\t{\n\t\t\tWant:    []bool{true, false},\n\t\t\tFlagArg: []string{\"1\", \"0\"},\n\t\t},\n\t\t{\n\t\t\tWant:    []bool{true, false, false},\n\t\t\tFlagArg: []string{\"true,false\", \"false\"},\n\t\t},\n\t\t{\n\t\t\tWant:    []bool{true, false, false, true, false, true, false},\n\t\t\tFlagArg: []string{`\"true,false,false,1,0,     T\"`, \" false \"},\n\t\t},\n\t\t{\n\t\t\tWant:    []bool{false, false, true, false, true, false, true},\n\t\t\tFlagArg: []string{`\"0, False,  T,false  , true,F\"`, \"true\"},\n\t\t},\n\t}\n\n\tfor i, test := range tests {\n\n\t\tvar bs []bool\n\t\tf := setUpBSFlagSet(&bs)\n\n\t\tif err := f.Parse([]string{fmt.Sprintf(\"--bs=%s\", strings.Join(test.FlagArg, \",\"))}); err != nil {\n\t\t\tt.Fatalf(\"flag parsing failed with error: %s\\nparsing:\\t%#v\\nwant:\\t\\t%#v\",\n\t\t\t\terr, test.FlagArg, test.Want[i])\n\t\t}\n\n\t\tfor j, b := range bs {\n\t\t\tif b != test.Want[j] {\n\t\t\t\tt.Fatalf(\"bad value parsed for test %d on bool %d:\\nwant:\\t%t\\ngot:\\t%t\", i, j, test.Want[j], b)\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/bool_test.go",
    "content": "// Copyright 2009 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 pflag\n\nimport (\n\t\"bytes\"\n\t\"strconv\"\n\t\"testing\"\n)\n\n// This value can be a boolean (\"true\", \"false\") or \"maybe\"\ntype triStateValue int\n\nconst (\n\ttriStateFalse triStateValue = 0\n\ttriStateTrue  triStateValue = 1\n\ttriStateMaybe triStateValue = 2\n)\n\nconst strTriStateMaybe = \"maybe\"\n\nfunc (v *triStateValue) IsBoolFlag() bool {\n\treturn true\n}\n\nfunc (v *triStateValue) Get() interface{} {\n\treturn triStateValue(*v)\n}\n\nfunc (v *triStateValue) Set(s string) error {\n\tif s == strTriStateMaybe {\n\t\t*v = triStateMaybe\n\t\treturn nil\n\t}\n\tboolVal, err := strconv.ParseBool(s)\n\tif boolVal {\n\t\t*v = triStateTrue\n\t} else {\n\t\t*v = triStateFalse\n\t}\n\treturn err\n}\n\nfunc (v *triStateValue) String() string {\n\tif *v == triStateMaybe {\n\t\treturn strTriStateMaybe\n\t}\n\treturn strconv.FormatBool(*v == triStateTrue)\n}\n\n// The type of the flag as required by the pflag.Value interface\nfunc (v *triStateValue) Type() string {\n\treturn \"version\"\n}\n\nfunc setUpFlagSet(tristate *triStateValue) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\t*tristate = triStateFalse\n\tflag := f.VarPF(tristate, \"tristate\", \"t\", \"tristate value (true, maybe or false)\")\n\tflag.NoOptDefVal = \"true\"\n\treturn f\n}\n\nfunc TestExplicitTrue(t *testing.T) {\n\tvar tristate triStateValue\n\tf := setUpFlagSet(&tristate)\n\terr := f.Parse([]string{\"--tristate=true\"})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tif tristate != triStateTrue {\n\t\tt.Fatal(\"expected\", triStateTrue, \"(triStateTrue) but got\", tristate, \"instead\")\n\t}\n}\n\nfunc TestImplicitTrue(t *testing.T) {\n\tvar tristate triStateValue\n\tf := setUpFlagSet(&tristate)\n\terr := f.Parse([]string{\"--tristate\"})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tif tristate != triStateTrue {\n\t\tt.Fatal(\"expected\", triStateTrue, \"(triStateTrue) but got\", tristate, \"instead\")\n\t}\n}\n\nfunc TestShortFlag(t *testing.T) {\n\tvar tristate triStateValue\n\tf := setUpFlagSet(&tristate)\n\terr := f.Parse([]string{\"-t\"})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tif tristate != triStateTrue {\n\t\tt.Fatal(\"expected\", triStateTrue, \"(triStateTrue) but got\", tristate, \"instead\")\n\t}\n}\n\nfunc TestShortFlagExtraArgument(t *testing.T) {\n\tvar tristate triStateValue\n\tf := setUpFlagSet(&tristate)\n\t// The\"maybe\"turns into an arg, since short boolean options will only do true/false\n\terr := f.Parse([]string{\"-t\", \"maybe\"})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tif tristate != triStateTrue {\n\t\tt.Fatal(\"expected\", triStateTrue, \"(triStateTrue) but got\", tristate, \"instead\")\n\t}\n\targs := f.Args()\n\tif len(args) != 1 || args[0] != \"maybe\" {\n\t\tt.Fatal(\"expected an extra 'maybe' argument to stick around\")\n\t}\n}\n\nfunc TestExplicitMaybe(t *testing.T) {\n\tvar tristate triStateValue\n\tf := setUpFlagSet(&tristate)\n\terr := f.Parse([]string{\"--tristate=maybe\"})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tif tristate != triStateMaybe {\n\t\tt.Fatal(\"expected\", triStateMaybe, \"(triStateMaybe) but got\", tristate, \"instead\")\n\t}\n}\n\nfunc TestExplicitFalse(t *testing.T) {\n\tvar tristate triStateValue\n\tf := setUpFlagSet(&tristate)\n\terr := f.Parse([]string{\"--tristate=false\"})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tif tristate != triStateFalse {\n\t\tt.Fatal(\"expected\", triStateFalse, \"(triStateFalse) but got\", tristate, \"instead\")\n\t}\n}\n\nfunc TestImplicitFalse(t *testing.T) {\n\tvar tristate triStateValue\n\tf := setUpFlagSet(&tristate)\n\terr := f.Parse([]string{})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tif tristate != triStateFalse {\n\t\tt.Fatal(\"expected\", triStateFalse, \"(triStateFalse) but got\", tristate, \"instead\")\n\t}\n}\n\nfunc TestInvalidValue(t *testing.T) {\n\tvar tristate triStateValue\n\tf := setUpFlagSet(&tristate)\n\tvar buf bytes.Buffer\n\tf.SetOutput(&buf)\n\terr := f.Parse([]string{\"--tristate=invalid\"})\n\tif err == nil {\n\t\tt.Fatal(\"expected an error but did not get any, tristate has value\", tristate)\n\t}\n}\n\nfunc TestBoolP(t *testing.T) {\n\tb := BoolP(\"bool\", \"b\", false, \"bool value in CommandLine\")\n\tc := BoolP(\"c\", \"c\", false, \"other bool value\")\n\targs := []string{\"--bool\"}\n\tif err := CommandLine.Parse(args); err != nil {\n\t\tt.Error(\"expected no error, got \", err)\n\t}\n\tif *b != true {\n\t\tt.Errorf(\"expected b=true got b=%v\", *b)\n\t}\n\tif *c != false {\n\t\tt.Errorf(\"expect c=false got c=%v\", *c)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/count.go",
    "content": "package pflag\n\nimport \"strconv\"\n\n// -- count Value\ntype countValue int\n\nfunc newCountValue(val int, p *int) *countValue {\n\t*p = val\n\treturn (*countValue)(p)\n}\n\nfunc (i *countValue) Set(s string) error {\n\tv, err := strconv.ParseInt(s, 0, 64)\n\t// -1 means that no specific value was passed, so increment\n\tif v == -1 {\n\t\t*i = countValue(*i + 1)\n\t} else {\n\t\t*i = countValue(v)\n\t}\n\treturn err\n}\n\nfunc (i *countValue) Type() string {\n\treturn \"count\"\n}\n\nfunc (i *countValue) String() string { return strconv.Itoa(int(*i)) }\n\nfunc countConv(sval string) (interface{}, error) {\n\ti, err := strconv.Atoi(sval)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn i, nil\n}\n\n// GetCount return the int value of a flag with the given name\nfunc (f *FlagSet) GetCount(name string) (int, error) {\n\tval, err := f.getFlagType(name, \"count\", countConv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn val.(int), nil\n}\n\n// CountVar defines a count flag with specified name, default value, and usage string.\n// The argument p points to an int variable in which to store the value of the flag.\n// A count flag will add 1 to its value evey time it is found on the command line\nfunc (f *FlagSet) CountVar(p *int, name string, usage string) {\n\tf.CountVarP(p, name, \"\", usage)\n}\n\n// CountVarP is like CountVar only take a shorthand for the flag name.\nfunc (f *FlagSet) CountVarP(p *int, name, shorthand string, usage string) {\n\tflag := f.VarPF(newCountValue(0, p), name, shorthand, usage)\n\tflag.NoOptDefVal = \"-1\"\n}\n\n// CountVar like CountVar only the flag is placed on the CommandLine instead of a given flag set\nfunc CountVar(p *int, name string, usage string) {\n\tCommandLine.CountVar(p, name, usage)\n}\n\n// CountVarP is like CountVar only take a shorthand for the flag name.\nfunc CountVarP(p *int, name, shorthand string, usage string) {\n\tCommandLine.CountVarP(p, name, shorthand, usage)\n}\n\n// Count defines a count flag with specified name, default value, and usage string.\n// The return value is the address of an int variable that stores the value of the flag.\n// A count flag will add 1 to its value evey time it is found on the command line\nfunc (f *FlagSet) Count(name string, usage string) *int {\n\tp := new(int)\n\tf.CountVarP(p, name, \"\", usage)\n\treturn p\n}\n\n// CountP is like Count only takes a shorthand for the flag name.\nfunc (f *FlagSet) CountP(name, shorthand string, usage string) *int {\n\tp := new(int)\n\tf.CountVarP(p, name, shorthand, usage)\n\treturn p\n}\n\n// Count defines a count flag with specified name, default value, and usage string.\n// The return value is the address of an int variable that stores the value of the flag.\n// A count flag will add 1 to its value evey time it is found on the command line\nfunc Count(name string, usage string) *int {\n\treturn CommandLine.CountP(name, \"\", usage)\n}\n\n// CountP is like Count only takes a shorthand for the flag name.\nfunc CountP(name, shorthand string, usage string) *int {\n\treturn CommandLine.CountP(name, shorthand, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/count_test.go",
    "content": "package pflag\n\nimport (\n\t\"os\"\n\t\"testing\"\n)\n\nfunc setUpCount(c *int) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.CountVarP(c, \"verbose\", \"v\", \"a counter\")\n\treturn f\n}\n\nfunc TestCount(t *testing.T) {\n\ttestCases := []struct {\n\t\tinput    []string\n\t\tsuccess  bool\n\t\texpected int\n\t}{\n\t\t{[]string{\"-vvv\"}, true, 3},\n\t\t{[]string{\"-v\", \"-v\", \"-v\"}, true, 3},\n\t\t{[]string{\"-v\", \"--verbose\", \"-v\"}, true, 3},\n\t\t{[]string{\"-v=3\", \"-v\"}, true, 4},\n\t\t{[]string{\"-v=a\"}, false, 0},\n\t}\n\n\tdevnull, _ := os.Open(os.DevNull)\n\tos.Stderr = devnull\n\tfor i := range testCases {\n\t\tvar count int\n\t\tf := setUpCount(&count)\n\n\t\ttc := &testCases[i]\n\n\t\terr := f.Parse(tc.input)\n\t\tif err != nil && tc.success == true {\n\t\t\tt.Errorf(\"expected success, got %q\", err)\n\t\t\tcontinue\n\t\t} else if err == nil && tc.success == false {\n\t\t\tt.Errorf(\"expected failure, got success\")\n\t\t\tcontinue\n\t\t} else if tc.success {\n\t\t\tc, err := f.GetCount(\"verbose\")\n\t\t\tif err != nil {\n\t\t\t\tt.Errorf(\"Got error trying to fetch the counter flag\")\n\t\t\t}\n\t\t\tif c != tc.expected {\n\t\t\t\tt.Errorf(\"expected %q, got %q\", tc.expected, c)\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/duration.go",
    "content": "package pflag\n\nimport (\n\t\"time\"\n)\n\n// -- time.Duration Value\ntype durationValue time.Duration\n\nfunc newDurationValue(val time.Duration, p *time.Duration) *durationValue {\n\t*p = val\n\treturn (*durationValue)(p)\n}\n\nfunc (d *durationValue) Set(s string) error {\n\tv, err := time.ParseDuration(s)\n\t*d = durationValue(v)\n\treturn err\n}\n\nfunc (d *durationValue) Type() string {\n\treturn \"duration\"\n}\n\nfunc (d *durationValue) String() string { return (*time.Duration)(d).String() }\n\nfunc durationConv(sval string) (interface{}, error) {\n\treturn time.ParseDuration(sval)\n}\n\n// GetDuration return the duration value of a flag with the given name\nfunc (f *FlagSet) GetDuration(name string) (time.Duration, error) {\n\tval, err := f.getFlagType(name, \"duration\", durationConv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn val.(time.Duration), nil\n}\n\n// DurationVar defines a time.Duration flag with specified name, default value, and usage string.\n// The argument p points to a time.Duration variable in which to store the value of the flag.\nfunc (f *FlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string) {\n\tf.VarP(newDurationValue(value, p), name, \"\", usage)\n}\n\n// DurationVarP is like DurationVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string) {\n\tf.VarP(newDurationValue(value, p), name, shorthand, usage)\n}\n\n// DurationVar defines a time.Duration flag with specified name, default value, and usage string.\n// The argument p points to a time.Duration variable in which to store the value of the flag.\nfunc DurationVar(p *time.Duration, name string, value time.Duration, usage string) {\n\tCommandLine.VarP(newDurationValue(value, p), name, \"\", usage)\n}\n\n// DurationVarP is like DurationVar, but accepts a shorthand letter that can be used after a single dash.\nfunc DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string) {\n\tCommandLine.VarP(newDurationValue(value, p), name, shorthand, usage)\n}\n\n// Duration defines a time.Duration flag with specified name, default value, and usage string.\n// The return value is the address of a time.Duration variable that stores the value of the flag.\nfunc (f *FlagSet) Duration(name string, value time.Duration, usage string) *time.Duration {\n\tp := new(time.Duration)\n\tf.DurationVarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// DurationP is like Duration, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration {\n\tp := new(time.Duration)\n\tf.DurationVarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// Duration defines a time.Duration flag with specified name, default value, and usage string.\n// The return value is the address of a time.Duration variable that stores the value of the flag.\nfunc Duration(name string, value time.Duration, usage string) *time.Duration {\n\treturn CommandLine.DurationP(name, \"\", value, usage)\n}\n\n// DurationP is like Duration, but accepts a shorthand letter that can be used after a single dash.\nfunc DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration {\n\treturn CommandLine.DurationP(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/example_test.go",
    "content": "// Copyright 2012 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 pflag_test\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/spf13/pflag\"\n)\n\nfunc ExampleShorthandLookup() {\n\tname := \"verbose\"\n\tshort := name[:1]\n\n\tpflag.BoolP(name, short, false, \"verbose output\")\n\n\t// len(short) must be == 1\n\tflag := pflag.ShorthandLookup(short)\n\n\tfmt.Println(flag.Name)\n}\n\nfunc ExampleFlagSet_ShorthandLookup() {\n\tname := \"verbose\"\n\tshort := name[:1]\n\n\tfs := pflag.NewFlagSet(\"Example\", pflag.ContinueOnError)\n\tfs.BoolP(name, short, false, \"verbose output\")\n\n\t// len(short) must be == 1\n\tflag := fs.ShorthandLookup(short)\n\n\tfmt.Println(flag.Name)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/export_test.go",
    "content": "// Copyright 2010 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 pflag\n\nimport (\n\t\"io/ioutil\"\n\t\"os\"\n)\n\n// Additional routines compiled into the package only during testing.\n\n// ResetForTesting clears all flag state and sets the usage function as directed.\n// After calling ResetForTesting, parse errors in flag handling will not\n// exit the program.\nfunc ResetForTesting(usage func()) {\n\tCommandLine = &FlagSet{\n\t\tname:          os.Args[0],\n\t\terrorHandling: ContinueOnError,\n\t\toutput:        ioutil.Discard,\n\t}\n\tUsage = usage\n}\n\n// GetCommandLine returns the default FlagSet.\nfunc GetCommandLine() *FlagSet {\n\treturn CommandLine\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/flag.go",
    "content": "// Copyright 2009 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/*\nPackage pflag is a drop-in replacement for Go's flag package, implementing\nPOSIX/GNU-style --flags.\n\npflag is compatible with the GNU extensions to the POSIX recommendations\nfor command-line options. See\nhttp://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html\n\nUsage:\n\npflag is a drop-in replacement of Go's native flag package. If you import\npflag under the name \"flag\" then all code should continue to function\nwith no changes.\n\n\timport flag \"github.com/spf13/pflag\"\n\nThere is one exception to this: if you directly instantiate the Flag struct\nthere is one more field \"Shorthand\" that you will need to set.\nMost code never instantiates this struct directly, and instead uses\nfunctions such as String(), BoolVar(), and Var(), and is therefore\nunaffected.\n\nDefine flags using flag.String(), Bool(), Int(), etc.\n\nThis declares an integer flag, -flagname, stored in the pointer ip, with type *int.\n\tvar ip = flag.Int(\"flagname\", 1234, \"help message for flagname\")\nIf you like, you can bind the flag to a variable using the Var() functions.\n\tvar flagvar int\n\tfunc init() {\n\t\tflag.IntVar(&flagvar, \"flagname\", 1234, \"help message for flagname\")\n\t}\nOr you can create custom flags that satisfy the Value interface (with\npointer receivers) and couple them to flag parsing by\n\tflag.Var(&flagVal, \"name\", \"help message for flagname\")\nFor such flags, the default value is just the initial value of the variable.\n\nAfter all flags are defined, call\n\tflag.Parse()\nto parse the command line into the defined flags.\n\nFlags may then be used directly. If you're using the flags themselves,\nthey are all pointers; if you bind to variables, they're values.\n\tfmt.Println(\"ip has value \", *ip)\n\tfmt.Println(\"flagvar has value \", flagvar)\n\nAfter parsing, the arguments after the flag are available as the\nslice flag.Args() or individually as flag.Arg(i).\nThe arguments are indexed from 0 through flag.NArg()-1.\n\nThe pflag package also defines some new functions that are not in flag,\nthat give one-letter shorthands for flags. You can use these by appending\n'P' to the name of any function that defines a flag.\n\tvar ip = flag.IntP(\"flagname\", \"f\", 1234, \"help message\")\n\tvar flagvar bool\n\tfunc init() {\n\t\tflag.BoolVarP(\"boolname\", \"b\", true, \"help message\")\n\t}\n\tflag.VarP(&flagVar, \"varname\", \"v\", 1234, \"help message\")\nShorthand letters can be used with single dashes on the command line.\nBoolean shorthand flags can be combined with other shorthand flags.\n\nCommand line flag syntax:\n\t--flag    // boolean flags only\n\t--flag=x\n\nUnlike the flag package, a single dash before an option means something\ndifferent than a double dash. Single dashes signify a series of shorthand\nletters for flags. All but the last shorthand letter must be boolean flags.\n\t// boolean flags\n\t-f\n\t-abc\n\t// non-boolean flags\n\t-n 1234\n\t-Ifile\n\t// mixed\n\t-abcs \"hello\"\n\t-abcn1234\n\nFlag parsing stops after the terminator \"--\". Unlike the flag package,\nflags can be interspersed with arguments anywhere on the command line\nbefore this terminator.\n\nInteger flags accept 1234, 0664, 0x1234 and may be negative.\nBoolean flags (in their long form) accept 1, 0, t, f, true, false,\nTRUE, FALSE, True, False.\nDuration flags accept any input valid for time.ParseDuration.\n\nThe default set of command-line flags is controlled by\ntop-level functions.  The FlagSet type allows one to define\nindependent sets of flags, such as to implement subcommands\nin a command-line interface. The methods of FlagSet are\nanalogous to the top-level functions for the command-line\nflag set.\n*/\npackage pflag\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"sort\"\n\t\"strings\"\n)\n\n// ErrHelp is the error returned if the flag -help is invoked but no such flag is defined.\nvar ErrHelp = errors.New(\"pflag: help requested\")\n\n// ErrorHandling defines how to handle flag parsing errors.\ntype ErrorHandling int\n\nconst (\n\t// ContinueOnError will return an err from Parse() if an error is found\n\tContinueOnError ErrorHandling = iota\n\t// ExitOnError will call os.Exit(2) if an error is found when parsing\n\tExitOnError\n\t// PanicOnError will panic() if an error is found when parsing flags\n\tPanicOnError\n)\n\n// NormalizedName is a flag name that has been normalized according to rules\n// for the FlagSet (e.g. making '-' and '_' equivalent).\ntype NormalizedName string\n\n// A FlagSet represents a set of defined flags.\ntype FlagSet struct {\n\t// Usage is the function called when an error occurs while parsing flags.\n\t// The field is a function (not a method) that may be changed to point to\n\t// a custom error handler.\n\tUsage func()\n\n\t// SortFlags is used to indicate, if user wants to have sorted flags in\n\t// help/usage messages.\n\tSortFlags bool\n\n\tname              string\n\tparsed            bool\n\tactual            map[NormalizedName]*Flag\n\torderedActual     []*Flag\n\tsortedActual      []*Flag\n\tformal            map[NormalizedName]*Flag\n\torderedFormal     []*Flag\n\tsortedFormal      []*Flag\n\tshorthands        map[byte]*Flag\n\targs              []string // arguments after flags\n\targsLenAtDash     int      // len(args) when a '--' was located when parsing, or -1 if no --\n\terrorHandling     ErrorHandling\n\toutput            io.Writer // nil means stderr; use out() accessor\n\tinterspersed      bool      // allow interspersed option/non-option args\n\tnormalizeNameFunc func(f *FlagSet, name string) NormalizedName\n}\n\n// A Flag represents the state of a flag.\ntype Flag struct {\n\tName                string              // name as it appears on command line\n\tShorthand           string              // one-letter abbreviated flag\n\tUsage               string              // help message\n\tValue               Value               // value as set\n\tDefValue            string              // default value (as text); for usage message\n\tChanged             bool                // If the user set the value (or if left to default)\n\tNoOptDefVal         string              // default value (as text); if the flag is on the command line without any options\n\tDeprecated          string              // If this flag is deprecated, this string is the new or now thing to use\n\tHidden              bool                // used by cobra.Command to allow flags to be hidden from help/usage text\n\tShorthandDeprecated string              // If the shorthand of this flag is deprecated, this string is the new or now thing to use\n\tAnnotations         map[string][]string // used by cobra.Command bash autocomple code\n}\n\n// Value is the interface to the dynamic value stored in a flag.\n// (The default value is represented as a string.)\ntype Value interface {\n\tString() string\n\tSet(string) error\n\tType() string\n}\n\n// sortFlags returns the flags as a slice in lexicographical sorted order.\nfunc sortFlags(flags map[NormalizedName]*Flag) []*Flag {\n\tlist := make(sort.StringSlice, len(flags))\n\ti := 0\n\tfor k := range flags {\n\t\tlist[i] = string(k)\n\t\ti++\n\t}\n\tlist.Sort()\n\tresult := make([]*Flag, len(list))\n\tfor i, name := range list {\n\t\tresult[i] = flags[NormalizedName(name)]\n\t}\n\treturn result\n}\n\n// SetNormalizeFunc allows you to add a function which can translate flag names.\n// Flags added to the FlagSet will be translated and then when anything tries to\n// look up the flag that will also be translated. So it would be possible to create\n// a flag named \"getURL\" and have it translated to \"geturl\".  A user could then pass\n// \"--getUrl\" which may also be translated to \"geturl\" and everything will work.\nfunc (f *FlagSet) SetNormalizeFunc(n func(f *FlagSet, name string) NormalizedName) {\n\tf.normalizeNameFunc = n\n\tf.sortedFormal = f.sortedFormal[:0]\n\tfor k, v := range f.orderedFormal {\n\t\tdelete(f.formal, NormalizedName(v.Name))\n\t\tnname := f.normalizeFlagName(v.Name)\n\t\tv.Name = string(nname)\n\t\tf.formal[nname] = v\n\t\tf.orderedFormal[k] = v\n\t}\n}\n\n// GetNormalizeFunc returns the previously set NormalizeFunc of a function which\n// does no translation, if not set previously.\nfunc (f *FlagSet) GetNormalizeFunc() func(f *FlagSet, name string) NormalizedName {\n\tif f.normalizeNameFunc != nil {\n\t\treturn f.normalizeNameFunc\n\t}\n\treturn func(f *FlagSet, name string) NormalizedName { return NormalizedName(name) }\n}\n\nfunc (f *FlagSet) normalizeFlagName(name string) NormalizedName {\n\tn := f.GetNormalizeFunc()\n\treturn n(f, name)\n}\n\nfunc (f *FlagSet) out() io.Writer {\n\tif f.output == nil {\n\t\treturn os.Stderr\n\t}\n\treturn f.output\n}\n\n// SetOutput sets the destination for usage and error messages.\n// If output is nil, os.Stderr is used.\nfunc (f *FlagSet) SetOutput(output io.Writer) {\n\tf.output = output\n}\n\n// VisitAll visits the flags in lexicographical order or\n// in primordial order if f.SortFlags is false, calling fn for each.\n// It visits all flags, even those not set.\nfunc (f *FlagSet) VisitAll(fn func(*Flag)) {\n\tif len(f.formal) == 0 {\n\t\treturn\n\t}\n\n\tvar flags []*Flag\n\tif f.SortFlags {\n\t\tif len(f.formal) != len(f.sortedFormal) {\n\t\t\tf.sortedFormal = sortFlags(f.formal)\n\t\t}\n\t\tflags = f.sortedFormal\n\t} else {\n\t\tflags = f.orderedFormal\n\t}\n\n\tfor _, flag := range flags {\n\t\tfn(flag)\n\t}\n}\n\n// HasFlags returns a bool to indicate if the FlagSet has any flags definied.\nfunc (f *FlagSet) HasFlags() bool {\n\treturn len(f.formal) > 0\n}\n\n// HasAvailableFlags returns a bool to indicate if the FlagSet has any flags\n// definied that are not hidden or deprecated.\nfunc (f *FlagSet) HasAvailableFlags() bool {\n\tfor _, flag := range f.formal {\n\t\tif !flag.Hidden && len(flag.Deprecated) == 0 {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// VisitAll visits the command-line flags in lexicographical order or\n// in primordial order if f.SortFlags is false, calling fn for each.\n// It visits all flags, even those not set.\nfunc VisitAll(fn func(*Flag)) {\n\tCommandLine.VisitAll(fn)\n}\n\n// Visit visits the flags in lexicographical order or\n// in primordial order if f.SortFlags is false, calling fn for each.\n// It visits only those flags that have been set.\nfunc (f *FlagSet) Visit(fn func(*Flag)) {\n\tif len(f.actual) == 0 {\n\t\treturn\n\t}\n\n\tvar flags []*Flag\n\tif f.SortFlags {\n\t\tif len(f.actual) != len(f.sortedActual) {\n\t\t\tf.sortedActual = sortFlags(f.actual)\n\t\t}\n\t\tflags = f.sortedActual\n\t} else {\n\t\tflags = f.orderedActual\n\t}\n\n\tfor _, flag := range flags {\n\t\tfn(flag)\n\t}\n}\n\n// Visit visits the command-line flags in lexicographical order or\n// in primordial order if f.SortFlags is false, calling fn for each.\n// It visits only those flags that have been set.\nfunc Visit(fn func(*Flag)) {\n\tCommandLine.Visit(fn)\n}\n\n// Lookup returns the Flag structure of the named flag, returning nil if none exists.\nfunc (f *FlagSet) Lookup(name string) *Flag {\n\treturn f.lookup(f.normalizeFlagName(name))\n}\n\n// ShorthandLookup returns the Flag structure of the short handed flag,\n// returning nil if none exists.\n// It panics, if len(name) > 1.\nfunc (f *FlagSet) ShorthandLookup(name string) *Flag {\n\tif name == \"\" {\n\t\treturn nil\n\t}\n\tif len(name) > 1 {\n\t\tmsg := fmt.Sprintf(\"can not look up shorthand which is more than one ASCII character: %q\", name)\n\t\tfmt.Fprintf(f.out(), msg)\n\t\tpanic(msg)\n\t}\n\tc := name[0]\n\treturn f.shorthands[c]\n}\n\n// lookup returns the Flag structure of the named flag, returning nil if none exists.\nfunc (f *FlagSet) lookup(name NormalizedName) *Flag {\n\treturn f.formal[name]\n}\n\n// func to return a given type for a given flag name\nfunc (f *FlagSet) getFlagType(name string, ftype string, convFunc func(sval string) (interface{}, error)) (interface{}, error) {\n\tflag := f.Lookup(name)\n\tif flag == nil {\n\t\terr := fmt.Errorf(\"flag accessed but not defined: %s\", name)\n\t\treturn nil, err\n\t}\n\n\tif flag.Value.Type() != ftype {\n\t\terr := fmt.Errorf(\"trying to get %s value of flag of type %s\", ftype, flag.Value.Type())\n\t\treturn nil, err\n\t}\n\n\tsval := flag.Value.String()\n\tresult, err := convFunc(sval)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result, nil\n}\n\n// ArgsLenAtDash will return the length of f.Args at the moment when a -- was\n// found during arg parsing. This allows your program to know which args were\n// before the -- and which came after.\nfunc (f *FlagSet) ArgsLenAtDash() int {\n\treturn f.argsLenAtDash\n}\n\n// MarkDeprecated indicated that a flag is deprecated in your program. It will\n// continue to function but will not show up in help or usage messages. Using\n// this flag will also print the given usageMessage.\nfunc (f *FlagSet) MarkDeprecated(name string, usageMessage string) error {\n\tflag := f.Lookup(name)\n\tif flag == nil {\n\t\treturn fmt.Errorf(\"flag %q does not exist\", name)\n\t}\n\tif usageMessage == \"\" {\n\t\treturn fmt.Errorf(\"deprecated message for flag %q must be set\", name)\n\t}\n\tflag.Deprecated = usageMessage\n\treturn nil\n}\n\n// MarkShorthandDeprecated will mark the shorthand of a flag deprecated in your\n// program. It will continue to function but will not show up in help or usage\n// messages. Using this flag will also print the given usageMessage.\nfunc (f *FlagSet) MarkShorthandDeprecated(name string, usageMessage string) error {\n\tflag := f.Lookup(name)\n\tif flag == nil {\n\t\treturn fmt.Errorf(\"flag %q does not exist\", name)\n\t}\n\tif usageMessage == \"\" {\n\t\treturn fmt.Errorf(\"deprecated message for flag %q must be set\", name)\n\t}\n\tflag.ShorthandDeprecated = usageMessage\n\treturn nil\n}\n\n// MarkHidden sets a flag to 'hidden' in your program. It will continue to\n// function but will not show up in help or usage messages.\nfunc (f *FlagSet) MarkHidden(name string) error {\n\tflag := f.Lookup(name)\n\tif flag == nil {\n\t\treturn fmt.Errorf(\"flag %q does not exist\", name)\n\t}\n\tflag.Hidden = true\n\treturn nil\n}\n\n// Lookup returns the Flag structure of the named command-line flag,\n// returning nil if none exists.\nfunc Lookup(name string) *Flag {\n\treturn CommandLine.Lookup(name)\n}\n\n// ShorthandLookup returns the Flag structure of the short handed flag,\n// returning nil if none exists.\nfunc ShorthandLookup(name string) *Flag {\n\treturn CommandLine.ShorthandLookup(name)\n}\n\n// Set sets the value of the named flag.\nfunc (f *FlagSet) Set(name, value string) error {\n\tnormalName := f.normalizeFlagName(name)\n\tflag, ok := f.formal[normalName]\n\tif !ok {\n\t\treturn fmt.Errorf(\"no such flag -%v\", name)\n\t}\n\n\terr := flag.Value.Set(value)\n\tif err != nil {\n\t\tvar flagName string\n\t\tif flag.Shorthand != \"\" && flag.ShorthandDeprecated == \"\" {\n\t\t\tflagName = fmt.Sprintf(\"-%s, --%s\", flag.Shorthand, flag.Name)\n\t\t} else {\n\t\t\tflagName = fmt.Sprintf(\"--%s\", flag.Name)\n\t\t}\n\t\treturn fmt.Errorf(\"invalid argument %q for %q flag: %v\", value, flagName, err)\n\t}\n\n\tif f.actual == nil {\n\t\tf.actual = make(map[NormalizedName]*Flag)\n\t}\n\tf.actual[normalName] = flag\n\tf.orderedActual = append(f.orderedActual, flag)\n\n\tflag.Changed = true\n\n\tif flag.Deprecated != \"\" {\n\t\tfmt.Fprintf(f.out(), \"Flag --%s has been deprecated, %s\\n\", flag.Name, flag.Deprecated)\n\t}\n\treturn nil\n}\n\n// SetAnnotation allows one to set arbitrary annotations on a flag in the FlagSet.\n// This is sometimes used by spf13/cobra programs which want to generate additional\n// bash completion information.\nfunc (f *FlagSet) SetAnnotation(name, key string, values []string) error {\n\tnormalName := f.normalizeFlagName(name)\n\tflag, ok := f.formal[normalName]\n\tif !ok {\n\t\treturn fmt.Errorf(\"no such flag -%v\", name)\n\t}\n\tif flag.Annotations == nil {\n\t\tflag.Annotations = map[string][]string{}\n\t}\n\tflag.Annotations[key] = values\n\treturn nil\n}\n\n// Changed returns true if the flag was explicitly set during Parse() and false\n// otherwise\nfunc (f *FlagSet) Changed(name string) bool {\n\tflag := f.Lookup(name)\n\t// If a flag doesn't exist, it wasn't changed....\n\tif flag == nil {\n\t\treturn false\n\t}\n\treturn flag.Changed\n}\n\n// Set sets the value of the named command-line flag.\nfunc Set(name, value string) error {\n\treturn CommandLine.Set(name, value)\n}\n\n// PrintDefaults prints, to standard error unless configured\n// otherwise, the default values of all defined flags in the set.\nfunc (f *FlagSet) PrintDefaults() {\n\tusages := f.FlagUsages()\n\tfmt.Fprint(f.out(), usages)\n}\n\n// defaultIsZeroValue returns true if the default value for this flag represents\n// a zero value.\nfunc (f *Flag) defaultIsZeroValue() bool {\n\tswitch f.Value.(type) {\n\tcase boolFlag:\n\t\treturn f.DefValue == \"false\"\n\tcase *durationValue:\n\t\t// Beginning in Go 1.7, duration zero values are \"0s\"\n\t\treturn f.DefValue == \"0\" || f.DefValue == \"0s\"\n\tcase *intValue, *int8Value, *int32Value, *int64Value, *uintValue, *uint8Value, *uint16Value, *uint32Value, *uint64Value, *countValue, *float32Value, *float64Value:\n\t\treturn f.DefValue == \"0\"\n\tcase *stringValue:\n\t\treturn f.DefValue == \"\"\n\tcase *ipValue, *ipMaskValue, *ipNetValue:\n\t\treturn f.DefValue == \"<nil>\"\n\tcase *intSliceValue, *stringSliceValue, *stringArrayValue:\n\t\treturn f.DefValue == \"[]\"\n\tdefault:\n\t\tswitch f.Value.String() {\n\t\tcase \"false\":\n\t\t\treturn true\n\t\tcase \"<nil>\":\n\t\t\treturn true\n\t\tcase \"\":\n\t\t\treturn true\n\t\tcase \"0\":\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n}\n\n// UnquoteUsage extracts a back-quoted name from the usage\n// string for a flag and returns it and the un-quoted usage.\n// Given \"a `name` to show\" it returns (\"name\", \"a name to show\").\n// If there are no back quotes, the name is an educated guess of the\n// type of the flag's value, or the empty string if the flag is boolean.\nfunc UnquoteUsage(flag *Flag) (name string, usage string) {\n\t// Look for a back-quoted name, but avoid the strings package.\n\tusage = flag.Usage\n\tfor i := 0; i < len(usage); i++ {\n\t\tif usage[i] == '`' {\n\t\t\tfor j := i + 1; j < len(usage); j++ {\n\t\t\t\tif usage[j] == '`' {\n\t\t\t\t\tname = usage[i+1 : j]\n\t\t\t\t\tusage = usage[:i] + name + usage[j+1:]\n\t\t\t\t\treturn name, usage\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak // Only one back quote; use type name.\n\t\t}\n\t}\n\n\tname = flag.Value.Type()\n\tswitch name {\n\tcase \"bool\":\n\t\tname = \"\"\n\tcase \"float64\":\n\t\tname = \"float\"\n\tcase \"int64\":\n\t\tname = \"int\"\n\tcase \"uint64\":\n\t\tname = \"uint\"\n\t}\n\n\treturn\n}\n\n// Splits the string `s` on whitespace into an initial substring up to\n// `i` runes in length and the remainder. Will go `slop` over `i` if\n// that encompasses the entire string (which allows the caller to\n// avoid short orphan words on the final line).\nfunc wrapN(i, slop int, s string) (string, string) {\n\tif i+slop > len(s) {\n\t\treturn s, \"\"\n\t}\n\n\tw := strings.LastIndexAny(s[:i], \" \\t\")\n\tif w <= 0 {\n\t\treturn s, \"\"\n\t}\n\n\treturn s[:w], s[w+1:]\n}\n\n// Wraps the string `s` to a maximum width `w` with leading indent\n// `i`. The first line is not indented (this is assumed to be done by\n// caller). Pass `w` == 0 to do no wrapping\nfunc wrap(i, w int, s string) string {\n\tif w == 0 {\n\t\treturn s\n\t}\n\n\t// space between indent i and end of line width w into which\n\t// we should wrap the text.\n\twrap := w - i\n\n\tvar r, l string\n\n\t// Not enough space for sensible wrapping. Wrap as a block on\n\t// the next line instead.\n\tif wrap < 24 {\n\t\ti = 16\n\t\twrap = w - i\n\t\tr += \"\\n\" + strings.Repeat(\" \", i)\n\t}\n\t// If still not enough space then don't even try to wrap.\n\tif wrap < 24 {\n\t\treturn s\n\t}\n\n\t// Try to avoid short orphan words on the final line, by\n\t// allowing wrapN to go a bit over if that would fit in the\n\t// remainder of the line.\n\tslop := 5\n\twrap = wrap - slop\n\n\t// Handle first line, which is indented by the caller (or the\n\t// special case above)\n\tl, s = wrapN(wrap, slop, s)\n\tr = r + l\n\n\t// Now wrap the rest\n\tfor s != \"\" {\n\t\tvar t string\n\n\t\tt, s = wrapN(wrap, slop, s)\n\t\tr = r + \"\\n\" + strings.Repeat(\" \", i) + t\n\t}\n\n\treturn r\n\n}\n\n// FlagUsagesWrapped returns a string containing the usage information\n// for all flags in the FlagSet. Wrapped to `cols` columns (0 for no\n// wrapping)\nfunc (f *FlagSet) FlagUsagesWrapped(cols int) string {\n\tbuf := new(bytes.Buffer)\n\n\tlines := make([]string, 0, len(f.formal))\n\n\tmaxlen := 0\n\tf.VisitAll(func(flag *Flag) {\n\t\tif flag.Deprecated != \"\" || flag.Hidden {\n\t\t\treturn\n\t\t}\n\n\t\tline := \"\"\n\t\tif flag.Shorthand != \"\" && flag.ShorthandDeprecated == \"\" {\n\t\t\tline = fmt.Sprintf(\"  -%s, --%s\", flag.Shorthand, flag.Name)\n\t\t} else {\n\t\t\tline = fmt.Sprintf(\"      --%s\", flag.Name)\n\t\t}\n\n\t\tvarname, usage := UnquoteUsage(flag)\n\t\tif varname != \"\" {\n\t\t\tline += \" \" + varname\n\t\t}\n\t\tif flag.NoOptDefVal != \"\" {\n\t\t\tswitch flag.Value.Type() {\n\t\t\tcase \"string\":\n\t\t\t\tline += fmt.Sprintf(\"[=\\\"%s\\\"]\", flag.NoOptDefVal)\n\t\t\tcase \"bool\":\n\t\t\t\tif flag.NoOptDefVal != \"true\" {\n\t\t\t\t\tline += fmt.Sprintf(\"[=%s]\", flag.NoOptDefVal)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tline += fmt.Sprintf(\"[=%s]\", flag.NoOptDefVal)\n\t\t\t}\n\t\t}\n\n\t\t// This special character will be replaced with spacing once the\n\t\t// correct alignment is calculated\n\t\tline += \"\\x00\"\n\t\tif len(line) > maxlen {\n\t\t\tmaxlen = len(line)\n\t\t}\n\n\t\tline += usage\n\t\tif !flag.defaultIsZeroValue() {\n\t\t\tif flag.Value.Type() == \"string\" {\n\t\t\t\tline += fmt.Sprintf(\" (default %q)\", flag.DefValue)\n\t\t\t} else {\n\t\t\t\tline += fmt.Sprintf(\" (default %s)\", flag.DefValue)\n\t\t\t}\n\t\t}\n\n\t\tlines = append(lines, line)\n\t})\n\n\tfor _, line := range lines {\n\t\tsidx := strings.Index(line, \"\\x00\")\n\t\tspacing := strings.Repeat(\" \", maxlen-sidx)\n\t\t// maxlen + 2 comes from + 1 for the \\x00 and + 1 for the (deliberate) off-by-one in maxlen-sidx\n\t\tfmt.Fprintln(buf, line[:sidx], spacing, wrap(maxlen+2, cols, line[sidx+1:]))\n\t}\n\n\treturn buf.String()\n}\n\n// FlagUsages returns a string containing the usage information for all flags in\n// the FlagSet\nfunc (f *FlagSet) FlagUsages() string {\n\treturn f.FlagUsagesWrapped(0)\n}\n\n// PrintDefaults prints to standard error the default values of all defined command-line flags.\nfunc PrintDefaults() {\n\tCommandLine.PrintDefaults()\n}\n\n// defaultUsage is the default function to print a usage message.\nfunc defaultUsage(f *FlagSet) {\n\tfmt.Fprintf(f.out(), \"Usage of %s:\\n\", f.name)\n\tf.PrintDefaults()\n}\n\n// NOTE: Usage is not just defaultUsage(CommandLine)\n// because it serves (via godoc flag Usage) as the example\n// for how to write your own usage function.\n\n// Usage prints to standard error a usage message documenting all defined command-line flags.\n// The function is a variable that may be changed to point to a custom function.\n// By default it prints a simple header and calls PrintDefaults; for details about the\n// format of the output and how to control it, see the documentation for PrintDefaults.\nvar Usage = func() {\n\tfmt.Fprintf(os.Stderr, \"Usage of %s:\\n\", os.Args[0])\n\tPrintDefaults()\n}\n\n// NFlag returns the number of flags that have been set.\nfunc (f *FlagSet) NFlag() int { return len(f.actual) }\n\n// NFlag returns the number of command-line flags that have been set.\nfunc NFlag() int { return len(CommandLine.actual) }\n\n// Arg returns the i'th argument.  Arg(0) is the first remaining argument\n// after flags have been processed.\nfunc (f *FlagSet) Arg(i int) string {\n\tif i < 0 || i >= len(f.args) {\n\t\treturn \"\"\n\t}\n\treturn f.args[i]\n}\n\n// Arg returns the i'th command-line argument.  Arg(0) is the first remaining argument\n// after flags have been processed.\nfunc Arg(i int) string {\n\treturn CommandLine.Arg(i)\n}\n\n// NArg is the number of arguments remaining after flags have been processed.\nfunc (f *FlagSet) NArg() int { return len(f.args) }\n\n// NArg is the number of arguments remaining after flags have been processed.\nfunc NArg() int { return len(CommandLine.args) }\n\n// Args returns the non-flag arguments.\nfunc (f *FlagSet) Args() []string { return f.args }\n\n// Args returns the non-flag command-line arguments.\nfunc Args() []string { return CommandLine.args }\n\n// Var defines a flag with the specified name and usage string. The type and\n// value of the flag are represented by the first argument, of type Value, which\n// typically holds a user-defined implementation of Value. For instance, the\n// caller could create a flag that turns a comma-separated string into a slice\n// of strings by giving the slice the methods of Value; in particular, Set would\n// decompose the comma-separated string into the slice.\nfunc (f *FlagSet) Var(value Value, name string, usage string) {\n\tf.VarP(value, name, \"\", usage)\n}\n\n// VarPF is like VarP, but returns the flag created\nfunc (f *FlagSet) VarPF(value Value, name, shorthand, usage string) *Flag {\n\t// Remember the default value as a string; it won't change.\n\tflag := &Flag{\n\t\tName:      name,\n\t\tShorthand: shorthand,\n\t\tUsage:     usage,\n\t\tValue:     value,\n\t\tDefValue:  value.String(),\n\t}\n\tf.AddFlag(flag)\n\treturn flag\n}\n\n// VarP is like Var, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) VarP(value Value, name, shorthand, usage string) {\n\tf.VarPF(value, name, shorthand, usage)\n}\n\n// AddFlag will add the flag to the FlagSet\nfunc (f *FlagSet) AddFlag(flag *Flag) {\n\tnormalizedFlagName := f.normalizeFlagName(flag.Name)\n\n\t_, alreadyThere := f.formal[normalizedFlagName]\n\tif alreadyThere {\n\t\tmsg := fmt.Sprintf(\"%s flag redefined: %s\", f.name, flag.Name)\n\t\tfmt.Fprintln(f.out(), msg)\n\t\tpanic(msg) // Happens only if flags are declared with identical names\n\t}\n\tif f.formal == nil {\n\t\tf.formal = make(map[NormalizedName]*Flag)\n\t}\n\n\tflag.Name = string(normalizedFlagName)\n\tf.formal[normalizedFlagName] = flag\n\tf.orderedFormal = append(f.orderedFormal, flag)\n\n\tif flag.Shorthand == \"\" {\n\t\treturn\n\t}\n\tif len(flag.Shorthand) > 1 {\n\t\tmsg := fmt.Sprintf(\"%q shorthand is more than one ASCII character\", flag.Shorthand)\n\t\tfmt.Fprintf(f.out(), msg)\n\t\tpanic(msg)\n\t}\n\tif f.shorthands == nil {\n\t\tf.shorthands = make(map[byte]*Flag)\n\t}\n\tc := flag.Shorthand[0]\n\tused, alreadyThere := f.shorthands[c]\n\tif alreadyThere {\n\t\tmsg := fmt.Sprintf(\"unable to redefine %q shorthand in %q flagset: it's already used for %q flag\", c, f.name, used.Name)\n\t\tfmt.Fprintf(f.out(), msg)\n\t\tpanic(msg)\n\t}\n\tf.shorthands[c] = flag\n}\n\n// AddFlagSet adds one FlagSet to another. If a flag is already present in f\n// the flag from newSet will be ignored.\nfunc (f *FlagSet) AddFlagSet(newSet *FlagSet) {\n\tif newSet == nil {\n\t\treturn\n\t}\n\tnewSet.VisitAll(func(flag *Flag) {\n\t\tif f.Lookup(flag.Name) == nil {\n\t\t\tf.AddFlag(flag)\n\t\t}\n\t})\n}\n\n// Var defines a flag with the specified name and usage string. The type and\n// value of the flag are represented by the first argument, of type Value, which\n// typically holds a user-defined implementation of Value. For instance, the\n// caller could create a flag that turns a comma-separated string into a slice\n// of strings by giving the slice the methods of Value; in particular, Set would\n// decompose the comma-separated string into the slice.\nfunc Var(value Value, name string, usage string) {\n\tCommandLine.VarP(value, name, \"\", usage)\n}\n\n// VarP is like Var, but accepts a shorthand letter that can be used after a single dash.\nfunc VarP(value Value, name, shorthand, usage string) {\n\tCommandLine.VarP(value, name, shorthand, usage)\n}\n\n// failf prints to standard error a formatted error and usage message and\n// returns the error.\nfunc (f *FlagSet) failf(format string, a ...interface{}) error {\n\terr := fmt.Errorf(format, a...)\n\tfmt.Fprintln(f.out(), err)\n\tf.usage()\n\treturn err\n}\n\n// usage calls the Usage method for the flag set, or the usage function if\n// the flag set is CommandLine.\nfunc (f *FlagSet) usage() {\n\tif f == CommandLine {\n\t\tUsage()\n\t} else if f.Usage == nil {\n\t\tdefaultUsage(f)\n\t} else {\n\t\tf.Usage()\n\t}\n}\n\nfunc (f *FlagSet) parseLongArg(s string, args []string, fn parseFunc) (a []string, err error) {\n\ta = args\n\tname := s[2:]\n\tif len(name) == 0 || name[0] == '-' || name[0] == '=' {\n\t\terr = f.failf(\"bad flag syntax: %s\", s)\n\t\treturn\n\t}\n\n\tsplit := strings.SplitN(name, \"=\", 2)\n\tname = split[0]\n\tflag, exists := f.formal[f.normalizeFlagName(name)]\n\tif !exists {\n\t\tif name == \"help\" { // special case for nice help message.\n\t\t\tf.usage()\n\t\t\treturn a, ErrHelp\n\t\t}\n\t\terr = f.failf(\"unknown flag: --%s\", name)\n\t\treturn\n\t}\n\n\tvar value string\n\tif len(split) == 2 {\n\t\t// '--flag=arg'\n\t\tvalue = split[1]\n\t} else if flag.NoOptDefVal != \"\" {\n\t\t// '--flag' (arg was optional)\n\t\tvalue = flag.NoOptDefVal\n\t} else if len(a) > 0 {\n\t\t// '--flag arg'\n\t\tvalue = a[0]\n\t\ta = a[1:]\n\t} else {\n\t\t// '--flag' (arg was required)\n\t\terr = f.failf(\"flag needs an argument: %s\", s)\n\t\treturn\n\t}\n\n\terr = fn(flag, value)\n\treturn\n}\n\nfunc (f *FlagSet) parseSingleShortArg(shorthands string, args []string, fn parseFunc) (outShorts string, outArgs []string, err error) {\n\tif strings.HasPrefix(shorthands, \"test.\") {\n\t\treturn\n\t}\n\n\toutArgs = args\n\toutShorts = shorthands[1:]\n\tc := shorthands[0]\n\n\tflag, exists := f.shorthands[c]\n\tif !exists {\n\t\tif c == 'h' { // special case for nice help message.\n\t\t\tf.usage()\n\t\t\terr = ErrHelp\n\t\t\treturn\n\t\t}\n\t\terr = f.failf(\"unknown shorthand flag: %q in -%s\", c, shorthands)\n\t\treturn\n\t}\n\n\tvar value string\n\tif len(shorthands) > 2 && shorthands[1] == '=' {\n\t\t// '-f=arg'\n\t\tvalue = shorthands[2:]\n\t\toutShorts = \"\"\n\t} else if flag.NoOptDefVal != \"\" {\n\t\t// '-f' (arg was optional)\n\t\tvalue = flag.NoOptDefVal\n\t} else if len(shorthands) > 1 {\n\t\t// '-farg'\n\t\tvalue = shorthands[1:]\n\t\toutShorts = \"\"\n\t} else if len(args) > 0 {\n\t\t// '-f arg'\n\t\tvalue = args[0]\n\t\toutArgs = args[1:]\n\t} else {\n\t\t// '-f' (arg was required)\n\t\terr = f.failf(\"flag needs an argument: %q in -%s\", c, shorthands)\n\t\treturn\n\t}\n\n\tif flag.ShorthandDeprecated != \"\" {\n\t\tfmt.Fprintf(f.out(), \"Flag shorthand -%s has been deprecated, %s\\n\", flag.Shorthand, flag.ShorthandDeprecated)\n\t}\n\n\terr = fn(flag, value)\n\treturn\n}\n\nfunc (f *FlagSet) parseShortArg(s string, args []string, fn parseFunc) (a []string, err error) {\n\ta = args\n\tshorthands := s[1:]\n\n\t// \"shorthands\" can be a series of shorthand letters of flags (e.g. \"-vvv\").\n\tfor len(shorthands) > 0 {\n\t\tshorthands, a, err = f.parseSingleShortArg(shorthands, args, fn)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\treturn\n}\n\nfunc (f *FlagSet) parseArgs(args []string, fn parseFunc) (err error) {\n\tfor len(args) > 0 {\n\t\ts := args[0]\n\t\targs = args[1:]\n\t\tif len(s) == 0 || s[0] != '-' || len(s) == 1 {\n\t\t\tif !f.interspersed {\n\t\t\t\tf.args = append(f.args, s)\n\t\t\t\tf.args = append(f.args, args...)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tf.args = append(f.args, s)\n\t\t\tcontinue\n\t\t}\n\n\t\tif s[1] == '-' {\n\t\t\tif len(s) == 2 { // \"--\" terminates the flags\n\t\t\t\tf.argsLenAtDash = len(f.args)\n\t\t\t\tf.args = append(f.args, args...)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\targs, err = f.parseLongArg(s, args, fn)\n\t\t} else {\n\t\t\targs, err = f.parseShortArg(s, args, fn)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}\n\n// Parse parses flag definitions from the argument list, which should not\n// include the command name.  Must be called after all flags in the FlagSet\n// are defined and before flags are accessed by the program.\n// The return value will be ErrHelp if -help was set but not defined.\nfunc (f *FlagSet) Parse(arguments []string) error {\n\tf.parsed = true\n\n\tif len(arguments) < 0 {\n\t\treturn nil\n\t}\n\n\tf.args = make([]string, 0, len(arguments))\n\n\tset := func(flag *Flag, value string) error {\n\t\treturn f.Set(flag.Name, value)\n\t}\n\n\terr := f.parseArgs(arguments, set)\n\tif err != nil {\n\t\tswitch f.errorHandling {\n\t\tcase ContinueOnError:\n\t\t\treturn err\n\t\tcase ExitOnError:\n\t\t\tos.Exit(2)\n\t\tcase PanicOnError:\n\t\t\tpanic(err)\n\t\t}\n\t}\n\treturn nil\n}\n\ntype parseFunc func(flag *Flag, value string) error\n\n// ParseAll parses flag definitions from the argument list, which should not\n// include the command name. The arguments for fn are flag and value. Must be\n// called after all flags in the FlagSet are defined and before flags are\n// accessed by the program. The return value will be ErrHelp if -help was set\n// but not defined.\nfunc (f *FlagSet) ParseAll(arguments []string, fn func(flag *Flag, value string) error) error {\n\tf.parsed = true\n\tf.args = make([]string, 0, len(arguments))\n\n\terr := f.parseArgs(arguments, fn)\n\tif err != nil {\n\t\tswitch f.errorHandling {\n\t\tcase ContinueOnError:\n\t\t\treturn err\n\t\tcase ExitOnError:\n\t\t\tos.Exit(2)\n\t\tcase PanicOnError:\n\t\t\tpanic(err)\n\t\t}\n\t}\n\treturn nil\n}\n\n// Parsed reports whether f.Parse has been called.\nfunc (f *FlagSet) Parsed() bool {\n\treturn f.parsed\n}\n\n// Parse parses the command-line flags from os.Args[1:].  Must be called\n// after all flags are defined and before flags are accessed by the program.\nfunc Parse() {\n\t// Ignore errors; CommandLine is set for ExitOnError.\n\tCommandLine.Parse(os.Args[1:])\n}\n\n// ParseAll parses the command-line flags from os.Args[1:] and called fn for each.\n// The arguments for fn are flag and value. Must be called after all flags are\n// defined and before flags are accessed by the program.\nfunc ParseAll(fn func(flag *Flag, value string) error) {\n\t// Ignore errors; CommandLine is set for ExitOnError.\n\tCommandLine.ParseAll(os.Args[1:], fn)\n}\n\n// SetInterspersed sets whether to support interspersed option/non-option arguments.\nfunc SetInterspersed(interspersed bool) {\n\tCommandLine.SetInterspersed(interspersed)\n}\n\n// Parsed returns true if the command-line flags have been parsed.\nfunc Parsed() bool {\n\treturn CommandLine.Parsed()\n}\n\n// CommandLine is the default set of command-line flags, parsed from os.Args.\nvar CommandLine = NewFlagSet(os.Args[0], ExitOnError)\n\n// NewFlagSet returns a new, empty flag set with the specified name,\n// error handling property and SortFlags set to true.\nfunc NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet {\n\tf := &FlagSet{\n\t\tname:          name,\n\t\terrorHandling: errorHandling,\n\t\targsLenAtDash: -1,\n\t\tinterspersed:  true,\n\t\tSortFlags:     true,\n\t}\n\treturn f\n}\n\n// SetInterspersed sets whether to support interspersed option/non-option arguments.\nfunc (f *FlagSet) SetInterspersed(interspersed bool) {\n\tf.interspersed = interspersed\n}\n\n// Init sets the name and error handling property for a flag set.\n// By default, the zero FlagSet uses an empty name and the\n// ContinueOnError error handling policy.\nfunc (f *FlagSet) Init(name string, errorHandling ErrorHandling) {\n\tf.name = name\n\tf.errorHandling = errorHandling\n\tf.argsLenAtDash = -1\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/flag_test.go",
    "content": "// Copyright 2009 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 pflag\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"net\"\n\t\"os\"\n\t\"reflect\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\t\"testing\"\n\t\"time\"\n)\n\nvar (\n\ttestBool                     = Bool(\"test_bool\", false, \"bool value\")\n\ttestInt                      = Int(\"test_int\", 0, \"int value\")\n\ttestInt64                    = Int64(\"test_int64\", 0, \"int64 value\")\n\ttestUint                     = Uint(\"test_uint\", 0, \"uint value\")\n\ttestUint64                   = Uint64(\"test_uint64\", 0, \"uint64 value\")\n\ttestString                   = String(\"test_string\", \"0\", \"string value\")\n\ttestFloat                    = Float64(\"test_float64\", 0, \"float64 value\")\n\ttestDuration                 = Duration(\"test_duration\", 0, \"time.Duration value\")\n\ttestOptionalInt              = Int(\"test_optional_int\", 0, \"optional int value\")\n\tnormalizeFlagNameInvocations = 0\n)\n\nfunc boolString(s string) string {\n\tif s == \"0\" {\n\t\treturn \"false\"\n\t}\n\treturn \"true\"\n}\n\nfunc TestEverything(t *testing.T) {\n\tm := make(map[string]*Flag)\n\tdesired := \"0\"\n\tvisitor := func(f *Flag) {\n\t\tif len(f.Name) > 5 && f.Name[0:5] == \"test_\" {\n\t\t\tm[f.Name] = f\n\t\t\tok := false\n\t\t\tswitch {\n\t\t\tcase f.Value.String() == desired:\n\t\t\t\tok = true\n\t\t\tcase f.Name == \"test_bool\" && f.Value.String() == boolString(desired):\n\t\t\t\tok = true\n\t\t\tcase f.Name == \"test_duration\" && f.Value.String() == desired+\"s\":\n\t\t\t\tok = true\n\t\t\t}\n\t\t\tif !ok {\n\t\t\t\tt.Error(\"Visit: bad value\", f.Value.String(), \"for\", f.Name)\n\t\t\t}\n\t\t}\n\t}\n\tVisitAll(visitor)\n\tif len(m) != 9 {\n\t\tt.Error(\"VisitAll misses some flags\")\n\t\tfor k, v := range m {\n\t\t\tt.Log(k, *v)\n\t\t}\n\t}\n\tm = make(map[string]*Flag)\n\tVisit(visitor)\n\tif len(m) != 0 {\n\t\tt.Errorf(\"Visit sees unset flags\")\n\t\tfor k, v := range m {\n\t\t\tt.Log(k, *v)\n\t\t}\n\t}\n\t// Now set all flags\n\tSet(\"test_bool\", \"true\")\n\tSet(\"test_int\", \"1\")\n\tSet(\"test_int64\", \"1\")\n\tSet(\"test_uint\", \"1\")\n\tSet(\"test_uint64\", \"1\")\n\tSet(\"test_string\", \"1\")\n\tSet(\"test_float64\", \"1\")\n\tSet(\"test_duration\", \"1s\")\n\tSet(\"test_optional_int\", \"1\")\n\tdesired = \"1\"\n\tVisit(visitor)\n\tif len(m) != 9 {\n\t\tt.Error(\"Visit fails after set\")\n\t\tfor k, v := range m {\n\t\t\tt.Log(k, *v)\n\t\t}\n\t}\n\t// Now test they're visited in sort order.\n\tvar flagNames []string\n\tVisit(func(f *Flag) { flagNames = append(flagNames, f.Name) })\n\tif !sort.StringsAreSorted(flagNames) {\n\t\tt.Errorf(\"flag names not sorted: %v\", flagNames)\n\t}\n}\n\nfunc TestUsage(t *testing.T) {\n\tcalled := false\n\tResetForTesting(func() { called = true })\n\tif GetCommandLine().Parse([]string{\"--x\"}) == nil {\n\t\tt.Error(\"parse did not fail for unknown flag\")\n\t}\n\tif !called {\n\t\tt.Error(\"did not call Usage for unknown flag\")\n\t}\n}\n\nfunc TestAddFlagSet(t *testing.T) {\n\toldSet := NewFlagSet(\"old\", ContinueOnError)\n\tnewSet := NewFlagSet(\"new\", ContinueOnError)\n\n\toldSet.String(\"flag1\", \"flag1\", \"flag1\")\n\toldSet.String(\"flag2\", \"flag2\", \"flag2\")\n\n\tnewSet.String(\"flag2\", \"flag2\", \"flag2\")\n\tnewSet.String(\"flag3\", \"flag3\", \"flag3\")\n\n\toldSet.AddFlagSet(newSet)\n\n\tif len(oldSet.formal) != 3 {\n\t\tt.Errorf(\"Unexpected result adding a FlagSet to a FlagSet %v\", oldSet)\n\t}\n}\n\nfunc TestAnnotation(t *testing.T) {\n\tf := NewFlagSet(\"shorthand\", ContinueOnError)\n\n\tif err := f.SetAnnotation(\"missing-flag\", \"key\", nil); err == nil {\n\t\tt.Errorf(\"Expected error setting annotation on non-existent flag\")\n\t}\n\n\tf.StringP(\"stringa\", \"a\", \"\", \"string value\")\n\tif err := f.SetAnnotation(\"stringa\", \"key\", nil); err != nil {\n\t\tt.Errorf(\"Unexpected error setting new nil annotation: %v\", err)\n\t}\n\tif annotation := f.Lookup(\"stringa\").Annotations[\"key\"]; annotation != nil {\n\t\tt.Errorf(\"Unexpected annotation: %v\", annotation)\n\t}\n\n\tf.StringP(\"stringb\", \"b\", \"\", \"string2 value\")\n\tif err := f.SetAnnotation(\"stringb\", \"key\", []string{\"value1\"}); err != nil {\n\t\tt.Errorf(\"Unexpected error setting new annotation: %v\", err)\n\t}\n\tif annotation := f.Lookup(\"stringb\").Annotations[\"key\"]; !reflect.DeepEqual(annotation, []string{\"value1\"}) {\n\t\tt.Errorf(\"Unexpected annotation: %v\", annotation)\n\t}\n\n\tif err := f.SetAnnotation(\"stringb\", \"key\", []string{\"value2\"}); err != nil {\n\t\tt.Errorf(\"Unexpected error updating annotation: %v\", err)\n\t}\n\tif annotation := f.Lookup(\"stringb\").Annotations[\"key\"]; !reflect.DeepEqual(annotation, []string{\"value2\"}) {\n\t\tt.Errorf(\"Unexpected annotation: %v\", annotation)\n\t}\n}\n\nfunc testParse(f *FlagSet, t *testing.T) {\n\tif f.Parsed() {\n\t\tt.Error(\"f.Parse() = true before Parse\")\n\t}\n\tboolFlag := f.Bool(\"bool\", false, \"bool value\")\n\tbool2Flag := f.Bool(\"bool2\", false, \"bool2 value\")\n\tbool3Flag := f.Bool(\"bool3\", false, \"bool3 value\")\n\tintFlag := f.Int(\"int\", 0, \"int value\")\n\tint8Flag := f.Int8(\"int8\", 0, \"int value\")\n\tint32Flag := f.Int32(\"int32\", 0, \"int value\")\n\tint64Flag := f.Int64(\"int64\", 0, \"int64 value\")\n\tuintFlag := f.Uint(\"uint\", 0, \"uint value\")\n\tuint8Flag := f.Uint8(\"uint8\", 0, \"uint value\")\n\tuint16Flag := f.Uint16(\"uint16\", 0, \"uint value\")\n\tuint32Flag := f.Uint32(\"uint32\", 0, \"uint value\")\n\tuint64Flag := f.Uint64(\"uint64\", 0, \"uint64 value\")\n\tstringFlag := f.String(\"string\", \"0\", \"string value\")\n\tfloat32Flag := f.Float32(\"float32\", 0, \"float32 value\")\n\tfloat64Flag := f.Float64(\"float64\", 0, \"float64 value\")\n\tipFlag := f.IP(\"ip\", net.ParseIP(\"127.0.0.1\"), \"ip value\")\n\tmaskFlag := f.IPMask(\"mask\", ParseIPv4Mask(\"0.0.0.0\"), \"mask value\")\n\tdurationFlag := f.Duration(\"duration\", 5*time.Second, \"time.Duration value\")\n\toptionalIntNoValueFlag := f.Int(\"optional-int-no-value\", 0, \"int value\")\n\tf.Lookup(\"optional-int-no-value\").NoOptDefVal = \"9\"\n\toptionalIntWithValueFlag := f.Int(\"optional-int-with-value\", 0, \"int value\")\n\tf.Lookup(\"optional-int-no-value\").NoOptDefVal = \"9\"\n\textra := \"one-extra-argument\"\n\targs := []string{\n\t\t\"--bool\",\n\t\t\"--bool2=true\",\n\t\t\"--bool3=false\",\n\t\t\"--int=22\",\n\t\t\"--int8=-8\",\n\t\t\"--int32=-32\",\n\t\t\"--int64=0x23\",\n\t\t\"--uint\", \"24\",\n\t\t\"--uint8=8\",\n\t\t\"--uint16=16\",\n\t\t\"--uint32=32\",\n\t\t\"--uint64=25\",\n\t\t\"--string=hello\",\n\t\t\"--float32=-172e12\",\n\t\t\"--float64=2718e28\",\n\t\t\"--ip=10.11.12.13\",\n\t\t\"--mask=255.255.255.0\",\n\t\t\"--duration=2m\",\n\t\t\"--optional-int-no-value\",\n\t\t\"--optional-int-with-value=42\",\n\t\textra,\n\t}\n\tif err := f.Parse(args); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif !f.Parsed() {\n\t\tt.Error(\"f.Parse() = false after Parse\")\n\t}\n\tif *boolFlag != true {\n\t\tt.Error(\"bool flag should be true, is \", *boolFlag)\n\t}\n\tif v, err := f.GetBool(\"bool\"); err != nil || v != *boolFlag {\n\t\tt.Error(\"GetBool does not work.\")\n\t}\n\tif *bool2Flag != true {\n\t\tt.Error(\"bool2 flag should be true, is \", *bool2Flag)\n\t}\n\tif *bool3Flag != false {\n\t\tt.Error(\"bool3 flag should be false, is \", *bool2Flag)\n\t}\n\tif *intFlag != 22 {\n\t\tt.Error(\"int flag should be 22, is \", *intFlag)\n\t}\n\tif v, err := f.GetInt(\"int\"); err != nil || v != *intFlag {\n\t\tt.Error(\"GetInt does not work.\")\n\t}\n\tif *int8Flag != -8 {\n\t\tt.Error(\"int8 flag should be 0x23, is \", *int8Flag)\n\t}\n\tif v, err := f.GetInt8(\"int8\"); err != nil || v != *int8Flag {\n\t\tt.Error(\"GetInt8 does not work.\")\n\t}\n\tif *int32Flag != -32 {\n\t\tt.Error(\"int32 flag should be 0x23, is \", *int32Flag)\n\t}\n\tif v, err := f.GetInt32(\"int32\"); err != nil || v != *int32Flag {\n\t\tt.Error(\"GetInt32 does not work.\")\n\t}\n\tif *int64Flag != 0x23 {\n\t\tt.Error(\"int64 flag should be 0x23, is \", *int64Flag)\n\t}\n\tif v, err := f.GetInt64(\"int64\"); err != nil || v != *int64Flag {\n\t\tt.Error(\"GetInt64 does not work.\")\n\t}\n\tif *uintFlag != 24 {\n\t\tt.Error(\"uint flag should be 24, is \", *uintFlag)\n\t}\n\tif v, err := f.GetUint(\"uint\"); err != nil || v != *uintFlag {\n\t\tt.Error(\"GetUint does not work.\")\n\t}\n\tif *uint8Flag != 8 {\n\t\tt.Error(\"uint8 flag should be 8, is \", *uint8Flag)\n\t}\n\tif v, err := f.GetUint8(\"uint8\"); err != nil || v != *uint8Flag {\n\t\tt.Error(\"GetUint8 does not work.\")\n\t}\n\tif *uint16Flag != 16 {\n\t\tt.Error(\"uint16 flag should be 16, is \", *uint16Flag)\n\t}\n\tif v, err := f.GetUint16(\"uint16\"); err != nil || v != *uint16Flag {\n\t\tt.Error(\"GetUint16 does not work.\")\n\t}\n\tif *uint32Flag != 32 {\n\t\tt.Error(\"uint32 flag should be 32, is \", *uint32Flag)\n\t}\n\tif v, err := f.GetUint32(\"uint32\"); err != nil || v != *uint32Flag {\n\t\tt.Error(\"GetUint32 does not work.\")\n\t}\n\tif *uint64Flag != 25 {\n\t\tt.Error(\"uint64 flag should be 25, is \", *uint64Flag)\n\t}\n\tif v, err := f.GetUint64(\"uint64\"); err != nil || v != *uint64Flag {\n\t\tt.Error(\"GetUint64 does not work.\")\n\t}\n\tif *stringFlag != \"hello\" {\n\t\tt.Error(\"string flag should be `hello`, is \", *stringFlag)\n\t}\n\tif v, err := f.GetString(\"string\"); err != nil || v != *stringFlag {\n\t\tt.Error(\"GetString does not work.\")\n\t}\n\tif *float32Flag != -172e12 {\n\t\tt.Error(\"float32 flag should be -172e12, is \", *float32Flag)\n\t}\n\tif v, err := f.GetFloat32(\"float32\"); err != nil || v != *float32Flag {\n\t\tt.Errorf(\"GetFloat32 returned %v but float32Flag was %v\", v, *float32Flag)\n\t}\n\tif *float64Flag != 2718e28 {\n\t\tt.Error(\"float64 flag should be 2718e28, is \", *float64Flag)\n\t}\n\tif v, err := f.GetFloat64(\"float64\"); err != nil || v != *float64Flag {\n\t\tt.Errorf(\"GetFloat64 returned %v but float64Flag was %v\", v, *float64Flag)\n\t}\n\tif !(*ipFlag).Equal(net.ParseIP(\"10.11.12.13\")) {\n\t\tt.Error(\"ip flag should be 10.11.12.13, is \", *ipFlag)\n\t}\n\tif v, err := f.GetIP(\"ip\"); err != nil || !v.Equal(*ipFlag) {\n\t\tt.Errorf(\"GetIP returned %v but ipFlag was %v\", v, *ipFlag)\n\t}\n\tif (*maskFlag).String() != ParseIPv4Mask(\"255.255.255.0\").String() {\n\t\tt.Error(\"mask flag should be 255.255.255.0, is \", (*maskFlag).String())\n\t}\n\tif v, err := f.GetIPv4Mask(\"mask\"); err != nil || v.String() != (*maskFlag).String() {\n\t\tt.Errorf(\"GetIP returned %v maskFlag was %v error was %v\", v, *maskFlag, err)\n\t}\n\tif *durationFlag != 2*time.Minute {\n\t\tt.Error(\"duration flag should be 2m, is \", *durationFlag)\n\t}\n\tif v, err := f.GetDuration(\"duration\"); err != nil || v != *durationFlag {\n\t\tt.Error(\"GetDuration does not work.\")\n\t}\n\tif _, err := f.GetInt(\"duration\"); err == nil {\n\t\tt.Error(\"GetInt parsed a time.Duration?!?!\")\n\t}\n\tif *optionalIntNoValueFlag != 9 {\n\t\tt.Error(\"optional int flag should be the default value, is \", *optionalIntNoValueFlag)\n\t}\n\tif *optionalIntWithValueFlag != 42 {\n\t\tt.Error(\"optional int flag should be 42, is \", *optionalIntWithValueFlag)\n\t}\n\tif len(f.Args()) != 1 {\n\t\tt.Error(\"expected one argument, got\", len(f.Args()))\n\t} else if f.Args()[0] != extra {\n\t\tt.Errorf(\"expected argument %q got %q\", extra, f.Args()[0])\n\t}\n}\n\nfunc testParseAll(f *FlagSet, t *testing.T) {\n\tif f.Parsed() {\n\t\tt.Error(\"f.Parse() = true before Parse\")\n\t}\n\tf.BoolP(\"boola\", \"a\", false, \"bool value\")\n\tf.BoolP(\"boolb\", \"b\", false, \"bool2 value\")\n\tf.BoolP(\"boolc\", \"c\", false, \"bool3 value\")\n\tf.BoolP(\"boold\", \"d\", false, \"bool4 value\")\n\tf.StringP(\"stringa\", \"s\", \"0\", \"string value\")\n\tf.StringP(\"stringz\", \"z\", \"0\", \"string value\")\n\tf.StringP(\"stringx\", \"x\", \"0\", \"string value\")\n\tf.StringP(\"stringy\", \"y\", \"0\", \"string value\")\n\tf.Lookup(\"stringx\").NoOptDefVal = \"1\"\n\targs := []string{\n\t\t\"-ab\",\n\t\t\"-cs=xx\",\n\t\t\"--stringz=something\",\n\t\t\"-d=true\",\n\t\t\"-x\",\n\t\t\"-y\",\n\t\t\"ee\",\n\t}\n\twant := []string{\n\t\t\"boola\", \"true\",\n\t\t\"boolb\", \"true\",\n\t\t\"boolc\", \"true\",\n\t\t\"stringa\", \"xx\",\n\t\t\"stringz\", \"something\",\n\t\t\"boold\", \"true\",\n\t\t\"stringx\", \"1\",\n\t\t\"stringy\", \"ee\",\n\t}\n\tgot := []string{}\n\tstore := func(flag *Flag, value string) error {\n\t\tgot = append(got, flag.Name)\n\t\tif len(value) > 0 {\n\t\t\tgot = append(got, value)\n\t\t}\n\t\treturn nil\n\t}\n\tif err := f.ParseAll(args, store); err != nil {\n\t\tt.Errorf(\"expected no error, got %s\", err)\n\t}\n\tif !f.Parsed() {\n\t\tt.Errorf(\"f.Parse() = false after Parse\")\n\t}\n\tif !reflect.DeepEqual(got, want) {\n\t\tt.Errorf(\"f.ParseAll() fail to restore the args\")\n\t\tt.Errorf(\"Got: %v\", got)\n\t\tt.Errorf(\"Want: %v\", want)\n\t}\n}\n\nfunc TestShorthand(t *testing.T) {\n\tf := NewFlagSet(\"shorthand\", ContinueOnError)\n\tif f.Parsed() {\n\t\tt.Error(\"f.Parse() = true before Parse\")\n\t}\n\tboolaFlag := f.BoolP(\"boola\", \"a\", false, \"bool value\")\n\tboolbFlag := f.BoolP(\"boolb\", \"b\", false, \"bool2 value\")\n\tboolcFlag := f.BoolP(\"boolc\", \"c\", false, \"bool3 value\")\n\tbooldFlag := f.BoolP(\"boold\", \"d\", false, \"bool4 value\")\n\tstringaFlag := f.StringP(\"stringa\", \"s\", \"0\", \"string value\")\n\tstringzFlag := f.StringP(\"stringz\", \"z\", \"0\", \"string value\")\n\textra := \"interspersed-argument\"\n\tnotaflag := \"--i-look-like-a-flag\"\n\targs := []string{\n\t\t\"-ab\",\n\t\textra,\n\t\t\"-cs\",\n\t\t\"hello\",\n\t\t\"-z=something\",\n\t\t\"-d=true\",\n\t\t\"--\",\n\t\tnotaflag,\n\t}\n\tf.SetOutput(ioutil.Discard)\n\tif err := f.Parse(args); err != nil {\n\t\tt.Error(\"expected no error, got \", err)\n\t}\n\tif !f.Parsed() {\n\t\tt.Error(\"f.Parse() = false after Parse\")\n\t}\n\tif *boolaFlag != true {\n\t\tt.Error(\"boola flag should be true, is \", *boolaFlag)\n\t}\n\tif *boolbFlag != true {\n\t\tt.Error(\"boolb flag should be true, is \", *boolbFlag)\n\t}\n\tif *boolcFlag != true {\n\t\tt.Error(\"boolc flag should be true, is \", *boolcFlag)\n\t}\n\tif *booldFlag != true {\n\t\tt.Error(\"boold flag should be true, is \", *booldFlag)\n\t}\n\tif *stringaFlag != \"hello\" {\n\t\tt.Error(\"stringa flag should be `hello`, is \", *stringaFlag)\n\t}\n\tif *stringzFlag != \"something\" {\n\t\tt.Error(\"stringz flag should be `something`, is \", *stringzFlag)\n\t}\n\tif len(f.Args()) != 2 {\n\t\tt.Error(\"expected one argument, got\", len(f.Args()))\n\t} else if f.Args()[0] != extra {\n\t\tt.Errorf(\"expected argument %q got %q\", extra, f.Args()[0])\n\t} else if f.Args()[1] != notaflag {\n\t\tt.Errorf(\"expected argument %q got %q\", notaflag, f.Args()[1])\n\t}\n\tif f.ArgsLenAtDash() != 1 {\n\t\tt.Errorf(\"expected argsLenAtDash %d got %d\", f.ArgsLenAtDash(), 1)\n\t}\n}\n\nfunc TestShorthandLookup(t *testing.T) {\n\tf := NewFlagSet(\"shorthand\", ContinueOnError)\n\tif f.Parsed() {\n\t\tt.Error(\"f.Parse() = true before Parse\")\n\t}\n\tf.BoolP(\"boola\", \"a\", false, \"bool value\")\n\tf.BoolP(\"boolb\", \"b\", false, \"bool2 value\")\n\targs := []string{\n\t\t\"-ab\",\n\t}\n\tf.SetOutput(ioutil.Discard)\n\tif err := f.Parse(args); err != nil {\n\t\tt.Error(\"expected no error, got \", err)\n\t}\n\tif !f.Parsed() {\n\t\tt.Error(\"f.Parse() = false after Parse\")\n\t}\n\tflag := f.ShorthandLookup(\"a\")\n\tif flag == nil {\n\t\tt.Errorf(\"f.ShorthandLookup(\\\"a\\\") returned nil\")\n\t}\n\tif flag.Name != \"boola\" {\n\t\tt.Errorf(\"f.ShorthandLookup(\\\"a\\\") found %q instead of \\\"boola\\\"\", flag.Name)\n\t}\n\tflag = f.ShorthandLookup(\"\")\n\tif flag != nil {\n\t\tt.Errorf(\"f.ShorthandLookup(\\\"\\\") did not return nil\")\n\t}\n\tdefer func() {\n\t\trecover()\n\t}()\n\tflag = f.ShorthandLookup(\"ab\")\n\t// should NEVER get here. lookup should panic. defer'd func should recover it.\n\tt.Errorf(\"f.ShorthandLookup(\\\"ab\\\") did not panic\")\n}\n\nfunc TestParse(t *testing.T) {\n\tResetForTesting(func() { t.Error(\"bad parse\") })\n\ttestParse(GetCommandLine(), t)\n}\n\nfunc TestParseAll(t *testing.T) {\n\tResetForTesting(func() { t.Error(\"bad parse\") })\n\ttestParseAll(GetCommandLine(), t)\n}\n\nfunc TestFlagSetParse(t *testing.T) {\n\ttestParse(NewFlagSet(\"test\", ContinueOnError), t)\n}\n\nfunc TestChangedHelper(t *testing.T) {\n\tf := NewFlagSet(\"changedtest\", ContinueOnError)\n\tf.Bool(\"changed\", false, \"changed bool\")\n\tf.Bool(\"settrue\", true, \"true to true\")\n\tf.Bool(\"setfalse\", false, \"false to false\")\n\tf.Bool(\"unchanged\", false, \"unchanged bool\")\n\n\targs := []string{\"--changed\", \"--settrue\", \"--setfalse=false\"}\n\tif err := f.Parse(args); err != nil {\n\t\tt.Error(\"f.Parse() = false after Parse\")\n\t}\n\tif !f.Changed(\"changed\") {\n\t\tt.Errorf(\"--changed wasn't changed!\")\n\t}\n\tif !f.Changed(\"settrue\") {\n\t\tt.Errorf(\"--settrue wasn't changed!\")\n\t}\n\tif !f.Changed(\"setfalse\") {\n\t\tt.Errorf(\"--setfalse wasn't changed!\")\n\t}\n\tif f.Changed(\"unchanged\") {\n\t\tt.Errorf(\"--unchanged was changed!\")\n\t}\n\tif f.Changed(\"invalid\") {\n\t\tt.Errorf(\"--invalid was changed!\")\n\t}\n\tif f.ArgsLenAtDash() != -1 {\n\t\tt.Errorf(\"Expected argsLenAtDash: %d but got %d\", -1, f.ArgsLenAtDash())\n\t}\n}\n\nfunc replaceSeparators(name string, from []string, to string) string {\n\tresult := name\n\tfor _, sep := range from {\n\t\tresult = strings.Replace(result, sep, to, -1)\n\t}\n\t// Type convert to indicate normalization has been done.\n\treturn result\n}\n\nfunc wordSepNormalizeFunc(f *FlagSet, name string) NormalizedName {\n\tseps := []string{\"-\", \"_\"}\n\tname = replaceSeparators(name, seps, \".\")\n\tnormalizeFlagNameInvocations++\n\n\treturn NormalizedName(name)\n}\n\nfunc testWordSepNormalizedNames(args []string, t *testing.T) {\n\tf := NewFlagSet(\"normalized\", ContinueOnError)\n\tif f.Parsed() {\n\t\tt.Error(\"f.Parse() = true before Parse\")\n\t}\n\twithDashFlag := f.Bool(\"with-dash-flag\", false, \"bool value\")\n\t// Set this after some flags have been added and before others.\n\tf.SetNormalizeFunc(wordSepNormalizeFunc)\n\twithUnderFlag := f.Bool(\"with_under_flag\", false, \"bool value\")\n\twithBothFlag := f.Bool(\"with-both_flag\", false, \"bool value\")\n\tif err := f.Parse(args); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif !f.Parsed() {\n\t\tt.Error(\"f.Parse() = false after Parse\")\n\t}\n\tif *withDashFlag != true {\n\t\tt.Error(\"withDashFlag flag should be true, is \", *withDashFlag)\n\t}\n\tif *withUnderFlag != true {\n\t\tt.Error(\"withUnderFlag flag should be true, is \", *withUnderFlag)\n\t}\n\tif *withBothFlag != true {\n\t\tt.Error(\"withBothFlag flag should be true, is \", *withBothFlag)\n\t}\n}\n\nfunc TestWordSepNormalizedNames(t *testing.T) {\n\targs := []string{\n\t\t\"--with-dash-flag\",\n\t\t\"--with-under-flag\",\n\t\t\"--with-both-flag\",\n\t}\n\ttestWordSepNormalizedNames(args, t)\n\n\targs = []string{\n\t\t\"--with_dash_flag\",\n\t\t\"--with_under_flag\",\n\t\t\"--with_both_flag\",\n\t}\n\ttestWordSepNormalizedNames(args, t)\n\n\targs = []string{\n\t\t\"--with-dash_flag\",\n\t\t\"--with-under_flag\",\n\t\t\"--with-both_flag\",\n\t}\n\ttestWordSepNormalizedNames(args, t)\n}\n\nfunc aliasAndWordSepFlagNames(f *FlagSet, name string) NormalizedName {\n\tseps := []string{\"-\", \"_\"}\n\n\toldName := replaceSeparators(\"old-valid_flag\", seps, \".\")\n\tnewName := replaceSeparators(\"valid-flag\", seps, \".\")\n\n\tname = replaceSeparators(name, seps, \".\")\n\tswitch name {\n\tcase oldName:\n\t\tname = newName\n\t\tbreak\n\t}\n\n\treturn NormalizedName(name)\n}\n\nfunc TestCustomNormalizedNames(t *testing.T) {\n\tf := NewFlagSet(\"normalized\", ContinueOnError)\n\tif f.Parsed() {\n\t\tt.Error(\"f.Parse() = true before Parse\")\n\t}\n\n\tvalidFlag := f.Bool(\"valid-flag\", false, \"bool value\")\n\tf.SetNormalizeFunc(aliasAndWordSepFlagNames)\n\tsomeOtherFlag := f.Bool(\"some-other-flag\", false, \"bool value\")\n\n\targs := []string{\"--old_valid_flag\", \"--some-other_flag\"}\n\tif err := f.Parse(args); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif *validFlag != true {\n\t\tt.Errorf(\"validFlag is %v even though we set the alias --old_valid_falg\", *validFlag)\n\t}\n\tif *someOtherFlag != true {\n\t\tt.Error(\"someOtherFlag should be true, is \", *someOtherFlag)\n\t}\n}\n\n// Every flag we add, the name (displayed also in usage) should normalized\nfunc TestNormalizationFuncShouldChangeFlagName(t *testing.T) {\n\t// Test normalization after addition\n\tf := NewFlagSet(\"normalized\", ContinueOnError)\n\n\tf.Bool(\"valid_flag\", false, \"bool value\")\n\tif f.Lookup(\"valid_flag\").Name != \"valid_flag\" {\n\t\tt.Error(\"The new flag should have the name 'valid_flag' instead of \", f.Lookup(\"valid_flag\").Name)\n\t}\n\n\tf.SetNormalizeFunc(wordSepNormalizeFunc)\n\tif f.Lookup(\"valid_flag\").Name != \"valid.flag\" {\n\t\tt.Error(\"The new flag should have the name 'valid.flag' instead of \", f.Lookup(\"valid_flag\").Name)\n\t}\n\n\t// Test normalization before addition\n\tf = NewFlagSet(\"normalized\", ContinueOnError)\n\tf.SetNormalizeFunc(wordSepNormalizeFunc)\n\n\tf.Bool(\"valid_flag\", false, \"bool value\")\n\tif f.Lookup(\"valid_flag\").Name != \"valid.flag\" {\n\t\tt.Error(\"The new flag should have the name 'valid.flag' instead of \", f.Lookup(\"valid_flag\").Name)\n\t}\n}\n\n// Declare a user-defined flag type.\ntype flagVar []string\n\nfunc (f *flagVar) String() string {\n\treturn fmt.Sprint([]string(*f))\n}\n\nfunc (f *flagVar) Set(value string) error {\n\t*f = append(*f, value)\n\treturn nil\n}\n\nfunc (f *flagVar) Type() string {\n\treturn \"flagVar\"\n}\n\nfunc TestUserDefined(t *testing.T) {\n\tvar flags FlagSet\n\tflags.Init(\"test\", ContinueOnError)\n\tvar v flagVar\n\tflags.VarP(&v, \"v\", \"v\", \"usage\")\n\tif err := flags.Parse([]string{\"--v=1\", \"-v2\", \"-v\", \"3\"}); err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(v) != 3 {\n\t\tt.Fatal(\"expected 3 args; got \", len(v))\n\t}\n\texpect := \"[1 2 3]\"\n\tif v.String() != expect {\n\t\tt.Errorf(\"expected value %q got %q\", expect, v.String())\n\t}\n}\n\nfunc TestSetOutput(t *testing.T) {\n\tvar flags FlagSet\n\tvar buf bytes.Buffer\n\tflags.SetOutput(&buf)\n\tflags.Init(\"test\", ContinueOnError)\n\tflags.Parse([]string{\"--unknown\"})\n\tif out := buf.String(); !strings.Contains(out, \"--unknown\") {\n\t\tt.Logf(\"expected output mentioning unknown; got %q\", out)\n\t}\n}\n\n// This tests that one can reset the flags. This still works but not well, and is\n// superseded by FlagSet.\nfunc TestChangingArgs(t *testing.T) {\n\tResetForTesting(func() { t.Fatal(\"bad parse\") })\n\toldArgs := os.Args\n\tdefer func() { os.Args = oldArgs }()\n\tos.Args = []string{\"cmd\", \"--before\", \"subcmd\"}\n\tbefore := Bool(\"before\", false, \"\")\n\tif err := GetCommandLine().Parse(os.Args[1:]); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tcmd := Arg(0)\n\tos.Args = []string{\"subcmd\", \"--after\", \"args\"}\n\tafter := Bool(\"after\", false, \"\")\n\tParse()\n\targs := Args()\n\n\tif !*before || cmd != \"subcmd\" || !*after || len(args) != 1 || args[0] != \"args\" {\n\t\tt.Fatalf(\"expected true subcmd true [args] got %v %v %v %v\", *before, cmd, *after, args)\n\t}\n}\n\n// Test that -help invokes the usage message and returns ErrHelp.\nfunc TestHelp(t *testing.T) {\n\tvar helpCalled = false\n\tfs := NewFlagSet(\"help test\", ContinueOnError)\n\tfs.Usage = func() { helpCalled = true }\n\tvar flag bool\n\tfs.BoolVar(&flag, \"flag\", false, \"regular flag\")\n\t// Regular flag invocation should work\n\terr := fs.Parse([]string{\"--flag=true\"})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got \", err)\n\t}\n\tif !flag {\n\t\tt.Error(\"flag was not set by --flag\")\n\t}\n\tif helpCalled {\n\t\tt.Error(\"help called for regular flag\")\n\t\thelpCalled = false // reset for next test\n\t}\n\t// Help flag should work as expected.\n\terr = fs.Parse([]string{\"--help\"})\n\tif err == nil {\n\t\tt.Fatal(\"error expected\")\n\t}\n\tif err != ErrHelp {\n\t\tt.Fatal(\"expected ErrHelp; got \", err)\n\t}\n\tif !helpCalled {\n\t\tt.Fatal(\"help was not called\")\n\t}\n\t// If we define a help flag, that should override.\n\tvar help bool\n\tfs.BoolVar(&help, \"help\", false, \"help flag\")\n\thelpCalled = false\n\terr = fs.Parse([]string{\"--help\"})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error for defined --help; got \", err)\n\t}\n\tif helpCalled {\n\t\tt.Fatal(\"help was called; should not have been for defined help flag\")\n\t}\n}\n\nfunc TestNoInterspersed(t *testing.T) {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.SetInterspersed(false)\n\tf.Bool(\"true\", true, \"always true\")\n\tf.Bool(\"false\", false, \"always false\")\n\terr := f.Parse([]string{\"--true\", \"break\", \"--false\"})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got \", err)\n\t}\n\targs := f.Args()\n\tif len(args) != 2 || args[0] != \"break\" || args[1] != \"--false\" {\n\t\tt.Fatal(\"expected interspersed options/non-options to fail\")\n\t}\n}\n\nfunc TestTermination(t *testing.T) {\n\tf := NewFlagSet(\"termination\", ContinueOnError)\n\tboolFlag := f.BoolP(\"bool\", \"l\", false, \"bool value\")\n\tif f.Parsed() {\n\t\tt.Error(\"f.Parse() = true before Parse\")\n\t}\n\targ1 := \"ls\"\n\targ2 := \"-l\"\n\targs := []string{\n\t\t\"--\",\n\t\targ1,\n\t\targ2,\n\t}\n\tf.SetOutput(ioutil.Discard)\n\tif err := f.Parse(args); err != nil {\n\t\tt.Fatal(\"expected no error; got \", err)\n\t}\n\tif !f.Parsed() {\n\t\tt.Error(\"f.Parse() = false after Parse\")\n\t}\n\tif *boolFlag {\n\t\tt.Error(\"expected boolFlag=false, got true\")\n\t}\n\tif len(f.Args()) != 2 {\n\t\tt.Errorf(\"expected 2 arguments, got %d: %v\", len(f.Args()), f.Args())\n\t}\n\tif f.Args()[0] != arg1 {\n\t\tt.Errorf(\"expected argument %q got %q\", arg1, f.Args()[0])\n\t}\n\tif f.Args()[1] != arg2 {\n\t\tt.Errorf(\"expected argument %q got %q\", arg2, f.Args()[1])\n\t}\n\tif f.ArgsLenAtDash() != 0 {\n\t\tt.Errorf(\"expected argsLenAtDash %d got %d\", 0, f.ArgsLenAtDash())\n\t}\n}\n\nfunc TestDeprecatedFlagInDocs(t *testing.T) {\n\tf := NewFlagSet(\"bob\", ContinueOnError)\n\tf.Bool(\"badflag\", true, \"always true\")\n\tf.MarkDeprecated(\"badflag\", \"use --good-flag instead\")\n\n\tout := new(bytes.Buffer)\n\tf.SetOutput(out)\n\tf.PrintDefaults()\n\n\tif strings.Contains(out.String(), \"badflag\") {\n\t\tt.Errorf(\"found deprecated flag in usage!\")\n\t}\n}\n\nfunc TestDeprecatedFlagShorthandInDocs(t *testing.T) {\n\tf := NewFlagSet(\"bob\", ContinueOnError)\n\tname := \"noshorthandflag\"\n\tf.BoolP(name, \"n\", true, \"always true\")\n\tf.MarkShorthandDeprecated(\"noshorthandflag\", fmt.Sprintf(\"use --%s instead\", name))\n\n\tout := new(bytes.Buffer)\n\tf.SetOutput(out)\n\tf.PrintDefaults()\n\n\tif strings.Contains(out.String(), \"-n,\") {\n\t\tt.Errorf(\"found deprecated flag shorthand in usage!\")\n\t}\n}\n\nfunc parseReturnStderr(t *testing.T, f *FlagSet, args []string) (string, error) {\n\toldStderr := os.Stderr\n\tr, w, _ := os.Pipe()\n\tos.Stderr = w\n\n\terr := f.Parse(args)\n\n\toutC := make(chan string)\n\t// copy the output in a separate goroutine so printing can't block indefinitely\n\tgo func() {\n\t\tvar buf bytes.Buffer\n\t\tio.Copy(&buf, r)\n\t\toutC <- buf.String()\n\t}()\n\n\tw.Close()\n\tos.Stderr = oldStderr\n\tout := <-outC\n\n\treturn out, err\n}\n\nfunc TestDeprecatedFlagUsage(t *testing.T) {\n\tf := NewFlagSet(\"bob\", ContinueOnError)\n\tf.Bool(\"badflag\", true, \"always true\")\n\tusageMsg := \"use --good-flag instead\"\n\tf.MarkDeprecated(\"badflag\", usageMsg)\n\n\targs := []string{\"--badflag\"}\n\tout, err := parseReturnStderr(t, f, args)\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got \", err)\n\t}\n\n\tif !strings.Contains(out, usageMsg) {\n\t\tt.Errorf(\"usageMsg not printed when using a deprecated flag!\")\n\t}\n}\n\nfunc TestDeprecatedFlagShorthandUsage(t *testing.T) {\n\tf := NewFlagSet(\"bob\", ContinueOnError)\n\tname := \"noshorthandflag\"\n\tf.BoolP(name, \"n\", true, \"always true\")\n\tusageMsg := fmt.Sprintf(\"use --%s instead\", name)\n\tf.MarkShorthandDeprecated(name, usageMsg)\n\n\targs := []string{\"-n\"}\n\tout, err := parseReturnStderr(t, f, args)\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got \", err)\n\t}\n\n\tif !strings.Contains(out, usageMsg) {\n\t\tt.Errorf(\"usageMsg not printed when using a deprecated flag!\")\n\t}\n}\n\nfunc TestDeprecatedFlagUsageNormalized(t *testing.T) {\n\tf := NewFlagSet(\"bob\", ContinueOnError)\n\tf.Bool(\"bad-double_flag\", true, \"always true\")\n\tf.SetNormalizeFunc(wordSepNormalizeFunc)\n\tusageMsg := \"use --good-flag instead\"\n\tf.MarkDeprecated(\"bad_double-flag\", usageMsg)\n\n\targs := []string{\"--bad_double_flag\"}\n\tout, err := parseReturnStderr(t, f, args)\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got \", err)\n\t}\n\n\tif !strings.Contains(out, usageMsg) {\n\t\tt.Errorf(\"usageMsg not printed when using a deprecated flag!\")\n\t}\n}\n\n// Name normalization function should be called only once on flag addition\nfunc TestMultipleNormalizeFlagNameInvocations(t *testing.T) {\n\tnormalizeFlagNameInvocations = 0\n\n\tf := NewFlagSet(\"normalized\", ContinueOnError)\n\tf.SetNormalizeFunc(wordSepNormalizeFunc)\n\tf.Bool(\"with_under_flag\", false, \"bool value\")\n\n\tif normalizeFlagNameInvocations != 1 {\n\t\tt.Fatal(\"Expected normalizeFlagNameInvocations to be 1; got \", normalizeFlagNameInvocations)\n\t}\n}\n\n//\nfunc TestHiddenFlagInUsage(t *testing.T) {\n\tf := NewFlagSet(\"bob\", ContinueOnError)\n\tf.Bool(\"secretFlag\", true, \"shhh\")\n\tf.MarkHidden(\"secretFlag\")\n\n\tout := new(bytes.Buffer)\n\tf.SetOutput(out)\n\tf.PrintDefaults()\n\n\tif strings.Contains(out.String(), \"secretFlag\") {\n\t\tt.Errorf(\"found hidden flag in usage!\")\n\t}\n}\n\n//\nfunc TestHiddenFlagUsage(t *testing.T) {\n\tf := NewFlagSet(\"bob\", ContinueOnError)\n\tf.Bool(\"secretFlag\", true, \"shhh\")\n\tf.MarkHidden(\"secretFlag\")\n\n\targs := []string{\"--secretFlag\"}\n\tout, err := parseReturnStderr(t, f, args)\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got \", err)\n\t}\n\n\tif strings.Contains(out, \"shhh\") {\n\t\tt.Errorf(\"usage message printed when using a hidden flag!\")\n\t}\n}\n\nconst defaultOutput = `      --A                         for bootstrapping, allow 'any' type\n      --Alongflagname             disable bounds checking\n  -C, --CCC                       a boolean defaulting to true (default true)\n      --D path                    set relative path for local imports\n  -E, --EEE num[=1234]            a num with NoOptDefVal (default 4321)\n      --F number                  a non-zero number (default 2.7)\n      --G float                   a float that defaults to zero\n      --IP ip                     IP address with no default\n      --IPMask ipMask             Netmask address with no default\n      --IPNet ipNet               IP network with no default\n      --Ints intSlice             int slice with zero default\n      --N int                     a non-zero int (default 27)\n      --ND1 string[=\"bar\"]        a string with NoOptDefVal (default \"foo\")\n      --ND2 num[=4321]            a num with NoOptDefVal (default 1234)\n      --StringArray stringArray   string array with zero default\n      --StringSlice stringSlice   string slice with zero default\n      --Z int                     an int that defaults to zero\n      --custom custom             custom Value implementation\n      --customP custom            a VarP with default (default 10)\n      --maxT timeout              set timeout for dial\n`\n\n// Custom value that satisfies the Value interface.\ntype customValue int\n\nfunc (cv *customValue) String() string { return fmt.Sprintf(\"%v\", *cv) }\n\nfunc (cv *customValue) Set(s string) error {\n\tv, err := strconv.ParseInt(s, 0, 64)\n\t*cv = customValue(v)\n\treturn err\n}\n\nfunc (cv *customValue) Type() string { return \"custom\" }\n\nfunc TestPrintDefaults(t *testing.T) {\n\tfs := NewFlagSet(\"print defaults test\", ContinueOnError)\n\tvar buf bytes.Buffer\n\tfs.SetOutput(&buf)\n\tfs.Bool(\"A\", false, \"for bootstrapping, allow 'any' type\")\n\tfs.Bool(\"Alongflagname\", false, \"disable bounds checking\")\n\tfs.BoolP(\"CCC\", \"C\", true, \"a boolean defaulting to true\")\n\tfs.String(\"D\", \"\", \"set relative `path` for local imports\")\n\tfs.Float64(\"F\", 2.7, \"a non-zero `number`\")\n\tfs.Float64(\"G\", 0, \"a float that defaults to zero\")\n\tfs.Int(\"N\", 27, \"a non-zero int\")\n\tfs.IntSlice(\"Ints\", []int{}, \"int slice with zero default\")\n\tfs.IP(\"IP\", nil, \"IP address with no default\")\n\tfs.IPMask(\"IPMask\", nil, \"Netmask address with no default\")\n\tfs.IPNet(\"IPNet\", net.IPNet{}, \"IP network with no default\")\n\tfs.Int(\"Z\", 0, \"an int that defaults to zero\")\n\tfs.Duration(\"maxT\", 0, \"set `timeout` for dial\")\n\tfs.String(\"ND1\", \"foo\", \"a string with NoOptDefVal\")\n\tfs.Lookup(\"ND1\").NoOptDefVal = \"bar\"\n\tfs.Int(\"ND2\", 1234, \"a `num` with NoOptDefVal\")\n\tfs.Lookup(\"ND2\").NoOptDefVal = \"4321\"\n\tfs.IntP(\"EEE\", \"E\", 4321, \"a `num` with NoOptDefVal\")\n\tfs.ShorthandLookup(\"E\").NoOptDefVal = \"1234\"\n\tfs.StringSlice(\"StringSlice\", []string{}, \"string slice with zero default\")\n\tfs.StringArray(\"StringArray\", []string{}, \"string array with zero default\")\n\n\tvar cv customValue\n\tfs.Var(&cv, \"custom\", \"custom Value implementation\")\n\n\tcv2 := customValue(10)\n\tfs.VarP(&cv2, \"customP\", \"\", \"a VarP with default\")\n\n\tfs.PrintDefaults()\n\tgot := buf.String()\n\tif got != defaultOutput {\n\t\tfmt.Println(\"\\n\" + got)\n\t\tfmt.Println(\"\\n\" + defaultOutput)\n\t\tt.Errorf(\"got %q want %q\\n\", got, defaultOutput)\n\t}\n}\n\nfunc TestVisitAllFlagOrder(t *testing.T) {\n\tfs := NewFlagSet(\"TestVisitAllFlagOrder\", ContinueOnError)\n\tfs.SortFlags = false\n\t// https://github.com/spf13/pflag/issues/120\n\tfs.SetNormalizeFunc(func(f *FlagSet, name string) NormalizedName {\n\t\treturn NormalizedName(name)\n\t})\n\n\tnames := []string{\"C\", \"B\", \"A\", \"D\"}\n\tfor _, name := range names {\n\t\tfs.Bool(name, false, \"\")\n\t}\n\n\ti := 0\n\tfs.VisitAll(func(f *Flag) {\n\t\tif names[i] != f.Name {\n\t\t\tt.Errorf(\"Incorrect order. Expected %v, got %v\", names[i], f.Name)\n\t\t}\n\t\ti++\n\t})\n}\n\nfunc TestVisitFlagOrder(t *testing.T) {\n\tfs := NewFlagSet(\"TestVisitFlagOrder\", ContinueOnError)\n\tfs.SortFlags = false\n\tnames := []string{\"C\", \"B\", \"A\", \"D\"}\n\tfor _, name := range names {\n\t\tfs.Bool(name, false, \"\")\n\t\tfs.Set(name, \"true\")\n\t}\n\n\ti := 0\n\tfs.Visit(func(f *Flag) {\n\t\tif names[i] != f.Name {\n\t\t\tt.Errorf(\"Incorrect order. Expected %v, got %v\", names[i], f.Name)\n\t\t}\n\t\ti++\n\t})\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/float32.go",
    "content": "package pflag\n\nimport \"strconv\"\n\n// -- float32 Value\ntype float32Value float32\n\nfunc newFloat32Value(val float32, p *float32) *float32Value {\n\t*p = val\n\treturn (*float32Value)(p)\n}\n\nfunc (f *float32Value) Set(s string) error {\n\tv, err := strconv.ParseFloat(s, 32)\n\t*f = float32Value(v)\n\treturn err\n}\n\nfunc (f *float32Value) Type() string {\n\treturn \"float32\"\n}\n\nfunc (f *float32Value) String() string { return strconv.FormatFloat(float64(*f), 'g', -1, 32) }\n\nfunc float32Conv(sval string) (interface{}, error) {\n\tv, err := strconv.ParseFloat(sval, 32)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn float32(v), nil\n}\n\n// GetFloat32 return the float32 value of a flag with the given name\nfunc (f *FlagSet) GetFloat32(name string) (float32, error) {\n\tval, err := f.getFlagType(name, \"float32\", float32Conv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn val.(float32), nil\n}\n\n// Float32Var defines a float32 flag with specified name, default value, and usage string.\n// The argument p points to a float32 variable in which to store the value of the flag.\nfunc (f *FlagSet) Float32Var(p *float32, name string, value float32, usage string) {\n\tf.VarP(newFloat32Value(value, p), name, \"\", usage)\n}\n\n// Float32VarP is like Float32Var, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Float32VarP(p *float32, name, shorthand string, value float32, usage string) {\n\tf.VarP(newFloat32Value(value, p), name, shorthand, usage)\n}\n\n// Float32Var defines a float32 flag with specified name, default value, and usage string.\n// The argument p points to a float32 variable in which to store the value of the flag.\nfunc Float32Var(p *float32, name string, value float32, usage string) {\n\tCommandLine.VarP(newFloat32Value(value, p), name, \"\", usage)\n}\n\n// Float32VarP is like Float32Var, but accepts a shorthand letter that can be used after a single dash.\nfunc Float32VarP(p *float32, name, shorthand string, value float32, usage string) {\n\tCommandLine.VarP(newFloat32Value(value, p), name, shorthand, usage)\n}\n\n// Float32 defines a float32 flag with specified name, default value, and usage string.\n// The return value is the address of a float32 variable that stores the value of the flag.\nfunc (f *FlagSet) Float32(name string, value float32, usage string) *float32 {\n\tp := new(float32)\n\tf.Float32VarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// Float32P is like Float32, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Float32P(name, shorthand string, value float32, usage string) *float32 {\n\tp := new(float32)\n\tf.Float32VarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// Float32 defines a float32 flag with specified name, default value, and usage string.\n// The return value is the address of a float32 variable that stores the value of the flag.\nfunc Float32(name string, value float32, usage string) *float32 {\n\treturn CommandLine.Float32P(name, \"\", value, usage)\n}\n\n// Float32P is like Float32, but accepts a shorthand letter that can be used after a single dash.\nfunc Float32P(name, shorthand string, value float32, usage string) *float32 {\n\treturn CommandLine.Float32P(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/float64.go",
    "content": "package pflag\n\nimport \"strconv\"\n\n// -- float64 Value\ntype float64Value float64\n\nfunc newFloat64Value(val float64, p *float64) *float64Value {\n\t*p = val\n\treturn (*float64Value)(p)\n}\n\nfunc (f *float64Value) Set(s string) error {\n\tv, err := strconv.ParseFloat(s, 64)\n\t*f = float64Value(v)\n\treturn err\n}\n\nfunc (f *float64Value) Type() string {\n\treturn \"float64\"\n}\n\nfunc (f *float64Value) String() string { return strconv.FormatFloat(float64(*f), 'g', -1, 64) }\n\nfunc float64Conv(sval string) (interface{}, error) {\n\treturn strconv.ParseFloat(sval, 64)\n}\n\n// GetFloat64 return the float64 value of a flag with the given name\nfunc (f *FlagSet) GetFloat64(name string) (float64, error) {\n\tval, err := f.getFlagType(name, \"float64\", float64Conv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn val.(float64), nil\n}\n\n// Float64Var defines a float64 flag with specified name, default value, and usage string.\n// The argument p points to a float64 variable in which to store the value of the flag.\nfunc (f *FlagSet) Float64Var(p *float64, name string, value float64, usage string) {\n\tf.VarP(newFloat64Value(value, p), name, \"\", usage)\n}\n\n// Float64VarP is like Float64Var, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Float64VarP(p *float64, name, shorthand string, value float64, usage string) {\n\tf.VarP(newFloat64Value(value, p), name, shorthand, usage)\n}\n\n// Float64Var defines a float64 flag with specified name, default value, and usage string.\n// The argument p points to a float64 variable in which to store the value of the flag.\nfunc Float64Var(p *float64, name string, value float64, usage string) {\n\tCommandLine.VarP(newFloat64Value(value, p), name, \"\", usage)\n}\n\n// Float64VarP is like Float64Var, but accepts a shorthand letter that can be used after a single dash.\nfunc Float64VarP(p *float64, name, shorthand string, value float64, usage string) {\n\tCommandLine.VarP(newFloat64Value(value, p), name, shorthand, usage)\n}\n\n// Float64 defines a float64 flag with specified name, default value, and usage string.\n// The return value is the address of a float64 variable that stores the value of the flag.\nfunc (f *FlagSet) Float64(name string, value float64, usage string) *float64 {\n\tp := new(float64)\n\tf.Float64VarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// Float64P is like Float64, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Float64P(name, shorthand string, value float64, usage string) *float64 {\n\tp := new(float64)\n\tf.Float64VarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// Float64 defines a float64 flag with specified name, default value, and usage string.\n// The return value is the address of a float64 variable that stores the value of the flag.\nfunc Float64(name string, value float64, usage string) *float64 {\n\treturn CommandLine.Float64P(name, \"\", value, usage)\n}\n\n// Float64P is like Float64, but accepts a shorthand letter that can be used after a single dash.\nfunc Float64P(name, shorthand string, value float64, usage string) *float64 {\n\treturn CommandLine.Float64P(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/golangflag.go",
    "content": "// Copyright 2009 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 pflag\n\nimport (\n\tgoflag \"flag\"\n\t\"reflect\"\n\t\"strings\"\n)\n\n// flagValueWrapper implements pflag.Value around a flag.Value.  The main\n// difference here is the addition of the Type method that returns a string\n// name of the type.  As this is generally unknown, we approximate that with\n// reflection.\ntype flagValueWrapper struct {\n\tinner    goflag.Value\n\tflagType string\n}\n\n// We are just copying the boolFlag interface out of goflag as that is what\n// they use to decide if a flag should get \"true\" when no arg is given.\ntype goBoolFlag interface {\n\tgoflag.Value\n\tIsBoolFlag() bool\n}\n\nfunc wrapFlagValue(v goflag.Value) Value {\n\t// If the flag.Value happens to also be a pflag.Value, just use it directly.\n\tif pv, ok := v.(Value); ok {\n\t\treturn pv\n\t}\n\n\tpv := &flagValueWrapper{\n\t\tinner: v,\n\t}\n\n\tt := reflect.TypeOf(v)\n\tif t.Kind() == reflect.Interface || t.Kind() == reflect.Ptr {\n\t\tt = t.Elem()\n\t}\n\n\tpv.flagType = strings.TrimSuffix(t.Name(), \"Value\")\n\treturn pv\n}\n\nfunc (v *flagValueWrapper) String() string {\n\treturn v.inner.String()\n}\n\nfunc (v *flagValueWrapper) Set(s string) error {\n\treturn v.inner.Set(s)\n}\n\nfunc (v *flagValueWrapper) Type() string {\n\treturn v.flagType\n}\n\n// PFlagFromGoFlag will return a *pflag.Flag given a *flag.Flag\n// If the *flag.Flag.Name was a single character (ex: `v`) it will be accessiblei\n// with both `-v` and `--v` in flags. If the golang flag was more than a single\n// character (ex: `verbose`) it will only be accessible via `--verbose`\nfunc PFlagFromGoFlag(goflag *goflag.Flag) *Flag {\n\t// Remember the default value as a string; it won't change.\n\tflag := &Flag{\n\t\tName:  goflag.Name,\n\t\tUsage: goflag.Usage,\n\t\tValue: wrapFlagValue(goflag.Value),\n\t\t// Looks like golang flags don't set DefValue correctly  :-(\n\t\t//DefValue: goflag.DefValue,\n\t\tDefValue: goflag.Value.String(),\n\t}\n\t// Ex: if the golang flag was -v, allow both -v and --v to work\n\tif len(flag.Name) == 1 {\n\t\tflag.Shorthand = flag.Name\n\t}\n\tif fv, ok := goflag.Value.(goBoolFlag); ok && fv.IsBoolFlag() {\n\t\tflag.NoOptDefVal = \"true\"\n\t}\n\treturn flag\n}\n\n// AddGoFlag will add the given *flag.Flag to the pflag.FlagSet\nfunc (f *FlagSet) AddGoFlag(goflag *goflag.Flag) {\n\tif f.Lookup(goflag.Name) != nil {\n\t\treturn\n\t}\n\tnewflag := PFlagFromGoFlag(goflag)\n\tf.AddFlag(newflag)\n}\n\n// AddGoFlagSet will add the given *flag.FlagSet to the pflag.FlagSet\nfunc (f *FlagSet) AddGoFlagSet(newSet *goflag.FlagSet) {\n\tif newSet == nil {\n\t\treturn\n\t}\n\tnewSet.VisitAll(func(goflag *goflag.Flag) {\n\t\tf.AddGoFlag(goflag)\n\t})\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/golangflag_test.go",
    "content": "// Copyright 2009 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 pflag\n\nimport (\n\tgoflag \"flag\"\n\t\"testing\"\n)\n\nfunc TestGoflags(t *testing.T) {\n\tgoflag.String(\"stringFlag\", \"stringFlag\", \"stringFlag\")\n\tgoflag.Bool(\"boolFlag\", false, \"boolFlag\")\n\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\n\tf.AddGoFlagSet(goflag.CommandLine)\n\terr := f.Parse([]string{\"--stringFlag=bob\", \"--boolFlag\"})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; get\", err)\n\t}\n\n\tgetString, err := f.GetString(\"stringFlag\")\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; get\", err)\n\t}\n\tif getString != \"bob\" {\n\t\tt.Fatalf(\"expected getString=bob but got getString=%s\", getString)\n\t}\n\n\tgetBool, err := f.GetBool(\"boolFlag\")\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; get\", err)\n\t}\n\tif getBool != true {\n\t\tt.Fatalf(\"expected getBool=true but got getBool=%v\", getBool)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/int.go",
    "content": "package pflag\n\nimport \"strconv\"\n\n// -- int Value\ntype intValue int\n\nfunc newIntValue(val int, p *int) *intValue {\n\t*p = val\n\treturn (*intValue)(p)\n}\n\nfunc (i *intValue) Set(s string) error {\n\tv, err := strconv.ParseInt(s, 0, 64)\n\t*i = intValue(v)\n\treturn err\n}\n\nfunc (i *intValue) Type() string {\n\treturn \"int\"\n}\n\nfunc (i *intValue) String() string { return strconv.Itoa(int(*i)) }\n\nfunc intConv(sval string) (interface{}, error) {\n\treturn strconv.Atoi(sval)\n}\n\n// GetInt return the int value of a flag with the given name\nfunc (f *FlagSet) GetInt(name string) (int, error) {\n\tval, err := f.getFlagType(name, \"int\", intConv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn val.(int), nil\n}\n\n// IntVar defines an int flag with specified name, default value, and usage string.\n// The argument p points to an int variable in which to store the value of the flag.\nfunc (f *FlagSet) IntVar(p *int, name string, value int, usage string) {\n\tf.VarP(newIntValue(value, p), name, \"\", usage)\n}\n\n// IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) IntVarP(p *int, name, shorthand string, value int, usage string) {\n\tf.VarP(newIntValue(value, p), name, shorthand, usage)\n}\n\n// IntVar defines an int flag with specified name, default value, and usage string.\n// The argument p points to an int variable in which to store the value of the flag.\nfunc IntVar(p *int, name string, value int, usage string) {\n\tCommandLine.VarP(newIntValue(value, p), name, \"\", usage)\n}\n\n// IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash.\nfunc IntVarP(p *int, name, shorthand string, value int, usage string) {\n\tCommandLine.VarP(newIntValue(value, p), name, shorthand, usage)\n}\n\n// Int defines an int flag with specified name, default value, and usage string.\n// The return value is the address of an int variable that stores the value of the flag.\nfunc (f *FlagSet) Int(name string, value int, usage string) *int {\n\tp := new(int)\n\tf.IntVarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// IntP is like Int, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) IntP(name, shorthand string, value int, usage string) *int {\n\tp := new(int)\n\tf.IntVarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// Int defines an int flag with specified name, default value, and usage string.\n// The return value is the address of an int variable that stores the value of the flag.\nfunc Int(name string, value int, usage string) *int {\n\treturn CommandLine.IntP(name, \"\", value, usage)\n}\n\n// IntP is like Int, but accepts a shorthand letter that can be used after a single dash.\nfunc IntP(name, shorthand string, value int, usage string) *int {\n\treturn CommandLine.IntP(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/int32.go",
    "content": "package pflag\n\nimport \"strconv\"\n\n// -- int32 Value\ntype int32Value int32\n\nfunc newInt32Value(val int32, p *int32) *int32Value {\n\t*p = val\n\treturn (*int32Value)(p)\n}\n\nfunc (i *int32Value) Set(s string) error {\n\tv, err := strconv.ParseInt(s, 0, 32)\n\t*i = int32Value(v)\n\treturn err\n}\n\nfunc (i *int32Value) Type() string {\n\treturn \"int32\"\n}\n\nfunc (i *int32Value) String() string { return strconv.FormatInt(int64(*i), 10) }\n\nfunc int32Conv(sval string) (interface{}, error) {\n\tv, err := strconv.ParseInt(sval, 0, 32)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn int32(v), nil\n}\n\n// GetInt32 return the int32 value of a flag with the given name\nfunc (f *FlagSet) GetInt32(name string) (int32, error) {\n\tval, err := f.getFlagType(name, \"int32\", int32Conv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn val.(int32), nil\n}\n\n// Int32Var defines an int32 flag with specified name, default value, and usage string.\n// The argument p points to an int32 variable in which to store the value of the flag.\nfunc (f *FlagSet) Int32Var(p *int32, name string, value int32, usage string) {\n\tf.VarP(newInt32Value(value, p), name, \"\", usage)\n}\n\n// Int32VarP is like Int32Var, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Int32VarP(p *int32, name, shorthand string, value int32, usage string) {\n\tf.VarP(newInt32Value(value, p), name, shorthand, usage)\n}\n\n// Int32Var defines an int32 flag with specified name, default value, and usage string.\n// The argument p points to an int32 variable in which to store the value of the flag.\nfunc Int32Var(p *int32, name string, value int32, usage string) {\n\tCommandLine.VarP(newInt32Value(value, p), name, \"\", usage)\n}\n\n// Int32VarP is like Int32Var, but accepts a shorthand letter that can be used after a single dash.\nfunc Int32VarP(p *int32, name, shorthand string, value int32, usage string) {\n\tCommandLine.VarP(newInt32Value(value, p), name, shorthand, usage)\n}\n\n// Int32 defines an int32 flag with specified name, default value, and usage string.\n// The return value is the address of an int32 variable that stores the value of the flag.\nfunc (f *FlagSet) Int32(name string, value int32, usage string) *int32 {\n\tp := new(int32)\n\tf.Int32VarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// Int32P is like Int32, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Int32P(name, shorthand string, value int32, usage string) *int32 {\n\tp := new(int32)\n\tf.Int32VarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// Int32 defines an int32 flag with specified name, default value, and usage string.\n// The return value is the address of an int32 variable that stores the value of the flag.\nfunc Int32(name string, value int32, usage string) *int32 {\n\treturn CommandLine.Int32P(name, \"\", value, usage)\n}\n\n// Int32P is like Int32, but accepts a shorthand letter that can be used after a single dash.\nfunc Int32P(name, shorthand string, value int32, usage string) *int32 {\n\treturn CommandLine.Int32P(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/int64.go",
    "content": "package pflag\n\nimport \"strconv\"\n\n// -- int64 Value\ntype int64Value int64\n\nfunc newInt64Value(val int64, p *int64) *int64Value {\n\t*p = val\n\treturn (*int64Value)(p)\n}\n\nfunc (i *int64Value) Set(s string) error {\n\tv, err := strconv.ParseInt(s, 0, 64)\n\t*i = int64Value(v)\n\treturn err\n}\n\nfunc (i *int64Value) Type() string {\n\treturn \"int64\"\n}\n\nfunc (i *int64Value) String() string { return strconv.FormatInt(int64(*i), 10) }\n\nfunc int64Conv(sval string) (interface{}, error) {\n\treturn strconv.ParseInt(sval, 0, 64)\n}\n\n// GetInt64 return the int64 value of a flag with the given name\nfunc (f *FlagSet) GetInt64(name string) (int64, error) {\n\tval, err := f.getFlagType(name, \"int64\", int64Conv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn val.(int64), nil\n}\n\n// Int64Var defines an int64 flag with specified name, default value, and usage string.\n// The argument p points to an int64 variable in which to store the value of the flag.\nfunc (f *FlagSet) Int64Var(p *int64, name string, value int64, usage string) {\n\tf.VarP(newInt64Value(value, p), name, \"\", usage)\n}\n\n// Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Int64VarP(p *int64, name, shorthand string, value int64, usage string) {\n\tf.VarP(newInt64Value(value, p), name, shorthand, usage)\n}\n\n// Int64Var defines an int64 flag with specified name, default value, and usage string.\n// The argument p points to an int64 variable in which to store the value of the flag.\nfunc Int64Var(p *int64, name string, value int64, usage string) {\n\tCommandLine.VarP(newInt64Value(value, p), name, \"\", usage)\n}\n\n// Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash.\nfunc Int64VarP(p *int64, name, shorthand string, value int64, usage string) {\n\tCommandLine.VarP(newInt64Value(value, p), name, shorthand, usage)\n}\n\n// Int64 defines an int64 flag with specified name, default value, and usage string.\n// The return value is the address of an int64 variable that stores the value of the flag.\nfunc (f *FlagSet) Int64(name string, value int64, usage string) *int64 {\n\tp := new(int64)\n\tf.Int64VarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Int64P(name, shorthand string, value int64, usage string) *int64 {\n\tp := new(int64)\n\tf.Int64VarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// Int64 defines an int64 flag with specified name, default value, and usage string.\n// The return value is the address of an int64 variable that stores the value of the flag.\nfunc Int64(name string, value int64, usage string) *int64 {\n\treturn CommandLine.Int64P(name, \"\", value, usage)\n}\n\n// Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash.\nfunc Int64P(name, shorthand string, value int64, usage string) *int64 {\n\treturn CommandLine.Int64P(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/int8.go",
    "content": "package pflag\n\nimport \"strconv\"\n\n// -- int8 Value\ntype int8Value int8\n\nfunc newInt8Value(val int8, p *int8) *int8Value {\n\t*p = val\n\treturn (*int8Value)(p)\n}\n\nfunc (i *int8Value) Set(s string) error {\n\tv, err := strconv.ParseInt(s, 0, 8)\n\t*i = int8Value(v)\n\treturn err\n}\n\nfunc (i *int8Value) Type() string {\n\treturn \"int8\"\n}\n\nfunc (i *int8Value) String() string { return strconv.FormatInt(int64(*i), 10) }\n\nfunc int8Conv(sval string) (interface{}, error) {\n\tv, err := strconv.ParseInt(sval, 0, 8)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn int8(v), nil\n}\n\n// GetInt8 return the int8 value of a flag with the given name\nfunc (f *FlagSet) GetInt8(name string) (int8, error) {\n\tval, err := f.getFlagType(name, \"int8\", int8Conv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn val.(int8), nil\n}\n\n// Int8Var defines an int8 flag with specified name, default value, and usage string.\n// The argument p points to an int8 variable in which to store the value of the flag.\nfunc (f *FlagSet) Int8Var(p *int8, name string, value int8, usage string) {\n\tf.VarP(newInt8Value(value, p), name, \"\", usage)\n}\n\n// Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Int8VarP(p *int8, name, shorthand string, value int8, usage string) {\n\tf.VarP(newInt8Value(value, p), name, shorthand, usage)\n}\n\n// Int8Var defines an int8 flag with specified name, default value, and usage string.\n// The argument p points to an int8 variable in which to store the value of the flag.\nfunc Int8Var(p *int8, name string, value int8, usage string) {\n\tCommandLine.VarP(newInt8Value(value, p), name, \"\", usage)\n}\n\n// Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash.\nfunc Int8VarP(p *int8, name, shorthand string, value int8, usage string) {\n\tCommandLine.VarP(newInt8Value(value, p), name, shorthand, usage)\n}\n\n// Int8 defines an int8 flag with specified name, default value, and usage string.\n// The return value is the address of an int8 variable that stores the value of the flag.\nfunc (f *FlagSet) Int8(name string, value int8, usage string) *int8 {\n\tp := new(int8)\n\tf.Int8VarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Int8P(name, shorthand string, value int8, usage string) *int8 {\n\tp := new(int8)\n\tf.Int8VarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// Int8 defines an int8 flag with specified name, default value, and usage string.\n// The return value is the address of an int8 variable that stores the value of the flag.\nfunc Int8(name string, value int8, usage string) *int8 {\n\treturn CommandLine.Int8P(name, \"\", value, usage)\n}\n\n// Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash.\nfunc Int8P(name, shorthand string, value int8, usage string) *int8 {\n\treturn CommandLine.Int8P(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/int_slice.go",
    "content": "package pflag\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// -- intSlice Value\ntype intSliceValue struct {\n\tvalue   *[]int\n\tchanged bool\n}\n\nfunc newIntSliceValue(val []int, p *[]int) *intSliceValue {\n\tisv := new(intSliceValue)\n\tisv.value = p\n\t*isv.value = val\n\treturn isv\n}\n\nfunc (s *intSliceValue) Set(val string) error {\n\tss := strings.Split(val, \",\")\n\tout := make([]int, len(ss))\n\tfor i, d := range ss {\n\t\tvar err error\n\t\tout[i], err = strconv.Atoi(d)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\tif !s.changed {\n\t\t*s.value = out\n\t} else {\n\t\t*s.value = append(*s.value, out...)\n\t}\n\ts.changed = true\n\treturn nil\n}\n\nfunc (s *intSliceValue) Type() string {\n\treturn \"intSlice\"\n}\n\nfunc (s *intSliceValue) String() string {\n\tout := make([]string, len(*s.value))\n\tfor i, d := range *s.value {\n\t\tout[i] = fmt.Sprintf(\"%d\", d)\n\t}\n\treturn \"[\" + strings.Join(out, \",\") + \"]\"\n}\n\nfunc intSliceConv(val string) (interface{}, error) {\n\tval = strings.Trim(val, \"[]\")\n\t// Empty string would cause a slice with one (empty) entry\n\tif len(val) == 0 {\n\t\treturn []int{}, nil\n\t}\n\tss := strings.Split(val, \",\")\n\tout := make([]int, len(ss))\n\tfor i, d := range ss {\n\t\tvar err error\n\t\tout[i], err = strconv.Atoi(d)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t}\n\treturn out, nil\n}\n\n// GetIntSlice return the []int value of a flag with the given name\nfunc (f *FlagSet) GetIntSlice(name string) ([]int, error) {\n\tval, err := f.getFlagType(name, \"intSlice\", intSliceConv)\n\tif err != nil {\n\t\treturn []int{}, err\n\t}\n\treturn val.([]int), nil\n}\n\n// IntSliceVar defines a intSlice flag with specified name, default value, and usage string.\n// The argument p points to a []int variable in which to store the value of the flag.\nfunc (f *FlagSet) IntSliceVar(p *[]int, name string, value []int, usage string) {\n\tf.VarP(newIntSliceValue(value, p), name, \"\", usage)\n}\n\n// IntSliceVarP is like IntSliceVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) IntSliceVarP(p *[]int, name, shorthand string, value []int, usage string) {\n\tf.VarP(newIntSliceValue(value, p), name, shorthand, usage)\n}\n\n// IntSliceVar defines a int[] flag with specified name, default value, and usage string.\n// The argument p points to a int[] variable in which to store the value of the flag.\nfunc IntSliceVar(p *[]int, name string, value []int, usage string) {\n\tCommandLine.VarP(newIntSliceValue(value, p), name, \"\", usage)\n}\n\n// IntSliceVarP is like IntSliceVar, but accepts a shorthand letter that can be used after a single dash.\nfunc IntSliceVarP(p *[]int, name, shorthand string, value []int, usage string) {\n\tCommandLine.VarP(newIntSliceValue(value, p), name, shorthand, usage)\n}\n\n// IntSlice defines a []int flag with specified name, default value, and usage string.\n// The return value is the address of a []int variable that stores the value of the flag.\nfunc (f *FlagSet) IntSlice(name string, value []int, usage string) *[]int {\n\tp := []int{}\n\tf.IntSliceVarP(&p, name, \"\", value, usage)\n\treturn &p\n}\n\n// IntSliceP is like IntSlice, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) IntSliceP(name, shorthand string, value []int, usage string) *[]int {\n\tp := []int{}\n\tf.IntSliceVarP(&p, name, shorthand, value, usage)\n\treturn &p\n}\n\n// IntSlice defines a []int flag with specified name, default value, and usage string.\n// The return value is the address of a []int variable that stores the value of the flag.\nfunc IntSlice(name string, value []int, usage string) *[]int {\n\treturn CommandLine.IntSliceP(name, \"\", value, usage)\n}\n\n// IntSliceP is like IntSlice, but accepts a shorthand letter that can be used after a single dash.\nfunc IntSliceP(name, shorthand string, value []int, usage string) *[]int {\n\treturn CommandLine.IntSliceP(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/int_slice_test.go",
    "content": "// Copyright 2009 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 pflag\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc setUpISFlagSet(isp *[]int) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.IntSliceVar(isp, \"is\", []int{}, \"Command separated list!\")\n\treturn f\n}\n\nfunc setUpISFlagSetWithDefault(isp *[]int) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.IntSliceVar(isp, \"is\", []int{0, 1}, \"Command separated list!\")\n\treturn f\n}\n\nfunc TestEmptyIS(t *testing.T) {\n\tvar is []int\n\tf := setUpISFlagSet(&is)\n\terr := f.Parse([]string{})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tgetIS, err := f.GetIntSlice(\"is\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetIntSlice():\", err)\n\t}\n\tif len(getIS) != 0 {\n\t\tt.Fatalf(\"got is %v with len=%d but expected length=0\", getIS, len(getIS))\n\t}\n}\n\nfunc TestIS(t *testing.T) {\n\tvar is []int\n\tf := setUpISFlagSet(&is)\n\n\tvals := []string{\"1\", \"2\", \"4\", \"3\"}\n\targ := fmt.Sprintf(\"--is=%s\", strings.Join(vals, \",\"))\n\terr := f.Parse([]string{arg})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range is {\n\t\td, err := strconv.Atoi(vals[i])\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif d != v {\n\t\t\tt.Fatalf(\"expected is[%d] to be %s but got: %d\", i, vals[i], v)\n\t\t}\n\t}\n\tgetIS, err := f.GetIntSlice(\"is\")\n\tif err != nil {\n\t\tt.Fatalf(\"got error: %v\", err)\n\t}\n\tfor i, v := range getIS {\n\t\td, err := strconv.Atoi(vals[i])\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif d != v {\n\t\t\tt.Fatalf(\"expected is[%d] to be %s but got: %d from GetIntSlice\", i, vals[i], v)\n\t\t}\n\t}\n}\n\nfunc TestISDefault(t *testing.T) {\n\tvar is []int\n\tf := setUpISFlagSetWithDefault(&is)\n\n\tvals := []string{\"0\", \"1\"}\n\n\terr := f.Parse([]string{})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range is {\n\t\td, err := strconv.Atoi(vals[i])\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif d != v {\n\t\t\tt.Fatalf(\"expected is[%d] to be %d but got: %d\", i, d, v)\n\t\t}\n\t}\n\n\tgetIS, err := f.GetIntSlice(\"is\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetIntSlice():\", err)\n\t}\n\tfor i, v := range getIS {\n\t\td, err := strconv.Atoi(vals[i])\n\t\tif err != nil {\n\t\t\tt.Fatal(\"got an error from GetIntSlice():\", err)\n\t\t}\n\t\tif d != v {\n\t\t\tt.Fatalf(\"expected is[%d] to be %d from GetIntSlice but got: %d\", i, d, v)\n\t\t}\n\t}\n}\n\nfunc TestISWithDefault(t *testing.T) {\n\tvar is []int\n\tf := setUpISFlagSetWithDefault(&is)\n\n\tvals := []string{\"1\", \"2\"}\n\targ := fmt.Sprintf(\"--is=%s\", strings.Join(vals, \",\"))\n\terr := f.Parse([]string{arg})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range is {\n\t\td, err := strconv.Atoi(vals[i])\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif d != v {\n\t\t\tt.Fatalf(\"expected is[%d] to be %d but got: %d\", i, d, v)\n\t\t}\n\t}\n\n\tgetIS, err := f.GetIntSlice(\"is\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetIntSlice():\", err)\n\t}\n\tfor i, v := range getIS {\n\t\td, err := strconv.Atoi(vals[i])\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif d != v {\n\t\t\tt.Fatalf(\"expected is[%d] to be %d from GetIntSlice but got: %d\", i, d, v)\n\t\t}\n\t}\n}\n\nfunc TestISCalledTwice(t *testing.T) {\n\tvar is []int\n\tf := setUpISFlagSet(&is)\n\n\tin := []string{\"1,2\", \"3\"}\n\texpected := []int{1, 2, 3}\n\targfmt := \"--is=%s\"\n\targ1 := fmt.Sprintf(argfmt, in[0])\n\targ2 := fmt.Sprintf(argfmt, in[1])\n\terr := f.Parse([]string{arg1, arg2})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range is {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected is[%d] to be %d but got: %d\", i, expected[i], v)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/ip.go",
    "content": "package pflag\n\nimport (\n\t\"fmt\"\n\t\"net\"\n\t\"strings\"\n)\n\n// -- net.IP value\ntype ipValue net.IP\n\nfunc newIPValue(val net.IP, p *net.IP) *ipValue {\n\t*p = val\n\treturn (*ipValue)(p)\n}\n\nfunc (i *ipValue) String() string { return net.IP(*i).String() }\nfunc (i *ipValue) Set(s string) error {\n\tip := net.ParseIP(strings.TrimSpace(s))\n\tif ip == nil {\n\t\treturn fmt.Errorf(\"failed to parse IP: %q\", s)\n\t}\n\t*i = ipValue(ip)\n\treturn nil\n}\n\nfunc (i *ipValue) Type() string {\n\treturn \"ip\"\n}\n\nfunc ipConv(sval string) (interface{}, error) {\n\tip := net.ParseIP(sval)\n\tif ip != nil {\n\t\treturn ip, nil\n\t}\n\treturn nil, fmt.Errorf(\"invalid string being converted to IP address: %s\", sval)\n}\n\n// GetIP return the net.IP value of a flag with the given name\nfunc (f *FlagSet) GetIP(name string) (net.IP, error) {\n\tval, err := f.getFlagType(name, \"ip\", ipConv)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn val.(net.IP), nil\n}\n\n// IPVar defines an net.IP flag with specified name, default value, and usage string.\n// The argument p points to an net.IP variable in which to store the value of the flag.\nfunc (f *FlagSet) IPVar(p *net.IP, name string, value net.IP, usage string) {\n\tf.VarP(newIPValue(value, p), name, \"\", usage)\n}\n\n// IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) {\n\tf.VarP(newIPValue(value, p), name, shorthand, usage)\n}\n\n// IPVar defines an net.IP flag with specified name, default value, and usage string.\n// The argument p points to an net.IP variable in which to store the value of the flag.\nfunc IPVar(p *net.IP, name string, value net.IP, usage string) {\n\tCommandLine.VarP(newIPValue(value, p), name, \"\", usage)\n}\n\n// IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash.\nfunc IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) {\n\tCommandLine.VarP(newIPValue(value, p), name, shorthand, usage)\n}\n\n// IP defines an net.IP flag with specified name, default value, and usage string.\n// The return value is the address of an net.IP variable that stores the value of the flag.\nfunc (f *FlagSet) IP(name string, value net.IP, usage string) *net.IP {\n\tp := new(net.IP)\n\tf.IPVarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// IPP is like IP, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) IPP(name, shorthand string, value net.IP, usage string) *net.IP {\n\tp := new(net.IP)\n\tf.IPVarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// IP defines an net.IP flag with specified name, default value, and usage string.\n// The return value is the address of an net.IP variable that stores the value of the flag.\nfunc IP(name string, value net.IP, usage string) *net.IP {\n\treturn CommandLine.IPP(name, \"\", value, usage)\n}\n\n// IPP is like IP, but accepts a shorthand letter that can be used after a single dash.\nfunc IPP(name, shorthand string, value net.IP, usage string) *net.IP {\n\treturn CommandLine.IPP(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/ip_slice.go",
    "content": "package pflag\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net\"\n\t\"strings\"\n)\n\n// -- ipSlice Value\ntype ipSliceValue struct {\n\tvalue   *[]net.IP\n\tchanged bool\n}\n\nfunc newIPSliceValue(val []net.IP, p *[]net.IP) *ipSliceValue {\n\tipsv := new(ipSliceValue)\n\tipsv.value = p\n\t*ipsv.value = val\n\treturn ipsv\n}\n\n// Set converts, and assigns, the comma-separated IP argument string representation as the []net.IP value of this flag.\n// If Set is called on a flag that already has a []net.IP assigned, the newly converted values will be appended.\nfunc (s *ipSliceValue) Set(val string) error {\n\n\t// remove all quote characters\n\trmQuote := strings.NewReplacer(`\"`, \"\", `'`, \"\", \"`\", \"\")\n\n\t// read flag arguments with CSV parser\n\tipStrSlice, err := readAsCSV(rmQuote.Replace(val))\n\tif err != nil && err != io.EOF {\n\t\treturn err\n\t}\n\n\t// parse ip values into slice\n\tout := make([]net.IP, 0, len(ipStrSlice))\n\tfor _, ipStr := range ipStrSlice {\n\t\tip := net.ParseIP(strings.TrimSpace(ipStr))\n\t\tif ip == nil {\n\t\t\treturn fmt.Errorf(\"invalid string being converted to IP address: %s\", ipStr)\n\t\t}\n\t\tout = append(out, ip)\n\t}\n\n\tif !s.changed {\n\t\t*s.value = out\n\t} else {\n\t\t*s.value = append(*s.value, out...)\n\t}\n\n\ts.changed = true\n\n\treturn nil\n}\n\n// Type returns a string that uniquely represents this flag's type.\nfunc (s *ipSliceValue) Type() string {\n\treturn \"ipSlice\"\n}\n\n// String defines a \"native\" format for this net.IP slice flag value.\nfunc (s *ipSliceValue) String() string {\n\n\tipStrSlice := make([]string, len(*s.value))\n\tfor i, ip := range *s.value {\n\t\tipStrSlice[i] = ip.String()\n\t}\n\n\tout, _ := writeAsCSV(ipStrSlice)\n\n\treturn \"[\" + out + \"]\"\n}\n\nfunc ipSliceConv(val string) (interface{}, error) {\n\tval = strings.Trim(val, \"[]\")\n\t// Emtpy string would cause a slice with one (empty) entry\n\tif len(val) == 0 {\n\t\treturn []net.IP{}, nil\n\t}\n\tss := strings.Split(val, \",\")\n\tout := make([]net.IP, len(ss))\n\tfor i, sval := range ss {\n\t\tip := net.ParseIP(strings.TrimSpace(sval))\n\t\tif ip == nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid string being converted to IP address: %s\", sval)\n\t\t}\n\t\tout[i] = ip\n\t}\n\treturn out, nil\n}\n\n// GetIPSlice returns the []net.IP value of a flag with the given name\nfunc (f *FlagSet) GetIPSlice(name string) ([]net.IP, error) {\n\tval, err := f.getFlagType(name, \"ipSlice\", ipSliceConv)\n\tif err != nil {\n\t\treturn []net.IP{}, err\n\t}\n\treturn val.([]net.IP), nil\n}\n\n// IPSliceVar defines a ipSlice flag with specified name, default value, and usage string.\n// The argument p points to a []net.IP variable in which to store the value of the flag.\nfunc (f *FlagSet) IPSliceVar(p *[]net.IP, name string, value []net.IP, usage string) {\n\tf.VarP(newIPSliceValue(value, p), name, \"\", usage)\n}\n\n// IPSliceVarP is like IPSliceVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) IPSliceVarP(p *[]net.IP, name, shorthand string, value []net.IP, usage string) {\n\tf.VarP(newIPSliceValue(value, p), name, shorthand, usage)\n}\n\n// IPSliceVar defines a []net.IP flag with specified name, default value, and usage string.\n// The argument p points to a []net.IP variable in which to store the value of the flag.\nfunc IPSliceVar(p *[]net.IP, name string, value []net.IP, usage string) {\n\tCommandLine.VarP(newIPSliceValue(value, p), name, \"\", usage)\n}\n\n// IPSliceVarP is like IPSliceVar, but accepts a shorthand letter that can be used after a single dash.\nfunc IPSliceVarP(p *[]net.IP, name, shorthand string, value []net.IP, usage string) {\n\tCommandLine.VarP(newIPSliceValue(value, p), name, shorthand, usage)\n}\n\n// IPSlice defines a []net.IP flag with specified name, default value, and usage string.\n// The return value is the address of a []net.IP variable that stores the value of that flag.\nfunc (f *FlagSet) IPSlice(name string, value []net.IP, usage string) *[]net.IP {\n\tp := []net.IP{}\n\tf.IPSliceVarP(&p, name, \"\", value, usage)\n\treturn &p\n}\n\n// IPSliceP is like IPSlice, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) IPSliceP(name, shorthand string, value []net.IP, usage string) *[]net.IP {\n\tp := []net.IP{}\n\tf.IPSliceVarP(&p, name, shorthand, value, usage)\n\treturn &p\n}\n\n// IPSlice defines a []net.IP flag with specified name, default value, and usage string.\n// The return value is the address of a []net.IP variable that stores the value of the flag.\nfunc IPSlice(name string, value []net.IP, usage string) *[]net.IP {\n\treturn CommandLine.IPSliceP(name, \"\", value, usage)\n}\n\n// IPSliceP is like IPSlice, but accepts a shorthand letter that can be used after a single dash.\nfunc IPSliceP(name, shorthand string, value []net.IP, usage string) *[]net.IP {\n\treturn CommandLine.IPSliceP(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/ip_slice_test.go",
    "content": "package pflag\n\nimport (\n\t\"fmt\"\n\t\"net\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc setUpIPSFlagSet(ipsp *[]net.IP) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.IPSliceVar(ipsp, \"ips\", []net.IP{}, \"Command separated list!\")\n\treturn f\n}\n\nfunc setUpIPSFlagSetWithDefault(ipsp *[]net.IP) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.IPSliceVar(ipsp, \"ips\",\n\t\t[]net.IP{\n\t\t\tnet.ParseIP(\"192.168.1.1\"),\n\t\t\tnet.ParseIP(\"0:0:0:0:0:0:0:1\"),\n\t\t},\n\t\t\"Command separated list!\")\n\treturn f\n}\n\nfunc TestEmptyIP(t *testing.T) {\n\tvar ips []net.IP\n\tf := setUpIPSFlagSet(&ips)\n\terr := f.Parse([]string{})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tgetIPS, err := f.GetIPSlice(\"ips\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetIPSlice():\", err)\n\t}\n\tif len(getIPS) != 0 {\n\t\tt.Fatalf(\"got ips %v with len=%d but expected length=0\", getIPS, len(getIPS))\n\t}\n}\n\nfunc TestIPS(t *testing.T) {\n\tvar ips []net.IP\n\tf := setUpIPSFlagSet(&ips)\n\n\tvals := []string{\"192.168.1.1\", \"10.0.0.1\", \"0:0:0:0:0:0:0:2\"}\n\targ := fmt.Sprintf(\"--ips=%s\", strings.Join(vals, \",\"))\n\terr := f.Parse([]string{arg})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range ips {\n\t\tif ip := net.ParseIP(vals[i]); ip == nil {\n\t\t\tt.Fatalf(\"invalid string being converted to IP address: %s\", vals[i])\n\t\t} else if !ip.Equal(v) {\n\t\t\tt.Fatalf(\"expected ips[%d] to be %s but got: %s from GetIPSlice\", i, vals[i], v)\n\t\t}\n\t}\n}\n\nfunc TestIPSDefault(t *testing.T) {\n\tvar ips []net.IP\n\tf := setUpIPSFlagSetWithDefault(&ips)\n\n\tvals := []string{\"192.168.1.1\", \"0:0:0:0:0:0:0:1\"}\n\terr := f.Parse([]string{})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range ips {\n\t\tif ip := net.ParseIP(vals[i]); ip == nil {\n\t\t\tt.Fatalf(\"invalid string being converted to IP address: %s\", vals[i])\n\t\t} else if !ip.Equal(v) {\n\t\t\tt.Fatalf(\"expected ips[%d] to be %s but got: %s\", i, vals[i], v)\n\t\t}\n\t}\n\n\tgetIPS, err := f.GetIPSlice(\"ips\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetIPSlice\")\n\t}\n\tfor i, v := range getIPS {\n\t\tif ip := net.ParseIP(vals[i]); ip == nil {\n\t\t\tt.Fatalf(\"invalid string being converted to IP address: %s\", vals[i])\n\t\t} else if !ip.Equal(v) {\n\t\t\tt.Fatalf(\"expected ips[%d] to be %s but got: %s\", i, vals[i], v)\n\t\t}\n\t}\n}\n\nfunc TestIPSWithDefault(t *testing.T) {\n\tvar ips []net.IP\n\tf := setUpIPSFlagSetWithDefault(&ips)\n\n\tvals := []string{\"192.168.1.1\", \"0:0:0:0:0:0:0:1\"}\n\targ := fmt.Sprintf(\"--ips=%s\", strings.Join(vals, \",\"))\n\terr := f.Parse([]string{arg})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range ips {\n\t\tif ip := net.ParseIP(vals[i]); ip == nil {\n\t\t\tt.Fatalf(\"invalid string being converted to IP address: %s\", vals[i])\n\t\t} else if !ip.Equal(v) {\n\t\t\tt.Fatalf(\"expected ips[%d] to be %s but got: %s\", i, vals[i], v)\n\t\t}\n\t}\n\n\tgetIPS, err := f.GetIPSlice(\"ips\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetIPSlice\")\n\t}\n\tfor i, v := range getIPS {\n\t\tif ip := net.ParseIP(vals[i]); ip == nil {\n\t\t\tt.Fatalf(\"invalid string being converted to IP address: %s\", vals[i])\n\t\t} else if !ip.Equal(v) {\n\t\t\tt.Fatalf(\"expected ips[%d] to be %s but got: %s\", i, vals[i], v)\n\t\t}\n\t}\n}\n\nfunc TestIPSCalledTwice(t *testing.T) {\n\tvar ips []net.IP\n\tf := setUpIPSFlagSet(&ips)\n\n\tin := []string{\"192.168.1.2,0:0:0:0:0:0:0:1\", \"10.0.0.1\"}\n\texpected := []net.IP{net.ParseIP(\"192.168.1.2\"), net.ParseIP(\"0:0:0:0:0:0:0:1\"), net.ParseIP(\"10.0.0.1\")}\n\targfmt := \"ips=%s\"\n\targ1 := fmt.Sprintf(argfmt, in[0])\n\targ2 := fmt.Sprintf(argfmt, in[1])\n\terr := f.Parse([]string{arg1, arg2})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range ips {\n\t\tif !expected[i].Equal(v) {\n\t\t\tt.Fatalf(\"expected ips[%d] to be %s but got: %s\", i, expected[i], v)\n\t\t}\n\t}\n}\n\nfunc TestIPSBadQuoting(t *testing.T) {\n\n\ttests := []struct {\n\t\tWant    []net.IP\n\t\tFlagArg []string\n\t}{\n\t\t{\n\t\t\tWant: []net.IP{\n\t\t\t\tnet.ParseIP(\"a4ab:61d:f03e:5d7d:fad7:d4c2:a1a5:568\"),\n\t\t\t\tnet.ParseIP(\"203.107.49.208\"),\n\t\t\t\tnet.ParseIP(\"14.57.204.90\"),\n\t\t\t},\n\t\t\tFlagArg: []string{\n\t\t\t\t\"a4ab:61d:f03e:5d7d:fad7:d4c2:a1a5:568\",\n\t\t\t\t\"203.107.49.208\",\n\t\t\t\t\"14.57.204.90\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tWant: []net.IP{\n\t\t\t\tnet.ParseIP(\"204.228.73.195\"),\n\t\t\t\tnet.ParseIP(\"86.141.15.94\"),\n\t\t\t},\n\t\t\tFlagArg: []string{\n\t\t\t\t\"204.228.73.195\",\n\t\t\t\t\"86.141.15.94\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tWant: []net.IP{\n\t\t\t\tnet.ParseIP(\"c70c:db36:3001:890f:c6ea:3f9b:7a39:cc3f\"),\n\t\t\t\tnet.ParseIP(\"4d17:1d6e:e699:bd7a:88c5:5e7e:ac6a:4472\"),\n\t\t\t},\n\t\t\tFlagArg: []string{\n\t\t\t\t\"c70c:db36:3001:890f:c6ea:3f9b:7a39:cc3f\",\n\t\t\t\t\"4d17:1d6e:e699:bd7a:88c5:5e7e:ac6a:4472\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tWant: []net.IP{\n\t\t\t\tnet.ParseIP(\"5170:f971:cfac:7be3:512a:af37:952c:bc33\"),\n\t\t\t\tnet.ParseIP(\"93.21.145.140\"),\n\t\t\t\tnet.ParseIP(\"2cac:61d3:c5ff:6caf:73e0:1b1a:c336:c1ca\"),\n\t\t\t},\n\t\t\tFlagArg: []string{\n\t\t\t\t\" 5170:f971:cfac:7be3:512a:af37:952c:bc33  , 93.21.145.140     \",\n\t\t\t\t\"2cac:61d3:c5ff:6caf:73e0:1b1a:c336:c1ca\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tWant: []net.IP{\n\t\t\t\tnet.ParseIP(\"2e5e:66b2:6441:848:5b74:76ea:574c:3a7b\"),\n\t\t\t\tnet.ParseIP(\"2e5e:66b2:6441:848:5b74:76ea:574c:3a7b\"),\n\t\t\t\tnet.ParseIP(\"2e5e:66b2:6441:848:5b74:76ea:574c:3a7b\"),\n\t\t\t\tnet.ParseIP(\"2e5e:66b2:6441:848:5b74:76ea:574c:3a7b\"),\n\t\t\t},\n\t\t\tFlagArg: []string{\n\t\t\t\t`\"2e5e:66b2:6441:848:5b74:76ea:574c:3a7b,        2e5e:66b2:6441:848:5b74:76ea:574c:3a7b,2e5e:66b2:6441:848:5b74:76ea:574c:3a7b     \"`,\n\t\t\t\t\" 2e5e:66b2:6441:848:5b74:76ea:574c:3a7b\"},\n\t\t},\n\t}\n\n\tfor i, test := range tests {\n\n\t\tvar ips []net.IP\n\t\tf := setUpIPSFlagSet(&ips)\n\n\t\tif err := f.Parse([]string{fmt.Sprintf(\"--ips=%s\", strings.Join(test.FlagArg, \",\"))}); err != nil {\n\t\t\tt.Fatalf(\"flag parsing failed with error: %s\\nparsing:\\t%#v\\nwant:\\t\\t%s\",\n\t\t\t\terr, test.FlagArg, test.Want[i])\n\t\t}\n\n\t\tfor j, b := range ips {\n\t\t\tif !b.Equal(test.Want[j]) {\n\t\t\t\tt.Fatalf(\"bad value parsed for test %d on net.IP %d:\\nwant:\\t%s\\ngot:\\t%s\", i, j, test.Want[j], b)\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/ip_test.go",
    "content": "package pflag\n\nimport (\n\t\"fmt\"\n\t\"net\"\n\t\"os\"\n\t\"testing\"\n)\n\nfunc setUpIP(ip *net.IP) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.IPVar(ip, \"address\", net.ParseIP(\"0.0.0.0\"), \"IP Address\")\n\treturn f\n}\n\nfunc TestIP(t *testing.T) {\n\ttestCases := []struct {\n\t\tinput    string\n\t\tsuccess  bool\n\t\texpected string\n\t}{\n\t\t{\"0.0.0.0\", true, \"0.0.0.0\"},\n\t\t{\" 0.0.0.0 \", true, \"0.0.0.0\"},\n\t\t{\"1.2.3.4\", true, \"1.2.3.4\"},\n\t\t{\"127.0.0.1\", true, \"127.0.0.1\"},\n\t\t{\"255.255.255.255\", true, \"255.255.255.255\"},\n\t\t{\"\", false, \"\"},\n\t\t{\"0\", false, \"\"},\n\t\t{\"localhost\", false, \"\"},\n\t\t{\"0.0.0\", false, \"\"},\n\t\t{\"0.0.0.\", false, \"\"},\n\t\t{\"0.0.0.0.\", false, \"\"},\n\t\t{\"0.0.0.256\", false, \"\"},\n\t\t{\"0 . 0 . 0 . 0\", false, \"\"},\n\t}\n\n\tdevnull, _ := os.Open(os.DevNull)\n\tos.Stderr = devnull\n\tfor i := range testCases {\n\t\tvar addr net.IP\n\t\tf := setUpIP(&addr)\n\n\t\ttc := &testCases[i]\n\n\t\targ := fmt.Sprintf(\"--address=%s\", tc.input)\n\t\terr := f.Parse([]string{arg})\n\t\tif err != nil && tc.success == true {\n\t\t\tt.Errorf(\"expected success, got %q\", err)\n\t\t\tcontinue\n\t\t} else if err == nil && tc.success == false {\n\t\t\tt.Errorf(\"expected failure\")\n\t\t\tcontinue\n\t\t} else if tc.success {\n\t\t\tip, err := f.GetIP(\"address\")\n\t\t\tif err != nil {\n\t\t\t\tt.Errorf(\"Got error trying to fetch the IP flag: %v\", err)\n\t\t\t}\n\t\t\tif ip.String() != tc.expected {\n\t\t\t\tt.Errorf(\"expected %q, got %q\", tc.expected, ip.String())\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/ipmask.go",
    "content": "package pflag\n\nimport (\n\t\"fmt\"\n\t\"net\"\n\t\"strconv\"\n)\n\n// -- net.IPMask value\ntype ipMaskValue net.IPMask\n\nfunc newIPMaskValue(val net.IPMask, p *net.IPMask) *ipMaskValue {\n\t*p = val\n\treturn (*ipMaskValue)(p)\n}\n\nfunc (i *ipMaskValue) String() string { return net.IPMask(*i).String() }\nfunc (i *ipMaskValue) Set(s string) error {\n\tip := ParseIPv4Mask(s)\n\tif ip == nil {\n\t\treturn fmt.Errorf(\"failed to parse IP mask: %q\", s)\n\t}\n\t*i = ipMaskValue(ip)\n\treturn nil\n}\n\nfunc (i *ipMaskValue) Type() string {\n\treturn \"ipMask\"\n}\n\n// ParseIPv4Mask written in IP form (e.g. 255.255.255.0).\n// This function should really belong to the net package.\nfunc ParseIPv4Mask(s string) net.IPMask {\n\tmask := net.ParseIP(s)\n\tif mask == nil {\n\t\tif len(s) != 8 {\n\t\t\treturn nil\n\t\t}\n\t\t// net.IPMask.String() actually outputs things like ffffff00\n\t\t// so write a horrible parser for that as well  :-(\n\t\tm := []int{}\n\t\tfor i := 0; i < 4; i++ {\n\t\t\tb := \"0x\" + s[2*i:2*i+2]\n\t\t\td, err := strconv.ParseInt(b, 0, 0)\n\t\t\tif err != nil {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tm = append(m, int(d))\n\t\t}\n\t\ts := fmt.Sprintf(\"%d.%d.%d.%d\", m[0], m[1], m[2], m[3])\n\t\tmask = net.ParseIP(s)\n\t\tif mask == nil {\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn net.IPv4Mask(mask[12], mask[13], mask[14], mask[15])\n}\n\nfunc parseIPv4Mask(sval string) (interface{}, error) {\n\tmask := ParseIPv4Mask(sval)\n\tif mask == nil {\n\t\treturn nil, fmt.Errorf(\"unable to parse %s as net.IPMask\", sval)\n\t}\n\treturn mask, nil\n}\n\n// GetIPv4Mask return the net.IPv4Mask value of a flag with the given name\nfunc (f *FlagSet) GetIPv4Mask(name string) (net.IPMask, error) {\n\tval, err := f.getFlagType(name, \"ipMask\", parseIPv4Mask)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn val.(net.IPMask), nil\n}\n\n// IPMaskVar defines an net.IPMask flag with specified name, default value, and usage string.\n// The argument p points to an net.IPMask variable in which to store the value of the flag.\nfunc (f *FlagSet) IPMaskVar(p *net.IPMask, name string, value net.IPMask, usage string) {\n\tf.VarP(newIPMaskValue(value, p), name, \"\", usage)\n}\n\n// IPMaskVarP is like IPMaskVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) IPMaskVarP(p *net.IPMask, name, shorthand string, value net.IPMask, usage string) {\n\tf.VarP(newIPMaskValue(value, p), name, shorthand, usage)\n}\n\n// IPMaskVar defines an net.IPMask flag with specified name, default value, and usage string.\n// The argument p points to an net.IPMask variable in which to store the value of the flag.\nfunc IPMaskVar(p *net.IPMask, name string, value net.IPMask, usage string) {\n\tCommandLine.VarP(newIPMaskValue(value, p), name, \"\", usage)\n}\n\n// IPMaskVarP is like IPMaskVar, but accepts a shorthand letter that can be used after a single dash.\nfunc IPMaskVarP(p *net.IPMask, name, shorthand string, value net.IPMask, usage string) {\n\tCommandLine.VarP(newIPMaskValue(value, p), name, shorthand, usage)\n}\n\n// IPMask defines an net.IPMask flag with specified name, default value, and usage string.\n// The return value is the address of an net.IPMask variable that stores the value of the flag.\nfunc (f *FlagSet) IPMask(name string, value net.IPMask, usage string) *net.IPMask {\n\tp := new(net.IPMask)\n\tf.IPMaskVarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// IPMaskP is like IPMask, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) IPMaskP(name, shorthand string, value net.IPMask, usage string) *net.IPMask {\n\tp := new(net.IPMask)\n\tf.IPMaskVarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// IPMask defines an net.IPMask flag with specified name, default value, and usage string.\n// The return value is the address of an net.IPMask variable that stores the value of the flag.\nfunc IPMask(name string, value net.IPMask, usage string) *net.IPMask {\n\treturn CommandLine.IPMaskP(name, \"\", value, usage)\n}\n\n// IPMaskP is like IP, but accepts a shorthand letter that can be used after a single dash.\nfunc IPMaskP(name, shorthand string, value net.IPMask, usage string) *net.IPMask {\n\treturn CommandLine.IPMaskP(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/ipnet.go",
    "content": "package pflag\n\nimport (\n\t\"fmt\"\n\t\"net\"\n\t\"strings\"\n)\n\n// IPNet adapts net.IPNet for use as a flag.\ntype ipNetValue net.IPNet\n\nfunc (ipnet ipNetValue) String() string {\n\tn := net.IPNet(ipnet)\n\treturn n.String()\n}\n\nfunc (ipnet *ipNetValue) Set(value string) error {\n\t_, n, err := net.ParseCIDR(strings.TrimSpace(value))\n\tif err != nil {\n\t\treturn err\n\t}\n\t*ipnet = ipNetValue(*n)\n\treturn nil\n}\n\nfunc (*ipNetValue) Type() string {\n\treturn \"ipNet\"\n}\n\nfunc newIPNetValue(val net.IPNet, p *net.IPNet) *ipNetValue {\n\t*p = val\n\treturn (*ipNetValue)(p)\n}\n\nfunc ipNetConv(sval string) (interface{}, error) {\n\t_, n, err := net.ParseCIDR(strings.TrimSpace(sval))\n\tif err == nil {\n\t\treturn *n, nil\n\t}\n\treturn nil, fmt.Errorf(\"invalid string being converted to IPNet: %s\", sval)\n}\n\n// GetIPNet return the net.IPNet value of a flag with the given name\nfunc (f *FlagSet) GetIPNet(name string) (net.IPNet, error) {\n\tval, err := f.getFlagType(name, \"ipNet\", ipNetConv)\n\tif err != nil {\n\t\treturn net.IPNet{}, err\n\t}\n\treturn val.(net.IPNet), nil\n}\n\n// IPNetVar defines an net.IPNet flag with specified name, default value, and usage string.\n// The argument p points to an net.IPNet variable in which to store the value of the flag.\nfunc (f *FlagSet) IPNetVar(p *net.IPNet, name string, value net.IPNet, usage string) {\n\tf.VarP(newIPNetValue(value, p), name, \"\", usage)\n}\n\n// IPNetVarP is like IPNetVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) IPNetVarP(p *net.IPNet, name, shorthand string, value net.IPNet, usage string) {\n\tf.VarP(newIPNetValue(value, p), name, shorthand, usage)\n}\n\n// IPNetVar defines an net.IPNet flag with specified name, default value, and usage string.\n// The argument p points to an net.IPNet variable in which to store the value of the flag.\nfunc IPNetVar(p *net.IPNet, name string, value net.IPNet, usage string) {\n\tCommandLine.VarP(newIPNetValue(value, p), name, \"\", usage)\n}\n\n// IPNetVarP is like IPNetVar, but accepts a shorthand letter that can be used after a single dash.\nfunc IPNetVarP(p *net.IPNet, name, shorthand string, value net.IPNet, usage string) {\n\tCommandLine.VarP(newIPNetValue(value, p), name, shorthand, usage)\n}\n\n// IPNet defines an net.IPNet flag with specified name, default value, and usage string.\n// The return value is the address of an net.IPNet variable that stores the value of the flag.\nfunc (f *FlagSet) IPNet(name string, value net.IPNet, usage string) *net.IPNet {\n\tp := new(net.IPNet)\n\tf.IPNetVarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// IPNetP is like IPNet, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) IPNetP(name, shorthand string, value net.IPNet, usage string) *net.IPNet {\n\tp := new(net.IPNet)\n\tf.IPNetVarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// IPNet defines an net.IPNet flag with specified name, default value, and usage string.\n// The return value is the address of an net.IPNet variable that stores the value of the flag.\nfunc IPNet(name string, value net.IPNet, usage string) *net.IPNet {\n\treturn CommandLine.IPNetP(name, \"\", value, usage)\n}\n\n// IPNetP is like IPNet, but accepts a shorthand letter that can be used after a single dash.\nfunc IPNetP(name, shorthand string, value net.IPNet, usage string) *net.IPNet {\n\treturn CommandLine.IPNetP(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/ipnet_test.go",
    "content": "package pflag\n\nimport (\n\t\"fmt\"\n\t\"net\"\n\t\"os\"\n\t\"testing\"\n)\n\nfunc setUpIPNet(ip *net.IPNet) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\t_, def, _ := net.ParseCIDR(\"0.0.0.0/0\")\n\tf.IPNetVar(ip, \"address\", *def, \"IP Address\")\n\treturn f\n}\n\nfunc TestIPNet(t *testing.T) {\n\ttestCases := []struct {\n\t\tinput    string\n\t\tsuccess  bool\n\t\texpected string\n\t}{\n\t\t{\"0.0.0.0/0\", true, \"0.0.0.0/0\"},\n\t\t{\" 0.0.0.0/0 \", true, \"0.0.0.0/0\"},\n\t\t{\"1.2.3.4/8\", true, \"1.0.0.0/8\"},\n\t\t{\"127.0.0.1/16\", true, \"127.0.0.0/16\"},\n\t\t{\"255.255.255.255/19\", true, \"255.255.224.0/19\"},\n\t\t{\"255.255.255.255/32\", true, \"255.255.255.255/32\"},\n\t\t{\"\", false, \"\"},\n\t\t{\"/0\", false, \"\"},\n\t\t{\"0\", false, \"\"},\n\t\t{\"0/0\", false, \"\"},\n\t\t{\"localhost/0\", false, \"\"},\n\t\t{\"0.0.0/4\", false, \"\"},\n\t\t{\"0.0.0./8\", false, \"\"},\n\t\t{\"0.0.0.0./12\", false, \"\"},\n\t\t{\"0.0.0.256/16\", false, \"\"},\n\t\t{\"0.0.0.0 /20\", false, \"\"},\n\t\t{\"0.0.0.0/ 24\", false, \"\"},\n\t\t{\"0 . 0 . 0 . 0 / 28\", false, \"\"},\n\t\t{\"0.0.0.0/33\", false, \"\"},\n\t}\n\n\tdevnull, _ := os.Open(os.DevNull)\n\tos.Stderr = devnull\n\tfor i := range testCases {\n\t\tvar addr net.IPNet\n\t\tf := setUpIPNet(&addr)\n\n\t\ttc := &testCases[i]\n\n\t\targ := fmt.Sprintf(\"--address=%s\", tc.input)\n\t\terr := f.Parse([]string{arg})\n\t\tif err != nil && tc.success == true {\n\t\t\tt.Errorf(\"expected success, got %q\", err)\n\t\t\tcontinue\n\t\t} else if err == nil && tc.success == false {\n\t\t\tt.Errorf(\"expected failure\")\n\t\t\tcontinue\n\t\t} else if tc.success {\n\t\t\tip, err := f.GetIPNet(\"address\")\n\t\t\tif err != nil {\n\t\t\t\tt.Errorf(\"Got error trying to fetch the IP flag: %v\", err)\n\t\t\t}\n\t\t\tif ip.String() != tc.expected {\n\t\t\t\tt.Errorf(\"expected %q, got %q\", tc.expected, ip.String())\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/string.go",
    "content": "package pflag\n\n// -- string Value\ntype stringValue string\n\nfunc newStringValue(val string, p *string) *stringValue {\n\t*p = val\n\treturn (*stringValue)(p)\n}\n\nfunc (s *stringValue) Set(val string) error {\n\t*s = stringValue(val)\n\treturn nil\n}\nfunc (s *stringValue) Type() string {\n\treturn \"string\"\n}\n\nfunc (s *stringValue) String() string { return string(*s) }\n\nfunc stringConv(sval string) (interface{}, error) {\n\treturn sval, nil\n}\n\n// GetString return the string value of a flag with the given name\nfunc (f *FlagSet) GetString(name string) (string, error) {\n\tval, err := f.getFlagType(name, \"string\", stringConv)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn val.(string), nil\n}\n\n// StringVar defines a string flag with specified name, default value, and usage string.\n// The argument p points to a string variable in which to store the value of the flag.\nfunc (f *FlagSet) StringVar(p *string, name string, value string, usage string) {\n\tf.VarP(newStringValue(value, p), name, \"\", usage)\n}\n\n// StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) StringVarP(p *string, name, shorthand string, value string, usage string) {\n\tf.VarP(newStringValue(value, p), name, shorthand, usage)\n}\n\n// StringVar defines a string flag with specified name, default value, and usage string.\n// The argument p points to a string variable in which to store the value of the flag.\nfunc StringVar(p *string, name string, value string, usage string) {\n\tCommandLine.VarP(newStringValue(value, p), name, \"\", usage)\n}\n\n// StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash.\nfunc StringVarP(p *string, name, shorthand string, value string, usage string) {\n\tCommandLine.VarP(newStringValue(value, p), name, shorthand, usage)\n}\n\n// String defines a string flag with specified name, default value, and usage string.\n// The return value is the address of a string variable that stores the value of the flag.\nfunc (f *FlagSet) String(name string, value string, usage string) *string {\n\tp := new(string)\n\tf.StringVarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// StringP is like String, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) StringP(name, shorthand string, value string, usage string) *string {\n\tp := new(string)\n\tf.StringVarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// String defines a string flag with specified name, default value, and usage string.\n// The return value is the address of a string variable that stores the value of the flag.\nfunc String(name string, value string, usage string) *string {\n\treturn CommandLine.StringP(name, \"\", value, usage)\n}\n\n// StringP is like String, but accepts a shorthand letter that can be used after a single dash.\nfunc StringP(name, shorthand string, value string, usage string) *string {\n\treturn CommandLine.StringP(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/string_array.go",
    "content": "package pflag\n\n// -- stringArray Value\ntype stringArrayValue struct {\n\tvalue   *[]string\n\tchanged bool\n}\n\nfunc newStringArrayValue(val []string, p *[]string) *stringArrayValue {\n\tssv := new(stringArrayValue)\n\tssv.value = p\n\t*ssv.value = val\n\treturn ssv\n}\n\nfunc (s *stringArrayValue) Set(val string) error {\n\tif !s.changed {\n\t\t*s.value = []string{val}\n\t\ts.changed = true\n\t} else {\n\t\t*s.value = append(*s.value, val)\n\t}\n\treturn nil\n}\n\nfunc (s *stringArrayValue) Type() string {\n\treturn \"stringArray\"\n}\n\nfunc (s *stringArrayValue) String() string {\n\tstr, _ := writeAsCSV(*s.value)\n\treturn \"[\" + str + \"]\"\n}\n\nfunc stringArrayConv(sval string) (interface{}, error) {\n\tsval = sval[1 : len(sval)-1]\n\t// An empty string would cause a array with one (empty) string\n\tif len(sval) == 0 {\n\t\treturn []string{}, nil\n\t}\n\treturn readAsCSV(sval)\n}\n\n// GetStringArray return the []string value of a flag with the given name\nfunc (f *FlagSet) GetStringArray(name string) ([]string, error) {\n\tval, err := f.getFlagType(name, \"stringArray\", stringArrayConv)\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\treturn val.([]string), nil\n}\n\n// StringArrayVar defines a string flag with specified name, default value, and usage string.\n// The argument p points to a []string variable in which to store the values of the multiple flags.\n// The value of each argument will not try to be separated by comma\nfunc (f *FlagSet) StringArrayVar(p *[]string, name string, value []string, usage string) {\n\tf.VarP(newStringArrayValue(value, p), name, \"\", usage)\n}\n\n// StringArrayVarP is like StringArrayVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) StringArrayVarP(p *[]string, name, shorthand string, value []string, usage string) {\n\tf.VarP(newStringArrayValue(value, p), name, shorthand, usage)\n}\n\n// StringArrayVar defines a string flag with specified name, default value, and usage string.\n// The argument p points to a []string variable in which to store the value of the flag.\n// The value of each argument will not try to be separated by comma\nfunc StringArrayVar(p *[]string, name string, value []string, usage string) {\n\tCommandLine.VarP(newStringArrayValue(value, p), name, \"\", usage)\n}\n\n// StringArrayVarP is like StringArrayVar, but accepts a shorthand letter that can be used after a single dash.\nfunc StringArrayVarP(p *[]string, name, shorthand string, value []string, usage string) {\n\tCommandLine.VarP(newStringArrayValue(value, p), name, shorthand, usage)\n}\n\n// StringArray defines a string flag with specified name, default value, and usage string.\n// The return value is the address of a []string variable that stores the value of the flag.\n// The value of each argument will not try to be separated by comma\nfunc (f *FlagSet) StringArray(name string, value []string, usage string) *[]string {\n\tp := []string{}\n\tf.StringArrayVarP(&p, name, \"\", value, usage)\n\treturn &p\n}\n\n// StringArrayP is like StringArray, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) StringArrayP(name, shorthand string, value []string, usage string) *[]string {\n\tp := []string{}\n\tf.StringArrayVarP(&p, name, shorthand, value, usage)\n\treturn &p\n}\n\n// StringArray defines a string flag with specified name, default value, and usage string.\n// The return value is the address of a []string variable that stores the value of the flag.\n// The value of each argument will not try to be separated by comma\nfunc StringArray(name string, value []string, usage string) *[]string {\n\treturn CommandLine.StringArrayP(name, \"\", value, usage)\n}\n\n// StringArrayP is like StringArray, but accepts a shorthand letter that can be used after a single dash.\nfunc StringArrayP(name, shorthand string, value []string, usage string) *[]string {\n\treturn CommandLine.StringArrayP(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/string_array_test.go",
    "content": "// Copyright 2009 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 pflag\n\nimport (\n\t\"fmt\"\n\t\"testing\"\n)\n\nfunc setUpSAFlagSet(sap *[]string) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.StringArrayVar(sap, \"sa\", []string{}, \"Command separated list!\")\n\treturn f\n}\n\nfunc setUpSAFlagSetWithDefault(sap *[]string) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.StringArrayVar(sap, \"sa\", []string{\"default\", \"values\"}, \"Command separated list!\")\n\treturn f\n}\n\nfunc TestEmptySA(t *testing.T) {\n\tvar sa []string\n\tf := setUpSAFlagSet(&sa)\n\terr := f.Parse([]string{})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tgetSA, err := f.GetStringArray(\"sa\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetStringArray():\", err)\n\t}\n\tif len(getSA) != 0 {\n\t\tt.Fatalf(\"got sa %v with len=%d but expected length=0\", getSA, len(getSA))\n\t}\n}\n\nfunc TestEmptySAValue(t *testing.T) {\n\tvar sa []string\n\tf := setUpSAFlagSet(&sa)\n\terr := f.Parse([]string{\"--sa=\"})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tgetSA, err := f.GetStringArray(\"sa\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetStringArray():\", err)\n\t}\n\tif len(getSA) != 0 {\n\t\tt.Fatalf(\"got sa %v with len=%d but expected length=0\", getSA, len(getSA))\n\t}\n}\n\nfunc TestSADefault(t *testing.T) {\n\tvar sa []string\n\tf := setUpSAFlagSetWithDefault(&sa)\n\n\tvals := []string{\"default\", \"values\"}\n\n\terr := f.Parse([]string{})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range sa {\n\t\tif vals[i] != v {\n\t\t\tt.Fatalf(\"expected sa[%d] to be %s but got: %s\", i, vals[i], v)\n\t\t}\n\t}\n\n\tgetSA, err := f.GetStringArray(\"sa\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetStringArray():\", err)\n\t}\n\tfor i, v := range getSA {\n\t\tif vals[i] != v {\n\t\t\tt.Fatalf(\"expected sa[%d] to be %s from GetStringArray but got: %s\", i, vals[i], v)\n\t\t}\n\t}\n}\n\nfunc TestSAWithDefault(t *testing.T) {\n\tvar sa []string\n\tf := setUpSAFlagSetWithDefault(&sa)\n\n\tval := \"one\"\n\targ := fmt.Sprintf(\"--sa=%s\", val)\n\terr := f.Parse([]string{arg})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tif len(sa) != 1 {\n\t\tt.Fatalf(\"expected number of values to be %d but %d\", 1, len(sa))\n\t}\n\n\tif sa[0] != val {\n\t\tt.Fatalf(\"expected value to be %s but got: %s\", sa[0], val)\n\t}\n\n\tgetSA, err := f.GetStringArray(\"sa\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetStringArray():\", err)\n\t}\n\n\tif len(getSA) != 1 {\n\t\tt.Fatalf(\"expected number of values to be %d but %d\", 1, len(getSA))\n\t}\n\n\tif getSA[0] != val {\n\t\tt.Fatalf(\"expected value to be %s but got: %s\", getSA[0], val)\n\t}\n}\n\nfunc TestSACalledTwice(t *testing.T) {\n\tvar sa []string\n\tf := setUpSAFlagSet(&sa)\n\n\tin := []string{\"one\", \"two\"}\n\texpected := []string{\"one\", \"two\"}\n\targfmt := \"--sa=%s\"\n\targ1 := fmt.Sprintf(argfmt, in[0])\n\targ2 := fmt.Sprintf(argfmt, in[1])\n\terr := f.Parse([]string{arg1, arg2})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tif len(expected) != len(sa) {\n\t\tt.Fatalf(\"expected number of sa to be %d but got: %d\", len(expected), len(sa))\n\t}\n\tfor i, v := range sa {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected sa[%d] to be %s but got: %s\", i, expected[i], v)\n\t\t}\n\t}\n\n\tvalues, err := f.GetStringArray(\"sa\")\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tif len(expected) != len(values) {\n\t\tt.Fatalf(\"expected number of values to be %d but got: %d\", len(expected), len(sa))\n\t}\n\tfor i, v := range values {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected got sa[%d] to be %s but got: %s\", i, expected[i], v)\n\t\t}\n\t}\n}\n\nfunc TestSAWithSpecialChar(t *testing.T) {\n\tvar sa []string\n\tf := setUpSAFlagSet(&sa)\n\n\tin := []string{\"one,two\", `\"three\"`, `\"four,five\",six`, \"seven eight\"}\n\texpected := []string{\"one,two\", `\"three\"`, `\"four,five\",six`, \"seven eight\"}\n\targfmt := \"--sa=%s\"\n\targ1 := fmt.Sprintf(argfmt, in[0])\n\targ2 := fmt.Sprintf(argfmt, in[1])\n\targ3 := fmt.Sprintf(argfmt, in[2])\n\targ4 := fmt.Sprintf(argfmt, in[3])\n\terr := f.Parse([]string{arg1, arg2, arg3, arg4})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tif len(expected) != len(sa) {\n\t\tt.Fatalf(\"expected number of sa to be %d but got: %d\", len(expected), len(sa))\n\t}\n\tfor i, v := range sa {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected sa[%d] to be %s but got: %s\", i, expected[i], v)\n\t\t}\n\t}\n\n\tvalues, err := f.GetStringArray(\"sa\")\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tif len(expected) != len(values) {\n\t\tt.Fatalf(\"expected number of values to be %d but got: %d\", len(expected), len(values))\n\t}\n\tfor i, v := range values {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected got sa[%d] to be %s but got: %s\", i, expected[i], v)\n\t\t}\n\t}\n}\n\nfunc TestSAWithSquareBrackets(t *testing.T) {\n\tvar sa []string\n\tf := setUpSAFlagSet(&sa)\n\n\tin := []string{\"][]-[\", \"[a-z]\", \"[a-z]+\"}\n\texpected := []string{\"][]-[\", \"[a-z]\", \"[a-z]+\"}\n\targfmt := \"--sa=%s\"\n\targ1 := fmt.Sprintf(argfmt, in[0])\n\targ2 := fmt.Sprintf(argfmt, in[1])\n\targ3 := fmt.Sprintf(argfmt, in[2])\n\terr := f.Parse([]string{arg1, arg2, arg3})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tif len(expected) != len(sa) {\n\t\tt.Fatalf(\"expected number of sa to be %d but got: %d\", len(expected), len(sa))\n\t}\n\tfor i, v := range sa {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected sa[%d] to be %s but got: %s\", i, expected[i], v)\n\t\t}\n\t}\n\n\tvalues, err := f.GetStringArray(\"sa\")\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tif len(expected) != len(values) {\n\t\tt.Fatalf(\"expected number of values to be %d but got: %d\", len(expected), len(values))\n\t}\n\tfor i, v := range values {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected got sa[%d] to be %s but got: %s\", i, expected[i], v)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/string_slice.go",
    "content": "package pflag\n\nimport (\n\t\"bytes\"\n\t\"encoding/csv\"\n\t\"strings\"\n)\n\n// -- stringSlice Value\ntype stringSliceValue struct {\n\tvalue   *[]string\n\tchanged bool\n}\n\nfunc newStringSliceValue(val []string, p *[]string) *stringSliceValue {\n\tssv := new(stringSliceValue)\n\tssv.value = p\n\t*ssv.value = val\n\treturn ssv\n}\n\nfunc readAsCSV(val string) ([]string, error) {\n\tif val == \"\" {\n\t\treturn []string{}, nil\n\t}\n\tstringReader := strings.NewReader(val)\n\tcsvReader := csv.NewReader(stringReader)\n\treturn csvReader.Read()\n}\n\nfunc writeAsCSV(vals []string) (string, error) {\n\tb := &bytes.Buffer{}\n\tw := csv.NewWriter(b)\n\terr := w.Write(vals)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tw.Flush()\n\treturn strings.TrimSuffix(b.String(), \"\\n\"), nil\n}\n\nfunc (s *stringSliceValue) Set(val string) error {\n\tv, err := readAsCSV(val)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !s.changed {\n\t\t*s.value = v\n\t} else {\n\t\t*s.value = append(*s.value, v...)\n\t}\n\ts.changed = true\n\treturn nil\n}\n\nfunc (s *stringSliceValue) Type() string {\n\treturn \"stringSlice\"\n}\n\nfunc (s *stringSliceValue) String() string {\n\tstr, _ := writeAsCSV(*s.value)\n\treturn \"[\" + str + \"]\"\n}\n\nfunc stringSliceConv(sval string) (interface{}, error) {\n\tsval = sval[1 : len(sval)-1]\n\t// An empty string would cause a slice with one (empty) string\n\tif len(sval) == 0 {\n\t\treturn []string{}, nil\n\t}\n\treturn readAsCSV(sval)\n}\n\n// GetStringSlice return the []string value of a flag with the given name\nfunc (f *FlagSet) GetStringSlice(name string) ([]string, error) {\n\tval, err := f.getFlagType(name, \"stringSlice\", stringSliceConv)\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\treturn val.([]string), nil\n}\n\n// StringSliceVar defines a string flag with specified name, default value, and usage string.\n// The argument p points to a []string variable in which to store the value of the flag.\nfunc (f *FlagSet) StringSliceVar(p *[]string, name string, value []string, usage string) {\n\tf.VarP(newStringSliceValue(value, p), name, \"\", usage)\n}\n\n// StringSliceVarP is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) StringSliceVarP(p *[]string, name, shorthand string, value []string, usage string) {\n\tf.VarP(newStringSliceValue(value, p), name, shorthand, usage)\n}\n\n// StringSliceVar defines a string flag with specified name, default value, and usage string.\n// The argument p points to a []string variable in which to store the value of the flag.\nfunc StringSliceVar(p *[]string, name string, value []string, usage string) {\n\tCommandLine.VarP(newStringSliceValue(value, p), name, \"\", usage)\n}\n\n// StringSliceVarP is like StringSliceVar, but accepts a shorthand letter that can be used after a single dash.\nfunc StringSliceVarP(p *[]string, name, shorthand string, value []string, usage string) {\n\tCommandLine.VarP(newStringSliceValue(value, p), name, shorthand, usage)\n}\n\n// StringSlice defines a string flag with specified name, default value, and usage string.\n// The return value is the address of a []string variable that stores the value of the flag.\nfunc (f *FlagSet) StringSlice(name string, value []string, usage string) *[]string {\n\tp := []string{}\n\tf.StringSliceVarP(&p, name, \"\", value, usage)\n\treturn &p\n}\n\n// StringSliceP is like StringSlice, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) StringSliceP(name, shorthand string, value []string, usage string) *[]string {\n\tp := []string{}\n\tf.StringSliceVarP(&p, name, shorthand, value, usage)\n\treturn &p\n}\n\n// StringSlice defines a string flag with specified name, default value, and usage string.\n// The return value is the address of a []string variable that stores the value of the flag.\nfunc StringSlice(name string, value []string, usage string) *[]string {\n\treturn CommandLine.StringSliceP(name, \"\", value, usage)\n}\n\n// StringSliceP is like StringSlice, but accepts a shorthand letter that can be used after a single dash.\nfunc StringSliceP(name, shorthand string, value []string, usage string) *[]string {\n\treturn CommandLine.StringSliceP(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/string_slice_test.go",
    "content": "// Copyright 2009 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 pflag\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc setUpSSFlagSet(ssp *[]string) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.StringSliceVar(ssp, \"ss\", []string{}, \"Command separated list!\")\n\treturn f\n}\n\nfunc setUpSSFlagSetWithDefault(ssp *[]string) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.StringSliceVar(ssp, \"ss\", []string{\"default\", \"values\"}, \"Command separated list!\")\n\treturn f\n}\n\nfunc TestEmptySS(t *testing.T) {\n\tvar ss []string\n\tf := setUpSSFlagSet(&ss)\n\terr := f.Parse([]string{})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tgetSS, err := f.GetStringSlice(\"ss\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetStringSlice():\", err)\n\t}\n\tif len(getSS) != 0 {\n\t\tt.Fatalf(\"got ss %v with len=%d but expected length=0\", getSS, len(getSS))\n\t}\n}\n\nfunc TestEmptySSValue(t *testing.T) {\n\tvar ss []string\n\tf := setUpSSFlagSet(&ss)\n\terr := f.Parse([]string{\"--ss=\"})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tgetSS, err := f.GetStringSlice(\"ss\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetStringSlice():\", err)\n\t}\n\tif len(getSS) != 0 {\n\t\tt.Fatalf(\"got ss %v with len=%d but expected length=0\", getSS, len(getSS))\n\t}\n}\n\nfunc TestSS(t *testing.T) {\n\tvar ss []string\n\tf := setUpSSFlagSet(&ss)\n\n\tvals := []string{\"one\", \"two\", \"4\", \"3\"}\n\targ := fmt.Sprintf(\"--ss=%s\", strings.Join(vals, \",\"))\n\terr := f.Parse([]string{arg})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range ss {\n\t\tif vals[i] != v {\n\t\t\tt.Fatalf(\"expected ss[%d] to be %s but got: %s\", i, vals[i], v)\n\t\t}\n\t}\n\n\tgetSS, err := f.GetStringSlice(\"ss\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetStringSlice():\", err)\n\t}\n\tfor i, v := range getSS {\n\t\tif vals[i] != v {\n\t\t\tt.Fatalf(\"expected ss[%d] to be %s from GetStringSlice but got: %s\", i, vals[i], v)\n\t\t}\n\t}\n}\n\nfunc TestSSDefault(t *testing.T) {\n\tvar ss []string\n\tf := setUpSSFlagSetWithDefault(&ss)\n\n\tvals := []string{\"default\", \"values\"}\n\n\terr := f.Parse([]string{})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range ss {\n\t\tif vals[i] != v {\n\t\t\tt.Fatalf(\"expected ss[%d] to be %s but got: %s\", i, vals[i], v)\n\t\t}\n\t}\n\n\tgetSS, err := f.GetStringSlice(\"ss\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetStringSlice():\", err)\n\t}\n\tfor i, v := range getSS {\n\t\tif vals[i] != v {\n\t\t\tt.Fatalf(\"expected ss[%d] to be %s from GetStringSlice but got: %s\", i, vals[i], v)\n\t\t}\n\t}\n}\n\nfunc TestSSWithDefault(t *testing.T) {\n\tvar ss []string\n\tf := setUpSSFlagSetWithDefault(&ss)\n\n\tvals := []string{\"one\", \"two\", \"4\", \"3\"}\n\targ := fmt.Sprintf(\"--ss=%s\", strings.Join(vals, \",\"))\n\terr := f.Parse([]string{arg})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range ss {\n\t\tif vals[i] != v {\n\t\t\tt.Fatalf(\"expected ss[%d] to be %s but got: %s\", i, vals[i], v)\n\t\t}\n\t}\n\n\tgetSS, err := f.GetStringSlice(\"ss\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetStringSlice():\", err)\n\t}\n\tfor i, v := range getSS {\n\t\tif vals[i] != v {\n\t\t\tt.Fatalf(\"expected ss[%d] to be %s from GetStringSlice but got: %s\", i, vals[i], v)\n\t\t}\n\t}\n}\n\nfunc TestSSCalledTwice(t *testing.T) {\n\tvar ss []string\n\tf := setUpSSFlagSet(&ss)\n\n\tin := []string{\"one,two\", \"three\"}\n\texpected := []string{\"one\", \"two\", \"three\"}\n\targfmt := \"--ss=%s\"\n\targ1 := fmt.Sprintf(argfmt, in[0])\n\targ2 := fmt.Sprintf(argfmt, in[1])\n\terr := f.Parse([]string{arg1, arg2})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tif len(expected) != len(ss) {\n\t\tt.Fatalf(\"expected number of ss to be %d but got: %d\", len(expected), len(ss))\n\t}\n\tfor i, v := range ss {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected ss[%d] to be %s but got: %s\", i, expected[i], v)\n\t\t}\n\t}\n\n\tvalues, err := f.GetStringSlice(\"ss\")\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tif len(expected) != len(values) {\n\t\tt.Fatalf(\"expected number of values to be %d but got: %d\", len(expected), len(ss))\n\t}\n\tfor i, v := range values {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected got ss[%d] to be %s but got: %s\", i, expected[i], v)\n\t\t}\n\t}\n}\n\nfunc TestSSWithComma(t *testing.T) {\n\tvar ss []string\n\tf := setUpSSFlagSet(&ss)\n\n\tin := []string{`\"one,two\"`, `\"three\"`, `\"four,five\",six`}\n\texpected := []string{\"one,two\", \"three\", \"four,five\", \"six\"}\n\targfmt := \"--ss=%s\"\n\targ1 := fmt.Sprintf(argfmt, in[0])\n\targ2 := fmt.Sprintf(argfmt, in[1])\n\targ3 := fmt.Sprintf(argfmt, in[2])\n\terr := f.Parse([]string{arg1, arg2, arg3})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tif len(expected) != len(ss) {\n\t\tt.Fatalf(\"expected number of ss to be %d but got: %d\", len(expected), len(ss))\n\t}\n\tfor i, v := range ss {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected ss[%d] to be %s but got: %s\", i, expected[i], v)\n\t\t}\n\t}\n\n\tvalues, err := f.GetStringSlice(\"ss\")\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tif len(expected) != len(values) {\n\t\tt.Fatalf(\"expected number of values to be %d but got: %d\", len(expected), len(values))\n\t}\n\tfor i, v := range values {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected got ss[%d] to be %s but got: %s\", i, expected[i], v)\n\t\t}\n\t}\n}\n\nfunc TestSSWithSquareBrackets(t *testing.T) {\n\tvar ss []string\n\tf := setUpSSFlagSet(&ss)\n\n\tin := []string{`\"[a-z]\"`, `\"[a-z]+\"`}\n\texpected := []string{\"[a-z]\", \"[a-z]+\"}\n\targfmt := \"--ss=%s\"\n\targ1 := fmt.Sprintf(argfmt, in[0])\n\targ2 := fmt.Sprintf(argfmt, in[1])\n\terr := f.Parse([]string{arg1, arg2})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tif len(expected) != len(ss) {\n\t\tt.Fatalf(\"expected number of ss to be %d but got: %d\", len(expected), len(ss))\n\t}\n\tfor i, v := range ss {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected ss[%d] to be %s but got: %s\", i, expected[i], v)\n\t\t}\n\t}\n\n\tvalues, err := f.GetStringSlice(\"ss\")\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tif len(expected) != len(values) {\n\t\tt.Fatalf(\"expected number of values to be %d but got: %d\", len(expected), len(values))\n\t}\n\tfor i, v := range values {\n\t\tif expected[i] != v {\n\t\t\tt.Fatalf(\"expected got ss[%d] to be %s but got: %s\", i, expected[i], v)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/uint.go",
    "content": "package pflag\n\nimport \"strconv\"\n\n// -- uint Value\ntype uintValue uint\n\nfunc newUintValue(val uint, p *uint) *uintValue {\n\t*p = val\n\treturn (*uintValue)(p)\n}\n\nfunc (i *uintValue) Set(s string) error {\n\tv, err := strconv.ParseUint(s, 0, 64)\n\t*i = uintValue(v)\n\treturn err\n}\n\nfunc (i *uintValue) Type() string {\n\treturn \"uint\"\n}\n\nfunc (i *uintValue) String() string { return strconv.FormatUint(uint64(*i), 10) }\n\nfunc uintConv(sval string) (interface{}, error) {\n\tv, err := strconv.ParseUint(sval, 0, 0)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn uint(v), nil\n}\n\n// GetUint return the uint value of a flag with the given name\nfunc (f *FlagSet) GetUint(name string) (uint, error) {\n\tval, err := f.getFlagType(name, \"uint\", uintConv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn val.(uint), nil\n}\n\n// UintVar defines a uint flag with specified name, default value, and usage string.\n// The argument p points to a uint variable in which to store the value of the flag.\nfunc (f *FlagSet) UintVar(p *uint, name string, value uint, usage string) {\n\tf.VarP(newUintValue(value, p), name, \"\", usage)\n}\n\n// UintVarP is like UintVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) UintVarP(p *uint, name, shorthand string, value uint, usage string) {\n\tf.VarP(newUintValue(value, p), name, shorthand, usage)\n}\n\n// UintVar defines a uint flag with specified name, default value, and usage string.\n// The argument p points to a uint  variable in which to store the value of the flag.\nfunc UintVar(p *uint, name string, value uint, usage string) {\n\tCommandLine.VarP(newUintValue(value, p), name, \"\", usage)\n}\n\n// UintVarP is like UintVar, but accepts a shorthand letter that can be used after a single dash.\nfunc UintVarP(p *uint, name, shorthand string, value uint, usage string) {\n\tCommandLine.VarP(newUintValue(value, p), name, shorthand, usage)\n}\n\n// Uint defines a uint flag with specified name, default value, and usage string.\n// The return value is the address of a uint  variable that stores the value of the flag.\nfunc (f *FlagSet) Uint(name string, value uint, usage string) *uint {\n\tp := new(uint)\n\tf.UintVarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// UintP is like Uint, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) UintP(name, shorthand string, value uint, usage string) *uint {\n\tp := new(uint)\n\tf.UintVarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// Uint defines a uint flag with specified name, default value, and usage string.\n// The return value is the address of a uint  variable that stores the value of the flag.\nfunc Uint(name string, value uint, usage string) *uint {\n\treturn CommandLine.UintP(name, \"\", value, usage)\n}\n\n// UintP is like Uint, but accepts a shorthand letter that can be used after a single dash.\nfunc UintP(name, shorthand string, value uint, usage string) *uint {\n\treturn CommandLine.UintP(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/uint16.go",
    "content": "package pflag\n\nimport \"strconv\"\n\n// -- uint16 value\ntype uint16Value uint16\n\nfunc newUint16Value(val uint16, p *uint16) *uint16Value {\n\t*p = val\n\treturn (*uint16Value)(p)\n}\n\nfunc (i *uint16Value) Set(s string) error {\n\tv, err := strconv.ParseUint(s, 0, 16)\n\t*i = uint16Value(v)\n\treturn err\n}\n\nfunc (i *uint16Value) Type() string {\n\treturn \"uint16\"\n}\n\nfunc (i *uint16Value) String() string { return strconv.FormatUint(uint64(*i), 10) }\n\nfunc uint16Conv(sval string) (interface{}, error) {\n\tv, err := strconv.ParseUint(sval, 0, 16)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn uint16(v), nil\n}\n\n// GetUint16 return the uint16 value of a flag with the given name\nfunc (f *FlagSet) GetUint16(name string) (uint16, error) {\n\tval, err := f.getFlagType(name, \"uint16\", uint16Conv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn val.(uint16), nil\n}\n\n// Uint16Var defines a uint flag with specified name, default value, and usage string.\n// The argument p points to a uint variable in which to store the value of the flag.\nfunc (f *FlagSet) Uint16Var(p *uint16, name string, value uint16, usage string) {\n\tf.VarP(newUint16Value(value, p), name, \"\", usage)\n}\n\n// Uint16VarP is like Uint16Var, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Uint16VarP(p *uint16, name, shorthand string, value uint16, usage string) {\n\tf.VarP(newUint16Value(value, p), name, shorthand, usage)\n}\n\n// Uint16Var defines a uint flag with specified name, default value, and usage string.\n// The argument p points to a uint  variable in which to store the value of the flag.\nfunc Uint16Var(p *uint16, name string, value uint16, usage string) {\n\tCommandLine.VarP(newUint16Value(value, p), name, \"\", usage)\n}\n\n// Uint16VarP is like Uint16Var, but accepts a shorthand letter that can be used after a single dash.\nfunc Uint16VarP(p *uint16, name, shorthand string, value uint16, usage string) {\n\tCommandLine.VarP(newUint16Value(value, p), name, shorthand, usage)\n}\n\n// Uint16 defines a uint flag with specified name, default value, and usage string.\n// The return value is the address of a uint  variable that stores the value of the flag.\nfunc (f *FlagSet) Uint16(name string, value uint16, usage string) *uint16 {\n\tp := new(uint16)\n\tf.Uint16VarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// Uint16P is like Uint16, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Uint16P(name, shorthand string, value uint16, usage string) *uint16 {\n\tp := new(uint16)\n\tf.Uint16VarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// Uint16 defines a uint flag with specified name, default value, and usage string.\n// The return value is the address of a uint  variable that stores the value of the flag.\nfunc Uint16(name string, value uint16, usage string) *uint16 {\n\treturn CommandLine.Uint16P(name, \"\", value, usage)\n}\n\n// Uint16P is like Uint16, but accepts a shorthand letter that can be used after a single dash.\nfunc Uint16P(name, shorthand string, value uint16, usage string) *uint16 {\n\treturn CommandLine.Uint16P(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/uint32.go",
    "content": "package pflag\n\nimport \"strconv\"\n\n// -- uint32 value\ntype uint32Value uint32\n\nfunc newUint32Value(val uint32, p *uint32) *uint32Value {\n\t*p = val\n\treturn (*uint32Value)(p)\n}\n\nfunc (i *uint32Value) Set(s string) error {\n\tv, err := strconv.ParseUint(s, 0, 32)\n\t*i = uint32Value(v)\n\treturn err\n}\n\nfunc (i *uint32Value) Type() string {\n\treturn \"uint32\"\n}\n\nfunc (i *uint32Value) String() string { return strconv.FormatUint(uint64(*i), 10) }\n\nfunc uint32Conv(sval string) (interface{}, error) {\n\tv, err := strconv.ParseUint(sval, 0, 32)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn uint32(v), nil\n}\n\n// GetUint32 return the uint32 value of a flag with the given name\nfunc (f *FlagSet) GetUint32(name string) (uint32, error) {\n\tval, err := f.getFlagType(name, \"uint32\", uint32Conv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn val.(uint32), nil\n}\n\n// Uint32Var defines a uint32 flag with specified name, default value, and usage string.\n// The argument p points to a uint32 variable in which to store the value of the flag.\nfunc (f *FlagSet) Uint32Var(p *uint32, name string, value uint32, usage string) {\n\tf.VarP(newUint32Value(value, p), name, \"\", usage)\n}\n\n// Uint32VarP is like Uint32Var, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Uint32VarP(p *uint32, name, shorthand string, value uint32, usage string) {\n\tf.VarP(newUint32Value(value, p), name, shorthand, usage)\n}\n\n// Uint32Var defines a uint32 flag with specified name, default value, and usage string.\n// The argument p points to a uint32  variable in which to store the value of the flag.\nfunc Uint32Var(p *uint32, name string, value uint32, usage string) {\n\tCommandLine.VarP(newUint32Value(value, p), name, \"\", usage)\n}\n\n// Uint32VarP is like Uint32Var, but accepts a shorthand letter that can be used after a single dash.\nfunc Uint32VarP(p *uint32, name, shorthand string, value uint32, usage string) {\n\tCommandLine.VarP(newUint32Value(value, p), name, shorthand, usage)\n}\n\n// Uint32 defines a uint32 flag with specified name, default value, and usage string.\n// The return value is the address of a uint32  variable that stores the value of the flag.\nfunc (f *FlagSet) Uint32(name string, value uint32, usage string) *uint32 {\n\tp := new(uint32)\n\tf.Uint32VarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// Uint32P is like Uint32, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Uint32P(name, shorthand string, value uint32, usage string) *uint32 {\n\tp := new(uint32)\n\tf.Uint32VarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// Uint32 defines a uint32 flag with specified name, default value, and usage string.\n// The return value is the address of a uint32  variable that stores the value of the flag.\nfunc Uint32(name string, value uint32, usage string) *uint32 {\n\treturn CommandLine.Uint32P(name, \"\", value, usage)\n}\n\n// Uint32P is like Uint32, but accepts a shorthand letter that can be used after a single dash.\nfunc Uint32P(name, shorthand string, value uint32, usage string) *uint32 {\n\treturn CommandLine.Uint32P(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/uint64.go",
    "content": "package pflag\n\nimport \"strconv\"\n\n// -- uint64 Value\ntype uint64Value uint64\n\nfunc newUint64Value(val uint64, p *uint64) *uint64Value {\n\t*p = val\n\treturn (*uint64Value)(p)\n}\n\nfunc (i *uint64Value) Set(s string) error {\n\tv, err := strconv.ParseUint(s, 0, 64)\n\t*i = uint64Value(v)\n\treturn err\n}\n\nfunc (i *uint64Value) Type() string {\n\treturn \"uint64\"\n}\n\nfunc (i *uint64Value) String() string { return strconv.FormatUint(uint64(*i), 10) }\n\nfunc uint64Conv(sval string) (interface{}, error) {\n\tv, err := strconv.ParseUint(sval, 0, 64)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn uint64(v), nil\n}\n\n// GetUint64 return the uint64 value of a flag with the given name\nfunc (f *FlagSet) GetUint64(name string) (uint64, error) {\n\tval, err := f.getFlagType(name, \"uint64\", uint64Conv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn val.(uint64), nil\n}\n\n// Uint64Var defines a uint64 flag with specified name, default value, and usage string.\n// The argument p points to a uint64 variable in which to store the value of the flag.\nfunc (f *FlagSet) Uint64Var(p *uint64, name string, value uint64, usage string) {\n\tf.VarP(newUint64Value(value, p), name, \"\", usage)\n}\n\n// Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) {\n\tf.VarP(newUint64Value(value, p), name, shorthand, usage)\n}\n\n// Uint64Var defines a uint64 flag with specified name, default value, and usage string.\n// The argument p points to a uint64 variable in which to store the value of the flag.\nfunc Uint64Var(p *uint64, name string, value uint64, usage string) {\n\tCommandLine.VarP(newUint64Value(value, p), name, \"\", usage)\n}\n\n// Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash.\nfunc Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) {\n\tCommandLine.VarP(newUint64Value(value, p), name, shorthand, usage)\n}\n\n// Uint64 defines a uint64 flag with specified name, default value, and usage string.\n// The return value is the address of a uint64 variable that stores the value of the flag.\nfunc (f *FlagSet) Uint64(name string, value uint64, usage string) *uint64 {\n\tp := new(uint64)\n\tf.Uint64VarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Uint64P(name, shorthand string, value uint64, usage string) *uint64 {\n\tp := new(uint64)\n\tf.Uint64VarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// Uint64 defines a uint64 flag with specified name, default value, and usage string.\n// The return value is the address of a uint64 variable that stores the value of the flag.\nfunc Uint64(name string, value uint64, usage string) *uint64 {\n\treturn CommandLine.Uint64P(name, \"\", value, usage)\n}\n\n// Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash.\nfunc Uint64P(name, shorthand string, value uint64, usage string) *uint64 {\n\treturn CommandLine.Uint64P(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/uint8.go",
    "content": "package pflag\n\nimport \"strconv\"\n\n// -- uint8 Value\ntype uint8Value uint8\n\nfunc newUint8Value(val uint8, p *uint8) *uint8Value {\n\t*p = val\n\treturn (*uint8Value)(p)\n}\n\nfunc (i *uint8Value) Set(s string) error {\n\tv, err := strconv.ParseUint(s, 0, 8)\n\t*i = uint8Value(v)\n\treturn err\n}\n\nfunc (i *uint8Value) Type() string {\n\treturn \"uint8\"\n}\n\nfunc (i *uint8Value) String() string { return strconv.FormatUint(uint64(*i), 10) }\n\nfunc uint8Conv(sval string) (interface{}, error) {\n\tv, err := strconv.ParseUint(sval, 0, 8)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn uint8(v), nil\n}\n\n// GetUint8 return the uint8 value of a flag with the given name\nfunc (f *FlagSet) GetUint8(name string) (uint8, error) {\n\tval, err := f.getFlagType(name, \"uint8\", uint8Conv)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn val.(uint8), nil\n}\n\n// Uint8Var defines a uint8 flag with specified name, default value, and usage string.\n// The argument p points to a uint8 variable in which to store the value of the flag.\nfunc (f *FlagSet) Uint8Var(p *uint8, name string, value uint8, usage string) {\n\tf.VarP(newUint8Value(value, p), name, \"\", usage)\n}\n\n// Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) {\n\tf.VarP(newUint8Value(value, p), name, shorthand, usage)\n}\n\n// Uint8Var defines a uint8 flag with specified name, default value, and usage string.\n// The argument p points to a uint8 variable in which to store the value of the flag.\nfunc Uint8Var(p *uint8, name string, value uint8, usage string) {\n\tCommandLine.VarP(newUint8Value(value, p), name, \"\", usage)\n}\n\n// Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash.\nfunc Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) {\n\tCommandLine.VarP(newUint8Value(value, p), name, shorthand, usage)\n}\n\n// Uint8 defines a uint8 flag with specified name, default value, and usage string.\n// The return value is the address of a uint8 variable that stores the value of the flag.\nfunc (f *FlagSet) Uint8(name string, value uint8, usage string) *uint8 {\n\tp := new(uint8)\n\tf.Uint8VarP(p, name, \"\", value, usage)\n\treturn p\n}\n\n// Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) Uint8P(name, shorthand string, value uint8, usage string) *uint8 {\n\tp := new(uint8)\n\tf.Uint8VarP(p, name, shorthand, value, usage)\n\treturn p\n}\n\n// Uint8 defines a uint8 flag with specified name, default value, and usage string.\n// The return value is the address of a uint8 variable that stores the value of the flag.\nfunc Uint8(name string, value uint8, usage string) *uint8 {\n\treturn CommandLine.Uint8P(name, \"\", value, usage)\n}\n\n// Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash.\nfunc Uint8P(name, shorthand string, value uint8, usage string) *uint8 {\n\treturn CommandLine.Uint8P(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/uint_slice.go",
    "content": "package pflag\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// -- uintSlice Value\ntype uintSliceValue struct {\n\tvalue   *[]uint\n\tchanged bool\n}\n\nfunc newUintSliceValue(val []uint, p *[]uint) *uintSliceValue {\n\tuisv := new(uintSliceValue)\n\tuisv.value = p\n\t*uisv.value = val\n\treturn uisv\n}\n\nfunc (s *uintSliceValue) Set(val string) error {\n\tss := strings.Split(val, \",\")\n\tout := make([]uint, len(ss))\n\tfor i, d := range ss {\n\t\tu, err := strconv.ParseUint(d, 10, 0)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tout[i] = uint(u)\n\t}\n\tif !s.changed {\n\t\t*s.value = out\n\t} else {\n\t\t*s.value = append(*s.value, out...)\n\t}\n\ts.changed = true\n\treturn nil\n}\n\nfunc (s *uintSliceValue) Type() string {\n\treturn \"uintSlice\"\n}\n\nfunc (s *uintSliceValue) String() string {\n\tout := make([]string, len(*s.value))\n\tfor i, d := range *s.value {\n\t\tout[i] = fmt.Sprintf(\"%d\", d)\n\t}\n\treturn \"[\" + strings.Join(out, \",\") + \"]\"\n}\n\nfunc uintSliceConv(val string) (interface{}, error) {\n\tval = strings.Trim(val, \"[]\")\n\t// Empty string would cause a slice with one (empty) entry\n\tif len(val) == 0 {\n\t\treturn []uint{}, nil\n\t}\n\tss := strings.Split(val, \",\")\n\tout := make([]uint, len(ss))\n\tfor i, d := range ss {\n\t\tu, err := strconv.ParseUint(d, 10, 0)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tout[i] = uint(u)\n\t}\n\treturn out, nil\n}\n\n// GetUintSlice returns the []uint value of a flag with the given name.\nfunc (f *FlagSet) GetUintSlice(name string) ([]uint, error) {\n\tval, err := f.getFlagType(name, \"uintSlice\", uintSliceConv)\n\tif err != nil {\n\t\treturn []uint{}, err\n\t}\n\treturn val.([]uint), nil\n}\n\n// UintSliceVar defines a uintSlice flag with specified name, default value, and usage string.\n// The argument p points to a []uint variable in which to store the value of the flag.\nfunc (f *FlagSet) UintSliceVar(p *[]uint, name string, value []uint, usage string) {\n\tf.VarP(newUintSliceValue(value, p), name, \"\", usage)\n}\n\n// UintSliceVarP is like UintSliceVar, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) UintSliceVarP(p *[]uint, name, shorthand string, value []uint, usage string) {\n\tf.VarP(newUintSliceValue(value, p), name, shorthand, usage)\n}\n\n// UintSliceVar defines a uint[] flag with specified name, default value, and usage string.\n// The argument p points to a uint[] variable in which to store the value of the flag.\nfunc UintSliceVar(p *[]uint, name string, value []uint, usage string) {\n\tCommandLine.VarP(newUintSliceValue(value, p), name, \"\", usage)\n}\n\n// UintSliceVarP is like the UintSliceVar, but accepts a shorthand letter that can be used after a single dash.\nfunc UintSliceVarP(p *[]uint, name, shorthand string, value []uint, usage string) {\n\tCommandLine.VarP(newUintSliceValue(value, p), name, shorthand, usage)\n}\n\n// UintSlice defines a []uint flag with specified name, default value, and usage string.\n// The return value is the address of a []uint variable that stores the value of the flag.\nfunc (f *FlagSet) UintSlice(name string, value []uint, usage string) *[]uint {\n\tp := []uint{}\n\tf.UintSliceVarP(&p, name, \"\", value, usage)\n\treturn &p\n}\n\n// UintSliceP is like UintSlice, but accepts a shorthand letter that can be used after a single dash.\nfunc (f *FlagSet) UintSliceP(name, shorthand string, value []uint, usage string) *[]uint {\n\tp := []uint{}\n\tf.UintSliceVarP(&p, name, shorthand, value, usage)\n\treturn &p\n}\n\n// UintSlice defines a []uint flag with specified name, default value, and usage string.\n// The return value is the address of a []uint variable that stores the value of the flag.\nfunc UintSlice(name string, value []uint, usage string) *[]uint {\n\treturn CommandLine.UintSliceP(name, \"\", value, usage)\n}\n\n// UintSliceP is like UintSlice, but accepts a shorthand letter that can be used after a single dash.\nfunc UintSliceP(name, shorthand string, value []uint, usage string) *[]uint {\n\treturn CommandLine.UintSliceP(name, shorthand, value, usage)\n}\n"
  },
  {
    "path": "vendor/github.com/spf13/pflag/uint_slice_test.go",
    "content": "package pflag\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc setUpUISFlagSet(uisp *[]uint) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.UintSliceVar(uisp, \"uis\", []uint{}, \"Command separated list!\")\n\treturn f\n}\n\nfunc setUpUISFlagSetWithDefault(uisp *[]uint) *FlagSet {\n\tf := NewFlagSet(\"test\", ContinueOnError)\n\tf.UintSliceVar(uisp, \"uis\", []uint{0, 1}, \"Command separated list!\")\n\treturn f\n}\n\nfunc TestEmptyUIS(t *testing.T) {\n\tvar uis []uint\n\tf := setUpUISFlagSet(&uis)\n\terr := f.Parse([]string{})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\n\tgetUIS, err := f.GetUintSlice(\"uis\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetUintSlice():\", err)\n\t}\n\tif len(getUIS) != 0 {\n\t\tt.Fatalf(\"got is %v with len=%d but expected length=0\", getUIS, len(getUIS))\n\t}\n}\n\nfunc TestUIS(t *testing.T) {\n\tvar uis []uint\n\tf := setUpUISFlagSet(&uis)\n\n\tvals := []string{\"1\", \"2\", \"4\", \"3\"}\n\targ := fmt.Sprintf(\"--uis=%s\", strings.Join(vals, \",\"))\n\terr := f.Parse([]string{arg})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range uis {\n\t\tu, err := strconv.ParseUint(vals[i], 10, 0)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif uint(u) != v {\n\t\t\tt.Fatalf(\"expected uis[%d] to be %s but got %d\", i, vals[i], v)\n\t\t}\n\t}\n\tgetUIS, err := f.GetUintSlice(\"uis\")\n\tif err != nil {\n\t\tt.Fatalf(\"got error: %v\", err)\n\t}\n\tfor i, v := range getUIS {\n\t\tu, err := strconv.ParseUint(vals[i], 10, 0)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif uint(u) != v {\n\t\t\tt.Fatalf(\"expected uis[%d] to be %s but got: %d from GetUintSlice\", i, vals[i], v)\n\t\t}\n\t}\n}\n\nfunc TestUISDefault(t *testing.T) {\n\tvar uis []uint\n\tf := setUpUISFlagSetWithDefault(&uis)\n\n\tvals := []string{\"0\", \"1\"}\n\n\terr := f.Parse([]string{})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range uis {\n\t\tu, err := strconv.ParseUint(vals[i], 10, 0)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif uint(u) != v {\n\t\t\tt.Fatalf(\"expect uis[%d] to be %d but got: %d\", i, u, v)\n\t\t}\n\t}\n\n\tgetUIS, err := f.GetUintSlice(\"uis\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetUintSlice():\", err)\n\t}\n\tfor i, v := range getUIS {\n\t\tu, err := strconv.ParseUint(vals[i], 10, 0)\n\t\tif err != nil {\n\t\t\tt.Fatal(\"got an error from GetIntSlice():\", err)\n\t\t}\n\t\tif uint(u) != v {\n\t\t\tt.Fatalf(\"expected uis[%d] to be %d from GetUintSlice but got: %d\", i, u, v)\n\t\t}\n\t}\n}\n\nfunc TestUISWithDefault(t *testing.T) {\n\tvar uis []uint\n\tf := setUpUISFlagSetWithDefault(&uis)\n\n\tvals := []string{\"1\", \"2\"}\n\targ := fmt.Sprintf(\"--uis=%s\", strings.Join(vals, \",\"))\n\terr := f.Parse([]string{arg})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range uis {\n\t\tu, err := strconv.ParseUint(vals[i], 10, 0)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif uint(u) != v {\n\t\t\tt.Fatalf(\"expected uis[%d] to be %d from GetUintSlice but got: %d\", i, u, v)\n\t\t}\n\t}\n\n\tgetUIS, err := f.GetUintSlice(\"uis\")\n\tif err != nil {\n\t\tt.Fatal(\"got an error from GetUintSlice():\", err)\n\t}\n\tfor i, v := range getUIS {\n\t\tu, err := strconv.ParseUint(vals[i], 10, 0)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"got error: %v\", err)\n\t\t}\n\t\tif uint(u) != v {\n\t\t\tt.Fatalf(\"expected uis[%d] to be %d from GetUintSlice but got: %d\", i, u, v)\n\t\t}\n\t}\n}\n\nfunc TestUISCalledTwice(t *testing.T) {\n\tvar uis []uint\n\tf := setUpUISFlagSet(&uis)\n\n\tin := []string{\"1,2\", \"3\"}\n\texpected := []int{1, 2, 3}\n\targfmt := \"--uis=%s\"\n\targ1 := fmt.Sprintf(argfmt, in[0])\n\targ2 := fmt.Sprintf(argfmt, in[1])\n\terr := f.Parse([]string{arg1, arg2})\n\tif err != nil {\n\t\tt.Fatal(\"expected no error; got\", err)\n\t}\n\tfor i, v := range uis {\n\t\tif uint(expected[i]) != v {\n\t\t\tt.Fatalf(\"expected uis[%d] to be %d but got: %d\", i, expected[i], v)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/.travis.yml",
    "content": "language: go\n\ngo:\n  - 1.8\n  - 1.9\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/LICENSE",
    "content": "Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright {yyyy} {name of copyright owner}\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/README.md",
    "content": "\nSpotify\n=======\n\n[![GoDoc](https://godoc.org/github.com/zmb3/spotify?status.svg)](http://godoc.org/github.com/zmb3/spotify)\n[![Build status](https://ci.appveyor.com/api/projects/status/1nr9vv0jqq438nj2?svg=true)](https://ci.appveyor.com/project/zmb3/spotify)\n[![Build Status](https://travis-ci.org/zmb3/spotify.svg)](https://travis-ci.org/zmb3/spotify)\n\nThis is a Go wrapper for working with Spotify's\n[Web API](https://developer.spotify.com/web-api/).\n\nIt aims to support every task listed in the Web API Endpoint Reference,\nlocated [here](https://developer.spotify.com/web-api/endpoint-reference/).\n\nBy using this library you agree to Spotify's\n[Developer Terms of Use](https://developer.spotify.com/developer-terms-of-use/).\n\n## Installation\n\nTo install the library, simply\n\n`go get github.com/zmb3/spotify`\n\n## Authentication\n\nSpotify uses OAuth2 for authentication and authorization.  \nAs of May 29, 2017 _all_ Web API endpoints require an access token.\n\nYou can authenticate using a client credentials flow, but this does not provide\nany authorization to access a user's private data.  For most use cases, you'll\nwant to use the authorization code flow.  This package includes an `Authenticator`\ntype to handle the details for you.\n\nStart by registering your application at the following page:\n\nhttps://developer.spotify.com/my-applications/.\n\nYou'll get a __client ID__ and __secret key__ for your application.  An easy way to\nprovide this data to your application is to set the SPOTIFY_ID and SPOTIFY_SECRET\nenvironment variables.  If you choose not to use environment variables, you can\nprovide this data manually.\n\n\n````Go\n// the redirect URL must be an exact match of a URL you've registered for your application\n// scopes determine which permissions the user is prompted to authorize\nauth := spotify.NewAuthenticator(redirectURL, spotify.ScopeUserReadPrivate)\n\n// if you didn't store your ID and secret key in the specified environment variables,\n// you can set them manually here\nauth.SetAuthInfo(clientID, secretKey)\n\n// get the user to this URL - how you do that is up to you\n// you should specify a unique state string to identify the session\nurl := auth.AuthURL(state)\n\n// the user will eventually be redirected back to your redirect URL\n// typically you'll have a handler set up like the following:\nfunc redirectHandler(w http.ResponseWriter, r *http.Request) {\n      // use the same state string here that you used to generate the URL\n      token, err := auth.Token(state, r)\n      if err != nil {\n            http.Error(w, \"Couldn't get token\", http.StatusNotFound)\n            return\n      }\n      // create a client using the specified token\n      client := auth.NewClient(token)\n\n      // the client can now be used to make authenticated requests\n}\n````\n\nYou may find the following resources useful:\n\n1. Spotify's Web API Authorization Guide:\nhttps://developer.spotify.com/web-api/authorization-guide/\n\n2. Go's OAuth2 package:\nhttps://godoc.org/golang.org/x/oauth2/google\n\n\n## Helpful Hints\n\n\n### Optional Parameters\n\nMany of the functions in this package come in two forms - a simple version that\nomits optional parameters and uses reasonable defaults, and a more sophisticated\nversion that accepts additional parameters.  The latter is suffixed with `Opt`\nto indicate that it accepts some optional parameters.\n\n### Automatic Retries\n\nThe API will throttle your requests if you are sending them too rapidly.\nThe client can be configured to wait and re-attempt the request.\nTo enable this, set the `AutoRetry` field on the `Client` struct to `true`.\n\nFor more information, see Spotify [rate-limits](https://developer.spotify.com/web-api/user-guide/#rate-limiting).\n\n## API Examples\n\nExamples of the API can be found in the [examples](examples) directory.\n\nYou may find tools such as [Spotify's Web API Console](https://developer.spotify.com/web-api/console/)\nor [Rapid API](https://rapidapi.com/package/SpotifyPublicAPI/functions?utm_source=SpotifyGitHub&utm_medium=button&utm_content=Vendor_GitHub)\nvaluable for experimenting with the API.\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/album.go",
    "content": "package spotify\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n)\n\n// SimpleAlbum contains basic data about an album.\ntype SimpleAlbum struct {\n\t// The name of the album.\n\tName string `json:\"name\"`\n\t// A slice of SimpleArtists\n\tArtists []SimpleArtist `json:\"artists\"`\n\t// The type of the album: one of \"album\",\n\t// \"single\", or \"compilation\".\n\tAlbumType string `json:\"album_type\"`\n\t// The SpotifyID for the album.\n\tID ID `json:\"id\"`\n\t// The SpotifyURI for the album.\n\tURI URI `json:\"uri\"`\n\t// The markets in which the album is available,\n\t// identified using ISO 3166-1 alpha-2 country\n\t// codes.  Note that al album is considered\n\t// available in a market when at least 1 of its\n\t// tracks is available in that market.\n\tAvailableMarkets []string `json:\"available_markets\"`\n\t// A link to the Web API enpoint providing full\n\t// details of the album.\n\tEndpoint string `json:\"href\"`\n\t// The cover art for the album in various sizes,\n\t// widest first.\n\tImages []Image `json:\"images\"`\n\t// Known external URLs for this album.\n\tExternalURLs map[string]string `json:\"external_urls\"`\n}\n\n// Copyright contains the copyright statement associated with an album.\ntype Copyright struct {\n\t// The copyright text for the album.\n\tText string `json:\"text\"`\n\t// The type of copyright.\n\tType string `json:\"type\"`\n}\n\n// FullAlbum provides extra album data in addition to the data provided by SimpleAlbum.\ntype FullAlbum struct {\n\tSimpleAlbum\n\tArtists    []SimpleArtist `json:\"artists\"`\n\tCopyrights []Copyright    `json:\"copyrights\"`\n\tGenres     []string       `json:\"genres\"`\n\t// The popularity of the album, represented as an integer between 0 and 100,\n\t// with 100 being the most popular.  Popularity of an album is calculated\n\t// from the popularify of the album's individual tracks.\n\tPopularity int `json:\"popularity\"`\n\t// The date the album was first released.  For example, \"1981-12-15\".\n\t// Depending on the ReleaseDatePrecision, it might be shown as\n\t// \"1981\" or \"1981-12\". You can use ReleaseDateTime to convert this\n\t// to a time.Time value.\n\tReleaseDate string `json:\"release_date\"`\n\t// The precision with which ReleaseDate value is known: \"year\", \"month\", or \"day\"\n\tReleaseDatePrecision string            `json:\"release_date_precision\"`\n\tTracks               SimpleTrackPage   `json:\"tracks\"`\n\tExternalIDs          map[string]string `json:\"external_ids\"`\n}\n\n// SavedAlbum provides info about an album saved to an user's account.\ntype SavedAlbum struct {\n\t// The date and time the track was saved, represented as an ISO\n\t// 8601 UTC timestamp with a zero offset (YYYY-MM-DDTHH:MM:SSZ).\n\t// You can use the TimestampLayout constant to convert this to\n\t// a time.Time value.\n\tAddedAt   string `json:\"added_at\"`\n\tFullAlbum `json:\"album\"`\n}\n\n// ReleaseDateTime converts the album's ReleaseDate to a time.TimeValue.\n// All of the fields in the result may not be valid.  For example, if\n// f.ReleaseDatePrecision is \"month\", then only the month and year\n// (but not the day) of the result are valid.\nfunc (f *FullAlbum) ReleaseDateTime() time.Time {\n\tif f.ReleaseDatePrecision == \"day\" {\n\t\tresult, _ := time.Parse(DateLayout, f.ReleaseDate)\n\t\treturn result\n\t}\n\tif f.ReleaseDatePrecision == \"month\" {\n\t\tym := strings.Split(f.ReleaseDate, \"-\")\n\t\tyear, _ := strconv.Atoi(ym[0])\n\t\tmonth, _ := strconv.Atoi(ym[1])\n\t\treturn time.Date(year, time.Month(month), 1, 0, 0, 0, 0, time.UTC)\n\t}\n\tyear, _ := strconv.Atoi(f.ReleaseDate)\n\treturn time.Date(year, 1, 1, 0, 0, 0, 0, time.UTC)\n}\n\n// GetAlbum gets Spotify catalog information for a single album, given its Spotify ID.\nfunc (c *Client) GetAlbum(id ID) (*FullAlbum, error) {\n\tspotifyURL := fmt.Sprintf(\"%salbums/%s\", c.baseURL, id)\n\n\tvar a FullAlbum\n\n\terr := c.get(spotifyURL, &a)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &a, nil\n}\n\nfunc toStringSlice(ids []ID) []string {\n\tresult := make([]string, len(ids))\n\tfor i, str := range ids {\n\t\tresult[i] = str.String()\n\t}\n\treturn result\n}\n\n// GetAlbums gets Spotify Catalog information for multiple albums, given their\n// Spotify IDs.  It supports up to 20 IDs in a single call.  Albums are returned\n// in the order requested.  If an album is not found, that position in the\n// result slice will be nil.\nfunc (c *Client) GetAlbums(ids ...ID) ([]*FullAlbum, error) {\n\tif len(ids) > 20 {\n\t\treturn nil, errors.New(\"spotify: exceeded maximum number of albums\")\n\t}\n\tspotifyURL := fmt.Sprintf(\"%salbums?ids=%s\", c.baseURL, strings.Join(toStringSlice(ids), \",\"))\n\n\tvar a struct {\n\t\tAlbums []*FullAlbum `json:\"albums\"`\n\t}\n\n\terr := c.get(spotifyURL, &a)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn a.Albums, nil\n}\n\n// AlbumType represents the type of an album. It can be used to filter\n// results when searching for albums.\ntype AlbumType int\n\n// AlbumType values that can be used to filter which types of albums are\n// searched for.  These are flags that can be bitwise OR'd together\n// to search for multiple types of albums simultaneously.\nconst (\n\tAlbumTypeAlbum       AlbumType = 1 << iota\n\tAlbumTypeSingle                = 1 << iota\n\tAlbummTypeAppearsOn            = 1 << iota\n\tAlbumTypeCompilation           = 1 << iota\n)\n\nfunc (at AlbumType) encode() string {\n\ttypes := []string{}\n\tif at&AlbumTypeAlbum != 0 {\n\t\ttypes = append(types, \"album\")\n\t}\n\tif at&AlbumTypeSingle != 0 {\n\t\ttypes = append(types, \"single\")\n\t}\n\tif at&AlbummTypeAppearsOn != 0 {\n\t\ttypes = append(types, \"appears_on\")\n\t}\n\tif at&AlbumTypeCompilation != 0 {\n\t\ttypes = append(types, \"compilation\")\n\t}\n\treturn strings.Join(types, \",\")\n}\n\n// GetAlbumTracks gets the tracks for a particular album.\n// If you only care about the tracks, this call is more efficient\n// than GetAlbum.\nfunc (c *Client) GetAlbumTracks(id ID) (*SimpleTrackPage, error) {\n\treturn c.GetAlbumTracksOpt(id, -1, -1)\n}\n\n// GetAlbumTracksOpt behaves like GetAlbumTracks, with the exception that it\n// allows you to specify extra parameters that limit the number of results returned.\n// The maximum number of results to return is specified by limit.\n// The offset argument can be used to specify the index of the first track to return.\n// It can be used along with limit to reqeust the next set of results.\nfunc (c *Client) GetAlbumTracksOpt(id ID, limit, offset int) (*SimpleTrackPage, error) {\n\tspotifyURL := fmt.Sprintf(\"%salbums/%s/tracks\", c.baseURL, id)\n\tv := url.Values{}\n\tif limit != -1 {\n\t\tv.Set(\"limit\", strconv.Itoa(limit))\n\t}\n\tif offset != -1 {\n\t\tv.Set(\"offset\", strconv.Itoa(offset))\n\t}\n\toptional := v.Encode()\n\tif optional != \"\" {\n\t\tspotifyURL = spotifyURL + \"?\" + optional\n\t}\n\n\tvar result SimpleTrackPage\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, nil\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/album_test.go",
    "content": "package spotify\n\nimport (\n\t\"net/http\"\n\t\"testing\"\n)\n\n// The example from https://developer.spotify.com/web-api/get-album/\nfunc TestFindAlbum(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/find_album.txt\")\n\tdefer server.Close()\n\n\talbum, err := client.GetAlbum(ID(\"0sNOF9WDwhWunNAHPD3Baj\"))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif album == nil {\n\t\tt.Fatal(\"Got nil album\")\n\t}\n\tif album.Name != \"She's So Unusual\" {\n\t\tt.Error(\"Got wrong album\")\n\t}\n\treleased := album.ReleaseDateTime()\n\tif released.Year() != 1983 {\n\t\tt.Errorf(\"Expected release date 1983, got %d\\n\", released.Year())\n\t}\n}\n\nfunc TestFindAlbumBadID(t *testing.T) {\n\tclient, server := testClientString(http.StatusNotFound, `{ \"error\": { \"status\": 404, \"message\": \"non existing id\" } }`)\n\tdefer server.Close()\n\n\talbum, err := client.GetAlbum(ID(\"asdf\"))\n\tif album != nil {\n\t\tt.Fatal(\"Expected nil album, got\", album.Name)\n\t}\n\tse, ok := err.(Error)\n\tif !ok {\n\t\tt.Error(\"Expected spotify error, got\", err)\n\t}\n\tif se.Status != 404 {\n\t\tt.Errorf(\"Expected HTTP 404, got %d. \", se.Status)\n\t}\n\tif se.Message != \"non existing id\" {\n\t\tt.Error(\"Unexpected error message: \", se.Message)\n\t}\n}\n\n// The example from https://developer.spotify.com/web-api/get-several-albums/\nfunc TestFindAlbums(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/find_albums.txt\")\n\tdefer server.Close()\n\n\tres, err := client.GetAlbums(ID(\"41MnTivkwTO3UUJ8DrqEJJ\"), ID(\"6JWc4iAiJ9FjyK0B59ABb4\"), ID(\"6UXCm6bOO4gFlDQZV5yL37\"), ID(\"0X8vBD8h1Ga9eLT8jx9VCC\"))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif len(res) != 4 {\n\t\tt.Fatalf(\"Expected 4 albums, got %d\", len(res))\n\t}\n\texpectedAlbums := []string{\n\t\t\"The Best Of Keane (Deluxe Edition)\",\n\t\t\"Strangeland\",\n\t\t\"Night Train\",\n\t\t\"Mirrored\",\n\t}\n\tfor i, name := range expectedAlbums {\n\t\tif res[i].Name != name {\n\t\t\tt.Error(\"Expected album\", name, \"but got\", res[i].Name)\n\t\t}\n\t}\n\trelease := res[0].ReleaseDateTime()\n\tif release.Year() != 2013 ||\n\t\trelease.Month() != 11 ||\n\t\trelease.Day() != 8 {\n\t\tt.Errorf(\"Expected release 2013-11-08, got %d-%02d-%02d\\n\",\n\t\t\trelease.Year(), release.Month(), release.Day())\n\t}\n\treleaseMonthPrecision := res[3].ReleaseDateTime()\n\tif releaseMonthPrecision.Year() != 2007 ||\n\t\treleaseMonthPrecision.Month() != 3 ||\n\t\treleaseMonthPrecision.Day() != 1 {\n\t\tt.Errorf(\"Expected release 2007-03-01, got %d-%02d-%02d\\n\",\n\t\t\treleaseMonthPrecision.Year(), releaseMonthPrecision.Month(), releaseMonthPrecision.Day())\n\t}\n}\n\nfunc TestFindAlbumTracks(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/find_album_tracks.txt\")\n\tdefer server.Close()\n\n\tres, err := client.GetAlbumTracksOpt(ID(\"0sNOF9WDwhWunNAHPD3Baj\"), 1, 0)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif res.Total != 13 {\n\t\tt.Fatal(\"Got\", res.Total, \"results, want 13\")\n\t}\n\tif len(res.Tracks) == 1 {\n\t\tif res.Tracks[0].Name != \"Money Changes Everything\" {\n\t\t\tt.Error(\"Expected track 'Money Changes Everything', got\", res.Tracks[0].Name)\n\t\t}\n\t} else {\n\t\tt.Error(\"Expected 1 track, got\", len(res.Tracks))\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/artist.go",
    "content": "package spotify\n\nimport (\n\t\"fmt\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// SimpleArtist contains basic info about an artist.\ntype SimpleArtist struct {\n\tName string `json:\"name\"`\n\tID   ID     `json:\"id\"`\n\t// The Spotify URI for the artist.\n\tURI URI `json:\"uri\"`\n\t// A link to the Web API enpoint providing full details of the artist.\n\tEndpoint     string            `json:\"href\"`\n\tExternalURLs map[string]string `json:\"external_urls\"`\n}\n\n// FullArtist provides extra artist data in addition to what is provided by SimpleArtist.\ntype FullArtist struct {\n\tSimpleArtist\n\t// The popularity of the artist, expressed as an integer between 0 and 100.\n\t// The artist's popularity is calculated from the popularity of the artist's tracks.\n\tPopularity int `json:\"popularity\"`\n\t// A list of genres the artist is associated with.  For example, \"Prog Rock\"\n\t// or \"Post-Grunge\".  If not yet classified, the slice is empty.\n\tGenres    []string `json:\"genres\"`\n\tFollowers Followers\n\t// Images of the artist in various sizes, widest first.\n\tImages []Image `json:\"images\"`\n}\n\n// GetArtist gets Spotify catalog information for a single artist, given its Spotify ID.\nfunc (c *Client) GetArtist(id ID) (*FullArtist, error) {\n\tspotifyURL := fmt.Sprintf(\"%sartists/%s\", c.baseURL, id)\n\n\tvar a FullArtist\n\terr := c.get(spotifyURL, &a)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &a, nil\n}\n\n// GetArtists gets spotify catalog information for several artists based on their\n// Spotify IDs.  It supports up to 50 artists in a single call.  Artists are\n// returned in the order requested.  If an artist is not found, that position\n// in the result will be nil.  Duplicate IDs will result in duplicate artists\n// in the result.\nfunc (c *Client) GetArtists(ids ...ID) ([]*FullArtist, error) {\n\tspotifyURL := fmt.Sprintf(\"%sartists?ids=%s\", c.baseURL, strings.Join(toStringSlice(ids), \",\"))\n\n\tvar a struct {\n\t\tArtists []*FullArtist\n\t}\n\n\terr := c.get(spotifyURL, &a)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn a.Artists, nil\n}\n\n// GetArtistsTopTracks gets Spotify catalog information about an artist's top\n// tracks in a particular country.  It returns a maximum of 10 tracks.  The\n// country is specified as an ISO 3166-1 alpha-2 country code.\nfunc (c *Client) GetArtistsTopTracks(artistID ID, country string) ([]FullTrack, error) {\n\tspotifyURL := fmt.Sprintf(\"%sartists/%s/top-tracks?country=%s\", c.baseURL, artistID, country)\n\n\tvar t struct {\n\t\tTracks []FullTrack `json:\"tracks\"`\n\t}\n\n\terr := c.get(spotifyURL, &t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn t.Tracks, nil\n}\n\n// GetRelatedArtists gets Spotify catalog information about artists similar to a\n// given artist.  Similarity is based on analysis of the Spotify community's\n// listening history.  This function returns up to 20 artists that are considered\n// related to the specified artist.\nfunc (c *Client) GetRelatedArtists(id ID) ([]FullArtist, error) {\n\tspotifyURL := fmt.Sprintf(\"%sartists/%s/related-artists\", c.baseURL, id)\n\n\tvar a struct {\n\t\tArtists []FullArtist `json:\"artists\"`\n\t}\n\n\terr := c.get(spotifyURL, &a)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn a.Artists, nil\n}\n\n// GetArtistAlbums gets Spotify catalog information about an artist's albums.\n// It is equivalent to GetArtistAlbumsOpt(artistID, nil).\nfunc (c *Client) GetArtistAlbums(artistID ID) (*SimpleAlbumPage, error) {\n\treturn c.GetArtistAlbumsOpt(artistID, nil, nil)\n}\n\n// GetArtistAlbumsOpt is just like GetArtistAlbums, but it accepts optional\n// parameters used to filter and sort the result.\n//\n// The AlbumType argument can be used to find a particular type of album.  Search\n// for multiple types by OR-ing the types together.\nfunc (c *Client) GetArtistAlbumsOpt(artistID ID, options *Options, t *AlbumType) (*SimpleAlbumPage, error) {\n\tspotifyURL := fmt.Sprintf(\"%sartists/%s/albums\", c.baseURL, artistID)\n\t// add optional query string if options were specified\n\tvalues := url.Values{}\n\tif t != nil {\n\t\tvalues.Set(\"album_type\", t.encode())\n\t}\n\tif options != nil {\n\t\tif options.Country != nil {\n\t\t\tvalues.Set(\"market\", *options.Country)\n\t\t} else {\n\t\t\t// if the market is not specified, Spotify will likely return a lot\n\t\t\t// of duplicates (one for each market in which the album is available)\n\t\t\t// - prevent this behavior by falling back to the US by default\n\t\t\t// TODO: would this ever be the desired behavior?\n\t\t\tvalues.Set(\"market\", CountryUSA)\n\t\t}\n\t\tif options.Limit != nil {\n\t\t\tvalues.Set(\"limit\", strconv.Itoa(*options.Limit))\n\t\t}\n\t\tif options.Offset != nil {\n\t\t\tvalues.Set(\"offset\", strconv.Itoa(*options.Offset))\n\t\t}\n\t}\n\tif query := values.Encode(); query != \"\" {\n\t\tspotifyURL += \"?\" + query\n\t}\n\n\tvar p SimpleAlbumPage\n\n\terr := c.get(spotifyURL, &p)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &p, nil\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/artist_test.go",
    "content": "// Copyright 2014, 2015 Zac Bergquist\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage spotify\n\nimport (\n\t\"net/http\"\n\t\"testing\"\n)\n\nconst albumsResponse = `\n{\n\t\"href\" : \"https://api.spotify.com/v1/artists/1vCWHaC5f2uS3yhpwWbIA6/albums?offset=0&limit=2&album_type=single\",\n\t\"items\" : [ {\n\t\t\"album_type\" : \"single\",\n\t\t\"available_markets\" : [ \"AD\", \"AR\", \"AT\", \"AU\", \"BE\", \"BG\", \"BO\", \"BR\", \"CH\", \"CL\", \"CO\", \"CR\", \"CY\", \"CZ\", \"DE\", \"DK\", \"DO\", \"EC\", \"EE\", \"ES\", \"FI\", \"FR\", \"GR\", \"GT\", \"HK\", \"HN\", \"HU\", \"IE\", \"IS\", \"IT\", \"LI\", \"LT\", \"LU\", \"LV\", \"MC\", \"MT\", \"MY\", \"NI\", \"NL\", \"NO\", \"NZ\", \"PA\", \"PE\", \"PH\", \"PL\", \"PT\", \"PY\", \"RO\", \"SE\", \"SG\", \"SI\", \"SK\", \"SV\", \"TR\", \"TW\", \"UY\" ],\n\t\t\"external_urls\" : {\n\t\t\t\"spotify\" : \"https://open.spotify.com/album/3ckwyt0bTOcDbXovWbweMp\"\n\t\t\t},\n\t\t\"href\" : \"https://api.spotify.com/v1/albums/3ckwyt0bTOcDbXovWbweMp\",\n\t\t\"id\" : \"3ckwyt0bTOcDbXovWbweMp\",\n\t\t\"images\" : [ {\n\t\t\t\"height\" : 640,\n\t\t\t\"url\" : \"https://i.scdn.co/image/144ac57ad073741e99b5243c59abebe1500ada0a\",\n\t\t\t\"width\" : 640\n\t\t\t}, {\n\t\t\t\"height\" : 300,\n\t\t\t\"url\" : \"https://i.scdn.co/image/4680e5f3af02219fd9e79ce432c1b18f97af6426\",\n\t\t\t\"width\" : 300\n\t\t\t}, {\n\t\t\t\"height\" : 64,\n\t\t\t\"url\" : \"https://i.scdn.co/image/8c803d6cb612b6f2b37a7276deb2ff05f5a77097\",\n\t\t\t\"width\" : 64\n\t\t\t} ],\n\t\t\"name\" : \"The Days / Nights\",\n\t\t\"type\" : \"album\",\n\t\t\"uri\" : \"spotify:album:3ckwyt0bTOcDbXovWbweMp\"\n\t\t}, {\n\t\t\t\"album_type\" : \"single\",\n\t\t\t\"available_markets\" : [ \"CA\", \"MX\", \"US\" ],\n\t\t\t\"external_urls\" : {\n\t\t\t\t\"spotify\" : \"https://open.spotify.com/album/1WXM7DYQRT7QX8AKBJRfK9\"\n\t\t\t},\n\t\t\"href\" : \"https://api.spotify.com/v1/albums/1WXM7DYQRT7QX8AKBJRfK9\",\n\t\t\"id\" : \"1WXM7DYQRT7QX8AKBJRfK9\",\n\t\t\"images\" : [ {\n\t\t\t\"height\" : 640,\n\t\t\t\"url\" : \"https://i.scdn.co/image/590dbe5504d2898c120b942bee2b699404783896\",\n\t\t\t\"width\" : 640\n\t\t\t}, {\n\t\t\t\"height\" : 300,\n\t\t\t\"url\" : \"https://i.scdn.co/image/9a4db24b1930e8683b4dfd19c7bd2a40672c6718\",\n\t\t\t\"width\" : 300\n\t\t\t}, {\n\t\t\t\"height\" : 64,\n\t\t\t\"url\" : \"https://i.scdn.co/image/d5cfc167e03ed328ae7dfa9b56d3628d81b6831b\",\n\t\t\t\"width\" : 64\n\t\t\t} ],\n\t\t\t\"name\" : \"The Days / Nights\",\n\t\t\t\"type\" : \"album\",\n\t\t\t\"uri\" : \"spotify:album:1WXM7DYQRT7QX8AKBJRfK9\"\n\t\t\t} ],\n\t\"limit\" : 2,\n\t\"next\" : \"https://api.spotify.com/v1/artists/1vCWHaC5f2uS3yhpwWbIA6/albums?offset=2&limit=2&album_type=single\",\n\t\"offset\" : 0,\n\t\"previous\" : null,\n\t\"total\" : 157\n}`\n\nfunc TestFindArtist(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/find_artist.txt\")\n\tdefer server.Close()\n\n\tartist, err := client.GetArtist(ID(\"0TnOYISbd1XYRBk9myaseg\"))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif followers := artist.Followers.Count; followers != 2265279 {\n\t\tt.Errorf(\"Got %d followers, want 2265279\\n\", followers)\n\t}\n\tif artist.Name != \"Pitbull\" {\n\t\tt.Error(\"Got \", artist.Name, \", wanted Pitbull\")\n\t}\n}\n\nfunc TestArtistTopTracks(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/artist_top_tracks.txt\")\n\tdefer server.Close()\n\n\ttracks, err := client.GetArtistsTopTracks(ID(\"43ZHCT0cAZBISjO8DG9PnE\"), \"SE\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif l := len(tracks); l != 10 {\n\t\tt.Fatalf(\"Got %d tracks, expected 10\\n\", l)\n\t}\n\ttrack := tracks[9]\n\tif track.Name != \"(You're The) Devil in Disguise\" {\n\t\tt.Error(\"Incorrect track name\")\n\t}\n\tif track.TrackNumber != 24 {\n\t\tt.Errorf(\"Track number was %d, expected 24\\n\", track.TrackNumber)\n\t}\n}\n\nfunc TestRelatedArtists(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/related_artists.txt\")\n\tdefer server.Close()\n\n\tartists, err := client.GetRelatedArtists(ID(\"43ZHCT0cAZBISjO8DG9PnE\"))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif count := len(artists); count != 20 {\n\t\tt.Fatalf(\"Got %d artists, wanted 20\\n\", count)\n\t}\n\ta2 := artists[2]\n\tif a2.Name != \"Carl Perkins\" {\n\t\tt.Error(\"Expected Carl Perkins, got \", a2.Name)\n\t}\n\tif a2.Popularity != 54 {\n\t\tt.Errorf(\"Expected popularity 54, got %d\\n\", a2.Popularity)\n\t}\n}\n\nfunc TestArtistAlbumsFiltered(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, albumsResponse)\n\tdefer server.Close()\n\n\tl := 2\n\tvar typ AlbumType = AlbumTypeSingle\n\n\toptions := Options{}\n\toptions.Limit = &l\n\n\talbums, err := client.GetArtistAlbumsOpt(ID(\"1vCWHaC5f2uS3yhpwWbIA6\"), &options, &typ)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif albums == nil {\n\t\tt.Fatal(\"Result is nil\")\n\t}\n\t// since we didn't specify a country, we got duplicate albums\n\t// (the album has a different ID in different regions)\n\tif l = len(albums.Albums); l != 2 {\n\t\tt.Fatalf(\"Expected 2 albums, got %d\\n\", l)\n\t}\n\tif albums.Albums[0].Name != \"The Days / Nights\" {\n\t\tt.Error(\"Expected 'The Days / Nights', got \", albums.Albums[0].Name)\n\t}\n\n\turl := \"https://open.spotify.com/album/3ckwyt0bTOcDbXovWbweMp\"\n\tspotifyURL, ok := albums.Albums[0].ExternalURLs[\"spotify\"]\n\tif !ok {\n\t\tt.Error(\"Missing Spotify external URL\")\n\t}\n\tif spotifyURL != url {\n\t\tt.Errorf(\"Wrong Spotify external URL: want %s, got %s\\n\", url, spotifyURL)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/audio_analysis.go",
    "content": "package spotify\n\nimport (\n\t\"fmt\"\n)\n\n// AudioAnalysis contains a detailed audio analysis for a single track\n// identified by its unique Spotify ID. See:\n// https://developer.spotify.com/web-api/get-audio-analysis/\ntype AudioAnalysis struct {\n\tBars     []Marker      `json:\"bars\"`\n\tBeats    []Marker      `json:\"beats\"`\n\tMeta     AnalysisMeta  `json:\"meta\"`\n\tSections []Section     `json:\"sections\"`\n\tSegments []Segment     `json:\"segments\"`\n\tTatums   []Marker      `json:\"tatums\"`\n\tTrack    AnalysisTrack `json:\"track\"`\n}\n\n// Marker represents beats, bars, tatums and are used in segment and section\n// descriptions.\ntype Marker struct {\n\tStart      float64 `json:\"start\"`\n\tDuration   float64 `json:\"duration\"`\n\tConfidence float64 `json:\"confidence\"`\n}\n\n// AnalysisMeta describes details about Spotify's audio analysis of the track\ntype AnalysisMeta struct {\n\tAnalyzerVersion string  `json:\"analyzer_version\"`\n\tPlatform        string  `json:\"platform\"`\n\tDetailedStatus  string  `json:\"detailed_status\"`\n\tStatusCode      int     `json:\"status\"`\n\tTimestamp       int64   `json:\"timestamp\"`\n\tAnalysisTime    float64 `json:\"analysis_time\"`\n\tInputProcess    string  `json:\"input_process\"`\n}\n\n// Section represents a large variation in rhythm or timbre, e.g. chorus, verse,\n// bridge, guitar solo, etc. Each section contains its own descriptions of\n// tempo, key, mode, time_signature, and loudness.\ntype Section struct {\n\tMarker\n\tLoudness                float64 `json:\"loudness\"`\n\tTempo                   float64 `json:\"tempo\"`\n\tTempoConfidence         float64 `json:\"tempo_confidence\"`\n\tKey                     Key     `json:\"key\"`\n\tKeyConfidence           float64 `json:\"key_confidence\"`\n\tMode                    Mode    `json:\"mode\"`\n\tModeConfidence          float64 `json:\"mode_confidence\"`\n\tTimeSignature           int     `json:\"time_signature\"`\n\tTimeSignatureConfidence float64 `json:\"time_signature_confidence\"`\n}\n\n// Segment is characterized by it's perceptual onset and duration in seconds,\n// loudness (dB), pitch and timbral content.\ntype Segment struct {\n\tMarker\n\tLoudnessStart   float64   `json:\"loudness_start\"`\n\tLoudnessMaxTime float64   `json:\"loudness_max_time\"`\n\tLoudnessMax     float64   `json:\"loudness_max\"`\n\tLoudnessEnd     float64   `json:\"loudness_end\"`\n\tPitches         []float64 `json:\"pitches\"`\n\tTimbre          []float64 `json:\"timbre\"`\n}\n\n// AnalysisTrack contains audio analysis data about the track as a whole\ntype AnalysisTrack struct {\n\tNumSamples              int64   `json:\"num_samples\"`\n\tDuration                float64 `json:\"duration\"`\n\tSampleMD5               string  `json:\"sample_md5\"`\n\tOffsetSeconds           int     `json:\"offset_seconds\"`\n\tWindowSeconds           int     `json:\"window_seconds\"`\n\tAnalysisSampleRate      int64   `json:\"analysis_sample_rate\"`\n\tAnalysisChannels        int     `json:\"analysis_channels\"`\n\tEndOfFadeIn             float64 `json:\"end_of_fade_in\"`\n\tStartOfFadeOut          float64 `json:\"start_of_fade_out\"`\n\tLoudness                float64 `json:\"loudness\"`\n\tTempo                   float64 `json:\"tempo\"`\n\tTempoConfidence         float64 `json:\"tempo_confidence\"`\n\tTimeSignature           int     `json:\"time_signature\"`\n\tTimeSignatureConfidence float64 `json:\"time_signature_confidence\"`\n\tKey                     Key     `json:\"key\"`\n\tKeyConfidence           float64 `json:\"key_confidence\"`\n\tMode                    Mode    `json:\"mode\"`\n\tModeConfidence          float64 `json:\"mode_confidence\"`\n\tCodeString              string  `json:\"codestring\"`\n\tCodeVersion             float64 `json:\"code_version\"`\n\tEchoprintString         string  `json:\"echoprintstring\"`\n\tEchoprintVersion        float64 `json:\"echoprint_version\"`\n\tSynchString             string  `json:\"synchstring\"`\n\tSynchVersion            float64 `json:\"synch_version\"`\n\tRhythmString            string  `json:\"rhythmstring\"`\n\tRhythmVersion           float64 `json:\"rhythm_version\"`\n}\n\n// GetAudioAnalysis queries the Spotify web API for an audio analysis of a\n// single track.\nfunc (c *Client) GetAudioAnalysis(id ID) (*AudioAnalysis, error) {\n\turl := fmt.Sprintf(\"%saudio-analysis/%s\", c.baseURL, id)\n\n\ttemp := AudioAnalysis{}\n\n\terr := c.get(url, &temp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &temp, nil\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/audio_analysis_test.go",
    "content": "package spotify\n\nimport (\n\t\"net/http\"\n\t\"reflect\"\n\t\"testing\"\n)\n\nconst fieldsDifferTemplate = \"Actual response is not the same as expected response on field %s\"\n\nvar expected = AudioAnalysis{\n\tBars: []Marker{\n\t\t{\n\t\t\tStart:      251.98282,\n\t\t\tDuration:   0.29765,\n\t\t\tConfidence: 0.652,\n\t\t},\n\t},\n\tBeats: []Marker{\n\t\t{\n\t\t\tStart:      251.98282,\n\t\t\tDuration:   0.29765,\n\t\t\tConfidence: 0.652,\n\t\t},\n\t},\n\tMeta: AnalysisMeta{\n\t\tAnalyzerVersion: \"4.0.0\",\n\t\tPlatform:        \"Linux\",\n\t\tDetailedStatus:  \"OK\",\n\t\tStatusCode:      0,\n\t\tTimestamp:       1456010389,\n\t\tAnalysisTime:    9.1394,\n\t\tInputProcess:    \"libvorbisfile L+R 44100->22050\",\n\t},\n\tSections: []Section{\n\t\t{\n\t\t\tMarker: Marker{\n\t\t\t\tStart:      237.02356,\n\t\t\t\tDuration:   18.32542,\n\t\t\t\tConfidence: 1,\n\t\t\t},\n\t\t\tLoudness:                -20.074,\n\t\t\tTempo:                   98.253,\n\t\t\tTempoConfidence:         0.767,\n\t\t\tKey:                     5,\n\t\t\tKeyConfidence:           0.327,\n\t\t\tMode:                    1,\n\t\t\tModeConfidence:          0.566,\n\t\t\tTimeSignature:           4,\n\t\t\tTimeSignatureConfidence: 1,\n\t\t},\n\t},\n\tSegments: []Segment{\n\t\t{\n\t\t\tMarker: Marker{\n\t\t\t\tStart:      252.15601,\n\t\t\t\tDuration:   3.19297,\n\t\t\t\tConfidence: 0.522,\n\t\t\t},\n\t\t\tLoudnessStart:   -23.356,\n\t\t\tLoudnessMaxTime: 0.06971,\n\t\t\tLoudnessMax:     -18.121,\n\t\t\tLoudnessEnd:     -60,\n\t\t\tPitches:         []float64{0.709, 0.092, 0.196, 0.084, 0.352, 0.134, 0.161, 1, 0.17, 0.161, 0.211, 0.15},\n\t\t\tTimbre:          []float64{23.312, -7.374, -45.719, 294.874, 51.869, -79.384, -89.048, 143.322, -4.676, -51.303, -33.274, -19.037},\n\t\t},\n\t},\n\tTatums: []Marker{\n\t\t{\n\t\t\tStart:      251.98282,\n\t\t\tDuration:   0.29765,\n\t\t\tConfidence: 0.652,\n\t\t},\n\t},\n\tTrack: AnalysisTrack{\n\t\tNumSamples:              100,\n\t\tDuration:                255.34898,\n\t\tSampleMD5:               \"\",\n\t\tOffsetSeconds:           0,\n\t\tWindowSeconds:           0,\n\t\tAnalysisSampleRate:      22050,\n\t\tAnalysisChannels:        1,\n\t\tEndOfFadeIn:             0,\n\t\tStartOfFadeOut:          251.73333,\n\t\tLoudness:                -11.84,\n\t\tTempo:                   98.002,\n\t\tTempoConfidence:         0.423,\n\t\tTimeSignature:           4,\n\t\tTimeSignatureConfidence: 1,\n\t\tKey:              5,\n\t\tKeyConfidence:    0.36,\n\t\tMode:             0,\n\t\tModeConfidence:   0.414,\n\t\tCodeString:       \"eJxVnAmS5DgOBL-ST-B9_P9j4x7M6qoxW9tpsZQSCeI...\",\n\t\tCodeVersion:      3.15,\n\t\tEchoprintString:  \"eJzlvQmSHDmStHslxw4cB-v9j_A-tahhVKV0IH9...\",\n\t\tEchoprintVersion: 4.12,\n\t\tSynchString:      \"eJx1mIlx7ToORFNRCCK455_YoE9Dtt-vmrKsK3EBsTY...\",\n\t\tSynchVersion:     1,\n\t\tRhythmString:     \"eJyNXAmOLT2r28pZQuZh_xv7g21Iqu_3pCd160xV...\",\n\t\tRhythmVersion:    1,\n\t},\n}\n\nfunc TestAudioAnalysis(t *testing.T) {\n\tc, s := testClientFile(http.StatusOK, \"test_data/get_audio_analysis.txt\")\n\tdefer s.Close()\n\n\tanalysis, err := c.GetAudioAnalysis(\"foo\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\n\tif !reflect.DeepEqual(analysis.Bars, expected.Bars) {\n\t\tt.Errorf(fieldsDifferTemplate, \"Bars\")\n\t}\n\n\tif !reflect.DeepEqual(analysis.Beats, expected.Beats) {\n\t\tt.Errorf(fieldsDifferTemplate, \"Beats\")\n\t}\n\n\tif !reflect.DeepEqual(analysis.Meta, expected.Meta) {\n\t\tt.Errorf(fieldsDifferTemplate, \"Meta\")\n\t}\n\n\tif !reflect.DeepEqual(analysis.Sections, expected.Sections) {\n\t\tt.Errorf(fieldsDifferTemplate, \"Sections\")\n\t}\n\n\tif !reflect.DeepEqual(analysis.Segments, expected.Segments) {\n\t\tt.Errorf(fieldsDifferTemplate, \"Segments\")\n\t}\n\n\tif !reflect.DeepEqual(analysis.Track, expected.Track) {\n\t\tt.Errorf(fieldsDifferTemplate, \"Track\")\n\t}\n\n\tif !reflect.DeepEqual(analysis.Tatums, expected.Tatums) {\n\t\tt.Errorf(fieldsDifferTemplate, \"Tatums\")\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/audio_features.go",
    "content": "package spotify\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\n// AudioFeatures contains various high-level acoustic attributes\n// for a particular track.\ntype AudioFeatures struct {\n\t//Acousticness is a confidence measure from 0.0 to 1.0 of whether\n\t// the track is acoustic.  A value of 1.0 represents high confidence\n\t// that the track is acoustic.\n\tAcousticness float32 `json:\"acousticness\"`\n\t// An HTTP URL to access the full audio analysis of the track.\n\t// The URL is cryptographically signed and configured to expire\n\t// after roughly 10 minutes.  Do not store these URLs for later use.\n\tAnalysisURL string `json:\"analysis_url\"`\n\t// Danceability describes how suitable a track is for dancing based\n\t// on a combination of musical elements including tempo, rhythm stability,\n\t// beat strength, and overall regularity.  A value of 0.0 is least danceable\n\t// and 1.0 is most danceable.\n\tDanceability float32 `json:\"danceability\"`\n\t// The length of the track in milliseconds.\n\tDuration int `json:\"duration_ms\"`\n\t// Energy is a measure from 0.0 to 1.0 and represents a perceptual mesaure\n\t// of intensity and activity.  Typically, energetic tracks feel fast, loud,\n\t// and noisy.\n\tEnergy float32 `json:\"energy\"`\n\t// The Spotify ID for the track.\n\tID ID `json:\"id\"`\n\t// Predicts whether a track contains no vocals.  \"Ooh\" and \"aah\" sounds are\n\t// treated as instrumental in this context.  Rap or spoken words are clearly\n\t// \"vocal\".  The closer the Instrumentalness value is to 1.0, the greater\n\t// likelihood the track contains no vocal content.  Values above 0.5 are\n\t// intended to represent instrumental tracks, but confidence is higher as the\n\t// value approaches 1.0.\n\tInstrumentalness float32 `json:\"instrumentalness\"`\n\t// The key the track is in.  Integers map to pitches using standard Pitch Class notation\n\t// (https://en.wikipedia.org/wiki/Pitch_class).\n\tKey int `json:\"key\"`\n\t// Detects the presence of an audience in the recording.  Higher liveness\n\t// values represent an increased probability that the track was performed live.\n\t// A value above 0.8 provides strong likelihook that the track is live.\n\tLiveness float32 `json:\"liveness\"`\n\t// The overall loudness of a track in decibels (dB).  Loudness values are\n\t// averaged across the entire track and are useful for comparing the relative\n\t// loudness of tracks.  Typical values range between -60 and 0 dB.\n\tLoudness float32 `json:\"loudness\"`\n\t// Mode indicates the modality (major or minor) of a track.\n\tMode int `json:\"mode\"`\n\t// Detects the presence of spoken words in a track.  The more exclusively\n\t// speech-like the recording, the closer to 1.0 the speechiness will be.\n\t// Values above 0.66 describe tracks that are probably made entirely of\n\t// spoken words.  Values between 0.33 and 0.66 describe tracks that may\n\t// contain both music and speech, including such cases as rap music.\n\t// Values below 0.33 most likely represent music and other non-speech-like tracks.\n\tSpeechiness float32 `json:\"speechiness\"`\n\t// The overall estimated tempo of the track in beats per minute (BPM).\n\tTempo float32 `json:\"tempo\"`\n\t// An estimated overall time signature of a track.  The time signature (meter)\n\t// is a notational convention to specify how many beats are in each bar (or measure).\n\tTimeSignature int `json:\"time_signature\"`\n\t// A link to the Web API endpoint providing full details of the track.\n\tTrackURL string `json:\"track_href\"`\n\t// The Spotify URI for the track.\n\tURI URI `json:\"uri\"`\n\t// A measure from 0.0 to 1.0 describing the musical positiveness conveyed\n\t// by a track.  Tracks with high valence sound more positive (e.g. happy,\n\t// cheerful, euphoric), while tracks with low valence sound more negative\n\t// (e.g. sad, depressed, angry).\n\tValence float32 `json:\"valence\"`\n}\n\n// Key represents a pitch using Pitch Class notation.\ntype Key int\n\nconst (\n\tC Key = iota\n\tCSharp\n\tD\n\tDSharp\n\tE\n\tF\n\tFSharp\n\tG\n\tGSharp\n\tA\n\tASharp\n\tB\n\tDFlat = CSharp\n\tEFlat = DSharp\n\tGFlat = FSharp\n\tAFlat = GSharp\n\tBFlat = ASharp\n)\n\n// Mode indicates the modality (major or minor) of a track.\ntype Mode int\n\nconst (\n\tMinor Mode = iota\n\tMajor\n)\n\n// GetAudioFeatures queries the Spotify Web API for various\n// high-level acoustic attributes of audio tracks.\n// Objects are returned in the order requested.  If an object\n// is not found, a nil value is returned in the appropriate position.\nfunc (c *Client) GetAudioFeatures(ids ...ID) ([]*AudioFeatures, error) {\n\turl := fmt.Sprintf(\"%saudio-features?ids=%s\", c.baseURL, strings.Join(toStringSlice(ids), \",\"))\n\n\ttemp := struct {\n\t\tF []*AudioFeatures `json:\"audio_features\"`\n\t}{}\n\n\terr := c.get(url, &temp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn temp.F, nil\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/audio_features_test.go",
    "content": "package spotify\n\nimport (\n\t\"net/http\"\n\t\"testing\"\n)\n\nvar response = `\n{\n  \"audio_features\" : [ {\n    \"danceability\" : 0.808,\n    \"energy\" : 0.626,\n    \"key\" : 7,\n    \"loudness\" : -12.733,\n    \"mode\" : 1,\n    \"speechiness\" : 0.168,\n    \"acousticness\" : 0.00187,\n    \"instrumentalness\" : 0.159,\n    \"liveness\" : 0.376,\n    \"valence\" : 0.369,\n    \"tempo\" : 123.990,\n    \"type\" : \"audio_features\",\n    \"id\" : \"4JpKVNYnVcJ8tuMKjAj50A\",\n    \"uri\" : \"spotify:track:4JpKVNYnVcJ8tuMKjAj50A\",\n    \"track_href\" : \"https://api.spotify.com/v1/tracks/4JpKVNYnVcJ8tuMKjAj50A\",\n    \"analysis_url\" : \"http://echonest-analysis.s3.amazonaws.com/TR/WhpYUARk1kNJ_qP0AdKGcDDFKOQTTgsOoINrqyPQjkUnbteuuBiyj_u94iFCSGzdxGiwqQ6d77f4QLL_8=/3/full.json?AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ&Expires=1459290544&Signature=4P03WGLL1a/%2BXp90jcsLGMfFC3Y%3D\",\n    \"duration_ms\" : 535223,\n    \"time_signature\" : 4\n  }, {\n    \"danceability\" : 0.457,\n    \"energy\" : 0.815,\n    \"key\" : 1,\n    \"loudness\" : -7.199,\n    \"mode\" : 1,\n    \"speechiness\" : 0.0340,\n    \"acousticness\" : 0.102,\n    \"instrumentalness\" : 0.0319,\n    \"liveness\" : 0.103,\n    \"valence\" : 0.382,\n    \"tempo\" : 96.083,\n    \"type\" : \"audio_features\",\n    \"id\" : \"2NRANZE9UCmPAS5XVbXL40\",\n    \"uri\" : \"spotify:track:2NRANZE9UCmPAS5XVbXL40\",\n    \"track_href\" : \"https://api.spotify.com/v1/tracks/2NRANZE9UCmPAS5XVbXL40\",\n    \"analysis_url\" : \"http://echonest-analysis.s3.amazonaws.com/TR/WhuQhwPDhmEg5TO4JjbJu0my-awIhk3eaXkRd1ofoJ7tXogPnMtbxkTyLOeHXu5Jke0FCIt52saKJyfPM=/3/full.json?AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ&Expires=1459290544&Signature=Jsg/GexxC7v06Tq70coL/d2x7kI%3D\",\n    \"duration_ms\" : 187800,\n    \"time_signature\" : 4\n  }, null, {\n    \"danceability\" : 0.281,\n    \"energy\" : 0.402,\n    \"key\" : 4,\n    \"loudness\" : -17.921,\n    \"mode\" : 1,\n    \"speechiness\" : 0.0291,\n    \"acousticness\" : 0.0734,\n    \"instrumentalness\" : 0.830,\n    \"liveness\" : 0.0593,\n    \"valence\" : 0.0748,\n    \"tempo\" : 115.700,\n    \"type\" : \"audio_features\",\n    \"id\" : \"24JygzOLM0EmRQeGtFcIcG\",\n    \"uri\" : \"spotify:track:24JygzOLM0EmRQeGtFcIcG\",\n    \"track_href\" : \"https://api.spotify.com/v1/tracks/24JygzOLM0EmRQeGtFcIcG\",\n    \"analysis_url\" : \"http://echonest-analysis.s3.amazonaws.com/TR/ehbkMg05Ck-FN7p3lV7vd8TUdBCvM6z5mgDiZRv6iSlw8P_b8GYBZ4PRAlOgTl3e5rS34_l3dZGDeYzH4=/3/full.json?AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ&Expires=1459290544&Signature=09T3QyRucjrOMoMutRmdJKLJ7hI%3D\",\n    \"duration_ms\" : 497493,\n    \"time_signature\" : 3\n  } ]\n}\n`\n\nfunc TestAudioFeatures(t *testing.T) {\n\tc, s := testClientString(http.StatusOK, response)\n\tdefer s.Close()\n\n\tids := []ID{\n\t\t\"4JpKVNYnVcJ8tuMKjAj50A\",\n\t\t\"2NRANZE9UCmPAS5XVbXL40\",\n\t\t\"abc\", // intentionally throw a bad one in\n\t\t\"24JygzOLM0EmRQeGtFcIcG\",\n\t}\n\tfeatures, err := c.GetAudioFeatures()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(features) != len(ids) {\n\t\tt.Errorf(\"Want %d results, got %d\\n\", len(ids), len(features))\n\t}\n\tif features[2] != nil {\n\t\tt.Errorf(\"Want nil result, got #%v\\n\", features[2])\n\t}\n\tif Key(features[0].Key) != G {\n\t\tt.Errorf(\"Want key G, got %v\\n\", features[0].Key)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/auth.go",
    "content": "package spotify\n\nimport (\n\t\"context\"\n\t\"crypto/tls\"\n\t\"errors\"\n\t\"net/http\"\n\t\"os\"\n\n\t\"golang.org/x/oauth2\"\n)\n\nconst (\n\t// AuthURL is the URL to Spotify Accounts Service's OAuth2 endpoint.\n\tAuthURL = \"https://accounts.spotify.com/authorize\"\n\t// TokenURL is the URL to the Spotify Accounts Service's OAuth2\n\t// token endpoint.\n\tTokenURL = \"https://accounts.spotify.com/api/token\"\n)\n\n// Scopes let you specify exactly which types of data your application wants to access.\n// The set of scopes you pass in your authentication request determines what access the\n// permissions the user is asked to grant.\nconst (\n\t// ScopeImageUpload seeks permission to upload images to Spotify on your behalf.\n\tScopeImageUpload = \"ugc-image-upload\"\n\t// ScopePlaylistReadPrivate seeks permission to read\n\t// a user's private playlists.\n\tScopePlaylistReadPrivate = \"playlist-read-private\"\n\t// ScopePlaylistModifyPublic seeks write access\n\t// to a user's public playlists.\n\tScopePlaylistModifyPublic = \"playlist-modify-public\"\n\t// ScopePlaylistModifyPrivate seeks write access to\n\t// a user's private playlists.\n\tScopePlaylistModifyPrivate = \"playlist-modify-private\"\n\t// ScopePlaylistReadCollaborative seeks permission to\n\t// access a user's collaborative playlists.\n\tScopePlaylistReadCollaborative = \"playlist-read-collaborative\"\n\t// ScopeUserFollowModify seeks write/delete access to\n\t// the list of artists and other users that a user follows.\n\tScopeUserFollowModify = \"user-follow-modify\"\n\t// ScopeUserFollowRead seeks read access to the list of\n\t// artists and other users that a user follows.\n\tScopeUserFollowRead = \"user-follow-read\"\n\t// ScopeUserLibraryModify seeks write/delete access to a\n\t// user's \"Your Music\" library.\n\tScopeUserLibraryModify = \"user-library-modify\"\n\t// ScopeUserLibraryRead seeks read access to a user's \"Your Music\" library.\n\tScopeUserLibraryRead = \"user-library-read\"\n\t// ScopeUserReadPrivate seeks read access to a user's\n\t// subsription details (type of user account).\n\tScopeUserReadPrivate = \"user-read-private\"\n\t// ScopeUserReadEmail seeks read access to a user's email address.\n\tScopeUserReadEmail = \"user-read-email\"\n\t// ScopeUserReadBirthdate seeks read access to a user's birthdate.\n\tScopeUserReadBirthdate = \"user-read-birthdate\"\n\t// ScopeUserReadCurrentlyPlaying seeks read access to a user's currently playing track\n\tScopeUserReadCurrentlyPlaying = \"user-read-currently-playing\"\n\t// ScopeUserReadPlaybackState seeks read access to the user's current playback state\n\tScopeUserReadPlaybackState = \"user-read-playback-state\"\n\t// ScopeUserModifyPlaybackState seeks write access to the user's current playback state\n\tScopeUserModifyPlaybackState = \"user-modify-playback-state\"\n\t// ScopeUserReadRecentlyPlayed allows access to a user's recently-played songs\n\tScopeUserReadRecentlyPlayed = \"user-read-recently-played\"\n\t// ScopeUserTopRead seeks read access to a user's top tracks and artists\n\tScopeUserTopRead = \"user-top-read\"\n)\n\n// Authenticator provides convenience functions for implementing the OAuth2 flow.\n// You should always use `NewAuthenticator` to make them.\n//\n// Example:\n//\n//     a := spotify.NewAuthenticator(redirectURL, spotify.ScopeUserLibaryRead, spotify.ScopeUserFollowRead)\n//     // direct user to Spotify to log in\n//     http.Redirect(w, r, a.AuthURL(\"state-string\"), http.StatusFound)\n//\n//     // then, in redirect handler:\n//     token, err := a.Token(state, r)\n//     client := a.NewClient(token)\n//\ntype Authenticator struct {\n\tconfig  *oauth2.Config\n\tcontext context.Context\n}\n\n// NewAuthenticator creates an authenticator which is used to implement the\n// OAuth2 authorization flow.  The redirectURL must exactly match one of the\n// URLs specified in your Spotify developer account.\n//\n// By default, NewAuthenticator pulls your client ID and secret key from the\n// SPOTIFY_ID and SPOTIFY_SECRET environment variables.  If you'd like to provide\n// them from some other source, you can call `SetAuthInfo(id, key)` on the\n// returned authenticator.\nfunc NewAuthenticator(redirectURL string, scopes ...string) Authenticator {\n\tcfg := &oauth2.Config{\n\t\tClientID:     os.Getenv(\"SPOTIFY_ID\"),\n\t\tClientSecret: os.Getenv(\"SPOTIFY_SECRET\"),\n\t\tRedirectURL:  redirectURL,\n\t\tScopes:       scopes,\n\t\tEndpoint: oauth2.Endpoint{\n\t\t\tAuthURL:  AuthURL,\n\t\t\tTokenURL: TokenURL,\n\t\t},\n\t}\n\n\t// disable HTTP/2 for DefaultClient, see: https://github.com/zmb3/spotify/issues/20\n\ttr := &http.Transport{\n\t\tTLSNextProto: map[string]func(authority string, c *tls.Conn) http.RoundTripper{},\n\t}\n\tctx := context.WithValue(context.Background(), oauth2.HTTPClient, &http.Client{Transport: tr})\n\treturn Authenticator{\n\t\tconfig:  cfg,\n\t\tcontext: ctx,\n\t}\n}\n\n// SetAuthInfo overwrites the client ID and secret key used by the authenticator.\n// You can use this if you don't want to store this information in environment variables.\nfunc (a *Authenticator) SetAuthInfo(clientID, secretKey string) {\n\ta.config.ClientID = clientID\n\ta.config.ClientSecret = secretKey\n}\n\n// AuthURL returns a URL to the the Spotify Accounts Service's OAuth2 endpoint.\n//\n// State is a token to protect the user from CSRF attacks.  You should pass the\n// same state to `Token`, where it will be validated.  For more info, refer to\n// http://tools.ietf.org/html/rfc6749#section-10.12.\nfunc (a Authenticator) AuthURL(state string) string {\n\treturn a.config.AuthCodeURL(state)\n}\n\n// Token pulls an authorization code from an HTTP request and attempts to exchange\n// it for an access token.  The standard use case is to call Token from the handler\n// that handles requests to your application's redirect URL.\nfunc (a Authenticator) Token(state string, r *http.Request) (*oauth2.Token, error) {\n\tvalues := r.URL.Query()\n\tif e := values.Get(\"error\"); e != \"\" {\n\t\treturn nil, errors.New(\"spotify: auth failed - \" + e)\n\t}\n\tcode := values.Get(\"code\")\n\tif code == \"\" {\n\t\treturn nil, errors.New(\"spotify: didn't get access code\")\n\t}\n\tactualState := values.Get(\"state\")\n\tif actualState != state {\n\t\treturn nil, errors.New(\"spotify: redirect state parameter doesn't match\")\n\t}\n\treturn a.config.Exchange(a.context, code)\n}\n\n// Exchange is like Token, except it allows you to manually specify the access\n// code instead of pulling it out of an HTTP request.\nfunc (a Authenticator) Exchange(code string) (*oauth2.Token, error) {\n\treturn a.config.Exchange(a.context, code)\n}\n\n// NewClient creates a Client that will use the specified access token for its API requests.\nfunc (a Authenticator) NewClient(token *oauth2.Token) Client {\n\tclient := a.config.Client(a.context, token)\n\treturn Client{\n\t\thttp:    client,\n\t\tbaseURL: baseAddress,\n\t}\n}\n\n// Token gets the client's current token.\nfunc (c *Client) Token() (*oauth2.Token, error) {\n\ttransport, ok := c.http.Transport.(*oauth2.Transport)\n\tif !ok {\n\t\treturn nil, errors.New(\"spotify: oauth2 transport type not correct\")\n\t}\n\tt, err := transport.Source.Token()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn t, nil\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/category.go",
    "content": "package spotify\n\nimport (\n\t\"fmt\"\n\t\"net/url\"\n\t\"strconv\"\n)\n\n// Category is used by Spotify to tag items in.  For example, on the Spotify\n// player's \"Browse\" tab.\ntype Category struct {\n\t// A link to the Web API endpoint returning full details of the category\n\tEndpoint string `json:\"href\"`\n\t// The category icon, in various sizes\n\tIcons []Image `json:\"icons\"`\n\t// The Spotify category ID.  This isn't a base-62 Spotify ID, its just\n\t// a short string that describes and identifies the category (ie \"party\").\n\tID string `json:\"id\"`\n\t// The name of the category\n\tName string `json:\"name\"`\n}\n\n// GetCategoryOpt is like GetCategory, but it accepts optional arguments.\n// The country parameter is an ISO 3166-1 alpha-2 country code.  It can be\n// used to ensure that the category exists for a particular country.  The\n// locale argument is an ISO 639 language code and an ISO 3166-1 alpha-2\n// country code, separated by an underscore.  It can be used to get the\n// category strings in a particular language (for example: \"es_MX\" means\n// get categories in Mexico, returned in Spanish).\n//\n// This call requries authorization.\nfunc (c *Client) GetCategoryOpt(id, country, locale string) (Category, error) {\n\tcat := Category{}\n\tspotifyURL := fmt.Sprintf(\"%sbrowse/categories/%s\", c.baseURL, id)\n\tvalues := url.Values{}\n\tif country != \"\" {\n\t\tvalues.Set(\"country\", country)\n\t}\n\tif locale != \"\" {\n\t\tvalues.Set(\"locale\", locale)\n\t}\n\tif query := values.Encode(); query != \"\" {\n\t\tspotifyURL += \"?\" + query\n\t}\n\n\terr := c.get(spotifyURL, &cat)\n\tif err != nil {\n\t\treturn cat, err\n\t}\n\n\treturn cat, err\n}\n\n// GetCategory gets a single category used to tag items in Spotify\n// (on, for example, the Spotify player's Browse tab).\nfunc (c *Client) GetCategory(id string) (Category, error) {\n\treturn c.GetCategoryOpt(id, \"\", \"\")\n}\n\n// GetCategoryPlaylists gets a list of Spotify playlists tagged with a paricular category.\nfunc (c *Client) GetCategoryPlaylists(catID string) (*SimplePlaylistPage, error) {\n\treturn c.GetCategoryPlaylistsOpt(catID, nil)\n}\n\n// GetCategoryPlaylistsOpt is like GetCategoryPlaylists, but it accepts optional\n// arguments.\nfunc (c *Client) GetCategoryPlaylistsOpt(catID string, opt *Options) (*SimplePlaylistPage, error) {\n\tspotifyURL := fmt.Sprintf(\"%sbrowse/categories/%s/playlists\", c.baseURL, catID)\n\tif opt != nil {\n\t\tvalues := url.Values{}\n\t\tif opt.Country != nil {\n\t\t\tvalues.Set(\"country\", *opt.Country)\n\t\t}\n\t\tif opt.Limit != nil {\n\t\t\tvalues.Set(\"limit\", strconv.Itoa(*opt.Limit))\n\t\t}\n\t\tif opt.Offset != nil {\n\t\t\tvalues.Set(\"offset\", strconv.Itoa(*opt.Offset))\n\t\t}\n\t\tif query := values.Encode(); query != \"\" {\n\t\t\tspotifyURL += \"?\" + query\n\t\t}\n\t}\n\n\twrapper := struct {\n\t\tPlaylists SimplePlaylistPage `json:\"playlists\"`\n\t}{}\n\n\terr := c.get(spotifyURL, &wrapper)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &wrapper.Playlists, nil\n}\n\n// GetCategories gets a list of categories used to tag items in Spotify\n// (on, for example, the Spotify player's \"Browse\" tab).\nfunc (c *Client) GetCategories() (*CategoryPage, error) {\n\treturn c.GetCategoriesOpt(nil, \"\")\n}\n\n// GetCategoriesOpt is like GetCategories, but it accepts optional parameters.\n//\n// The locale option can be used to get the results in a particular language.\n// It consists of an ISO 639 language code and an ISO 3166-1 alpha-2 country\n// code, separated by an underscore.  Specify the empty string to have results\n// returned in the Spotify default language (American English).\nfunc (c *Client) GetCategoriesOpt(opt *Options, locale string) (*CategoryPage, error) {\n\tspotifyURL := c.baseURL + \"browse/categories\"\n\tvalues := url.Values{}\n\tif locale != \"\" {\n\t\tvalues.Set(\"locale\", locale)\n\t}\n\tif opt != nil {\n\t\tif opt.Country != nil {\n\t\t\tvalues.Set(\"country\", *opt.Country)\n\t\t}\n\t\tif opt.Limit != nil {\n\t\t\tvalues.Set(\"limit\", strconv.Itoa(*opt.Limit))\n\t\t}\n\t\tif opt.Offset != nil {\n\t\t\tvalues.Set(\"offset\", strconv.Itoa(*opt.Offset))\n\t\t}\n\t}\n\tif query := values.Encode(); query != \"\" {\n\t\tspotifyURL += \"?\" + query\n\t}\n\n\twrapper := struct {\n\t\tCategories CategoryPage `json:\"categories\"`\n\t}{}\n\n\terr := c.get(spotifyURL, &wrapper)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &wrapper.Categories, nil\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/category_test.go",
    "content": "package spotify\n\nimport (\n\t\"net/http\"\n\t\"testing\"\n)\n\nfunc TestGetCategories(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, getCategories)\n\tdefer server.Close()\n\n\tpage, err := client.GetCategories()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif l := len(page.Categories); l != 2 {\n\t\tt.Fatalf(\"Expected 2 categories, got %d\\n\", l)\n\t}\n\tif name := page.Categories[1].Name; name != \"Mood\" {\n\t\tt.Errorf(\"Expected 'Mood', got '%s'\", name)\n\t}\n}\n\nfunc TestGetCategory(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, getCategory)\n\tdefer server.Close()\n\n\tcat, err := client.GetCategory(\"dinner\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif cat.ID != \"dinner\" || cat.Name != \"Dinner\" {\n\t\tt.Errorf(\"Invalid name/id (%s, %s)\\n\", cat.Name, cat.ID)\n\t}\n}\n\nfunc TestGetCategoryPlaylists(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, getCategoryPlaylists)\n\tdefer server.Close()\n\n\tpage, err := client.GetCategoryPlaylists(\"dinner\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif l := len(page.Playlists); l != 2 {\n\t\tt.Fatalf(\"Expected 2 playlists, got %d\\n\", l)\n\t}\n\tif name := page.Playlists[0].Name; name != \"Dinner with Friends\" {\n\t\tt.Errorf(\"Expected 'Dinner with Friends', got '%s'\\n\", name)\n\t}\n\tif tracks := page.Playlists[1].Tracks.Total; tracks != 91 {\n\t\tt.Errorf(\"Expected 'Dinner Music' to have 91 tracks, but got %d\\n\", tracks)\n\t}\n\tif page.Total != 36 {\n\t\tt.Errorf(\"Expected 26 playlists in category 'dinner' - got %d\\n\", page.Total)\n\t}\n}\n\nfunc TestGetCategoryOpt(t *testing.T) {\n\tclient, server := testClientString(http.StatusNotFound, \"\", func(r *http.Request) {\n\t\t// verify that the optional parameters were included in the request\n\t\tvalues := r.URL.Query()\n\t\tif c := values.Get(\"country\"); c != CountryBrazil {\n\t\t\tt.Errorf(\"Expected country '%s', got '%s'\\n\", CountryBrazil, c)\n\t\t}\n\t\tif l := values.Get(\"locale\"); l != \"es_MX\" {\n\t\t\tt.Errorf(\"Expected locale 'es_MX', got '%s'\\n\", l)\n\t\t}\n\t})\n\tdefer server.Close()\n\n\t_, err := client.GetCategoryOpt(\"id\", CountryBrazil, \"es_MX\")\n\tif err == nil {\n\t\tt.Fatal(\"Expected error\")\n\t}\n}\n\nfunc TestGetCategoryPlaylistsOpt(t *testing.T) {\n\tclient, server := testClientString(http.StatusNotFound, \"\", func(r *http.Request) {\n\t\tvalues := r.URL.Query()\n\t\tif c := values.Get(\"country\"); c != \"\" {\n\t\t\tt.Errorf(\"Country should not have been set, got %s\\n\", c)\n\t\t}\n\t\tif l := values.Get(\"limit\"); l != \"5\" {\n\t\t\tt.Errorf(\"Expected limit 5, got %s\\n\", l)\n\t\t}\n\t\tif o := values.Get(\"offset\"); o != \"10\" {\n\t\t\tt.Errorf(\"Expected offset 10, got %s\\n\", o)\n\t\t}\n\t})\n\tdefer server.Close()\n\n\topt := &Options{}\n\topt.Limit = new(int)\n\topt.Offset = new(int)\n\t*opt.Limit = 5\n\t*opt.Offset = 10\n\tclient.GetCategoryPlaylistsOpt(\"id\", opt)\n}\n\nfunc TestGetCategoriesInvalidToken(t *testing.T) {\n\tclient, server := testClientString(http.StatusUnauthorized, invalidToken)\n\tdefer server.Close()\n\n\t_, err := client.GetCategories()\n\tif err == nil {\n\t\tt.Fatal(\"Expected error but didn't get one\")\n\t}\n\tserr, ok := err.(Error)\n\tif !ok {\n\t\tt.Fatal(\"Expected a 'spotify.Error'\")\n\t}\n\tif serr.Status != http.StatusUnauthorized {\n\t\tt.Error(\"Error didn't have status code 401\")\n\t}\n}\n\nvar getCategories = `\n{\n  \"categories\" : {\n    \"href\" : \"https://api.spotify.com/v1/browse/categories?country=CA&offset=0&limit=2\",\n    \"items\" : [ {\n      \"href\" : \"https://api.spotify.com/v1/browse/categories/toplists\",\n      \"icons\" : [ {\n        \"height\" : 275,\n        \"url\" : \"https://datsnxq1rwndn.cloudfront.net/media/derived/toplists_11160599e6a04ac5d6f2757f5511778f_0_0_275_275.jpg\",\n        \"width\" : 275\n      } ],\n      \"id\" : \"toplists\",\n      \"name\" : \"Top Lists\"\n    }, {\n      \"href\" : \"https://api.spotify.com/v1/browse/categories/mood\",\n      \"icons\" : [ {\n        \"height\" : 274,\n        \"url\" : \"https://datsnxq1rwndn.cloudfront.net/media/original/mood-274x274_976986a31ac8c49794cbdc7246fd5ad7_274x274.jpg\",\n        \"width\" : 274\n      } ],\n      \"id\" : \"mood\",\n      \"name\" : \"Mood\"\n    } ],\n    \"limit\" : 2,\n    \"next\" : \"https://api.spotify.com/v1/browse/categories?country=CA&offset=2&limit=2\",\n    \"offset\" : 0,\n    \"previous\" : null,\n    \"total\" : 31\n  }\n}`\n\nvar getCategory = `\n{\n  \"href\" : \"https://api.spotify.com/v1/browse/categories/dinner\",\n  \"icons\" : [ {\n    \"height\" : 274,\n    \"url\" : \"https://datsnxq1rwndn.cloudfront.net/media/original/dinner_1b6506abba0ba52c54e6d695c8571078_274x274.jpg\",\n    \"width\" : 274\n  } ],\n  \"id\" : \"dinner\",\n  \"name\" : \"Dinner\"\n}`\n\nvar getCategoryPlaylists = `\n{\n  \"playlists\" : {\n    \"href\" : \"https://api.spotify.com/v1/browse/categories/dinner/playlists?offset=0&limit=2\",\n    \"items\" : [ {\n      \"collaborative\" : false,\n      \"external_urls\" : {\n        \"spotify\" : \"http://open.spotify.com/user/spotify/playlist/59ZbFPES4DQwEjBpWHzrtC\"\n      },\n      \"href\" : \"https://api.spotify.com/v1/users/spotify/playlists/59ZbFPES4DQwEjBpWHzrtC\",\n      \"id\" : \"59ZbFPES4DQwEjBpWHzrtC\",\n      \"images\" : [ {\n        \"height\" : 300,\n        \"url\" : \"https://i.scdn.co/image/68b6a65573a55095e9c0c0c33a274b18e0422736\",\n        \"width\" : 300\n      } ],\n      \"name\" : \"Dinner with Friends\",\n      \"owner\" : {\n        \"external_urls\" : {\n          \"spotify\" : \"http://open.spotify.com/user/spotify\"\n        },\n        \"href\" : \"https://api.spotify.com/v1/users/spotify\",\n        \"id\" : \"spotify\",\n        \"type\" : \"user\",\n        \"uri\" : \"spotify:user:spotify\"\n      },\n      \"public\" : null,\n      \"tracks\" : {\n        \"href\" : \"https://api.spotify.com/v1/users/spotify/playlists/59ZbFPES4DQwEjBpWHzrtC/tracks\",\n        \"total\" : 98\n      },\n      \"type\" : \"playlist\",\n      \"uri\" : \"spotify:user:spotify:playlist:59ZbFPES4DQwEjBpWHzrtC\"\n    }, {\n      \"collaborative\" : false,\n      \"external_urls\" : {\n        \"spotify\" : \"http://open.spotify.com/user/spotify/playlist/1WDw5izv4UhpobNdGXQug7\"\n      },\n      \"href\" : \"https://api.spotify.com/v1/users/spotify/playlists/1WDw5izv4UhpobNdGXQug7\",\n      \"id\" : \"1WDw5izv4UhpobNdGXQug7\",\n      \"images\" : [ {\n        \"height\" : 300,\n        \"url\" : \"https://i.scdn.co/image/acdcc5e1aa4e9c1db523d684a35f9c0785e50152\",\n        \"width\" : 300\n      } ],\n      \"name\" : \"Dinner Music\",\n      \"owner\" : {\n        \"external_urls\" : {\n          \"spotify\" : \"http://open.spotify.com/user/spotify\"\n        },\n        \"href\" : \"https://api.spotify.com/v1/users/spotify\",\n        \"id\" : \"spotify\",\n        \"type\" : \"user\",\n        \"uri\" : \"spotify:user:spotify\"\n      },\n      \"public\" : null,\n      \"tracks\" : {\n        \"href\" : \"https://api.spotify.com/v1/users/spotify/playlists/1WDw5izv4UhpobNdGXQug7/tracks\",\n        \"total\" : 91\n      },\n      \"type\" : \"playlist\",\n      \"uri\" : \"spotify:user:spotify:playlist:1WDw5izv4UhpobNdGXQug7\"\n    } ],\n    \"limit\" : 2,\n    \"next\" : \"https://api.spotify.com/v1/browse/categories/dinner/playlists?offset=2&limit=2\",\n    \"offset\" : 0,\n    \"previous\" : null,\n    \"total\" : 36\n  }\n}`\n\nvar invalidToken = `\n{\n  \"error\": {\n    \"status\": 401,\n    \"message\": \"Invalid access token\"\n  }\n}`\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/countries.go",
    "content": "package spotify\n\n// ISO 3166-1 alpha 2 country codes.\n//\n// see: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2\nconst (\n\tCountryArgentina          = \"AR\"\n\tCountryAustralia          = \"AU\"\n\tCountryAustria            = \"AT\"\n\tCountryBelarus            = \"BY\"\n\tCountryBelgium            = \"BE\"\n\tCountryBrazil             = \"BR\"\n\tCountryCanada             = \"CA\"\n\tCountryChile              = \"CL\"\n\tCountryChina              = \"CN\"\n\tCountryGermany            = \"DE\"\n\tCountryHongKong           = \"HK\"\n\tCountryIreland            = \"IE\"\n\tCountryIndia              = \"IN\"\n\tCountryItaly              = \"IT\"\n\tCountryJapan              = \"JP\"\n\tCountrySpain              = \"ES\"\n\tCountryFinland            = \"FI\"\n\tCountryFrance             = \"FR\"\n\tCountryMexico             = \"MX\"\n\tCountryNewZealand         = \"NZ\"\n\tCountryRussia             = \"RU\"\n\tCountrySwitzerland        = \"CH\"\n\tCountryUnitedArabEmirates = \"AE\"\n\tCountryUnitedKingdom      = \"GB\"\n\tCountryUSA                = \"US\"\n)\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/cursor.go",
    "content": "package spotify\n\n// This file contains the types that implement Spotify's cursor-based\n// paging object.  Like the standard paging object, this object is a\n// container for a set of items. Unlike the standard paging object, a\n// cursor-based paging object does not provide random access to the results.\n\n// Cursor contains a key that can be used to find the next set\n// of items.\ntype Cursor struct {\n\tAfter string `json:\"after\"`\n}\n\n// cursorPage contains all of the fields in a Spotify cursor-based\n// paging object, except for the actual items.  This type is meant\n// to be embedded in other types that add the Items field.\ntype cursorPage struct {\n\t// A link to the Web API endpoint returning the full\n\t// result of this request.\n\tEndpoint string `json:\"href\"`\n\t// The maximum number of items returned, as set in the query\n\t// (or default value if unset).\n\tLimit int `json:\"limit\"`\n\t// The URL to the next set of items.\n\tNext string `json:\"next\"`\n\t// The total number of items available to return.\n\tTotal int `json:\"total\"`\n\t// The cursor used to find the next set of items.\n\tCursor Cursor `json:\"cursors\"`\n}\n\n// FullArtistCursorPage is a cursor-based paging object containing\n// a set of FullArtist objects.\ntype FullArtistCursorPage struct {\n\tcursorPage\n\tArtists []FullArtist `json:\"items\"`\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/full_tests.bat",
    "content": "@echo off\nREM - The tests that actually hit the Spotify Web API don't run by default.\nREM - Use this script to run them in addition to the standard unit tests.\n\ncmd /C \"set FULLTEST=y && go test %*\"\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/library.go",
    "content": "package spotify\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"strings\"\n)\n\n// UserHasTracks checks if one or more tracks are saved to the current user's\n// \"Your Music\" library.\nfunc (c *Client) UserHasTracks(ids ...ID) ([]bool, error) {\n\tif l := len(ids); l == 0 || l > 50 {\n\t\treturn nil, errors.New(\"spotify: UserHasTracks supports 1 to 50 IDs per call\")\n\t}\n\tspotifyURL := fmt.Sprintf(\"%sme/tracks/contains?ids=%s\", c.baseURL, strings.Join(toStringSlice(ids), \",\"))\n\n\tvar result []bool\n\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn result, err\n}\n\n// AddTracksToLibrary saves one or more tracks to the current user's\n// \"Your Music\" library.  This call requires the ScopeUserLibraryModify scope.\n// A track can only be saved once; duplicate IDs are ignored.\nfunc (c *Client) AddTracksToLibrary(ids ...ID) error {\n\treturn c.modifyLibraryTracks(true, ids...)\n}\n\n// RemoveTracksFromLibrary removes one or more tracks from the current user's\n// \"Your Music\" library.  This call requires the ScopeUserModifyLibrary scope.\n// Trying to remove a track when you do not have the user's authorization\n// results in a `spotify.Error` with the status code set to http.StatusUnauthorized.\nfunc (c *Client) RemoveTracksFromLibrary(ids ...ID) error {\n\treturn c.modifyLibraryTracks(false, ids...)\n}\n\nfunc (c *Client) modifyLibraryTracks(add bool, ids ...ID) error {\n\tif l := len(ids); l == 0 || l > 50 {\n\t\treturn errors.New(\"spotify: this call supports 1 to 50 IDs per call\")\n\t}\n\tspotifyURL := fmt.Sprintf(\"%sme/tracks?ids=%s\", c.baseURL, strings.Join(toStringSlice(ids), \",\"))\n\tmethod := \"DELETE\"\n\tif add {\n\t\tmethod = \"PUT\"\n\t}\n\treq, err := http.NewRequest(method, spotifyURL, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = c.execute(req, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/library_test.go",
    "content": "package spotify\n\nimport (\n\t\"net/http\"\n\t\"testing\"\n)\n\nfunc TestUserHasTracks(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, `[ false, true ]`)\n\tdefer server.Close()\n\n\tcontains, err := client.UserHasTracks(\"0udZHhCi7p1YzMlvI4fXoK\", \"55nlbqqFVnSsArIeYSQlqx\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif l := len(contains); l != 2 {\n\t\tt.Error(\"Expected 2 results, got\", l)\n\t}\n\tif contains[0] || !contains[1] {\n\t\tt.Error(\"Expected [false, true], got\", contains)\n\t}\n}\n\nfunc TestAddTracksToLibrary(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, \"\")\n\tdefer server.Close()\n\n\terr := client.AddTracksToLibrary(\"4iV5W9uYEdYUVa79Axb7Rh\", \"1301WleyT98MSxVHPZCA6M\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n}\n\nfunc TestAddTracksToLibraryFailure(t *testing.T) {\n\tclient, server := testClientString(http.StatusUnauthorized, `\n{\n  \"error\": {\n    \"status\": 401,\n    \"message\": \"Invalid access token\"\n  }\n}`)\n\tdefer server.Close()\n\terr := client.AddTracksToLibrary(\"4iV5W9uYEdYUVa79Axb7Rh\", \"1301WleyT98MSxVHPZCA6M\")\n\tif err == nil {\n\t\tt.Error(\"Expected error and didn't get one\")\n\t}\n}\n\nfunc TestRemoveTracksFromLibrary(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, \"\")\n\tdefer server.Close()\n\n\terr := client.RemoveTracksFromLibrary(\"4iV5W9uYEdYUVa79Axb7Rh\", \"1301WleyT98MSxVHPZCA6M\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/page.go",
    "content": "package spotify\n\nimport (\n\t\"errors\"\n)\n\n// ErrNoMorePages is the error returned when you attempt to get the next\n// (or previous) set of data but you've reached the end of the data set.\nvar ErrNoMorePages = errors.New(\"spotify: no more pages\")\n\n// This file contains the types that implement Spotify's paging object.\n// See: https://developer.spotify.com/web-api/object-model/#paging-object\n\n// basePage contains all of the fields in a Spotify paging object, except\n// for the actual items.  This type is meant to be embedded in other types\n// that add the Items field.\ntype basePage struct {\n\t// A link to the Web API Endpoint returning the full\n\t// result of this request.\n\tEndpoint string `json:\"href\"`\n\t// The maximum number of items in the response, as set\n\t// in the query (or default value if unset).\n\tLimit int `json:\"limit\"`\n\t// The offset of the items returned, as set in the query\n\t// (or default value if unset).\n\tOffset int `json:\"offset\"`\n\t// The total number of items available to return.\n\tTotal int `json:\"total\"`\n\t// The URL to the next page of items (if available).\n\tNext string `json:\"next\"`\n\t// The URL to the previous page of items (if available).\n\tPrevious string `json:\"previous\"`\n}\n\n// FullArtistPage contains FullArtists returned by the Web API.\ntype FullArtistPage struct {\n\tbasePage\n\tArtists []FullArtist `json:\"items\"`\n}\n\n// SimpleAlbumPage contains SimpleAlbums returned by the Web API.\ntype SimpleAlbumPage struct {\n\tbasePage\n\tAlbums []SimpleAlbum `json:\"items\"`\n}\n\n// SavedAlbumPage contains SavedAlbums returned by the Web API.\ntype SavedAlbumPage struct {\n\tbasePage\n\tAlbums []SavedAlbum `json:\"items\"`\n}\n\n// SimplePlaylistPage contains SimplePlaylists returned by the Web API.\ntype SimplePlaylistPage struct {\n\tbasePage\n\tPlaylists []SimplePlaylist `json:\"items\"`\n}\n\n// SimpleTrackPage contains SimpleTracks returned by the Web API.\ntype SimpleTrackPage struct {\n\tbasePage\n\tTracks []SimpleTrack `json:\"items\"`\n}\n\n// FullTrackPage contains FullTracks returned by the Web API.\ntype FullTrackPage struct {\n\tbasePage\n\tTracks []FullTrack `json:\"items\"`\n}\n\n// SavedTrackPage contains SavedTracks return by the Web API.\ntype SavedTrackPage struct {\n\tbasePage\n\tTracks []SavedTrack `json:\"items\"`\n}\n\n// PlaylistTrackPage contains information about tracks in a playlist.\ntype PlaylistTrackPage struct {\n\tbasePage\n\tTracks []PlaylistTrack `json:\"items\"`\n}\n\n// CategoryPage contains Category objects returned by the Web API.\ntype CategoryPage struct {\n\tbasePage\n\tCategories []Category `json:\"items\"`\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/player.go",
    "content": "package spotify\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"time\"\n)\n\n// PlayerDevice contains information about a device that a user can play music on\ntype PlayerDevice struct {\n\t// ID of the device. This may be empty.\n\tID ID `json:\"id\"`\n\t// Active If this device is the currently active device.\n\tActive bool `json:\"is_active\"`\n\t// Restricted Whether controlling this device is restricted. At present if\n\t// this is \"true\" then no Web API commands will be accepted by this device.\n\tRestricted bool `json:\"is_restricted\"`\n\t// Name The name of the device.\n\tName string `json:\"name\"`\n\t// Type of device, such as \"Computer\", \"Smartphone\" or \"Speaker\".\n\tType string `json:\"type\"`\n\t// Volume The current volume in percent.\n\tVolume int `json:\"volume_percent\"`\n}\n\n// PlayerState contains information about the current playback.\ntype PlayerState struct {\n\tCurrentlyPlaying\n\t// Device The device that is currently active\n\tDevice PlayerDevice `json:\"device\"`\n\t// ShuffleState Shuffle is on or off\n\tShuffleState bool `json:\"shuffle_state\"`\n\t// RepeatState off, track, context\n\tRepeatState string `json:\"repeat_state\"`\n}\n\n// PlaybackContext is the playback context\ntype PlaybackContext struct {\n\t// ExternalURLs of the context, or null if not available.\n\tExternalURLs map[string]string `json:\"external_urls\"`\n\t// Endpoint of the context, or null if not available.\n\tEndpoint string `json:\"href\"`\n\t// Type of the item's context. Can be one of album, artist or playlist.\n\tType string `json:\"type\"`\n\t// URI is the Spotify URI for the context.\n\tURI URI `json:\"uri\"`\n}\n\n// CurrentlyPlaying contains the information about currently playing items\ntype CurrentlyPlaying struct {\n\t// Timestamp when data was fetched\n\tTimestamp int `json:\"timestamp\"`\n\t// PlaybackContext current context\n\tPlaybackContext PlaybackContext `json:\"context\"`\n\t// Progress into the currently playing track.\n\tProgress int `json:\"progress_ms\"`\n\t// Playing If something is currently playing.\n\tPlaying bool `json:\"is_playing\"`\n\t// The currently playing track. Can be null.\n\tItem *FullTrack `json:\"Item\"`\n}\n\ntype RecentlyPlayedItem struct {\n\t// Track is the track information\n\tTrack SimpleTrack `json:\"track\"`\n\n\t// PlayedAt is the time that this song was played\n\tPlayedAt time.Time `json:\"played_at\"`\n\n\t// PlaybackContext is the current playback context\n\tPlaybackContext PlaybackContext `json:\"context\"`\n}\n\ntype RecentlyPlayedResult struct {\n\tItems []RecentlyPlayedItem `json:\"items\"`\n}\n\n// PlaybackOffset can be specified either by track URI OR Position. If both are present the\n// request will return 400 BAD REQUEST. If incorrect values are provided for position or uri,\n// the request may be accepted but with an unpredictable resulting action on playback.\ntype PlaybackOffset struct {\n\t// Position is zero based and can’t be negative.\n\tPosition int `json:\"position,omitempty\"`\n\t// URI is a string representing the uri of the item to start at.\n\tURI URI `json:\"uri,omitempty\"`\n}\n\ntype PlayOptions struct {\n\t// DeviceID The id of the device this command is targeting. If not\n\t// supplied, the user's currently active device is the target.\n\tDeviceID *ID `json:\"-\"`\n\t// PlaybackContext Spotify URI of the context to play.\n\t// Valid contexts are albums, artists & playlists.\n\tPlaybackContext *URI `json:\"context_uri,omitempty\"`\n\t// URIs Array of the Spotify track URIs to play\n\tURIs []URI `json:\"uris,omitempty\"`\n\t// PlaybackOffset Indicates from where in the context playback should start.\n\t// Only available when context corresponds to an album or playlist\n\t// object, or when the URIs parameter is used.\n\tPlaybackOffset *PlaybackOffset `json:\"offset,omitempty\"`\n}\n\n// RecentlyPlayedOptions describes options for the recently-played request. All\n// fields are optional. Only one of `AfterEpochMs` and `BeforeEpochMs` may be\n// given. Note that it seems as if Spotify only remembers the fifty most-recent\n// tracks as of right now.\ntype RecentlyPlayedOptions struct {\n\t// Limit is the maximum number of items to return. Must be no greater than\n\t// fifty.\n\tLimit int\n\n\t// AfterEpochMs is a Unix epoch in milliseconds that describes a time after\n\t// which to return songs.\n\tAfterEpochMs int\n\n\t// BeforeEpochMs is a Unix epoch in milliseconds that describes a time\n\t// before which to return songs.\n\tBeforeEpochMs int\n}\n\n// PlayerDevices information about available devices for the current user.\n//\n// Requires the ScopeUserReadPlaybackState scope in order to read information\nfunc (c *Client) PlayerDevices() ([]PlayerDevice, error) {\n\tvar result struct {\n\t\tPlayerDevices []PlayerDevice `json:\"devices\"`\n\t}\n\n\terr := c.get(c.baseURL+\"me/player/devices\", &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn result.PlayerDevices, nil\n}\n\n// PlayerState gets information about the playing state for the current user\n//\n// Requires the ScopeUserReadPlaybackState scope in order to read information\nfunc (c *Client) PlayerState() (*PlayerState, error) {\n\treturn c.PlayerStateOpt(nil)\n}\n\n// PlayerStateOpt is like PlayerState, but it accepts additional\n// options for sorting and filtering the results.\nfunc (c *Client) PlayerStateOpt(opt *Options) (*PlayerState, error) {\n\tspotifyURL := c.baseURL + \"me/player\"\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.Country != nil {\n\t\t\tv.Set(\"market\", *opt.Country)\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\n\tvar result PlayerState\n\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, nil\n}\n\n// PlayerCurrentlyPlaying gets information about the currently playing status\n// for the current user.\n//\n// Requires the ScopeUserReadCurrentlyPlaying scope or the ScopeUserReadPlaybackState\n// scope in order to read information\nfunc (c *Client) PlayerCurrentlyPlaying() (*CurrentlyPlaying, error) {\n\treturn c.PlayerCurrentlyPlayingOpt(nil)\n}\n\n// PlayerCurrentlyPlayingOpt is like PlayerCurrentlyPlaying, but it accepts\n// additional options for sorting and filtering the results.\nfunc (c *Client) PlayerCurrentlyPlayingOpt(opt *Options) (*CurrentlyPlaying, error) {\n\tspotifyURL := c.baseURL + \"me/player/currently-playing\"\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.Country != nil {\n\t\t\tv.Set(\"market\", *opt.Country)\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\n\tvar result CurrentlyPlaying\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, nil\n}\n\n// PlayerRecentlyPlayed gets a list of recently-played tracks for the current\n// user. This call requires ScopeUserReadRecentlyPlayed.\nfunc (c *Client) PlayerRecentlyPlayed() ([]RecentlyPlayedItem, error) {\n\treturn c.PlayerRecentlyPlayedOpt(nil)\n}\n\n// PlayerRecentlyPlayedOpt is like PlayerRecentlyPlayed, but it accepts\n// additional options for sorting and filtering the results.\nfunc (c *Client) PlayerRecentlyPlayedOpt(opt *RecentlyPlayedOptions) ([]RecentlyPlayedItem, error) {\n\tspotifyURL := c.baseURL + \"me/player/recently-played\"\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.Limit != 0 {\n\t\t\tv.Set(\"limit\", strconv.FormatInt(int64(opt.Limit), 10))\n\t\t}\n\t\tif opt.BeforeEpochMs != 0 {\n\t\t\tv.Set(\"before\", strconv.FormatInt(int64(opt.BeforeEpochMs), 10))\n\t\t}\n\t\tif opt.AfterEpochMs != 0 {\n\t\t\tv.Set(\"after\", strconv.FormatInt(int64(opt.AfterEpochMs), 10))\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\n\tresult := RecentlyPlayedResult{}\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn result.Items, nil\n}\n\n// TransferPlayback transfers playback to a new device and determine if\n// it should start playing.\n//\n// Note that a value of false for the play parameter when also transferring\n// to another device_id will not pause playback. To ensure that playback is\n// paused on the new device you should send a pause command to the currently\n// active device before transferring to the new device_id.\n//\n// Requires the ScopeUserModifyPlaybackState in order to modify the player state\nfunc (c *Client) TransferPlayback(deviceID ID, play bool) error {\n\treqData := struct {\n\t\tDeviceID []ID `json:\"device_ids\"`\n\t\tPlay     bool `json:\"play\"`\n\t}{\n\t\tDeviceID: []ID{deviceID},\n\t\tPlay:     play,\n\t}\n\n\tbuf := new(bytes.Buffer)\n\terr := json.NewEncoder(buf).Encode(reqData)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq, err := http.NewRequest(http.MethodPut, c.baseURL+\"me/player\", buf)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = c.execute(req, nil, http.StatusNoContent)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\n// Play Start a new context or resume current playback on the user's active\n// device. This call requires ScopeUserModifyPlaybackState in order to modify the player state.\nfunc (c *Client) Play() error {\n\treturn c.PlayOpt(nil)\n}\n\n// PlayOpt is like Play but with more options\nfunc (c *Client) PlayOpt(opt *PlayOptions) error {\n\tspotifyURL := c.baseURL + \"me/player/play\"\n\tbuf := new(bytes.Buffer)\n\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.DeviceID != nil {\n\t\t\tv.Set(\"device_id\", opt.DeviceID.String())\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\n\t\terr := json.NewEncoder(buf).Encode(opt)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treq, err := http.NewRequest(http.MethodPut, spotifyURL, buf)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = c.execute(req, nil, http.StatusNoContent)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\n// Pause Playback on the user's currently active device.\n//\n// Requires the ScopeUserModifyPlaybackState in order to modify the player state\nfunc (c *Client) Pause() error {\n\treturn c.PauseOpt(nil)\n}\n\n// PauseOpt is like Pause but with more options\n//\n// Only expects PlayOptions.DeviceID, all other options will be ignored\nfunc (c *Client) PauseOpt(opt *PlayOptions) error {\n\tspotifyURL := c.baseURL + \"me/player/pause\"\n\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.DeviceID != nil {\n\t\t\tv.Set(\"device_id\", opt.DeviceID.String())\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\treq, err := http.NewRequest(http.MethodPut, spotifyURL, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = c.execute(req, nil, http.StatusNoContent)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\n// Next skips to the next track in the user's queue in the user's\n// currently active device. This call requires ScopeUserModifyPlaybackState\n// in order to modify the player state\nfunc (c *Client) Next() error {\n\treturn c.NextOpt(nil)\n}\n\n// NextOpt is like Next but with more options\n//\n// Only expects PlayOptions.DeviceID, all other options will be ignored\nfunc (c *Client) NextOpt(opt *PlayOptions) error {\n\tspotifyURL := c.baseURL + \"me/player/next\"\n\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.DeviceID != nil {\n\t\t\tv.Set(\"device_id\", opt.DeviceID.String())\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\treq, err := http.NewRequest(http.MethodPost, spotifyURL, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = c.execute(req, nil, http.StatusNoContent)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\n// Previous skips to the Previous track in the user's queue in the user's\n// currently active device. This call requires ScopeUserModifyPlaybackState\n// in order to modify the player state\nfunc (c *Client) Previous() error {\n\treturn c.PreviousOpt(nil)\n}\n\n// PreviousOpt is like Previous but with more options\n//\n// Only expects PlayOptions.DeviceID, all other options will be ignored\nfunc (c *Client) PreviousOpt(opt *PlayOptions) error {\n\tspotifyURL := c.baseURL + \"me/player/previous\"\n\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.DeviceID != nil {\n\t\t\tv.Set(\"device_id\", opt.DeviceID.String())\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\treq, err := http.NewRequest(http.MethodPost, spotifyURL, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = c.execute(req, nil, http.StatusNoContent)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\n// Seek to the given position in the user’s currently playing track.\n//\n// The position in milliseconds to seek to. Must be a positive number.\n// Passing in a position that is greater than the length of the track\n// will cause the player to start playing the next song.\n//\n// Requires the ScopeUserModifyPlaybackState in order to modify the player state\nfunc (c *Client) Seek(position int) error {\n\treturn c.SeekOpt(position, nil)\n}\n\n// SeekOpt is like Seek but with more options\n//\n// Only expects PlayOptions.DeviceID, all other options will be ignored\nfunc (c *Client) SeekOpt(position int, opt *PlayOptions) error {\n\treturn c.playerFuncWithOpt(\n\t\t\"me/player/seek\",\n\t\turl.Values{\n\t\t\t\"position_ms\": []string{strconv.FormatInt(int64(position), 10)},\n\t\t},\n\t\topt,\n\t)\n}\n\n// Repeat Set the repeat mode for the user's playback.\n//\n// Options are repeat-track, repeat-context, and off.\n//\n// Requires the ScopeUserModifyPlaybackState in order to modify the player state.\nfunc (c *Client) Repeat(state string) error {\n\treturn c.RepeatOpt(state, nil)\n}\n\n// RepeatOpt is like Repeat but with more options\n//\n// Only expects PlayOptions.DeviceID, all other options will be ignored.\nfunc (c *Client) RepeatOpt(state string, opt *PlayOptions) error {\n\treturn c.playerFuncWithOpt(\n\t\t\"me/player/repeat\",\n\t\turl.Values{\n\t\t\t\"state\": []string{state},\n\t\t},\n\t\topt,\n\t)\n}\n\n// Volume set the volume for the user's current playback device.\n//\n// Percent is must be a value from 0 to 100 inclusive.\n//\n// Requires the ScopeUserModifyPlaybackState in order to modify the player state\nfunc (c *Client) Volume(percent int) error {\n\treturn c.VolumeOpt(percent, nil)\n}\n\n// VolumeOpt is like Volume but with more options\n//\n// Only expects PlayOptions.DeviceID, all other options will be ignored\nfunc (c *Client) VolumeOpt(percent int, opt *PlayOptions) error {\n\treturn c.playerFuncWithOpt(\n\t\t\"me/player/volume\",\n\t\turl.Values{\n\t\t\t\"volume_percent\": []string{strconv.FormatInt(int64(percent), 10)},\n\t\t},\n\t\topt,\n\t)\n}\n\n// Shuffle switches shuffle on or off for user's playback.\n//\n// Requires the ScopeUserModifyPlaybackState in order to modify the player state\nfunc (c *Client) Shuffle(shuffle bool) error {\n\treturn c.ShuffleOpt(shuffle, nil)\n}\n\n// ShuffleOpt is like Shuffle but with more options\n//\n// Only expects PlayOptions.DeviceID, all other options will be ignored\nfunc (c *Client) ShuffleOpt(shuffle bool, opt *PlayOptions) error {\n\treturn c.playerFuncWithOpt(\n\t\t\"me/player/shuffle\",\n\t\turl.Values{\n\t\t\t\"state\": []string{strconv.FormatBool(shuffle)},\n\t\t},\n\t\topt,\n\t)\n}\n\nfunc (c *Client) playerFuncWithOpt(urlSuffix string, values url.Values, opt *PlayOptions) error {\n\tspotifyURL := c.baseURL + urlSuffix\n\n\tif opt != nil {\n\t\tif opt.DeviceID != nil {\n\t\t\tvalues.Set(\"device_id\", opt.DeviceID.String())\n\t\t}\n\t}\n\n\tif params := values.Encode(); params != \"\" {\n\t\tspotifyURL += \"?\" + params\n\t}\n\n\treq, err := http.NewRequest(http.MethodPut, spotifyURL, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = c.execute(req, nil, http.StatusNoContent)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/player_test.go",
    "content": "package spotify\n\nimport (\n\t\"net/http\"\n\t\"testing\"\n)\n\nfunc TestTransferPlaybackDeviceUnavailable(t *testing.T) {\n\tclient, server := testClientString(http.StatusAccepted, \"\")\n\tdefer server.Close()\n\terr := client.TransferPlayback(\"newdevice\", false)\n\tif err == nil {\n\t\tt.Error(\"expected error since auto retry is disabled\")\n\t}\n}\n\nfunc TestTransferPlayback(t *testing.T) {\n\tclient, server := testClientString(http.StatusNoContent, \"\")\n\tdefer server.Close()\n\n\terr := client.TransferPlayback(\"newdevice\", true)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n}\n\nfunc TestVolume(t *testing.T) {\n\tclient, server := testClientString(http.StatusNoContent, \"\")\n\tdefer server.Close()\n\n\terr := client.Volume(50)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n}\n\nfunc TestPlayerDevices(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/player_available_devices.txt\")\n\tdefer server.Close()\n\n\tlist, err := client.PlayerDevices()\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\tif len(list) != 2 {\n\t\tt.Error(\"Expected two devices\")\n\t}\n\n\tif list[0].Volume != 100 {\n\t\tt.Error(\"Expected volume to be 100%\")\n\t}\n\tif list[1].Volume != 0 {\n\t\tt.Error(\"Expected null becomes 0\")\n\t}\n}\n\nfunc TestPlayerState(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/player_state.txt\")\n\tdefer server.Close()\n\n\tstate, err := client.PlayerState()\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\n\tif len(state.PlaybackContext.ExternalURLs) != 1 {\n\t\tt.Error(\"Expected one external url\")\n\t}\n\n\tif state.Item == nil {\n\t\tt.Error(\"Expected item to be a track\")\n\t}\n\n\tif state.Timestamp != 1491302708055 {\n\t\tt.Error(\"Expected timestamp to be 1491302708055\")\n\t}\n\n\tif state.Progress != 102509 {\n\t\tt.Error(\"Expected progress to be 102509\")\n\t}\n\n\tif state.Playing {\n\t\tt.Error(\"Expected not to be playing\")\n\t}\n}\n\nfunc TestPlayerCurrentlyPlaying(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/player_currently_playing.txt\")\n\tdefer server.Close()\n\n\tstate, err := client.PlayerCurrentlyPlaying()\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\n\tif len(state.PlaybackContext.ExternalURLs) != 1 {\n\t\tt.Error(\"Expected one external url\")\n\t}\n\n\tif state.Item == nil {\n\t\tt.Error(\"Expected item to be a track\")\n\t}\n\n\tif state.Timestamp != 1491302708055 {\n\t\tt.Error(\"Expected timestamp to be 1491302708055\")\n\t}\n\n\tif state.Progress != 102509 {\n\t\tt.Error(\"Expected progress to be 102509\")\n\t}\n\n\tif state.Playing {\n\t\tt.Error(\"Expected not to be playing\")\n\t}\n}\n\nfunc TestPlayerRecentlyPlayed(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/player_recently_played.txt\")\n\tdefer server.Close()\n\n\titems, err := client.PlayerRecentlyPlayed()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif len(items) != 20 {\n\t\tt.Error(\"Too few or too many items were returned\")\n\t}\n\n\tactualTimePhrase := items[0].PlayedAt.Format(\"2006-01-02T15:04:05.999Z\")\n\texpectedTimePhrase := \"2017-05-27T20:07:54.721Z\"\n\n\tif actualTimePhrase != expectedTimePhrase {\n\t\tt.Errorf(\"Time of first track was not parsed correctly: [%s] != [%s]\", actualTimePhrase, expectedTimePhrase)\n\t}\n}\n\nfunc TestPlayArgsError(t *testing.T) {\n\tjson := `{\n\t\t\"error\" : {\n\t\t\t\"status\" : 400,\n\t\t\t\"message\" : \"Only one of either \\\"context_uri\\\" or \\\"uris\\\" can be specified\"\n\t\t}\n\t}`\n\tclient, server := testClientString(http.StatusUnauthorized, json)\n\tdefer server.Close()\n\n\terr := client.Play()\n\tif err == nil {\n\t\tt.Error(\"Expected an error\")\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/playlist.go",
    "content": "package spotify\n\nimport (\n\t\"bytes\"\n\t\"encoding/base64\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// PlaylistTracks contains details about the tracks in a playlist.\ntype PlaylistTracks struct {\n\t// A link to the Web API endpoint where full details of\n\t// the playlist's tracks can be retrieved.\n\tEndpoint string `json:\"href\"`\n\t// The total number of tracks in the playlist.\n\tTotal uint `json:\"total\"`\n}\n\n// SimplePlaylist contains basic info about a Spotify playlist.\ntype SimplePlaylist struct {\n\t// Indicates whether the playlist owner allows others to modify the playlist.\n\t// Note: only non-collaborative playlists are currently returned by Spotify's Web API.\n\tCollaborative bool              `json:\"collaborative\"`\n\tExternalURLs  map[string]string `json:\"external_urls\"`\n\t// A link to the Web API endpoint providing full details of the playlist.\n\tEndpoint string `json:\"href\"`\n\tID       ID     `json:\"id\"`\n\t// The playlist image.  Note: this field is only  returned for modified,\n\t// verified playlists. Otherwise the slice is empty.  If returned, the source\n\t// URL for the image is temporary and will expire in less than a day.\n\tImages   []Image `json:\"images\"`\n\tName     string  `json:\"name\"`\n\tOwner    User    `json:\"owner\"`\n\tIsPublic bool    `json:\"public\"`\n\t// The version identifier for the current playlist. Can be supplied in other\n\t// requests to target a specific playlist version.\n\tSnapshotID string `json:\"snapshot_id\"`\n\t// A collection to the Web API endpoint where full details of the playlist's\n\t// tracks can be retrieved, along with the total number of tracks in the playlist.\n\tTracks PlaylistTracks `json:\"tracks\"`\n\tURI    URI            `json:\"uri\"`\n}\n\n// FullPlaylist provides extra playlist data in addition to the data provided by SimplePlaylist.\ntype FullPlaylist struct {\n\tSimplePlaylist\n\t// The playlist description.  Only returned for modified, verified playlists.\n\tDescription string `json:\"description\"`\n\t// Information about the followers of this playlist.\n\tFollowers Followers         `json:\"followers\"`\n\tTracks    PlaylistTrackPage `json:\"tracks\"`\n}\n\n// PlaylistOptions contains optional parameters that can be used when querying\n// for featured playlists.  Only the non-nil fields are used in the request.\ntype PlaylistOptions struct {\n\tOptions\n\t// The desired language, consisting of a lowercase IO 639\n\t// language code and an uppercase ISO 3166-1 alpha-2\n\t// country code, joined by an underscore.  Provide this\n\t// parameter if you want the results returned in a particular\n\t// language.  If not specified, the result will be returned\n\t// in the Spotify default language (American English).\n\tLocale *string\n\t// A timestamp in ISO 8601 format (yyyy-MM-ddTHH:mm:ss).\n\t// use this paramter to specify the user's local time to\n\t// get results tailored for that specific date and time\n\t// in the day.  If not provided, the response defaults to\n\t// the current UTC time.\n\tTimestamp *string\n}\n\n// FeaturedPlaylistsOpt gets a list of playlists featured by Spotify.\n// It accepts a number of optional parameters via the opt argument.\nfunc (c *Client) FeaturedPlaylistsOpt(opt *PlaylistOptions) (message string, playlists *SimplePlaylistPage, e error) {\n\tspotifyURL := c.baseURL + \"browse/featured-playlists\"\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.Locale != nil {\n\t\t\tv.Set(\"locale\", *opt.Locale)\n\t\t}\n\t\tif opt.Country != nil {\n\t\t\tv.Set(\"country\", *opt.Country)\n\t\t}\n\t\tif opt.Timestamp != nil {\n\t\t\tv.Set(\"timestamp\", *opt.Timestamp)\n\t\t}\n\t\tif opt.Limit != nil {\n\t\t\tv.Set(\"limit\", strconv.Itoa(*opt.Limit))\n\t\t}\n\t\tif opt.Offset != nil {\n\t\t\tv.Set(\"offset\", strconv.Itoa(*opt.Offset))\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\n\tvar result struct {\n\t\tPlaylists SimplePlaylistPage `json:\"playlists\"`\n\t\tMessage   string             `json:\"message\"`\n\t}\n\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\treturn result.Message, &result.Playlists, nil\n}\n\n// FeaturedPlaylists gets a list of playlists featured by Spotify.\n// It is equivalent to c.FeaturedPlaylistsOpt(nil).\nfunc (c *Client) FeaturedPlaylists() (message string, playlists *SimplePlaylistPage, e error) {\n\treturn c.FeaturedPlaylistsOpt(nil)\n}\n\n// FollowPlaylist adds the current user as a follower of the specified\n// playlist.  Any playlist can be followed, regardless of its private/public\n// status, as long as you know the owner and playlist ID.\n//\n// If the public argument is true, then the playlist will be included in the\n// user's public playlists.  To be able to follow playlists privately, the user\n// must have granted the ScopePlaylistModifyPrivate scope.  The\n// ScopePlaylistModifyPublic scope is required to follow playlists publicly.\nfunc (c *Client) FollowPlaylist(owner ID, playlist ID, public bool) error {\n\tspotifyURL := buildFollowURI(c.baseURL, owner, playlist)\n\tbody := strings.NewReader(strconv.FormatBool(public))\n\treq, err := http.NewRequest(\"PUT\", spotifyURL, body)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\terr = c.execute(req, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\n// UnfollowPlaylist removes the current user as a follower of a playlist.\n// Unfollowing a publicly followed playlist requires ScopePlaylistModifyPublic.\n// Unfolowing a privately followed playlist requies ScopePlaylistModifyPrivate.\nfunc (c *Client) UnfollowPlaylist(owner, playlist ID) error {\n\tspotifyURL := buildFollowURI(c.baseURL, owner, playlist)\n\treq, err := http.NewRequest(\"DELETE\", spotifyURL, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = c.execute(req, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc buildFollowURI(url string, owner, playlist ID) string {\n\treturn fmt.Sprintf(\"%susers/%s/playlists/%s/followers\",\n\t\turl, string(owner), string(playlist))\n}\n\n// GetPlaylistsForUser gets a list of the playlists owned or followed by a\n// particular Spotify user.\n//\n// Private playlists and collaborative playlists are only retrievable for the\n// current user.  In order to read private playlists, the user must have granted\n// the ScopePlaylistReadPrivate scope.  Note that this scope alone will not\n// return collaborative playlists, even though they are always private.  In\n// order to read collaborative playlists, the user must have granted the\n// ScopePlaylistReadCollaborative scope.\nfunc (c *Client) GetPlaylistsForUser(userID string) (*SimplePlaylistPage, error) {\n\treturn c.GetPlaylistsForUserOpt(userID, nil)\n}\n\n// GetPlaylistsForUserOpt is like PlaylistsForUser, but it accepts optional paramters\n// for filtering the results.\nfunc (c *Client) GetPlaylistsForUserOpt(userID string, opt *Options) (*SimplePlaylistPage, error) {\n\tspotifyURL := c.baseURL + \"users/\" + userID + \"/playlists\"\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.Limit != nil {\n\t\t\tv.Set(\"limit\", strconv.Itoa(*opt.Limit))\n\t\t}\n\t\tif opt.Offset != nil {\n\t\t\tv.Set(\"offset\", strconv.Itoa(*opt.Offset))\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\n\tvar result SimplePlaylistPage\n\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, err\n}\n\n// GetPlaylist gets a playlist owned by a Spotify user.\n// Both public and private playlists belonging to any user\n// are retrievable with a valid access token.\nfunc (c *Client) GetPlaylist(userID string, playlistID ID) (*FullPlaylist, error) {\n\treturn c.GetPlaylistOpt(userID, playlistID, \"\")\n}\n\n// GetPlaylistOpt is like GetPlaylist, but it accepts an optional fields parameter\n// that can be used to filter the query.\n//\n// fields is a comma-separated list of the fields to return.\n// See the JSON tags on the FullPlaylist struct for valid field options.\n// For example, to get just the playlist's description and URI:\n//    fields = \"description,uri\"\n//\n// A dot separator can be used to specify non-reoccurring fields, while\n// parentheses can be used to specify reoccurring fields within objects.\n// For example, to get just the added date and the user ID of the adder:\n//    fields = \"tracks.items(added_at,added_by.id)\"\n//\n// Use multiple parentheses to drill down into nested objects, for example:\n//    fields = \"tracks.items(track(name,href,album(name,href)))\"\n//\n// Fields can be excluded by prefixing them with an exclamation mark, for example;\n//    fields = \"tracks.items(track(name,href,album(!name,href)))\"\nfunc (c *Client) GetPlaylistOpt(userID string, playlistID ID, fields string) (*FullPlaylist, error) {\n\tspotifyURL := fmt.Sprintf(\"%susers/%s/playlists/%s\", c.baseURL, userID, playlistID)\n\tif fields != \"\" {\n\t\tspotifyURL += \"?fields=\" + url.QueryEscape(fields)\n\t}\n\n\tvar playlist FullPlaylist\n\n\terr := c.get(spotifyURL, &playlist)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &playlist, err\n}\n\n// GetPlaylistTracks gets full details of the tracks in a playlist, given the\n// owner of the playlist and the playlist's Spotify ID.\nfunc (c *Client) GetPlaylistTracks(userID string, playlistID ID) (*PlaylistTrackPage, error) {\n\treturn c.GetPlaylistTracksOpt(userID, playlistID, nil, \"\")\n}\n\n// GetPlaylistTracksOpt is like GetPlaylistTracks, but it accepts optional parameters\n// for sorting and filtering the results.\n//\n// The field parameter is a comma-separated list of the fields to return.  See the\n// JSON struct tags for the PlaylistTrackPage type for valid field names.\n// For example, to get just the total number of tracks and the request limit:\n//     fields = \"total,limit\"\n//\n// A dot separator can be used to specify non-reoccurring fields, while parentheses\n// can be used to specify reoccurring fields within objects.  For example, to get\n// just the added date and user ID of the adder:\n//     fields = \"items(added_at,added_by.id\n//\n// Use multiple parentheses to drill down into nested objects.  For example:\n//     fields = \"items(track(name,href,album(name,href)))\"\n//\n// Fields can be excluded by prefixing them with an exclamation mark.  For example:\n//     fields = \"items.track.album(!external_urls,images)\"\nfunc (c *Client) GetPlaylistTracksOpt(userID string, playlistID ID,\n\topt *Options, fields string) (*PlaylistTrackPage, error) {\n\n\tspotifyURL := fmt.Sprintf(\"%susers/%s/playlists/%s/tracks\", c.baseURL, userID, playlistID)\n\tv := url.Values{}\n\tif fields != \"\" {\n\t\tv.Set(\"fields\", fields)\n\t}\n\tif opt != nil {\n\t\tif opt.Limit != nil {\n\t\t\tv.Set(\"limit\", strconv.Itoa(*opt.Limit))\n\t\t}\n\t\tif opt.Offset != nil {\n\t\t\tv.Set(\"offset\", strconv.Itoa(*opt.Offset))\n\t\t}\n\t}\n\tif params := v.Encode(); params != \"\" {\n\t\tspotifyURL += \"?\" + params\n\t}\n\n\tvar result PlaylistTrackPage\n\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, err\n}\n\n// CreatePlaylistForUser creates a playlist for a Spotify user.\n// The playlist will be empty until you add tracks to it.\n// The playlistName does not need to be unique - a user can have\n// several playlists with the same name.\n//\n// Creating a public playlist for a user requires ScopePlaylistModifyPublic;\n// creating a private playlist requires ScopePlaylistModifyPrivate.\n//\n// On success, the newly created playlist is returned.\nfunc (c *Client) CreatePlaylistForUser(userID, playlistName string, public bool) (*FullPlaylist, error) {\n\tspotifyURL := fmt.Sprintf(\"%susers/%s/playlists\", c.baseURL, userID)\n\tbody := struct {\n\t\tName   string `json:\"name\"`\n\t\tPublic bool   `json:\"public\"`\n\t}{\n\t\tplaylistName,\n\t\tpublic,\n\t}\n\tbodyJSON, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq, err := http.NewRequest(\"POST\", spotifyURL, bytes.NewReader(bodyJSON))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tvar p FullPlaylist\n\terr = c.execute(req, &p, http.StatusCreated)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &p, err\n}\n\n// ChangePlaylistName changes the name of a playlist.  This call requires that the\n// user has authorized the ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate\n// scopes (depending on whether the playlist is public or private).\n// The current user must own the playlist in order to modify it.\nfunc (c *Client) ChangePlaylistName(userID string, playlistID ID, newName string) error {\n\treturn c.modifyPlaylist(userID, playlistID, newName, nil)\n}\n\n// ChangePlaylistAccess modifies the public/private status of a playlist.  This call\n// requires that the user has authorized the ScopePlaylistModifyPublic or\n// ScopePlaylistModifyPrivate scopes (depending on whether the playlist is\n// currently public or private).  The current user must own the playlist in order to modify it.\nfunc (c *Client) ChangePlaylistAccess(userID string, playlistID ID, public bool) error {\n\treturn c.modifyPlaylist(userID, playlistID, \"\", &public)\n}\n\n// ChangePlaylistNameAndAccess combines ChangePlaylistName and ChangePlaylistAccess into\n// a single Web API call.  It requires that the user has authorized the ScopePlaylistModifyPublic\n// or ScopePlaylistModifyPrivate scopes (depending on whether the playlist is currently\n// public or private).  The current user must own the playlist in order to modify it.\nfunc (c *Client) ChangePlaylistNameAndAccess(userID string, playlistID ID, newName string, public bool) error {\n\treturn c.modifyPlaylist(userID, playlistID, newName, &public)\n}\n\nfunc (c *Client) modifyPlaylist(userID string, playlistID ID, newName string, public *bool) error {\n\tbody := struct {\n\t\tName   string `json:\"name,omitempty\"`\n\t\tPublic *bool  `json:\"public,omitempty\"`\n\t}{\n\t\tnewName,\n\t\tpublic,\n\t}\n\tbodyJSON, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn err\n\t}\n\tspotifyURL := fmt.Sprintf(\"%susers/%s/playlists/%s\", c.baseURL, userID, string(playlistID))\n\treq, err := http.NewRequest(\"PUT\", spotifyURL, bytes.NewReader(bodyJSON))\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\terr = c.execute(req, nil, http.StatusCreated)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\n// AddTracksToPlaylist adds one or more tracks to a user's playlist.\n// This call requires ScopePlaylistModifyPublic or ScopePlaylistModifyPrivate.\n// A maximum of 100 tracks can be added per call.  It returns a snapshot ID that\n// can be used to identify this version (the new version) of the playlist in\n// future requests.\nfunc (c *Client) AddTracksToPlaylist(userID string, playlistID ID,\n\ttrackIDs ...ID) (snapshotID string, err error) {\n\n\turis := make([]string, len(trackIDs))\n\tfor i, id := range trackIDs {\n\t\turis[i] = fmt.Sprintf(\"spotify:track:%s\", id)\n\t}\n\tm := make(map[string]interface{})\n\tm[\"uris\"] = uris\n\n\tspotifyURL := fmt.Sprintf(\"%susers/%s/playlists/%s/tracks\",\n\t\tc.baseURL, userID, string(playlistID))\n\tbody, err := json.Marshal(m)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treq, err := http.NewRequest(\"POST\", spotifyURL, bytes.NewReader(body))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tresult := struct {\n\t\tSnapshotID string `json:\"snapshot_id\"`\n\t}{}\n\n\terr = c.execute(req, &result, http.StatusCreated)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn result.SnapshotID, nil\n}\n\n// RemoveTracksFromPlaylist removes one or more tracks from a user's playlist.\n// This call requrles that the user has authorized the ScopePlaylistModifyPublic\n// or ScopePlaylistModifyPrivate scopes.\n//\n// If the track(s) occur multiple times in the specified playlist, then all occurrences\n// of the track will be removed.  If successful, the snapshot ID returned can be used to\n// identify the playlist version in future requests.\nfunc (c *Client) RemoveTracksFromPlaylist(userID string, playlistID ID,\n\ttrackIDs ...ID) (newSnapshotID string, err error) {\n\n\ttracks := make([]struct {\n\t\tURI string `json:\"uri\"`\n\t}, len(trackIDs))\n\n\tfor i, u := range trackIDs {\n\t\ttracks[i].URI = fmt.Sprintf(\"spotify:track:%s\", u)\n\t}\n\treturn c.removeTracksFromPlaylist(userID, playlistID, tracks, \"\")\n}\n\n// TrackToRemove specifies a track to be removed from a playlist.\n// Positions is a slice of 0-based track indices.\n// TrackToRemove is used with RemoveTracksFromPlaylistOpt.\ntype TrackToRemove struct {\n\tURI       string `json:\"uri\"`\n\tPositions []int  `json:\"positions\"`\n}\n\n// NewTrackToRemove creates a new TrackToRemove object with the specified\n// track ID and playlist locations.\nfunc NewTrackToRemove(trackID string, positions []int) TrackToRemove {\n\treturn TrackToRemove{\n\t\tURI:       fmt.Sprintf(\"spotify:track:%s\", trackID),\n\t\tPositions: positions,\n\t}\n}\n\n// RemoveTracksFromPlaylistOpt is like RemoveTracksFromPlaylist, but it supports\n// optional parameters that offer more fine-grained control.  Instead of deleting\n// all occurrences of a track, this function takes an index with each track URI\n// that indicates the position of the track in the playlist.\n//\n// In addition, the snapshotID parameter allows you to specify the snapshot ID\n// against which you want to make the changes.  Spotify will validate that the\n// specified tracks exist in the specified positions and make the changes, even\n// if more recent changes have been made to the playlist.  If a track in the\n// specified position is not found, the entire request will fail and no edits\n// will take place. (Note: the snapshot is optional, pass the empty string if\n// you don't care about it.)\nfunc (c *Client) RemoveTracksFromPlaylistOpt(userID string, playlistID ID,\n\ttracks []TrackToRemove, snapshotID string) (newSnapshotID string, err error) {\n\n\treturn c.removeTracksFromPlaylist(userID, playlistID, tracks, snapshotID)\n}\n\nfunc (c *Client) removeTracksFromPlaylist(userID string, playlistID ID,\n\ttracks interface{}, snapshotID string) (newSnapshotID string, err error) {\n\n\tm := make(map[string]interface{})\n\tm[\"tracks\"] = tracks\n\tif snapshotID != \"\" {\n\t\tm[\"snapshot_id\"] = snapshotID\n\t}\n\n\tspotifyURL := fmt.Sprintf(\"%susers/%s/playlists/%s/tracks\",\n\t\tc.baseURL, userID, string(playlistID))\n\tbody, err := json.Marshal(m)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treq, err := http.NewRequest(\"DELETE\", spotifyURL, bytes.NewReader(body))\n\tif err != nil {\n\t\treturn \"\", nil\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tresult := struct {\n\t\tSnapshotID string `json:\"snapshot_id\"`\n\t}{}\n\n\terr = c.execute(req, &result)\n\tif err != nil {\n\t\treturn \"\", nil\n\t}\n\n\treturn result.SnapshotID, err\n}\n\n// ReplacePlaylistTracks replaces all of the tracks in a playlist, overwriting its\n// exising tracks  This can be useful for replacing or reordering tracks, or for\n// clearing a playlist.\n//\n// Modifying a public playlist requires that the user has authorized the\n// ScopePlaylistModifyPublic scope.  Modifying a private playlist requires the\n// ScopePlaylistModifyPrivate scope.\n//\n// A maximum of 100 tracks is permited in this call.  Additional tracks must be\n// added via AddTracksToPlaylist.\nfunc (c *Client) ReplacePlaylistTracks(userID string, playlistID ID, trackIDs ...ID) error {\n\ttrackURIs := make([]string, len(trackIDs))\n\tfor i, u := range trackIDs {\n\t\ttrackURIs[i] = fmt.Sprintf(\"spotify:track:%s\", u)\n\t}\n\tspotifyURL := fmt.Sprintf(\"%susers/%s/playlists/%s/tracks?uris=%s\",\n\t\tc.baseURL, userID, playlistID, strings.Join(trackURIs, \",\"))\n\treq, err := http.NewRequest(\"PUT\", spotifyURL, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = c.execute(req, nil, http.StatusCreated)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\n// UserFollowsPlaylist checks if one or more (up to 5) Spotify users are following\n// a Spotify playlist, given the playlist's owner and ID.\n//\n// Checking if a user follows a playlist publicly doesn't require any scopes.\n// Checking if the user is privately following a playlist is only possible for the\n// current user when that user has granted access to the ScopePlaylistReadPrivate scope.\nfunc (c *Client) UserFollowsPlaylist(ownerID string, playlistID ID, userIDs ...string) ([]bool, error) {\n\tspotifyURL := fmt.Sprintf(\"%susers/%s/playlists/%s/followers/contains?ids=%s\",\n\t\tc.baseURL, ownerID, playlistID, strings.Join(userIDs, \",\"))\n\n\tfollows := make([]bool, len(userIDs))\n\n\terr := c.get(spotifyURL, &follows)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn follows, err\n}\n\n// PlaylistReorderOptions is used with ReorderPlaylistTracks to reorder\n// a track or group of tracks in a playlist.\n//\n// For example, in a playlist with 10 tracks, you can:\n//\n// - move the first track to the end of the playlist by setting\n//   RangeStart to 0 and InsertBefore to 10\n// - move the last track to the beginning of the playlist by setting\n//   RangeStart to 9 and InsertBefore to 0\n// - Move the last 2 tracks to the beginning of the playlist by setting\n//   RangeStart to 8 and RangeLength to 2.\ntype PlaylistReorderOptions struct {\n\t// The position of the first track to be reordered.\n\t// This field is required.\n\tRangeStart int `json:\"range_start\"`\n\t// The amount of tracks to be reordered.  This field is optional.  If\n\t// you don't set it, the value 1 will be used.\n\tRangeLength int `json:\"range_length,omitempty\"`\n\t// The position where the tracks should be inserted.  To reorder the\n\t// tracks to the end of the playlist, simply set this to the position\n\t// after the last track.  This field is required.\n\tInsertBefore int `json:\"insert_before\"`\n\t// The playlist's snapshot ID against which you wish to make the changes.\n\t// This field is optional.\n\tSnapshotID string `json:\"snapshot_id,omitempty\"`\n}\n\n// ReorderPlaylistTracks reorders a track or group of tracks in a playlist.  It\n// returns a snapshot ID that can be used to identify the [newly modified] playlist\n// version in future requests.\n//\n// See the docs for PlaylistReorderOptions for information on how the reordering\n// works.\n//\n// Reordering tracks in the current user's public playlist requires ScopePlaylistModifyPublic.\n// Reordering tracks in the user's private playlists (including collaborative playlists) requires\n// ScopePlaylistModifyPrivate.\nfunc (c *Client) ReorderPlaylistTracks(userID string, playlistID ID, opt PlaylistReorderOptions) (snapshotID string, err error) {\n\tspotifyURL := fmt.Sprintf(\"%susers/%s/playlists/%s/tracks\", c.baseURL, userID, playlistID)\n\tj, err := json.Marshal(opt)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treq, err := http.NewRequest(\"PUT\", spotifyURL, bytes.NewReader(j))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tresult := struct {\n\t\tSnapshotID string `json:\"snapshot_id\"`\n\t}{}\n\terr = c.execute(req, &result)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn result.SnapshotID, err\n}\n\n// SetPlaylistImage replaces the image used to represent a playlist.\n// This action can only be performed by the owner of the playlist,\n// and requires ScopeImageUpload as well as ScopeModifyPlaylist{Public|Private}..\nfunc (c *Client) SetPlaylistImage(userID string, playlistID ID, img io.Reader) error {\n\tspotifyURL := fmt.Sprintf(\"%susers/%s/playlists/%s/images\", c.baseURL, userID, playlistID)\n\t// data flow:\n\t// img (reader) -> copy into base64 encoder (writer) -> pipe (write end)\n\t// pipe (read end) -> request body\n\tr, w := io.Pipe()\n\tgo func() {\n\t\tenc := base64.NewEncoder(base64.StdEncoding, w)\n\t\t_, err := io.Copy(enc, img)\n\t\tenc.Close()\n\t\tw.CloseWithError(err)\n\t}()\n\n\treq, err := http.NewRequest(\"PUT\", spotifyURL, r)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.Header.Set(\"Content-Type\", \"image/jpeg\")\n\treturn c.execute(req, nil, http.StatusAccepted)\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/playlist_test.go",
    "content": "package spotify\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"testing\"\n\t\"time\"\n)\n\nfunc TestFeaturedPlaylists(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/featured_playlists.txt\")\n\tdefer server.Close()\n\n\tcountry := \"SE\"\n\topt := PlaylistOptions{}\n\topt.Country = &country\n\n\tmsg, p, err := client.FeaturedPlaylistsOpt(&opt)\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\tif msg != \"Enjoy a mellow afternoon.\" {\n\t\tt.Errorf(\"Want 'Enjoy a mellow afternoon.', got'%s'\\n\", msg)\n\t}\n\tif p.Playlists == nil || len(p.Playlists) == 0 {\n\t\tt.Fatal(\"Empty playlists result\")\n\t}\n\texpected := \"Hangover Friendly Singer-Songwriter\"\n\tif name := p.Playlists[0].Name; name != expected {\n\t\tt.Errorf(\"Want '%s', got '%s'\\n\", expected, name)\n\t}\n}\n\nfunc TestFeaturedPlaylistsExpiredToken(t *testing.T) {\n\tjson := `{\n\t\t\"error\": {\n\t\t\t\"status\": 401,\n\t\t\t\"message\": \"The access token expired\"\n\t\t}\n\t}`\n\tclient, server := testClientString(http.StatusUnauthorized, json)\n\tdefer server.Close()\n\n\tmsg, pl, err := client.FeaturedPlaylists()\n\tif msg != \"\" || pl != nil || err == nil {\n\t\tt.Fatal(\"Expected an error\")\n\t}\n\tserr, ok := err.(Error)\n\tif !ok {\n\t\tt.Fatalf(\"Expected spotify Error, got %T\", err)\n\t}\n\tif serr.Status != http.StatusUnauthorized {\n\t\tt.Error(\"Expected HTTP 401\")\n\t}\n}\n\nfunc TestPlaylistsForUser(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/playlists_for_user.txt\")\n\tdefer server.Close()\n\n\tplaylists, err := client.GetPlaylistsForUser(\"whizler\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif l := len(playlists.Playlists); l == 0 {\n\t\tt.Fatal(\"Didn't get any results\")\n\t}\n\tp := playlists.Playlists[0]\n\tif p.Name != \"Nederlandse Tipparade\" {\n\t\tt.Error(\"Expected Nederlandse Tipparade, got\", p.Name)\n\t}\n\tif p.Tracks.Total != 29 {\n\t\tt.Error(\"Expected 29 tracks, got\", p.Tracks.Total)\n\t}\n}\n\nfunc TestGetPlaylistOpt(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/get_playlist_opt.txt\")\n\tdefer server.Close()\n\n\tfields := \"href,name,owner(!href,external_urls),tracks.items(added_by.id,track(name,href,album(name,href)))\"\n\tp, err := client.GetPlaylistOpt(\"spotify\", \"59ZbFPES4DQwEjBpWHzrtC\", fields)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif p.Collaborative {\n\t\tt.Error(\"Playlist shouldn't be collaborative\")\n\t}\n\tif p.Description != \"\" {\n\t\tt.Error(\"No description should be included\")\n\t}\n\tif p.Tracks.Total != 10 {\n\t\tt.Error(\"Expected 10 tracks\")\n\t}\n}\n\nfunc TestFollowPlaylistSetsContentType(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, \"\", func(req *http.Request) {\n\t\tif req.Header.Get(\"Content-Type\") != \"application/json\" {\n\t\t\tt.Error(\"Follow playlist request didn't contain Content-Type: application/json\")\n\t\t}\n\t})\n\tdefer server.Close()\n\n\terr := client.FollowPlaylist(\"ownerID\", \"playlistID\", true)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n}\n\nfunc TestGetPlaylistTracks(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/playlist_tracks.txt\")\n\tdefer server.Close()\n\n\ttracks, err := client.GetPlaylistTracks(\"user\", \"playlistID\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif tracks.Total != 47 {\n\t\tt.Errorf(\"Got %d tracks, expected 47\\n\", tracks.Total)\n\t}\n\tif len(tracks.Tracks) == 0 {\n\t\tt.Fatal(\"No tracks returned\")\n\t}\n\texpected := \"Time Of Our Lives\"\n\tactual := tracks.Tracks[0].Track.Name\n\tif expected != actual {\n\t\tt.Errorf(\"Got '%s', expected '%s'\\n\", actual, expected)\n\t}\n\tadded := tracks.Tracks[0].AddedAt\n\ttm, err := time.Parse(TimestampLayout, added)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif f := tm.Format(DateLayout); f != \"2014-11-25\" {\n\t\tt.Errorf(\"Expected added at 2014-11-25, got %s\\n\", f)\n\t}\n}\n\nfunc TestUserFollowsPlaylist(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, `[ true, false ]`)\n\tdefer server.Close()\n\n\tfollows, err := client.UserFollowsPlaylist(\"jmperezperez\", ID(\"2v3iNvBS8Ay1Gt2uXtUKUT\"), \"possan\", \"elogain\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(follows) != 2 || !follows[0] || follows[1] {\n\t\tt.Errorf(\"Expected '[true, false]', got %#v\\n\", follows)\n\t}\n}\n\nvar newPlaylist = `\n{\n\"collaborative\": false,\n\"description\": null,\n\"external_urls\": {\n\t\"spotify\": \"http://open.spotify.com/user/thelinmichael/playlist/7d2D2S200NyUE5KYs80PwO\"\n},\n\"followers\": {\n\t\"href\": null,\n\t\"total\": 0\n},\n\"href\": \"https://api.spotify.com/v1/users/thelinmichael/playlists/7d2D2S200NyUE5KYs80PwO\",\n\"id\": \"7d2D2S200NyUE5KYs80PwO\",\n\"images\": [ ],\n\"name\": \"A New Playlist\",\n\"owner\": {\n\t\"external_urls\": {\n\t\"spotify\": \"http://open.spotify.com/user/thelinmichael\"\n\t},\n\t\"href\": \"https://api.spotify.com/v1/users/thelinmichael\",\n\t\"id\": \"thelinmichael\",\n\t\"type\": \"user\",\n\t\"url\": \"spotify:user:thelinmichael\"\n},\n\"public\": false,\n\"snapshot_id\": \"s0o3TSuYnRLl2jch+oA4OEbKwq/fNxhGBkSPnvhZdmWjNV0q3uCAWuGIhEx8SHIx\",\n\"tracks\": {\n\t\"href\": \"https://api.spotify.com/v1/users/thelinmichael/playlists/7d2D2S200NyUE5KYs80PwO/tracks\",\n\t\"items\": [ ],\n\t\"limit\": 100,\n\t\"next\": null,\n\t\"offset\": 0,\n\t\"previous\": null,\n\t\"total\": 0\n},\n\"type\": \"playlist\",\n\"url\": \"spotify:user:thelinmichael:playlist:7d2D2S200NyUE5KYs80PwO\"\n}`\n\nfunc TestCreatePlaylist(t *testing.T) {\n\tclient, server := testClientString(http.StatusCreated, newPlaylist)\n\tdefer server.Close()\n\n\tp, err := client.CreatePlaylistForUser(\"thelinmichael\", \"A New Playlist\", false)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif p.IsPublic {\n\t\tt.Error(\"Expected private playlist, got public\")\n\t}\n\tif p.Name != \"A New Playlist\" {\n\t\tt.Errorf(\"Expected 'A New Playlist', got '%s'\\n\", p.Name)\n\t}\n\tif p.Tracks.Total != 0 {\n\t\tt.Error(\"Expected new playlist to be empty\")\n\t}\n}\n\nfunc TestRenamePlaylist(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, \"\")\n\tdefer server.Close()\n\n\tif err := client.ChangePlaylistName(\"user\", ID(\"playlist-id\"), \"new name\"); err != nil {\n\t\tt.Error(err)\n\t}\n}\n\nfunc TestChangePlaylistAccess(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, \"\")\n\tdefer server.Close()\n\n\tif err := client.ChangePlaylistAccess(\"user\", ID(\"playlist-id\"), true); err != nil {\n\t\tt.Error(err)\n\t}\n}\n\nfunc TestChangePlaylistNamdAndAccess(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, \"\")\n\tdefer server.Close()\n\n\tif err := client.ChangePlaylistNameAndAccess(\"user\", ID(\"playlist-id\"), \"new_name\", true); err != nil {\n\t\tt.Error(err)\n\t}\n}\n\nfunc TestChangePlaylistNameFailure(t *testing.T) {\n\tclient, server := testClientString(http.StatusForbidden, \"\")\n\tdefer server.Close()\n\n\tif err := client.ChangePlaylistName(\"user\", ID(\"playlist-id\"), \"new_name\"); err == nil {\n\t\tt.Error(\"Expected error but didn't get one\")\n\t}\n}\n\nfunc TestAddTracksToPlaylist(t *testing.T) {\n\tclient, server := testClientString(http.StatusCreated, `{ \"snapshot_id\" : \"JbtmHBDBAYu3/bt8BOXKjzKx3i0b6LCa/wVjyl6qQ2Yf6nFXkbmzuEa+ZI/U1yF+\" }`)\n\tdefer server.Close()\n\n\tsnapshot, err := client.AddTracksToPlaylist(\"user\", ID(\"playlist_id\"), ID(\"track1\"), ID(\"track2\"))\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif snapshot != \"JbtmHBDBAYu3/bt8BOXKjzKx3i0b6LCa/wVjyl6qQ2Yf6nFXkbmzuEa+ZI/U1yF+\" {\n\t\tt.Error(\"Didn't get expected snapshot ID\")\n\t}\n}\n\nfunc TestRemoveTracksFromPlaylist(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, `{ \"snapshot_id\" : \"JbtmHBDBAYu3/bt8BOXKjzKx3i0b6LCa/wVjyl6qQ2Yf6nFXkbmzuEa+ZI/U1yF+\" }`, func(req *http.Request) {\n\t\trequestBody, err := ioutil.ReadAll(req.Body)\n\n\t\tvar body map[string]interface{}\n\t\terr = json.Unmarshal(requestBody, &body)\n\t\tif err != nil {\n\t\t\tt.Fatal(\"Error decoding request body:\", err)\n\t\t}\n\t\ttracksArray, ok := body[\"tracks\"]\n\t\tif !ok {\n\t\t\tt.Error(\"No tracks JSON object in request body\")\n\t\t}\n\t\ttracksSlice := tracksArray.([]interface{})\n\t\tif l := len(tracksSlice); l != 2 {\n\t\t\tt.Fatalf(\"Expected 2 tracks, got %d\\n\", l)\n\t\t}\n\t\ttrack0 := tracksSlice[0].(map[string]interface{})\n\t\ttrackURI, ok := track0[\"uri\"]\n\t\tif !ok {\n\t\t\tt.Error(\"Track object doesn't contain 'uri' field\")\n\t\t}\n\t\tif trackURI != \"spotify:track:track1\" {\n\t\t\tt.Errorf(\"Expeced URI: 'spotify:track:track1', got '%s'\\n\", trackURI)\n\t\t}\n\t})\n\tdefer server.Close()\n\n\tsnapshotID, err := client.RemoveTracksFromPlaylist(\"userID\", \"playlistID\", \"track1\", \"track2\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif snapshotID != \"JbtmHBDBAYu3/bt8BOXKjzKx3i0b6LCa/wVjyl6qQ2Yf6nFXkbmzuEa+ZI/U1yF+\" {\n\t\tt.Error(\"Incorrect snapshot ID\")\n\t}\n}\n\nfunc TestRemoveTracksFromPlaylistOpt(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, `{ \"snapshot_id\" : \"JbtmHBDBAYu3/bt8BOXKjzKx3i0b6LCa/wVjyl6qQ2Yf6nFXkbmzuEa+ZI/U1yF+\" }`, func(req *http.Request) {\n\t\trequestBody, err := ioutil.ReadAll(req.Body)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\tvar body map[string]interface{}\n\t\terr = json.Unmarshal(requestBody, &body)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tif _, ok := body[\"snapshot_id\"]; ok {\n\t\t\tt.Error(\"JSON contains snapshot_id field when none was specified\")\n\t\t\tfmt.Println(string(requestBody))\n\t\t\treturn\n\t\t}\n\t\tjsonTracks := body[\"tracks\"].([]interface{})\n\t\tif len(jsonTracks) != 3 {\n\t\t\tt.Fatal(\"Expected 3 tracks, got\", len(jsonTracks))\n\t\t}\n\t\ttrack1 := jsonTracks[1].(map[string]interface{})\n\t\texpected := \"spotify:track:track1\"\n\t\tif track1[\"uri\"] != expected {\n\t\t\tt.Fatalf(\"Want '%s', got '%s'\\n\", expected, track1[\"uri\"])\n\t\t}\n\t\tindices := track1[\"positions\"].([]interface{})\n\t\tif len(indices) != 1 || int(indices[0].(float64)) != 9 {\n\t\t\tt.Error(\"Track indices incorrect\")\n\t\t}\n\t})\n\tdefer server.Close()\n\n\ttracks := []TrackToRemove{\n\t\tNewTrackToRemove(\"track0\", []int{0, 4}), // remove track0 in position 0 and 4\n\t\tNewTrackToRemove(\"track1\", []int{9}),    // remove track1 in position 9...\n\t\tNewTrackToRemove(\"track2\", []int{8}),\n\t}\n\t// intentionally not passing a snapshot ID here\n\tsnapshotID, err := client.RemoveTracksFromPlaylistOpt(\"userID\", \"playlistID\", tracks, \"\")\n\tif err != nil || snapshotID != \"JbtmHBDBAYu3/bt8BOXKjzKx3i0b6LCa/wVjyl6qQ2Yf6nFXkbmzuEa+ZI/U1yF+\" {\n\t\tt.Fatal(\"Remove call failed. err=\", err)\n\t}\n}\n\nfunc TestReplacePlaylistTracks(t *testing.T) {\n\tclient, server := testClientString(http.StatusCreated, \"\")\n\tdefer server.Close()\n\n\terr := client.ReplacePlaylistTracks(\"userID\", \"playlistID\", \"track1\", \"track2\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n}\n\nfunc TestReplacePlaylistTracksForbidden(t *testing.T) {\n\tclient, server := testClientString(http.StatusForbidden, \"\")\n\tdefer server.Close()\n\n\terr := client.ReplacePlaylistTracks(\"userID\", \"playlistID\", \"track1\", \"track2\")\n\tif err == nil {\n\t\tt.Error(\"Replace succeeded but shouldn't have\")\n\t}\n}\n\nfunc TestReorderPlaylistRequest(t *testing.T) {\n\tclient, server := testClientString(http.StatusNotFound, \"\", func(req *http.Request) {\n\t\tif ct := req.Header.Get(\"Content-Type\"); ct != \"application/json\" {\n\t\t\tt.Errorf(\"Expected Content-Type: application/json, got '%s'\\n\", ct)\n\t\t}\n\t\tif req.Method != \"PUT\" {\n\t\t\tt.Errorf(\"Expected a PUT, got a %s\\n\", req.Method)\n\t\t}\n\t\t// unmarshal the JSON into a map[string]interface{}\n\t\t// so we can test for existence of certain keys\n\t\tvar body map[string]interface{}\n\t\tjson.NewDecoder(req.Body).Decode(&body)\n\n\t\tif start, ok := body[\"range_start\"]; ok {\n\t\t\tif start != float64(3) {\n\t\t\t\tt.Errorf(\"Expected range_start to be 3, but it was %#v\\n\", start)\n\t\t\t}\n\t\t} else {\n\t\t\tt.Errorf(\"Required field range_start is missing\")\n\t\t}\n\n\t\tif ib, ok := body[\"insert_before\"]; ok {\n\t\t\tif ib != float64(8) {\n\t\t\t\tt.Errorf(\"Expected insert_before to be 8, but it was %#v\\n\", ib)\n\t\t\t}\n\t\t} else {\n\t\t\tt.Errorf(\"Required field insert_before is missing\")\n\t\t}\n\n\t\tif _, ok := body[\"range_length\"]; ok {\n\t\t\tt.Error(\"Parameter range_length shouldn't have been in body\")\n\t\t}\n\t\tif _, ok := body[\"snapshot_id\"]; ok {\n\t\t\tt.Error(\"Parameter snapshot_id shouldn't have been in body\")\n\t\t}\n\t})\n\tdefer server.Close()\n\n\tclient.ReorderPlaylistTracks(\"user\", \"playlist\", PlaylistReorderOptions{\n\t\tRangeStart:   3,\n\t\tInsertBefore: 8,\n\t})\n}\n\nfunc TestSetPlaylistImage(t *testing.T) {\n\tclient, server := testClientString(http.StatusAccepted, \"\", func(req *http.Request) {\n\t\tif ct := req.Header.Get(\"Content-Type\"); ct != \"image/jpeg\" {\n\t\t\tt.Errorf(\"wrong content type, got %s, want image/jpeg\", ct)\n\t\t}\n\t\tif req.Method != \"PUT\" {\n\t\t\tt.Errorf(\"expected a PUT, got a %s\\n\", req.Method)\n\t\t}\n\t\tbody, err := ioutil.ReadAll(req.Body)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\tif !bytes.Equal(body, []byte(\"Zm9v\")) {\n\t\t\tt.Errorf(\"invalid request body: want Zm9v, got %s\", string(body))\n\t\t}\n\t})\n\tdefer server.Close()\n\n\terr := client.SetPlaylistImage(\"user\", \"playlist\", bytes.NewReader([]byte(\"foo\")))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/recommendation.go",
    "content": "package spotify\n\nimport (\n\t\"fmt\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// Seeds contains IDs of artists, genres and/or tracks\n// to be used as seeds for recommendations\ntype Seeds struct {\n\tArtists []ID\n\tTracks  []ID\n\tGenres  []string\n}\n\n// count returns the total number of seeds contained in s\nfunc (s Seeds) count() int {\n\treturn len(s.Artists) + len(s.Tracks) + len(s.Genres)\n}\n\n// Recommendations contains a list of recommended tracks based on seeds\ntype Recommendations struct {\n\tSeeds  []RecommendationSeed `json:\"seeds\"`\n\tTracks []SimpleTrack        `json:\"tracks\"`\n}\n\n// RecommendationSeed represents a recommendation seed after\n// being processed by the Spotify API\ntype RecommendationSeed struct {\n\tAfterFilteringSize int    `json:\"afterFilteringSize\"`\n\tAfterRelinkingSize int    `json:\"afterRelinkingSize\"`\n\tEndpoint           string `json:\"href\"`\n\tID                 ID     `json:\"id\"`\n\tInitialPoolSize    int    `json:\"initialPoolSize\"`\n\tType               string `json:\"type\"`\n}\n\n// MaxNumberOfSeeds allowed by Spotify for a recommendation request\nconst MaxNumberOfSeeds = 5\n\n// setSeedValues sets url values into v for each seed in seeds\nfunc setSeedValues(seeds Seeds, v url.Values) {\n\tif len(seeds.Artists) != 0 {\n\t\tv.Set(\"seed_artists\", strings.Join(toStringSlice(seeds.Artists), \",\"))\n\t}\n\tif len(seeds.Tracks) != 0 {\n\t\tv.Set(\"seed_tracks\", strings.Join(toStringSlice(seeds.Tracks), \",\"))\n\t}\n\tif len(seeds.Genres) != 0 {\n\t\tv.Set(\"seed_genres\", strings.Join(seeds.Genres, \",\"))\n\t}\n}\n\n// setTrackAttributesValues sets track attributes values to the given url values\nfunc setTrackAttributesValues(trackAttributes *TrackAttributes, values url.Values) {\n\tif trackAttributes == nil {\n\t\treturn\n\t}\n\tfor attr, val := range trackAttributes.intAttributes {\n\t\tvalues.Set(attr, strconv.Itoa(val))\n\t}\n\tfor attr, val := range trackAttributes.floatAttributes {\n\t\tvalues.Set(attr, strconv.FormatFloat(val, 'f', -1, 64))\n\t}\n}\n\n// GetRecommendations returns a list of recommended tracks based on the given seeds.\n// Recommendations are generated based on the available information for a given seed entity\n// and matched against similar artists and tracks. If there is sufficient information\n// about the provided seeds, a list of tracks will be returned together with pool size details.\n// For artists and tracks that are very new or obscure\n// there might not be enough data to generate a list of tracks.\nfunc (c *Client) GetRecommendations(seeds Seeds, trackAttributes *TrackAttributes, opt *Options) (*Recommendations, error) {\n\tv := url.Values{}\n\n\tif seeds.count() == 0 {\n\t\treturn nil, fmt.Errorf(\"spotify: at least one seed is required\")\n\t}\n\tif seeds.count() > MaxNumberOfSeeds {\n\t\treturn nil, fmt.Errorf(\"spotify: exceeded maximum of %d seeds\", MaxNumberOfSeeds)\n\t}\n\n\tsetSeedValues(seeds, v)\n\tsetTrackAttributesValues(trackAttributes, v)\n\n\tif opt != nil {\n\t\tif opt.Limit != nil {\n\t\t\tv.Set(\"limit\", strconv.Itoa(*opt.Limit))\n\t\t}\n\t\tif opt.Country != nil {\n\t\t\tv.Set(\"market\", *opt.Country)\n\t\t}\n\t}\n\n\tspotifyURL := c.baseURL + \"recommendations?\" + v.Encode()\n\n\tvar recommendations Recommendations\n\terr := c.get(spotifyURL, &recommendations)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &recommendations, err\n}\n\n// GetAvailableGenreSeeds retrieves a list of available genres seed parameter values for\n// recommendations.\nfunc (c *Client) GetAvailableGenreSeeds() ([]string, error) {\n\tspotifyURL := c.baseURL + \"recommendations/available-genre-seeds\"\n\n\tgenreSeeds := make(map[string][]string)\n\n\terr := c.get(spotifyURL, &genreSeeds)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn genreSeeds[\"genres\"], nil\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/recommendation_test.go",
    "content": "package spotify\n\nimport (\n\t\"net/url\"\n\t\"testing\"\n)\n\nfunc TestGetRecommendations(t *testing.T) {\n\t// test data corresponding to Spotify Console web API sample\n\tclient, server := testClientFile(200, \"test_data/recommendations.txt\")\n\tdefer server.Close()\n\n\tseeds := Seeds{\n\t\tArtists: []ID{\"4NHQUGzhtTLFvgF5SZesLK\"},\n\t\tTracks:  []ID{\"0c6xIDDpzE81m2q797ordA\"},\n\t\tGenres:  []string{\"classical\", \"country\"},\n\t}\n\tcountry := \"ES\"\n\tlimit := 10\n\topts := Options{\n\t\tCountry: &country,\n\t\tLimit:   &limit,\n\t}\n\trecommendations, err := client.GetRecommendations(seeds, nil, &opts)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif len(recommendations.Tracks) != 10 {\n\t\tt.Error(\"Expected 10 recommended tracks\")\n\t}\n\tif recommendations.Tracks[0].Artists[0].Name != \"Heinrich Isaac\" {\n\t\tt.Error(\"Expected the artist of the first recommended track to be Heinrich Isaac\")\n\t}\n}\n\nfunc TestSetSeedValues(t *testing.T) {\n\texpectedValues := \"seed_artists=4NHQUGzhtTLFvgF5SZesLK%2C5PHQUGzhtTUIvgF5SZesGY&seed_genres=classical%2Ccountry\"\n\tv := url.Values{}\n\tseeds := Seeds{\n\t\tArtists: []ID{\"4NHQUGzhtTLFvgF5SZesLK\", \"5PHQUGzhtTUIvgF5SZesGY\"},\n\t\tGenres:  []string{\"classical\", \"country\"},\n\t}\n\tsetSeedValues(seeds, v)\n\tactualValues := v.Encode()\n\tif actualValues != expectedValues {\n\t\tt.Errorf(\"Expected seed values to be %s but got %s\", expectedValues, actualValues)\n\t}\n}\n\nfunc TestSetTrackAttributesValues(t *testing.T) {\n\texpectedValues := \"max_duration_ms=200&min_duration_ms=20&min_energy=0.45&target_acousticness=0.27&target_duration_ms=160\"\n\tv := url.Values{}\n\tta := NewTrackAttributes().\n\t\tMaxDuration(200).\n\t\tMinDuration(20).\n\t\tTargetDuration(160).\n\t\tMinEnergy(0.45).\n\t\tTargetAcousticness(0.27)\n\n\tsetTrackAttributesValues(ta, v)\n\tactualValues := v.Encode()\n\tif actualValues != expectedValues {\n\t\tt.Errorf(\"Expected track attributes values to be %s but got %s\", expectedValues, actualValues)\n\t}\n}\n\nfunc TestSetEmptyTrackAttributesValues(t *testing.T) {\n\texpectedValues := \"\"\n\tv := url.Values{}\n\tsetTrackAttributesValues(nil, v)\n\tactualValues := v.Encode()\n\tif actualValues != expectedValues {\n\t\tt.Errorf(\"Expected track attributes values to be empty but got %s\", actualValues)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/search.go",
    "content": "package spotify\n\nimport (\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nconst (\n\t// MarketFromToken can be used in place of the Market parameter\n\t// if the Client has a valid access token.  In this case, the\n\t// results will be limited to content that is playable in the\n\t// country associated with the user's account.  The user must have\n\t// granted access to the user-read-private scope when the access\n\t// token was issued.\n\tMarketFromToken = \"from_token\"\n)\n\n// SearchType represents the type of a query used in the Search function.\ntype SearchType int\n\n// Search type values that can be passed to the Search function.  These are flags\n// that can be bitwise OR'd together to search for multiple types of content simultaneously.\nconst (\n\tSearchTypeAlbum    SearchType = 1 << iota\n\tSearchTypeArtist              = 1 << iota\n\tSearchTypePlaylist            = 1 << iota\n\tSearchTypeTrack               = 1 << iota\n)\n\nfunc (st SearchType) encode() string {\n\ttypes := []string{}\n\tif st&SearchTypeAlbum != 0 {\n\t\ttypes = append(types, \"album\")\n\t}\n\tif st&SearchTypeArtist != 0 {\n\t\ttypes = append(types, \"artist\")\n\t}\n\tif st&SearchTypePlaylist != 0 {\n\t\ttypes = append(types, \"playlist\")\n\t}\n\tif st&SearchTypeTrack != 0 {\n\t\ttypes = append(types, \"track\")\n\t}\n\treturn strings.Join(types, \",\")\n}\n\n// SearchResult contains the results of a call to Search.\n// Fields that weren't searched for will be nil pointers.\ntype SearchResult struct {\n\tArtists   *FullArtistPage     `json:\"artists\"`\n\tAlbums    *SimpleAlbumPage    `json:\"albums\"`\n\tPlaylists *SimplePlaylistPage `json:\"playlists\"`\n\tTracks    *FullTrackPage      `json:\"tracks\"`\n}\n\n// Search gets Spotify catalog information about artists, albums, tracks,\n// or playlists that match a keyword string.  t is a mask containing one or more\n// search types.  For example, `Search(query, SearchTypeArtist|SearchTypeAlbum)`\n// will search for artists or albums matching the specified keywords.\n//\n// Matching\n//\n// Matching of search keywords is NOT case sensitive.  Keywords are matched in\n// any order unless surrounded by double quotes. Searching for playlists will\n// return results where the query keyword(s) match any part of the playlist's\n// name or description. Only popular public playlists are returned.\n//\n// Operators\n//\n// The operator NOT can be used to exclude results.  For example,\n// query = \"roadhouse NOT blues\" returns items that match \"roadhouse\" but exludes\n// those that also contain the keyword \"blues\".  Similarly, the OR operator can\n// be used to broaden the search.  query = \"roadhouse OR blues\" returns all results\n// that include either of the terms.  Only one OR operator can be used in a query.\n//\n// Operators should be specified in uppercase.\n//\n// Wildcards\n//\n// The asterisk (*) character can, with some limitations, be used as a wildcard\n// (maximum of 2 per query).  It will match a variable number of non-white-space\n// characters.  It cannot be used in a quoted phrase, in a field filter, or as\n// the first character of a keyword string.\n//\n// Field filters\n//\n// By default, results are returned when a match is found in any field of the\n// target object type.  Searches can be made more specific by specifying an album,\n// artist, or track field filter.  For example, \"album:gold artist:abba type:album\"\n// will only return results with the text \"gold\" in the album name and the text\n// \"abba\" in the artist's name.\n//\n// The field filter \"year\" can be used with album, artist, and track searches to\n// limit the results to a particular year. For example \"bob year:2014\" or\n// \"bob year:1980-2020\".\n//\n// The field filter \"tag:new\" can be used in album searches to retrieve only\n// albums released in the last two weeks. The field filter \"tag:hipster\" can be\n// used in album searches to retrieve only albums with the lowest 10% popularity.\n//\n// Other possible field filters, depending on object types being searched,\n// include \"genre\", \"upc\", and \"isrc\".  For example \"damian genre:reggae-pop\".\nfunc (c *Client) Search(query string, t SearchType) (*SearchResult, error) {\n\treturn c.SearchOpt(query, t, nil)\n}\n\n// SearchOpt works just like Search, but it accepts additional\n// parameters for filtering the output.  See the documentation for Search more\n// more information.\n//\n// If the Country field is specified in the options, then the results will only\n// contain artists, albums, and tracks playable in the specified country\n// (playlist results are not affected by the Country option).  Additionally,\n// the constant MarketFromToken can be used with authenticated clients.\n// If the client has a valid access token, then the results will only include\n// content playable in the user's country.\nfunc (c *Client) SearchOpt(query string, t SearchType, opt *Options) (*SearchResult, error) {\n\tv := url.Values{}\n\tv.Set(\"q\", query)\n\tv.Set(\"type\", t.encode())\n\tif opt != nil {\n\t\tif opt.Limit != nil {\n\t\t\tv.Set(\"limit\", strconv.Itoa(*opt.Limit))\n\t\t}\n\t\tif opt.Country != nil {\n\t\t\tv.Set(\"market\", *opt.Country)\n\t\t}\n\t\tif opt.Offset != nil {\n\t\t\tv.Set(\"offset\", strconv.Itoa(*opt.Offset))\n\t\t}\n\t}\n\n\tspotifyURL := c.baseURL + \"search?\" + v.Encode()\n\n\tvar result SearchResult\n\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, err\n}\n\n// NextArtistResults loads the next page of artists into the specified search result.\nfunc (c *Client) NextArtistResults(s *SearchResult) error {\n\tif s.Artists == nil || s.Artists.Next == \"\" {\n\t\treturn ErrNoMorePages\n\t}\n\treturn c.get(s.Artists.Next, s)\n}\n\n// PreviousArtistResults loads the previous page of artists into the specified search result.\nfunc (c *Client) PreviousArtistResults(s *SearchResult) error {\n\tif s.Artists == nil || s.Artists.Previous == \"\" {\n\t\treturn ErrNoMorePages\n\t}\n\treturn c.get(s.Artists.Previous, s)\n}\n\n// NextAlbumResults loads the next page of albums into the specified search result.\nfunc (c *Client) NextAlbumResults(s *SearchResult) error {\n\tif s.Albums == nil || s.Albums.Next == \"\" {\n\t\treturn ErrNoMorePages\n\t}\n\treturn c.get(s.Albums.Next, s)\n}\n\n// PreviousAlbumResults loads the previous page of albums into the specified search result.\nfunc (c *Client) PreviousAlbumResults(s *SearchResult) error {\n\tif s.Albums == nil || s.Albums.Previous == \"\" {\n\t\treturn ErrNoMorePages\n\t}\n\treturn c.get(s.Albums.Previous, s)\n}\n\n// NextPlaylistResults loads the next page of playlists into the specified search result.\nfunc (c *Client) NextPlaylistResults(s *SearchResult) error {\n\tif s.Playlists == nil || s.Playlists.Next == \"\" {\n\t\treturn ErrNoMorePages\n\t}\n\treturn c.get(s.Playlists.Next, s)\n}\n\n// PreviousPlaylistResults loads the previous page of playlists into the specified search result.\nfunc (c *Client) PreviousPlaylistResults(s *SearchResult) error {\n\tif s.Playlists == nil || s.Playlists.Previous == \"\" {\n\t\treturn ErrNoMorePages\n\t}\n\treturn c.get(s.Playlists.Previous, s)\n}\n\n// PreviousTrackResults loads the previous page of tracks into the specified search result.\nfunc (c *Client) PreviousTrackResults(s *SearchResult) error {\n\tif s.Tracks == nil || s.Tracks.Previous == \"\" {\n\t\treturn ErrNoMorePages\n\t}\n\treturn c.get(s.Tracks.Previous, s)\n}\n\n// NextTrackResults loads the next page of tracks into the specified search result.\nfunc (c *Client) NextTrackResults(s *SearchResult) error {\n\tif s.Tracks == nil || s.Tracks.Next == \"\" {\n\t\treturn ErrNoMorePages\n\t}\n\treturn c.get(s.Tracks.Next, s)\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/search_test.go",
    "content": "package spotify\n\nimport (\n\t\"net/http\"\n\t\"testing\"\n)\n\nfunc TestSearchArtist(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/search_artist.txt\")\n\tdefer server.Close()\n\n\tresult, err := client.Search(\"tania bowra\", SearchTypeArtist)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif result.Albums != nil {\n\t\tt.Error(\"Searched for artists but received album results\")\n\t}\n\tif result.Playlists != nil {\n\t\tt.Error(\"Searched for artists but received playlist results\")\n\t}\n\tif result.Tracks != nil {\n\t\tt.Error(\"Searched for artists but received track results\")\n\t}\n\tif result.Artists == nil || len(result.Artists.Artists) == 0 {\n\t\tt.Error(\"Didn't receive artist results\")\n\t}\n\tif result.Artists.Artists[0].Name != \"Tania Bowra\" {\n\t\tt.Error(\"Got wrong artist name\")\n\t}\n}\n\nfunc TestSearchTracks(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/search_tracks.txt\")\n\tdefer server.Close()\n\n\tresult, err := client.Search(\"uptown\", SearchTypeTrack)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif result.Albums != nil {\n\t\tt.Error(\"Searched for tracks but got album results\")\n\t}\n\tif result.Playlists != nil {\n\t\tt.Error(\"Searched for tracks but got playlist results\")\n\t}\n\tif result.Artists != nil {\n\t\tt.Error(\"Searched for tracks but got artist results\")\n\t}\n\tif result.Tracks == nil || len(result.Tracks.Tracks) == 0 {\n\t\tt.Fatal(\"Didn't receive track results\")\n\t}\n\tif name := result.Tracks.Tracks[0].Name; name != \"Uptown Funk\" {\n\t\tt.Errorf(\"Got %s, wanted Uptown Funk\\n\", name)\n\t}\n}\n\nfunc TestSearchPlaylistTrack(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/search_trackplaylist.txt\")\n\tdefer server.Close()\n\n\tresult, err := client.Search(\"holiday\", SearchTypePlaylist|SearchTypeTrack)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif result.Albums != nil {\n\t\tt.Error(\"Searched for playlists and tracks but received album results\")\n\t}\n\tif result.Artists != nil {\n\t\tt.Error(\"Searched for playlists and tracks but received artist results\")\n\t}\n\tif result.Tracks == nil {\n\t\tt.Error(\"Didn't receive track results\")\n\t}\n\tif result.Playlists == nil {\n\t\tt.Error(\"Didn't receive playlist results\")\n\t}\n}\n\nfunc TestPrevNextSearchPageErrors(t *testing.T) {\n\tclient, server := testClientString(0, \"\")\n\tdefer server.Close()\n\n\t// we expect to get ErrNoMorePages when trying to get the prev/next page\n\t// under either of these conditions:\n\n\t//  1) there are no results (nil)\n\tnilResults := &SearchResult{nil, nil, nil, nil}\n\tif client.NextAlbumResults(nilResults) != ErrNoMorePages ||\n\t\tclient.NextArtistResults(nilResults) != ErrNoMorePages ||\n\t\tclient.NextPlaylistResults(nilResults) != ErrNoMorePages ||\n\t\tclient.NextTrackResults(nilResults) != ErrNoMorePages {\n\t\tt.Error(\"Next search result page should have failed for nil results\")\n\t}\n\tif client.PreviousAlbumResults(nilResults) != ErrNoMorePages ||\n\t\tclient.PreviousArtistResults(nilResults) != ErrNoMorePages ||\n\t\tclient.PreviousPlaylistResults(nilResults) != ErrNoMorePages ||\n\t\tclient.PreviousTrackResults(nilResults) != ErrNoMorePages {\n\t\tt.Error(\"Previous search result page should have failed for nil results\")\n\t}\n\t//  2) the prev/next URL is empty\n\temptyURL := &SearchResult{\n\t\tArtists:   new(FullArtistPage),\n\t\tAlbums:    new(SimpleAlbumPage),\n\t\tPlaylists: new(SimplePlaylistPage),\n\t\tTracks:    new(FullTrackPage),\n\t}\n\tif client.NextAlbumResults(emptyURL) != ErrNoMorePages ||\n\t\tclient.NextArtistResults(emptyURL) != ErrNoMorePages ||\n\t\tclient.NextPlaylistResults(emptyURL) != ErrNoMorePages ||\n\t\tclient.NextTrackResults(emptyURL) != ErrNoMorePages {\n\t\tt.Error(\"Next search result page should have failed with empty URL\")\n\t}\n\tif client.PreviousAlbumResults(emptyURL) != ErrNoMorePages ||\n\t\tclient.PreviousArtistResults(emptyURL) != ErrNoMorePages ||\n\t\tclient.PreviousPlaylistResults(emptyURL) != ErrNoMorePages ||\n\t\tclient.PreviousTrackResults(emptyURL) != ErrNoMorePages {\n\t\tt.Error(\"Previous search result page should have failed with empty URL\")\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/spotify.go",
    "content": "// Package spotify provides utilties for interfacing\n// with Spotify's Web API.\npackage spotify\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"time\"\n)\n\n// Version is the version of this library.\nconst Version = \"1.0.0\"\n\nconst (\n\t// DateLayout can be used with time.Parse to create time.Time values\n\t// from Spotify date strings.  For example, PrivateUser.Birthdate\n\t// uses this format.\n\tDateLayout = \"2006-01-02\"\n\t// TimestampLayout can be used with time.Parse to create time.Time\n\t// values from SpotifyTimestamp strings.  It is an ISO 8601 UTC timestamp\n\t// with a zero offset.  For example, PlaylistTrack's AddedAt field uses\n\t// this format.\n\tTimestampLayout = \"2006-01-02T15:04:05Z\"\n\n\t// defaultRetryDurationS helps us fix an apparent server bug whereby we will\n\t// be told to retry but not be given a wait-interval.\n\tdefaultRetryDuration = time.Second * 5\n\n\t// rateLimitExceededStatusCode is the code that the server returns when our\n\t// request frequency is too high.\n\trateLimitExceededStatusCode = 429\n)\n\nconst baseAddress = \"https://api.spotify.com/v1/\"\n\n// Client is a client for working with the Spotify Web API.\n// To create an authenticated client, use the `Authenticator.NewClient` method.\ntype Client struct {\n\thttp    *http.Client\n\tbaseURL string\n\n\tAutoRetry bool\n}\n\n// URI identifies an artist, album, track, or category.  For example,\n// spotify:track:6rqhFgbbKwnb9MLmUQDhG6\ntype URI string\n\n// ID is a base-62 identifier for an artist, track, album, etc.\n// It can be found at the end of a spotify.URI.\ntype ID string\n\nfunc (id *ID) String() string {\n\treturn string(*id)\n}\n\n// Followers contains information about the number of people following a\n// particular artist or playlist.\ntype Followers struct {\n\t// The total number of followers.\n\tCount uint `json:\"total\"`\n\t// A link to the Web API endpoint providing full details of the followers,\n\t// or the empty string if this data is not available.\n\tEndpoint string `json:\"href\"`\n}\n\n// Image identifies an image associated with an item.\ntype Image struct {\n\t// The image height, in pixels.\n\tHeight int `json:\"height\"`\n\t// The image width, in pixels.\n\tWidth int `json:\"width\"`\n\t// The source URL of the image.\n\tURL string `json:\"url\"`\n}\n\n// Download downloads the image and writes its data to the specified io.Writer.\nfunc (i Image) Download(dst io.Writer) error {\n\tresp, err := http.Get(i.URL)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\t// TODO: get Content-Type from header?\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn errors.New(\"Couldn't download image - HTTP\" + strconv.Itoa(resp.StatusCode))\n\t}\n\t_, err = io.Copy(dst, resp.Body)\n\treturn err\n}\n\n// Error represents an error returned by the Spotify Web API.\ntype Error struct {\n\t// A short description of the error.\n\tMessage string `json:\"message\"`\n\t// The HTTP status code.\n\tStatus int `json:\"status\"`\n}\n\nfunc (e Error) Error() string {\n\treturn e.Message\n}\n\n// decodeError decodes an Error from an io.Reader.\nfunc (c *Client) decodeError(resp *http.Response) error {\n\tresponseBody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(responseBody) == 0 {\n\t\treturn fmt.Errorf(\"spotify: HTTP %d: %s (body empty)\", resp.StatusCode, http.StatusText(resp.StatusCode))\n\t}\n\n\tbuf := bytes.NewBuffer(responseBody)\n\n\tvar e struct {\n\t\tE Error `json:\"error\"`\n\t}\n\terr = json.NewDecoder(buf).Decode(&e)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"spotify: couldn't decode error: (%d) [%s]\", len(responseBody), responseBody)\n\t}\n\n\tif e.E.Message == \"\" {\n\t\t// Some errors will result in there being a useful status-code but an\n\t\t// empty message, which will confuse the user (who only has access to\n\t\t// the message and not the code). An example of this is when we send\n\t\t// some of the arguments directly in the HTTP query and the URL ends-up\n\t\t// being too long.\n\n\t\te.E.Message = fmt.Sprintf(\"spotify: unexpected HTTP %d: %s (empty error)\",\n\t\t\tresp.StatusCode, http.StatusText(resp.StatusCode))\n\t}\n\n\treturn e.E\n}\n\n// shouldRetry determines whether the status code indicates that the\n// previous operation should be retried at a later time\nfunc shouldRetry(status int) bool {\n\treturn status == http.StatusAccepted || status == http.StatusTooManyRequests\n}\n\n// isFailure determines whether the code indicates failure\nfunc isFailure(code int, validCodes []int) bool {\n\tfor _, item := range validCodes {\n\t\tif item == code {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n// execute executes a non-GET request. `needsStatus` describes other HTTP status codes\n// that can represent success. Note that in all current usages of this function,\n// we need to still allow a 200 even if we'd also like to check for additional\n// success codes.\nfunc (c *Client) execute(req *http.Request, result interface{}, needsStatus ...int) error {\n\tfor {\n\t\tresp, err := c.http.Do(req)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer resp.Body.Close()\n\n\t\tif c.AutoRetry && shouldRetry(resp.StatusCode) {\n\t\t\ttime.Sleep(retryDuration(resp))\n\t\t\tcontinue\n\t\t}\n\t\tif resp.StatusCode != http.StatusOK && isFailure(resp.StatusCode, needsStatus) {\n\t\t\treturn c.decodeError(resp)\n\t\t}\n\n\t\tif result != nil {\n\t\t\tif err := json.NewDecoder(resp.Body).Decode(result); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tbreak\n\t}\n\treturn nil\n}\n\nfunc retryDuration(resp *http.Response) time.Duration {\n\traw := resp.Header.Get(\"Retry-After\")\n\tif raw == \"\" {\n\t\treturn defaultRetryDuration\n\t}\n\tseconds, err := strconv.ParseInt(raw, 10, 32)\n\tif err != nil {\n\t\treturn defaultRetryDuration\n\t}\n\treturn time.Duration(seconds) * time.Second\n}\n\nfunc (c *Client) get(url string, result interface{}) error {\n\tfor {\n\t\tresp, err := c.http.Get(url)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tdefer resp.Body.Close()\n\n\t\tif resp.StatusCode == rateLimitExceededStatusCode && c.AutoRetry {\n\t\t\ttime.Sleep(retryDuration(resp))\n\t\t\tcontinue\n\t\t}\n\t\tif resp.StatusCode != http.StatusOK {\n\t\t\treturn c.decodeError(resp)\n\t\t}\n\n\t\terr = json.NewDecoder(resp.Body).Decode(result)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tbreak\n\t}\n\n\treturn nil\n}\n\n// Options contains optional parameters that can be provided\n// to various API calls.  Only the non-nil fields are used\n// in queries.\ntype Options struct {\n\t// Country is an ISO 3166-1 alpha-2 country code.  Provide\n\t// this parameter if you want the list of returned items to\n\t// be relevant to a particular country.  If omitted, the\n\t// results will be relevant to all countries.\n\tCountry *string\n\t// Limit is the maximum number of items to return.\n\tLimit *int\n\t// Offset is the index of the first item to return.  Use it\n\t// with Limit to get the next set of items.\n\tOffset *int\n\t// Timerange is the period of time from which to return results\n\t// in certain API calls. The three options are the following string\n\t// literals: \"short\", \"medium\", and \"long\"\n\tTimerange *string\n}\n\n// NewReleasesOpt is like NewReleases, but it accepts optional parameters\n// for filtering the results.\nfunc (c *Client) NewReleasesOpt(opt *Options) (albums *SimpleAlbumPage, err error) {\n\tspotifyURL := c.baseURL + \"browse/new-releases\"\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.Country != nil {\n\t\t\tv.Set(\"country\", *opt.Country)\n\t\t}\n\t\tif opt.Limit != nil {\n\t\t\tv.Set(\"limit\", strconv.Itoa(*opt.Limit))\n\t\t}\n\t\tif opt.Offset != nil {\n\t\t\tv.Set(\"offset\", strconv.Itoa(*opt.Offset))\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\n\tvar objmap map[string]*json.RawMessage\n\terr = c.get(spotifyURL, &objmap)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar result SimpleAlbumPage\n\terr = json.Unmarshal(*objmap[\"albums\"], &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, nil\n}\n\n// NewReleases gets a list of new album releases featured in Spotify.\n// This call requires bearer authorization.\nfunc (c *Client) NewReleases() (albums *SimpleAlbumPage, err error) {\n\treturn c.NewReleasesOpt(nil)\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/spotify_test.go",
    "content": "package spotify\n\nimport (\n\t\"io\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"os\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc testClient(code int, body io.Reader, validators ...func(*http.Request)) (*Client, *httptest.Server) {\n\tserver := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tfor _, v := range validators {\n\t\t\tv(r)\n\t\t}\n\t\tw.WriteHeader(code)\n\t\tio.Copy(w, body)\n\t\tr.Body.Close()\n\t\tif closer, ok := body.(io.Closer); ok {\n\t\t\tcloser.Close()\n\t\t}\n\t}))\n\tclient := &Client{\n\t\thttp:    http.DefaultClient,\n\t\tbaseURL: server.URL + \"/\",\n\t}\n\treturn client, server\n}\n\n// Returns a client whose requests will always return\n// the specified status code and body.\nfunc testClientString(code int, body string, validators ...func(*http.Request)) (*Client, *httptest.Server) {\n\treturn testClient(code, strings.NewReader(body))\n}\n\n// Returns a client whose requests will always return\n// a response with the specified status code and a body\n// that is read from the specified file.\nfunc testClientFile(code int, filename string, validators ...func(*http.Request)) (*Client, *httptest.Server) {\n\tf, err := os.Open(filename)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn testClient(code, f)\n}\n\nfunc TestNewReleases(t *testing.T) {\n\tc, s := testClientFile(http.StatusOK, \"test_data/new_releases.txt\")\n\tdefer s.Close()\n\n\tr, err := c.NewReleases()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif r.Albums[0].ID != \"60mvULtYiNSRmpVvoa3RE4\" {\n\t\tt.Error(\"Invalid data:\", r.Albums[0].ID)\n\t}\n\tif r.Albums[0].Name != \"We Are One (Ole Ola) [The Official 2014 FIFA World Cup Song]\" {\n\t\tt.Error(\"Invalid data\", r.Albums[0].Name)\n\t}\n}\n\nfunc TestNewReleasesRateLimitExceeded(t *testing.T) {\n\tt.Parallel()\n\thandlers := []http.HandlerFunc{\n\t\t// first attempt fails\n\t\thttp.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tw.Header().Set(\"Retry-After\", \"2\")\n\t\t\tw.WriteHeader(rateLimitExceededStatusCode)\n\t\t\tio.WriteString(w, `{ \"error\": { \"message\": \"slow down\", \"status\": 429 } }`)\n\t\t}),\n\t\t// next attempt succeeds\n\t\thttp.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tf, err := os.Open(\"test_data/new_releases.txt\")\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\t\t\tdefer f.Close()\n\t\t\t_, err = io.Copy(w, f)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\t\t}),\n\t}\n\n\ti := 0\n\tserver := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\thandlers[i](w, r)\n\t\ti++\n\t}))\n\tdefer server.Close()\n\n\tclient := &Client{http: http.DefaultClient, baseURL: server.URL + \"/\", AutoRetry: true}\n\treleases, err := client.NewReleases()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif releases.Albums[0].ID != \"60mvULtYiNSRmpVvoa3RE4\" {\n\t\tt.Error(\"Invalid data:\", releases.Albums[0].ID)\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/track.go",
    "content": "package spotify\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"strings\"\n\t\"time\"\n)\n\n// SimpleTrack contains basic info about a track.\ntype SimpleTrack struct {\n\tArtists []SimpleArtist `json:\"artists\"`\n\t// A list of the countries in which the track can be played,\n\t// identified by their ISO 3166-1 alpha-2 codes.\n\tAvailableMarkets []string `json:\"available_markets\"`\n\t// The disc number (usually 1 unless the album consists of more than one disc).\n\tDiscNumber int `json:\"disc_number\"`\n\t// The length of the track, in milliseconds.\n\tDuration int `json:\"duration_ms\"`\n\t// Whether or not the track has explicit lyrics.\n\t// true => yes, it does; false => no, it does not.\n\tExplicit bool `json:\"explicit\"`\n\t// External URLs for this track.\n\tExternalURLs map[string]string `json:\"external_urls\"`\n\t// A link to the Web API endpoint providing full details for this track.\n\tEndpoint string `json:\"href\"`\n\tID       ID     `json:\"id\"`\n\tName     string `json:\"name\"`\n\t// A URL to a 30 second preview (MP3) of the track.\n\tPreviewURL string `json:\"preview_url\"`\n\t// The number of the track.  If an album has several\n\t// discs, the track number is the number on the specified\n\t// DiscNumber.\n\tTrackNumber int `json:\"track_number\"`\n\tURI         URI `json:\"uri\"`\n}\n\nfunc (st SimpleTrack) String() string {\n\treturn fmt.Sprintf(\"TRACK<[%s] [%s]>\", st.ID, st.Name)\n}\n\n// FullTrack provides extra track data in addition to what is provided by SimpleTrack.\ntype FullTrack struct {\n\tSimpleTrack\n\t// The album on which the track appears. The album object includes a link in href to full information about the album.\n\tAlbum SimpleAlbum `json:\"album\"`\n\t// Known external IDs for the track.\n\tExternalIDs map[string]string `json:\"external_ids\"`\n\t// Popularity of the track.  The value will be between 0 and 100,\n\t// with 100 being the most popular.  The popularity is calculated from\n\t// both total plays and most recent plays.\n\tPopularity int `json:\"popularity\"`\n}\n\n// PlaylistTrack contains info about a track in a playlist.\ntype PlaylistTrack struct {\n\t// The date and time the track was added to the playlist.\n\t// You can use the TimestampLayout constant to convert\n\t// this field to a time.Time value.\n\t// Warning: very old playlists may not populate this value.\n\tAddedAt string `json:\"added_at\"`\n\t// The Spotify user who added the track to the playlist.\n\t// Warning: vary old playlists may not populate this value.\n\tAddedBy User `json:\"added_by\"`\n\t// Information about the track.\n\tTrack FullTrack `json:\"track\"`\n}\n\n// SavedTrack provides info about a track saved to a user's account.\ntype SavedTrack struct {\n\t// The date and time the track was saved, represented as an ISO\n\t// 8601 UTC timestamp with a zero offset (YYYY-MM-DDTHH:MM:SSZ).\n\t// You can use the TimestampLayout constant to convert this to\n\t// a time.Time value.\n\tAddedAt   string `json:\"added_at\"`\n\tFullTrack `json:\"track\"`\n}\n\n// TimeDuration returns the track's duration as a time.Duration value.\nfunc (t *SimpleTrack) TimeDuration() time.Duration {\n\treturn time.Duration(t.Duration) * time.Millisecond\n}\n\n// GetTrack gets Spotify catalog information for\n// a single track identified by its unique Spotify ID.\nfunc (c *Client) GetTrack(id ID) (*FullTrack, error) {\n\tspotifyURL := c.baseURL + \"tracks/\" + string(id)\n\n\tvar t FullTrack\n\n\terr := c.get(spotifyURL, &t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &t, nil\n}\n\n// GetTracks gets Spotify catalog information for multiple tracks based on their\n// Spotify IDs.  It supports up to 50 tracks in a single call.  Tracks are\n// returned in the order requested.  If a track is not found, that position in the\n// result will be nil.  Duplicate ids in the query will result in duplicate\n// tracks in the result.\nfunc (c *Client) GetTracks(ids ...ID) ([]*FullTrack, error) {\n\tif len(ids) > 50 {\n\t\treturn nil, errors.New(\"spotify: FindTracks supports up to 50 tracks\")\n\t}\n\tspotifyURL := c.baseURL + \"tracks?ids=\" + strings.Join(toStringSlice(ids), \",\")\n\n\tvar t struct {\n\t\tTracks []*FullTrack `jsosn:\"tracks\"`\n\t}\n\n\terr := c.get(spotifyURL, &t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn t.Tracks, nil\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/track_attributes.go",
    "content": "package spotify\n\n// TrackAttributes contains various tuneable parameters that can be used for recommendations.\n// For each of the tuneable track attributes, target, min and max values may be provided.\n// Target:\n//   Tracks with the attribute values nearest to the target values will be preferred.\n//   For example, you might request TargetEnergy=0.6 and TargetDanceability=0.8.\n//   All target values will be weighed equally in ranking results.\n// Max:\n//   A hard ceiling on the selected track attribute’s value can be provided.\n//   For example, MaxInstrumentalness=0.35 would filter out most tracks\n//   that are likely to be instrumental.\n// Min:\n//   A hard floor on the selected track attribute’s value can be provided.\n//   For example, min_tempo=140 would restrict results to only those tracks\n//   with a tempo of greater than 140 beats per minute.\ntype TrackAttributes struct {\n\tintAttributes   map[string]int\n\tfloatAttributes map[string]float64\n}\n\n// NewTrackAttributes returns a new TrackAttributes instance with no attributes set.\n// Attributes can then be chained following a builder pattern:\n//\tta := NewTrackAttributes().\n//\t\t\tMaxAcousticness(0.15).\n//\t\t\tTargetPopularity(90)\nfunc NewTrackAttributes() *TrackAttributes {\n\treturn &TrackAttributes{\n\t\tintAttributes:   map[string]int{},\n\t\tfloatAttributes: map[string]float64{},\n\t}\n}\n\n// MaxAcousticness sets the maximum acousticness\n// Acousticness is a confidence measure from 0.0 to 1.0 of whether\n// the track is acoustic.  A value of 1.0 represents high confidence\n// that the track is acoustic.\nfunc (ta *TrackAttributes) MaxAcousticness(acousticness float64) *TrackAttributes {\n\tta.floatAttributes[\"max_acousticness\"] = acousticness\n\treturn ta\n}\n\n// MinAcousticness sets the minimum acousticness\n// Acousticness is a confidence measure from 0.0 to 1.0 of whether\n// the track is acoustic.  A value of 1.0 represents high confidence\n// that the track is acoustic.\nfunc (ta *TrackAttributes) MinAcousticness(acousticness float64) *TrackAttributes {\n\tta.floatAttributes[\"min_acousticness\"] = acousticness\n\treturn ta\n}\n\n// TargetAcousticness sets the target acousticness\n// Acousticness is a confidence measure from 0.0 to 1.0 of whether\n// the track is acoustic.  A value of 1.0 represents high confidence\n// that the track is acoustic.\nfunc (ta *TrackAttributes) TargetAcousticness(acousticness float64) *TrackAttributes {\n\tta.floatAttributes[\"target_acousticness\"] = acousticness\n\treturn ta\n}\n\n// MaxDanceability sets the maximum danceability\n// Danceability describes how suitable a track is for dancing based on\n// a combination of musical elements including tempo, rhythm stability,\n// beat strength, and overall regularity.\n// A value of 0.0 is least danceable and 1.0 is most danceable.\nfunc (ta *TrackAttributes) MaxDanceability(danceability float64) *TrackAttributes {\n\tta.floatAttributes[\"max_danceability\"] = danceability\n\treturn ta\n}\n\n// MinDanceability sets the minimum danceability\n// Danceability describes how suitable a track is for dancing based on\n// a combination of musical elements including tempo, rhythm stability,\n// beat strength, and overall regularity.\n// A value of 0.0 is least danceable and 1.0 is most danceable.\nfunc (ta *TrackAttributes) MinDanceability(danceability float64) *TrackAttributes {\n\tta.floatAttributes[\"min_danceability\"] = danceability\n\treturn ta\n}\n\n// TargetDanceability sets the target danceability\n// Danceability describes how suitable a track is for dancing based on\n// a combination of musical elements including tempo, rhythm stability,\n// beat strength, and overall regularity.\n// A value of 0.0 is least danceable and 1.0 is most danceable.\nfunc (ta *TrackAttributes) TargetDanceability(danceability float64) *TrackAttributes {\n\tta.floatAttributes[\"target_danceability\"] = danceability\n\treturn ta\n}\n\n// MaxDuration sets the maximum length of the track in milliseconds\nfunc (ta *TrackAttributes) MaxDuration(duration int) *TrackAttributes {\n\tta.intAttributes[\"max_duration_ms\"] = duration\n\treturn ta\n}\n\n// MinDuration sets the minimum length of the track in milliseconds\nfunc (ta *TrackAttributes) MinDuration(duration int) *TrackAttributes {\n\tta.intAttributes[\"min_duration_ms\"] = duration\n\treturn ta\n}\n\n// TargetDuration sets the target length of the track in milliseconds\nfunc (ta *TrackAttributes) TargetDuration(duration int) *TrackAttributes {\n\tta.intAttributes[\"target_duration_ms\"] = duration\n\treturn ta\n}\n\n// MaxEnergy sets the maximum energy\n// Energy is a measure from 0.0 to 1.0 and represents a perceptual mesaure\n// of intensity and activity.  Typically, energetic tracks feel fast, loud,\n// and noisy.\nfunc (ta *TrackAttributes) MaxEnergy(energy float64) *TrackAttributes {\n\tta.floatAttributes[\"max_energy\"] = energy\n\treturn ta\n}\n\n// MinEnergy sets the minimum energy\n// Energy is a measure from 0.0 to 1.0 and represents a perceptual mesaure\n// of intensity and activity.  Typically, energetic tracks feel fast, loud,\n// and noisy.\nfunc (ta *TrackAttributes) MinEnergy(energy float64) *TrackAttributes {\n\tta.floatAttributes[\"min_energy\"] = energy\n\treturn ta\n}\n\n// TargetEnergy sets the target energy\n// Energy is a measure from 0.0 to 1.0 and represents a perceptual mesaure\n// of intensity and activity.  Typically, energetic tracks feel fast, loud,\n// and noisy.\nfunc (ta *TrackAttributes) TargetEnergy(energy float64) *TrackAttributes {\n\tta.floatAttributes[\"target_energy\"] = energy\n\treturn ta\n}\n\n// MaxInstrumentalness sets the maximum instrumentalness\n// Instrumentalness predicts whether a track contains no vocals.\n// \"Ooh\" and \"aah\" sounds are treated as instrumental in this context.\n// Rap or spoken word tracks are clearly \"vocal\".\n// The closer the instrumentalness value is to 1.0,\n// the greater likelihood the track contains no vocal content.\n// Values above 0.5 are intended to represent instrumental tracks,\n// but confidence is higher as the value approaches 1.0.\nfunc (ta *TrackAttributes) MaxInstrumentalness(instrumentalness float64) *TrackAttributes {\n\tta.floatAttributes[\"max_instrumentalness\"] = instrumentalness\n\treturn ta\n\n}\n\n// MinInstrumentalness sets the minimum instrumentalness\n// Instrumentalness predicts whether a track contains no vocals.\n// \"Ooh\" and \"aah\" sounds are treated as instrumental in this context.\n// Rap or spoken word tracks are clearly \"vocal\".\n// The closer the instrumentalness value is to 1.0,\n// the greater likelihood the track contains no vocal content.\n// Values above 0.5 are intended to represent instrumental tracks,\n// but confidence is higher as the value approaches 1.0.\nfunc (ta *TrackAttributes) MinInstrumentalness(instrumentalness float64) *TrackAttributes {\n\tta.floatAttributes[\"min_instrumentalness\"] = instrumentalness\n\treturn ta\n\n}\n\n// TargetInstrumentalness sets the target instrumentalness\n// Instrumentalness predicts whether a track contains no vocals.\n// \"Ooh\" and \"aah\" sounds are treated as instrumental in this context.\n// Rap or spoken word tracks are clearly \"vocal\".\n// The closer the instrumentalness value is to 1.0,\n// the greater likelihood the track contains no vocal content.\n// Values above 0.5 are intended to represent instrumental tracks,\n// but confidence is higher as the value approaches 1.0.\nfunc (ta *TrackAttributes) TargetInstrumentalness(instrumentalness float64) *TrackAttributes {\n\tta.floatAttributes[\"target_instrumentalness\"] = instrumentalness\n\treturn ta\n\n}\n\n// MaxKey sets the maximum key\n// Integers map to pitches using standard Pitch Class notation\n// (https://en.wikipedia.org/wiki/Pitch_class).\nfunc (ta *TrackAttributes) MaxKey(key int) *TrackAttributes {\n\tta.intAttributes[\"max_key\"] = key\n\treturn ta\n}\n\n// MinKey sets the minimum key\n// Integers map to pitches using standard Pitch Class notation\n// (https://en.wikipedia.org/wiki/Pitch_class).\nfunc (ta *TrackAttributes) MinKey(key int) *TrackAttributes {\n\tta.intAttributes[\"min_key\"] = key\n\treturn ta\n}\n\n// TargetKey sets the target key\n// Integers map to pitches using standard Pitch Class notation\n// (https://en.wikipedia.org/wiki/Pitch_class).\nfunc (ta *TrackAttributes) TargetKey(key int) *TrackAttributes {\n\tta.intAttributes[\"target_key\"] = key\n\treturn ta\n}\n\n// MaxLiveness sets the maximum liveness\n// Detects the presence of an audience in the recording.  Higher liveness\n// values represent an increased probability that the track was performed live.\n// A value above 0.8 provides strong likelihook that the track is live.\nfunc (ta *TrackAttributes) MaxLiveness(liveness float64) *TrackAttributes {\n\tta.floatAttributes[\"max_liveness\"] = liveness\n\treturn ta\n}\n\n// MinLiveness sets the minimum liveness\n// Detects the presence of an audience in the recording.  Higher liveness\n// values represent an increased probability that the track was performed live.\n// A value above 0.8 provides strong likelihook that the track is live.\nfunc (ta *TrackAttributes) MinLiveness(liveness float64) *TrackAttributes {\n\tta.floatAttributes[\"min_liveness\"] = liveness\n\treturn ta\n}\n\n// TargetLiveness sets the target liveness\n// Detects the presence of an audience in the recording.  Higher liveness\n// values represent an increased probability that the track was performed live.\n// A value above 0.8 provides strong likelihook that the track is live.\nfunc (ta *TrackAttributes) TargetLiveness(liveness float64) *TrackAttributes {\n\tta.floatAttributes[\"target_liveness\"] = liveness\n\treturn ta\n}\n\n// MaxLoudness sets the maximum loudness in decibels (dB)\n// Loudness values are averaged across the entire track and are\n// useful for comparing the relative loudness of tracks.\n// Typical values range between -60 and 0 dB.\nfunc (ta *TrackAttributes) MaxLoudness(loudness float64) *TrackAttributes {\n\tta.floatAttributes[\"max_loudness\"] = loudness\n\treturn ta\n}\n\n// MinLoudness sets the minimum loudness in decibels (dB)\n// Loudness values are averaged across the entire track and are\n// useful for comparing the relative loudness of tracks.\n// Typical values range between -60 and 0 dB.\nfunc (ta *TrackAttributes) MinLoudness(loudness float64) *TrackAttributes {\n\tta.floatAttributes[\"min_loudness\"] = loudness\n\treturn ta\n}\n\n// TargetLoudness sets the target loudness in decibels (dB)\n// Loudness values are averaged across the entire track and are\n// useful for comparing the relative loudness of tracks.\n// Typical values range between -60 and 0 dB.\nfunc (ta *TrackAttributes) TargetLoudness(loudness float64) *TrackAttributes {\n\tta.floatAttributes[\"target_loudness\"] = loudness\n\treturn ta\n}\n\n// MaxMode sets the maximum mode\n// Mode indicates the modality (major or minor) of a track.\nfunc (ta *TrackAttributes) MaxMode(mode int) *TrackAttributes {\n\tta.intAttributes[\"max_mode\"] = mode\n\treturn ta\n}\n\n// MinMode sets the minimum mode\n// Mode indicates the modality (major or minor) of a track.\nfunc (ta *TrackAttributes) MinMode(mode int) *TrackAttributes {\n\tta.intAttributes[\"min_mode\"] = mode\n\treturn ta\n}\n\n// TargetMode sets the target mode\n// Mode indicates the modality (major or minor) of a track.\nfunc (ta *TrackAttributes) TargetMode(mode int) *TrackAttributes {\n\tta.intAttributes[\"target_mode\"] = mode\n\treturn ta\n}\n\n// MaxPopularity sets the maximum popularity.\n// The value will be between 0 and 100, with 100 being the most popular.\n// The popularity is calculated by algorithm and is based, in the most part,\n// on the total number of plays the track has had and how recent those plays are.\n// Note: When applying track relinking via the market parameter, it is expected to find\n// relinked tracks with popularities that do not match min_*, max_* and target_* popularities.\n// These relinked tracks are accurate replacements for unplayable tracks\n// with the expected popularity scores. Original, non-relinked tracks are\n// available via the linked_from attribute of the relinked track response.\nfunc (ta *TrackAttributes) MaxPopularity(popularity int) *TrackAttributes {\n\tta.intAttributes[\"max_popularity\"] = popularity\n\treturn ta\n}\n\n// MinPopularity sets the minimum popularity.\n// The value will be between 0 and 100, with 100 being the most popular.\n// The popularity is calculated by algorithm and is based, in the most part,\n// on the total number of plays the track has had and how recent those plays are.\n// Note: When applying track relinking via the market parameter, it is expected to find\n// relinked tracks with popularities that do not match min_*, max_* and target_* popularities.\n// These relinked tracks are accurate replacements for unplayable tracks\n// with the expected popularity scores. Original, non-relinked tracks are\n// available via the linked_from attribute of the relinked track response.\nfunc (ta *TrackAttributes) MinPopularity(popularity int) *TrackAttributes {\n\tta.intAttributes[\"min_popularity\"] = popularity\n\treturn ta\n}\n\n// TargetPopularity sets the target popularity.\n// The value will be between 0 and 100, with 100 being the most popular.\n// The popularity is calculated by algorithm and is based, in the most part,\n// on the total number of plays the track has had and how recent those plays are.\n// Note: When applying track relinking via the market parameter, it is expected to find\n// relinked tracks with popularities that do not match min_*, max_* and target_* popularities.\n// These relinked tracks are accurate replacements for unplayable tracks\n// with the expected popularity scores. Original, non-relinked tracks are\n// available via the linked_from attribute of the relinked track response.\nfunc (ta *TrackAttributes) TargetPopularity(popularity int) *TrackAttributes {\n\tta.intAttributes[\"target_popularity\"] = popularity\n\treturn ta\n}\n\n// MaxSpeechiness sets the maximum speechiness.\n// Speechiness detects the presence of spoken words in a track.\n// The more exclusively speech-like the recording, the closer to 1.0\n// the speechiness will be.\n// Values above 0.66 describe tracks that are probably made entirely of\n// spoken words.  Values between 0.33 and 0.66 describe tracks that may\n// contain both music and speech, including such cases as rap music.\n// Values below 0.33 most likely represent music and other non-speech-like tracks.\nfunc (ta *TrackAttributes) MaxSpeechiness(speechiness float64) *TrackAttributes {\n\tta.floatAttributes[\"max_speechiness\"] = speechiness\n\treturn ta\n\n}\n\n// MinSpeechiness sets the minimum speechiness.\n// Speechiness detects the presence of spoken words in a track.\n// The more exclusively speech-like the recording, the closer to 1.0\n// the speechiness will be.\n// Values above 0.66 describe tracks that are probably made entirely of\n// spoken words.  Values between 0.33 and 0.66 describe tracks that may\n// contain both music and speech, including such cases as rap music.\n// Values below 0.33 most likely represent music and other non-speech-like tracks.\nfunc (ta *TrackAttributes) MinSpeechiness(speechiness float64) *TrackAttributes {\n\tta.floatAttributes[\"min_speechiness\"] = speechiness\n\treturn ta\n\n}\n\n// TargetSpeechiness sets the target speechiness.\n// Speechiness detects the presence of spoken words in a track.\n// The more exclusively speech-like the recording, the closer to 1.0\n// the speechiness will be.\n// Values above 0.66 describe tracks that are probably made entirely of\n// spoken words.  Values between 0.33 and 0.66 describe tracks that may\n// contain both music and speech, including such cases as rap music.\n// Values below 0.33 most likely represent music and other non-speech-like tracks.\nfunc (ta *TrackAttributes) TargetSpeechiness(speechiness float64) *TrackAttributes {\n\tta.floatAttributes[\"target_speechiness\"] = speechiness\n\treturn ta\n}\n\n// MaxTempo sets the maximum tempo in beats per minute (BPM).\nfunc (ta *TrackAttributes) MaxTempo(tempo float64) *TrackAttributes {\n\tta.floatAttributes[\"max_tempo\"] = tempo\n\treturn ta\n}\n\n// MinTempo sets the minimum tempo in beats per minute (BPM).\nfunc (ta *TrackAttributes) MinTempo(tempo float64) *TrackAttributes {\n\tta.floatAttributes[\"min_tempo\"] = tempo\n\treturn ta\n}\n\n// TargetTempo sets the target tempo in beats per minute (BPM).\nfunc (ta *TrackAttributes) TargetTempo(tempo float64) *TrackAttributes {\n\tta.floatAttributes[\"target_tempo\"] = tempo\n\treturn ta\n\n}\n\n// MaxTimeSignature sets the maximum time signature\n// The time signature (meter) is a notational convention to\n// specify how many beats are in each bar (or measure).\nfunc (ta *TrackAttributes) MaxTimeSignature(timeSignature int) *TrackAttributes {\n\tta.intAttributes[\"max_time_signature\"] = timeSignature\n\treturn ta\n}\n\n// MinTimeSignature sets the minimum time signature\n// The time signature (meter) is a notational convention to\n// specify how many beats are in each bar (or measure).\nfunc (ta *TrackAttributes) MinTimeSignature(timeSignature int) *TrackAttributes {\n\tta.intAttributes[\"min_time_signature\"] = timeSignature\n\treturn ta\n}\n\n// TargetTimeSignature sets the target time signature\n// The time signature (meter) is a notational convention to\n// specify how many beats are in each bar (or measure).\nfunc (ta *TrackAttributes) TargetTimeSignature(timeSignature int) *TrackAttributes {\n\tta.intAttributes[\"target_time_signature\"] = timeSignature\n\treturn ta\n}\n\n// MaxValence sets the maximum valence.\n// Valence is a measure from 0.0 to 1.0 describing the musical positiveness\n/// conveyed by a track.\n// Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric),\n// while tracks with low valence sound more negative (e.g. sad, depressed, angry).\nfunc (ta *TrackAttributes) MaxValence(valence float64) *TrackAttributes {\n\tta.floatAttributes[\"max_valence\"] = valence\n\treturn ta\n}\n\n// MinValence sets the minimum valence.\n// Valence is a measure from 0.0 to 1.0 describing the musical positiveness\n/// conveyed by a track.\n// Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric),\n// while tracks with low valence sound more negative (e.g. sad, depressed, angry).\nfunc (ta *TrackAttributes) MinValence(valence float64) *TrackAttributes {\n\tta.floatAttributes[\"min_valence\"] = valence\n\treturn ta\n}\n\n// TargetValence sets the target valence.\n// Valence is a measure from 0.0 to 1.0 describing the musical positiveness\n/// conveyed by a track.\n// Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric),\n// while tracks with low valence sound more negative (e.g. sad, depressed, angry).\nfunc (ta *TrackAttributes) TargetValence(valence float64) *TrackAttributes {\n\tta.floatAttributes[\"target_valence\"] = valence\n\treturn ta\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/track_test.go",
    "content": "package spotify\n\nimport (\n\t\"net/http\"\n\t\"testing\"\n)\n\nfunc TestFindTrack(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/find_track.txt\")\n\tdefer server.Close()\n\n\ttrack, err := client.GetTrack(ID(\"1zHlj4dQ8ZAtrayhuDDmkY\"))\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\tif track.Name != \"Timber\" {\n\t\tt.Errorf(\"Wanted track Timer, got %s\\n\", track.Name)\n\t}\n}\n\nfunc TestFindTracksSimple(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/find_tracks_simple.txt\")\n\tdefer server.Close()\n\n\ttracks, err := client.GetTracks(ID(\"0eGsygTp906u18L0Oimnem\"), ID(\"1lDWb6b6ieDQ2xT7ewTC3G\"))\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\tif l := len(tracks); l != 2 {\n\t\tt.Errorf(\"Wanted 2 tracks, got %d\\n\", l)\n\t\treturn\n\t}\n\n}\n\nfunc TestFindTracksNotFound(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/find_tracks_notfound.txt\")\n\tdefer server.Close()\n\n\ttracks, err := client.GetTracks(ID(\"0eGsygTp906u18L0Oimnem\"), ID(\"1lDWb6b6iecccdsdckTC3G\"))\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\tif l := len(tracks); l != 2 {\n\t\tt.Errorf(\"Expected 2 results, got %d\\n\", l)\n\t\treturn\n\t}\n\tif tracks[0].Name != \"Mr. Brightside\" {\n\t\tt.Errorf(\"Expected Mr. Brightside, got %s\\n\", tracks[0].Name)\n\t}\n\tif tracks[1] != nil {\n\t\tt.Error(\"Expected nil track (invalid ID) but got valid track\")\n\t}\n}\n"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/user.go",
    "content": "package spotify\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// User contains the basic, publicly available information about a Spotify user.\ntype User struct {\n\t// The name displayed on the user's profile.\n\t// Note: Spotify currently fails to populate\n\t// this field when querying for a playlist.\n\tDisplayName string `json:\"display_name\"`\n\t// Known public external URLs for the user.\n\tExternalURLs map[string]string `json:\"external_urls\"`\n\t// Information about followers of the user.\n\tFollowers Followers `json:\"followers\"`\n\t// A link to the Web API endpoint for this user.\n\tEndpoint string `json:\"href\"`\n\t// The Spotify user ID for the user.\n\tID string `json:\"id\"`\n\t// The user's profile image.\n\tImages []Image `json:\"images\"`\n\t// The Spotify URI for the user.\n\tURI URI `json:\"uri\"`\n}\n\n// PrivateUser contains additional information about a user.\n// This data is private and requires user authentication.\ntype PrivateUser struct {\n\tUser\n\t// The country of the user, as set in the user's account profile.\n\t// An ISO 3166-1 alpha-2 country code.  This field is only available when the\n\t// current user has granted acess to the ScopeUserReadPrivate scope.\n\tCountry string `json:\"country\"`\n\t// The user's email address, as entered by the user when creating their account.\n\t// Note: this email is UNVERIFIED - there is no proof that it actually\n\t// belongs to the user.  This field is only available when the current user\n\t// has granted access to the ScopeUserReadEmail scope.\n\tEmail string `json:\"email\"`\n\t// The user's Spotify subscription level: \"premium\", \"free\", etc.\n\t// The subscription level \"open\" can be considered the same as \"free\".\n\t// This field is only available when the current user has granted access to\n\t// the ScopeUserReadPrivate scope.\n\tProduct string `json:\"product\"`\n\t// The user's date of birth, in the format 'YYYY-MM-DD'.  You can use\n\t// the DateLayout constant to convert this to a time.Time value.\n\t// This field is only available when the current user has granted\n\t// access to the ScopeUserReadBirthdate scope.\n\tBirthdate string `json:\"birthdate\"`\n}\n\n// GetUsersPublicProfile gets public profile information about a\n// Spotify User.  It does not require authentication.\nfunc (c *Client) GetUsersPublicProfile(userID ID) (*User, error) {\n\tspotifyURL := c.baseURL + \"users/\" + string(userID)\n\n\tvar user User\n\n\terr := c.get(spotifyURL, &user)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &user, nil\n}\n\n// CurrentUser gets detailed profile information about the\n// current user.\n//\n// Reading the user's email address requires that the application\n// has the ScopeUserReadEmail scope.  Reading the country, display\n// name, profile images, and product subscription level requires\n// that the application has the ScopeUserReadPrivate scope.\n//\n// Warning: The email address in the response will be the address\n// that was entered when the user created their spotify account.\n// This email address is unverified - do not assume that Spotify has\n// checked that the email address actually belongs to the user.\nfunc (c *Client) CurrentUser() (*PrivateUser, error) {\n\tvar result PrivateUser\n\n\terr := c.get(c.baseURL+\"me\", &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, nil\n}\n\n// CurrentUsersTracks gets a list of songs saved in the current\n// Spotify user's \"Your Music\" library.\nfunc (c *Client) CurrentUsersTracks() (*SavedTrackPage, error) {\n\treturn c.CurrentUsersTracksOpt(nil)\n}\n\n// CurrentUsersTracksOpt is like CurrentUsersTracks, but it accepts additional\n// options for sorting and filtering the results.\nfunc (c *Client) CurrentUsersTracksOpt(opt *Options) (*SavedTrackPage, error) {\n\tspotifyURL := c.baseURL + \"me/tracks\"\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.Country != nil {\n\t\t\tv.Set(\"country\", *opt.Country)\n\t\t}\n\t\tif opt.Limit != nil {\n\t\t\tv.Set(\"limit\", strconv.Itoa(*opt.Limit))\n\t\t}\n\t\tif opt.Offset != nil {\n\t\t\tv.Set(\"offset\", strconv.Itoa(*opt.Offset))\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\n\tvar result SavedTrackPage\n\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, nil\n}\n\n// FollowUser adds the current user as a follower of one or more\n// spotify users, identified by their Spotify IDs.\n//\n// Modifying the lists of artists or users the current user follows\n// requires that the application has the ScopeUserFollowModify scope.\nfunc (c *Client) FollowUser(ids ...ID) error {\n\treturn c.modifyFollowers(\"user\", true, ids...)\n}\n\n// FollowArtist adds the current user as a follower of one or more\n// spotify artists, identified by their Spotify IDs.\n//\n// Modifying the lists of artists or users the current user follows\n// requires that the application has the ScopeUserFollowModify scope.\nfunc (c *Client) FollowArtist(ids ...ID) error {\n\treturn c.modifyFollowers(\"artist\", true, ids...)\n}\n\n// UnfollowUser removes the current user as a follower of one or more\n// Spotify users.\n//\n// Modifying the lists of artists or users the current user follows\n// requires that the application has the ScopeUserFollowModify scope.\nfunc (c *Client) UnfollowUser(ids ...ID) error {\n\treturn c.modifyFollowers(\"user\", false, ids...)\n}\n\n// UnfollowArtist removes the current user as a follower of one or more\n// Spotify artists.\n//\n// Modifying the lists of artists or users the current user follows\n// requires that the application has the ScopeUserFollowModify scope.\nfunc (c *Client) UnfollowArtist(ids ...ID) error {\n\treturn c.modifyFollowers(\"artist\", false, ids...)\n}\n\n// CurrentUserFollows checks to see if the current user is following\n// one or more artists or other Spotify Users.  This call requires\n// ScopeUserFollowRead.\n//\n// The t argument indicates the type of the IDs, and must be either\n// \"user\" or \"artist\".\n//\n// The result is returned as a slice of bool values in the same order\n// in which the IDs were specified.\nfunc (c *Client) CurrentUserFollows(t string, ids ...ID) ([]bool, error) {\n\tif l := len(ids); l == 0 || l > 50 {\n\t\treturn nil, errors.New(\"spotify: UserFollows supports 1 to 50 IDs\")\n\t}\n\tif t != \"artist\" && t != \"user\" {\n\t\treturn nil, errors.New(\"spotify: t must be 'artist' or 'user'\")\n\t}\n\tspotifyURL := fmt.Sprintf(\"%sme/following/contains?type=%s&ids=%s\",\n\t\tc.baseURL, t, strings.Join(toStringSlice(ids), \",\"))\n\n\tvar result []bool\n\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn result, nil\n}\n\nfunc (c *Client) modifyFollowers(usertype string, follow bool, ids ...ID) error {\n\tif l := len(ids); l == 0 || l > 50 {\n\t\treturn errors.New(\"spotify: Follow/Unfollow supports 1 to 50 IDs\")\n\t}\n\tv := url.Values{}\n\tv.Add(\"type\", usertype)\n\tv.Add(\"ids\", strings.Join(toStringSlice(ids), \",\"))\n\tspotifyURL := c.baseURL + \"me/following?\" + v.Encode()\n\tmethod := \"PUT\"\n\tif !follow {\n\t\tmethod = \"DELETE\"\n\t}\n\treq, err := http.NewRequest(method, spotifyURL, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = c.execute(req, nil, http.StatusNoContent)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\n// CurrentUsersFollowedArtists gets the current user's followed artists.\n// This call requires that the user has granted the ScopeUserFollowRead scope.\nfunc (c *Client) CurrentUsersFollowedArtists() (*FullArtistCursorPage, error) {\n\treturn c.CurrentUsersFollowedArtistsOpt(-1, \"\")\n}\n\n// CurrentUsersFollowedArtistsOpt is like CurrentUsersFollowedArtists,\n// but it accept the optional arguments limit and after.  Limit is the\n// maximum number of items to return (1 <= limit <= 50), and after is\n// the last artist ID retrieved from the previous request.  If you don't\n// wish to specify either of the parameters, use -1 for limit and the empty\n// string for after.\nfunc (c *Client) CurrentUsersFollowedArtistsOpt(limit int, after string) (*FullArtistCursorPage, error) {\n\tspotifyURL := c.baseURL + \"me/following\"\n\tv := url.Values{}\n\tv.Set(\"type\", \"artist\")\n\tif limit != -1 {\n\t\tv.Set(\"limit\", strconv.Itoa(limit))\n\t}\n\tif after != \"\" {\n\t\tv.Set(\"after\", after)\n\t}\n\tif params := v.Encode(); params != \"\" {\n\t\tspotifyURL += \"?\" + params\n\t}\n\n\tvar result struct {\n\t\tA FullArtistCursorPage `json:\"artists\"`\n\t}\n\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result.A, nil\n}\n\n// CurrentUsersAlbums gets a list of albums saved in the current\n// Spotify user's \"Your Music\" library.\nfunc (c *Client) CurrentUsersAlbums() (*SavedAlbumPage, error) {\n\treturn c.CurrentUsersAlbumsOpt(nil)\n}\n\n// CurrentUsersAlbumsOpt is like CurrentUsersAlbums, but it accepts additional\n// options for sorting and filtering the results.\nfunc (c *Client) CurrentUsersAlbumsOpt(opt *Options) (*SavedAlbumPage, error) {\n\tspotifyURL := c.baseURL + \"me/albums\"\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.Country != nil {\n\t\t\tv.Set(\"market\", *opt.Country)\n\t\t}\n\t\tif opt.Limit != nil {\n\t\t\tv.Set(\"limit\", strconv.Itoa(*opt.Limit))\n\t\t}\n\t\tif opt.Offset != nil {\n\t\t\tv.Set(\"offset\", strconv.Itoa(*opt.Offset))\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\n\tvar result SavedAlbumPage\n\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, nil\n}\n\n// CurrentUsersPlaylists gets a list of the playlists owned or followed by\n// the current spotify user.\n//\n// Private playlists require the ScopePlaylistReadPrivate scope.  Note that\n// this scope alone will not return collaborative playlists, even though\n// they are always private.  In order to retrieve collaborative playlists\n// the user must authorize the ScopePlaylistReadCollaborative scope.\nfunc (c *Client) CurrentUsersPlaylists() (*SimplePlaylistPage, error) {\n\treturn c.CurrentUsersPlaylistsOpt(nil)\n}\n\n// CurrentUsersPlaylistsOpt is like CurrentUsersPlaylists, but it accepts\n// additional options for sorting and filtering the results.\nfunc (c *Client) CurrentUsersPlaylistsOpt(opt *Options) (*SimplePlaylistPage, error) {\n\tspotifyURL := c.baseURL + \"me/playlists\"\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.Limit != nil {\n\t\t\tv.Set(\"limit\", strconv.Itoa(*opt.Limit))\n\t\t}\n\t\tif opt.Offset != nil {\n\t\t\tv.Set(\"offset\", strconv.Itoa(*opt.Offset))\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\n\tvar result SimplePlaylistPage\n\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, nil\n}\n\n// CurrentUsersTopArtistsOpt gets a list of the top played artists in a given time\n// range of the current Spotify user. It supports up to 50 artists in a single\n// call. This call requires ScopeUserTopRead.\nfunc (c *Client) CurrentUsersTopArtistsOpt(opt *Options) (*FullArtistPage, error) {\n\tspotifyURL := c.baseURL + \"me/top/artists\"\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.Limit != nil {\n\t\t\tv.Set(\"limit\", strconv.Itoa(*opt.Limit))\n\t\t}\n\t\tif opt.Timerange != nil {\n\t\t\tv.Set(\"time_range\", *opt.Timerange+\"_term\")\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\n\tvar result FullArtistPage\n\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, nil\n}\n\n// CurrentUsersTopArtists is like CurrentUsersTopArtistsOpt but with\n// sensible defaults. The default limit is 20 and the default timerange\n// is medium_term.\nfunc (c *Client) CurrentUsersTopArtists() (*FullArtistPage, error) {\n\treturn c.CurrentUsersTopArtistsOpt(nil)\n}\n\n// CurrentUsersTopTracksOpt gets a list of the top played tracks in a given time\n// range of the current Spotify user. It supports up to 50 tracks in a single\n// call. This call requires ScopeUserTopRead.\nfunc (c *Client) CurrentUsersTopTracksOpt(opt *Options) (*FullTrackPage, error) {\n\tspotifyURL := c.baseURL + \"me/top/tracks\"\n\tif opt != nil {\n\t\tv := url.Values{}\n\t\tif opt.Limit != nil {\n\t\t\tv.Set(\"limit\", strconv.Itoa(*opt.Limit))\n\t\t}\n\t\tif opt.Timerange != nil {\n\t\t\tv.Set(\"time_range\", *opt.Timerange+\"_term\")\n\t\t}\n\t\tif params := v.Encode(); params != \"\" {\n\t\t\tspotifyURL += \"?\" + params\n\t\t}\n\t}\n\n\tvar result FullTrackPage\n\n\terr := c.get(spotifyURL, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, nil\n}\n\n// CurrentUsersTopTracks is like CurrentUsersTopTracksOpt but with\n// sensible defaults. The default limit is 20 and the default timerange\n// is medium_term.\nfunc (c *Client) CurrentUsersTopTracks() (*FullTrackPage, error) {\n\treturn c.CurrentUsersTopTracksOpt(nil)\n}"
  },
  {
    "path": "vendor/github.com/zmb3/spotify/user_test.go",
    "content": "package spotify\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"strings\"\n\t\"testing\"\n)\n\nconst userResponse = `\n{\n  \"display_name\" : \"Ronald Pompa\",\n  \"external_urls\" : {\n    \"spotify\" : \"https://open.spotify.com/user/wizzler\"\n    },\n    \"followers\" : {\n      \"href\" : null,\n      \"total\" : 3829\n    },\n    \"href\" : \"https://api.spotify.com/v1/users/wizzler\",\n    \"id\" : \"wizzler\",\n    \"images\" : [ {\n      \"height\" : null,\n      \"url\" : \"http://profile-images.scdn.co/images/userprofile/default/9d51820e73667ea5f1e97ea601cf0593b558050e\",\n      \"width\" : null\n    } ],\n    \"type\" : \"user\",\n    \"uri\" : \"spotify:user:wizzler\"\n}`\n\nfunc TestUserProfile(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, userResponse)\n\tdefer server.Close()\n\n\tuser, err := client.GetUsersPublicProfile(\"wizzler\")\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\tif user.ID != \"wizzler\" {\n\t\tt.Error(\"Expected user wizzler, got \", user.ID)\n\t}\n\tif f := user.Followers.Count; f != 3829 {\n\t\tt.Errorf(\"Expected 3829 followers, got %d\\n\", f)\n\t}\n}\n\nfunc TestCurrentUser(t *testing.T) {\n\tjson := `{\n\t\t\"country\" : \"US\",\n\t\t\"display_name\" : null,\n\t\t\"email\" : \"username@domain.com\",\n\t\t\"external_urls\" : {\n\t\t\t\"spotify\" : \"https://open.spotify.com/user/username\"\n\t\t},\n\t\t\"followers\" : {\n\t\t\t\"href\" : null,\n\t\t\t\"total\" : 0\n\t\t},\n\t\t\"href\" : \"https://api.spotify.com/v1/users/userame\",\n\t\t\"id\" : \"username\",\n\t\t\"images\" : [ ],\n\t\t\"product\" : \"premium\",\n\t\t\"type\" : \"user\",\n\t\t\"uri\" : \"spotify:user:username\",\n\t\t\"birthdate\" : \"1985-05-01\"\n\t}`\n\tclient, server := testClientString(http.StatusOK, json)\n\tdefer server.Close()\n\n\tme, err := client.CurrentUser()\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\tif me.Country != CountryUSA ||\n\t\tme.Email != \"username@domain.com\" ||\n\t\tme.Product != \"premium\" {\n\t\tt.Error(\"Received incorrect response\")\n\t}\n\tif me.Birthdate != \"1985-05-01\" {\n\t\tt.Errorf(\"Expected '1985-05-01', got '%s'\\n\", me.Birthdate)\n\t}\n}\n\nfunc TestFollowUsersMissingScope(t *testing.T) {\n\tjson := `{\n\t\t\"error\": {\n\t\t\t\"status\": 403,\n\t\t\t\"message\": \"Insufficient client scope\"\n\t\t}\n\t}`\n\tclient, server := testClientString(http.StatusForbidden, json, func(req *http.Request) {\n\t\tif req.URL.Query().Get(\"type\") != \"user\" {\n\t\t\tt.Error(\"Request made with the wrong type parameter\")\n\t\t}\n\t})\n\tdefer server.Close()\n\n\terr := client.FollowUser(ID(\"exampleuser01\"))\n\tserr, ok := err.(Error)\n\tif !ok {\n\t\tt.Fatal(\"Expected insufficient client scope error\")\n\t}\n\tif serr.Status != http.StatusForbidden {\n\t\tt.Error(\"Expected HTTP 403\")\n\t}\n}\n\nfunc TestFollowArtist(t *testing.T) {\n\tclient, server := testClientString(http.StatusNoContent, \"\", func(req *http.Request) {\n\t\tif req.URL.Query().Get(\"type\") != \"artist\" {\n\t\t\tt.Error(\"Request made with the wrong type parameter\")\n\t\t}\n\t})\n\tdefer server.Close()\n\n\tif err := client.FollowArtist(\"3ge4xOaKvWfhRwgx0Rldov\"); err != nil {\n\t\tt.Error(err)\n\t}\n}\n\nfunc TestFollowArtistAutoRetry(t *testing.T) {\n\tt.Parallel()\n\thandlers := []http.HandlerFunc{\n\t\t// first attempt fails\n\t\thttp.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tw.Header().Set(\"Retry-After\", \"2\")\n\t\t\tw.WriteHeader(rateLimitExceededStatusCode)\n\t\t\tio.WriteString(w, `{ \"error\": { \"message\": \"slow down\", \"status\": 429 } }`)\n\t\t}),\n\t\t// next attempt succeeds\n\t\thttp.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tw.WriteHeader(http.StatusNoContent)\n\t\t}),\n\t}\n\n\ti := 0\n\tserver := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\thandlers[i](w, r)\n\t\ti++\n\t}))\n\tdefer server.Close()\n\n\tclient := &Client{http: http.DefaultClient, baseURL: server.URL + \"/\", AutoRetry: true}\n\tif err := client.FollowArtist(\"3ge4xOaKvWfhRwgx0Rldov\"); err != nil {\n\t\tt.Error(err)\n\t}\n}\n\nfunc TestFollowUsersInvalidToken(t *testing.T) {\n\tjson := `{\n\t\t\"error\": {\n\t\t\t\"status\": 401,\n\t\t\t\"message\": \"Invalid access token\"\n\t\t}\n\t}`\n\tclient, server := testClientString(http.StatusUnauthorized, json, func(req *http.Request) {\n\t\tif req.URL.Query().Get(\"type\") != \"user\" {\n\t\t\tt.Error(\"Request made with the wrong type parameter\")\n\t\t}\n\t})\n\tdefer server.Close()\n\n\terr := client.FollowUser(ID(\"dummyID\"))\n\tserr, ok := err.(Error)\n\tif !ok {\n\t\tt.Fatal(\"Expected invalid token error\")\n\t}\n\tif serr.Status != http.StatusUnauthorized {\n\t\tt.Error(\"Expected HTTP 401\")\n\t}\n}\n\nfunc TestUserFollows(t *testing.T) {\n\tjson := \"[ false, true ]\"\n\tclient, server := testClientString(http.StatusOK, json)\n\tdefer server.Close()\n\n\tfollows, err := client.CurrentUserFollows(\"artist\", ID(\"74ASZWbe4lXaubB36ztrGX\"), ID(\"08td7MxkoHQkXnWAYD8d6Q\"))\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\tif len(follows) != 2 || follows[0] || !follows[1] {\n\t\tt.Error(\"Incorrect result\", follows)\n\t}\n}\n\nfunc TestCurrentUsersTracks(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/current_users_tracks.txt\")\n\tdefer server.Close()\n\n\ttracks, err := client.CurrentUsersTracks()\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\tif tracks.Limit != 20 {\n\t\tt.Errorf(\"Expected limit 20, got %d\\n\", tracks.Limit)\n\t}\n\tif tracks.Endpoint != \"https://api.spotify.com/v1/me/tracks?offset=0&limit=20\" {\n\t\tt.Error(\"Endpoint incorrect\")\n\t}\n\tif tracks.Total != 3 {\n\t\tt.Errorf(\"Expect 3 results, got %d\\n\", tracks.Total)\n\t\treturn\n\t}\n\tif len(tracks.Tracks) != tracks.Total {\n\t\tt.Error(\"Didn't get expected number of results\")\n\t\treturn\n\t}\n\texpected := \"You & I (Nobody In The World)\"\n\tif tracks.Tracks[0].Name != expected {\n\t\tt.Errorf(\"Expected '%s', got '%s'\\n\", expected, tracks.Tracks[0].Name)\n\t\tfmt.Printf(\"\\n%#v\\n\", tracks.Tracks[0])\n\t}\n}\n\nfunc TestCurrentUsersAlbums(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/current_users_albums.txt\")\n\tdefer server.Close()\n\n\talbums, err := client.CurrentUsersAlbums()\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\tif albums.Limit != 20 {\n\t\tt.Errorf(\"Expected limit 20, got %d\\n\", albums.Limit)\n\t}\n\tif albums.Endpoint != \"https://api.spotify.com/v1/me/albums?offset=0&limit=20\" {\n\t\tt.Error(\"Endpoint incorrect\")\n\t}\n\tif albums.Total != 2 {\n\t\tt.Errorf(\"Expect 2 results, got %d\\n\", albums.Total)\n\t\treturn\n\t}\n\tif len(albums.Albums) != albums.Total {\n\t\tt.Error(\"Didn't get expected number of results\")\n\t\treturn\n\t}\n\texpected := \"Love In The Future\"\n\tif albums.Albums[0].Name != expected {\n\t\tt.Errorf(\"Expected '%s', got '%s'\\n\", expected, albums.Albums[0].Name)\n\t\tfmt.Printf(\"\\n%#v\\n\", albums.Albums[0])\n\t}\n\n\tupc := \"886444160742\"\n\tu, ok := albums.Albums[0].ExternalIDs[\"upc\"]\n\tif !ok {\n\t\tt.Error(\"External IDs missing UPC\")\n\t}\n\tif u != upc {\n\t\tt.Errorf(\"Wrong UPC: want %s, got %s\\n\", upc, u)\n\t}\n}\n\nfunc TestCurrentUsersPlaylists(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/current_users_playlists.txt\")\n\tdefer server.Close()\n\n\tplaylists, err := client.CurrentUsersPlaylists()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif playlists.Limit != 20 {\n\t\tt.Errorf(\"Expected limit 20, got %d\\n\", playlists.Limit)\n\t}\n\tif playlists.Total != 4 {\n\t\tt.Errorf(\"Expected 4 playlists, got %d\\n\", playlists.Total)\n\t}\n\ttests := []struct {\n\t\tName       string\n\t\tPublic     bool\n\t\tTrackCount uint\n\t}{\n\t\t{\"Discover Weekly\", false, 30},\n\t\t{\"Your Favorite Coffeehouse\", false, 69},\n\t\t{\"Afternoon Acoustic\", false, 99},\n\t\t{\"Yoga and Meditation\", true, 31},\n\t}\n\tfor i := range tests {\n\t\tp := playlists.Playlists[i]\n\t\tif p.Name != tests[i].Name {\n\t\t\tt.Errorf(\"Expected '%s', got '%s'\\n\", tests[i].Name, p.Name)\n\t\t}\n\t\tif p.IsPublic != tests[i].Public {\n\t\t\tt.Errorf(\"Expected public to be %#v, got %#v\\n\", tests[i].Public, p.IsPublic)\n\t\t}\n\t\tif p.Tracks.Total != tests[i].TrackCount {\n\t\t\tt.Errorf(\"Expected %d tracks, got %d\\n\", tests[i].TrackCount, p.Tracks.Total)\n\t\t}\n\t}\n}\n\nfunc TestUsersFollowedArtists(t *testing.T) {\n\tjson := `\n{\n  \"artists\" : {\n    \"items\" : [ {\n      \"external_urls\" : {\n        \"spotify\" : \"https://open.spotify.com/artist/0I2XqVXqHScXjHhk6AYYRe\"\n      },\n      \"followers\" : {\n        \"href\" : null,\n        \"total\" : 7753\n      },\n      \"genres\" : [ \"swedish hip hop\" ],\n      \"href\" : \"https://api.spotify.com/v1/artists/0I2XqVXqHScXjHhk6AYYRe\",\n      \"id\" : \"0I2XqVXqHScXjHhk6AYYRe\",\n      \"images\" : [ {\n        \"height\" : 640,\n        \"url\" : \"https://i.scdn.co/image/2c8c0cea05bf3d3c070b7498d8d0b957c4cdec20\",\n        \"width\" : 640\n      }, {\n        \"height\" : 300,\n        \"url\" : \"https://i.scdn.co/image/394302b42c4b894786943e028cdd46d7baaa29b7\",\n        \"width\" : 300\n      }, {\n        \"height\" : 64,\n        \"url\" : \"https://i.scdn.co/image/ca9df7225ade6e5dfc62e7076709ca3409a7cbbf\",\n        \"width\" : 64\n      } ],\n      \"name\" : \"Afasi & Filthy\",\n      \"popularity\" : 54,\n      \"type\" : \"artist\",\n      \"uri\" : \"spotify:artist:0I2XqVXqHScXjHhk6AYYRe\"\n   } ],\n  \"next\" : \"https://api.spotify.com/v1/users/thelinmichael/following?type=artist&after=0aV6DOiouImYTqrR5YlIqx&limit=20\",\n  \"total\" : 183,\n    \"cursors\" : {\n      \"after\" : \"0aV6DOiouImYTqrR5YlIqx\"\n    },\n   \"limit\" : 20,\n   \"href\" : \"https://api.spotify.com/v1/users/thelinmichael/following?type=artist&limit=20\"\n  }\n}`\n\tclient, server := testClientString(http.StatusOK, json)\n\tdefer server.Close()\n\n\tartists, err := client.CurrentUsersFollowedArtists()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\texp := 20\n\tif artists.Limit != exp {\n\t\tt.Errorf(\"Expected limit %d, got %d\\n\", exp, artists.Limit)\n\t}\n\tif a := artists.Cursor.After; a != \"0aV6DOiouImYTqrR5YlIqx\" {\n\t\tt.Error(\"Invalid 'after' cursor\")\n\t}\n\tif l := len(artists.Artists); l != 1 {\n\t\tt.Fatalf(\"Expected 1 artist, got %d\\n\", l)\n\t}\n\tif n := artists.Artists[0].Name; n != \"Afasi & Filthy\" {\n\t\tt.Error(\"Got wrong artist name\")\n\t}\n}\n\nfunc TestCurrentUsersFollowedArtistsOpt(t *testing.T) {\n\tclient, server := testClientString(http.StatusOK, \"{}\", func(req *http.Request) {\n\t\tif url := req.URL.String(); !strings.HasSuffix(url, \"me/following?after=0aV6DOiouImYTqrR5YlIqx&limit=50&type=artist\") {\n\t\t\tt.Error(\"invalid request url\")\n\t\t}\n\t})\n\tdefer server.Close()\n\n\tclient.CurrentUsersFollowedArtistsOpt(50, \"0aV6DOiouImYTqrR5YlIqx\")\n}\n\nfunc TestCurrentUsersTopArtists(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/current_users_top_artists.txt\")\n\tdefer server.Close()\n\n\tartists, err := client.CurrentUsersTopArtists()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif artists.Endpoint != \"https://api.spotify.com/v1/me/top/artists\" {\n\t\tt.Error(\"Endpoint incorrect\")\n\t}\n\tif artists.Limit != 20 {\n\t\tt.Errorf(\"Expected limit 20, got %d\\n\", artists.Limit)\n\t}\n\tif artists.Total != 10 {\n\t\tt.Errorf(\"Expected total 10, got %d\\n\", artists.Total)\n\t\treturn\n\t}\n\tif len(artists.Artists) != artists.Total {\n\t\tt.Error(\"Didn't get expected number of results\")\n\t\treturn\n\t}\n\tif artists.Artists[0].Followers.Count != 8437 {\n\t\tt.Errorf(\"Expected follower count of 8437, got %d\\n\", artists.Artists[0].Followers.Count)\n\t}\n\n\tname := \"insaneintherainmusic\"\n\tif artists.Artists[0].Name != name {\n\t\tt.Errorf(\"Expected '%s', got '%s'\\n\", name, artists.Artists[0].Name)\n\t\tfmt.Printf(\"\\n%#v\\n\", artists.Artists[0])\n\t}\n}\n\nfunc TestCurrentUsersTopTracks(t *testing.T) {\n\tclient, server := testClientFile(http.StatusOK, \"test_data/current_users_top_tracks.txt\")\n\tdefer server.Close()\n\n\ttracks, err := client.CurrentUsersTopTracks()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif tracks.Endpoint != \"https://api.spotify.com/v1/me/top/tracks\" {\n\t\tt.Error(\"Endpoint incorrect\")\n\t}\n\tif tracks.Limit != 20 {\n\t\tt.Errorf(\"Expected limit 20, got %d\\n\", tracks.Limit)\n\t}\n\tif tracks.Total != 380 {\n\t\tt.Errorf(\"Expected total 380, got %d\\n\", tracks.Total)\n\t\treturn\n\t}\n\tif len(tracks.Tracks) != tracks.Limit {\n\t\tt.Errorf(\"Didn't get expected number of results\")\n\t\treturn\n\t}\n\n\tname := \"Adventure Awaits! (Alola Region Theme)\"\n\tif tracks.Tracks[0].Name != name {\n\t\tt.Errorf(\"Expected '%s', got '%s'\\n\", name, tracks.Tracks[0].Name)\n\t\tfmt.Printf(\"\\n%#v\\n\", tracks.Tracks[0])\n\t}\n\n\tisrc := \"QZ4JJ1764466\"\n\ti, ok := tracks.Tracks[0].ExternalIDs[\"isrc\"]\n\tif !ok {\n\t\tt.Error(\"External IDs missing ISRC\")\n\t}\n\tif i != isrc {\n\t\tt.Errorf(\"Wrong ISRC: want %s, got %s\\n\", isrc, i)\n\t}\n}\n"
  },
  {
    "path": "vendor/golang.org/x/net/.gitattributes",
    "content": "# Treat all files in this repo as binary, with no git magic updating\n# line endings. Windows users contributing to Go will need to use a\n# modern version of git and editors capable of LF line endings.\n#\n# We'll prevent accidental CRLF line endings from entering the repo\n# via the git-review gofmt checks.\n#\n# See golang.org/issue/9281\n\n* -text\n"
  },
  {
    "path": "vendor/golang.org/x/net/.gitignore",
    "content": "# Add no patterns to .hgignore except for files generated by the build.\nlast-change\n"
  },
  {
    "path": "vendor/golang.org/x/net/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/net/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://golang.org/issue/new), 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/net/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/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/README.md",
    "content": "# Go Networking\n\nThis repository holds supplementary Go networking libraries.\n\n## Download/Install\n\nThe easiest way to install is to run `go get -u golang.org/x/net`. You can\nalso manually git clone the repository to `$GOPATH/src/golang.org/x/net`.\n\n## Report Issues / Send Patches\n\nThis repository uses Gerrit for code changes. To learn how to submit\nchanges to this repository, see https://golang.org/doc/contribute.html.\nThe main issue tracker for the net repository is located at\nhttps://github.com/golang/go/issues. Prefix your issue with \"x/net:\" in the\nsubject line, so it is easy to find.\n"
  },
  {
    "path": "vendor/golang.org/x/net/codereview.cfg",
    "content": "issuerepo: golang/go\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// As of Go 1.7 this package is available in the standard library under the\n// name context.  https://golang.org/pkg/context.\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 // import \"golang.org/x/net/context\"\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"
  },
  {
    "path": "vendor/golang.org/x/net/context/context_test.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\"fmt\"\n\t\"math/rand\"\n\t\"runtime\"\n\t\"strings\"\n\t\"sync\"\n\t\"testing\"\n\t\"time\"\n)\n\n// otherContext is a Context that's not one of the types defined in context.go.\n// This lets us test code paths that differ based on the underlying type of the\n// Context.\ntype otherContext struct {\n\tContext\n}\n\nfunc TestBackground(t *testing.T) {\n\tc := Background()\n\tif c == nil {\n\t\tt.Fatalf(\"Background returned nil\")\n\t}\n\tselect {\n\tcase x := <-c.Done():\n\t\tt.Errorf(\"<-c.Done() == %v want nothing (it should block)\", x)\n\tdefault:\n\t}\n\tif got, want := fmt.Sprint(c), \"context.Background\"; got != want {\n\t\tt.Errorf(\"Background().String() = %q want %q\", got, want)\n\t}\n}\n\nfunc TestTODO(t *testing.T) {\n\tc := TODO()\n\tif c == nil {\n\t\tt.Fatalf(\"TODO returned nil\")\n\t}\n\tselect {\n\tcase x := <-c.Done():\n\t\tt.Errorf(\"<-c.Done() == %v want nothing (it should block)\", x)\n\tdefault:\n\t}\n\tif got, want := fmt.Sprint(c), \"context.TODO\"; got != want {\n\t\tt.Errorf(\"TODO().String() = %q want %q\", got, want)\n\t}\n}\n\nfunc TestWithCancel(t *testing.T) {\n\tc1, cancel := WithCancel(Background())\n\n\tif got, want := fmt.Sprint(c1), \"context.Background.WithCancel\"; got != want {\n\t\tt.Errorf(\"c1.String() = %q want %q\", got, want)\n\t}\n\n\to := otherContext{c1}\n\tc2, _ := WithCancel(o)\n\tcontexts := []Context{c1, o, c2}\n\n\tfor i, c := range contexts {\n\t\tif d := c.Done(); d == nil {\n\t\t\tt.Errorf(\"c[%d].Done() == %v want non-nil\", i, d)\n\t\t}\n\t\tif e := c.Err(); e != nil {\n\t\t\tt.Errorf(\"c[%d].Err() == %v want nil\", i, e)\n\t\t}\n\n\t\tselect {\n\t\tcase x := <-c.Done():\n\t\t\tt.Errorf(\"<-c.Done() == %v want nothing (it should block)\", x)\n\t\tdefault:\n\t\t}\n\t}\n\n\tcancel()\n\ttime.Sleep(100 * time.Millisecond) // let cancelation propagate\n\n\tfor i, c := range contexts {\n\t\tselect {\n\t\tcase <-c.Done():\n\t\tdefault:\n\t\t\tt.Errorf(\"<-c[%d].Done() blocked, but shouldn't have\", i)\n\t\t}\n\t\tif e := c.Err(); e != Canceled {\n\t\t\tt.Errorf(\"c[%d].Err() == %v want %v\", i, e, Canceled)\n\t\t}\n\t}\n}\n\nfunc TestParentFinishesChild(t *testing.T) {\n\t// Context tree:\n\t// parent -> cancelChild\n\t// parent -> valueChild -> timerChild\n\tparent, cancel := WithCancel(Background())\n\tcancelChild, stop := WithCancel(parent)\n\tdefer stop()\n\tvalueChild := WithValue(parent, \"key\", \"value\")\n\ttimerChild, stop := WithTimeout(valueChild, 10000*time.Hour)\n\tdefer stop()\n\n\tselect {\n\tcase x := <-parent.Done():\n\t\tt.Errorf(\"<-parent.Done() == %v want nothing (it should block)\", x)\n\tcase x := <-cancelChild.Done():\n\t\tt.Errorf(\"<-cancelChild.Done() == %v want nothing (it should block)\", x)\n\tcase x := <-timerChild.Done():\n\t\tt.Errorf(\"<-timerChild.Done() == %v want nothing (it should block)\", x)\n\tcase x := <-valueChild.Done():\n\t\tt.Errorf(\"<-valueChild.Done() == %v want nothing (it should block)\", x)\n\tdefault:\n\t}\n\n\t// The parent's children should contain the two cancelable children.\n\tpc := parent.(*cancelCtx)\n\tcc := cancelChild.(*cancelCtx)\n\ttc := timerChild.(*timerCtx)\n\tpc.mu.Lock()\n\tif len(pc.children) != 2 || !pc.children[cc] || !pc.children[tc] {\n\t\tt.Errorf(\"bad linkage: pc.children = %v, want %v and %v\",\n\t\t\tpc.children, cc, tc)\n\t}\n\tpc.mu.Unlock()\n\n\tif p, ok := parentCancelCtx(cc.Context); !ok || p != pc {\n\t\tt.Errorf(\"bad linkage: parentCancelCtx(cancelChild.Context) = %v, %v want %v, true\", p, ok, pc)\n\t}\n\tif p, ok := parentCancelCtx(tc.Context); !ok || p != pc {\n\t\tt.Errorf(\"bad linkage: parentCancelCtx(timerChild.Context) = %v, %v want %v, true\", p, ok, pc)\n\t}\n\n\tcancel()\n\n\tpc.mu.Lock()\n\tif len(pc.children) != 0 {\n\t\tt.Errorf(\"pc.cancel didn't clear pc.children = %v\", pc.children)\n\t}\n\tpc.mu.Unlock()\n\n\t// parent and children should all be finished.\n\tcheck := func(ctx Context, name string) {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\tdefault:\n\t\t\tt.Errorf(\"<-%s.Done() blocked, but shouldn't have\", name)\n\t\t}\n\t\tif e := ctx.Err(); e != Canceled {\n\t\t\tt.Errorf(\"%s.Err() == %v want %v\", name, e, Canceled)\n\t\t}\n\t}\n\tcheck(parent, \"parent\")\n\tcheck(cancelChild, \"cancelChild\")\n\tcheck(valueChild, \"valueChild\")\n\tcheck(timerChild, \"timerChild\")\n\n\t// WithCancel should return a canceled context on a canceled parent.\n\tprecanceledChild := WithValue(parent, \"key\", \"value\")\n\tselect {\n\tcase <-precanceledChild.Done():\n\tdefault:\n\t\tt.Errorf(\"<-precanceledChild.Done() blocked, but shouldn't have\")\n\t}\n\tif e := precanceledChild.Err(); e != Canceled {\n\t\tt.Errorf(\"precanceledChild.Err() == %v want %v\", e, Canceled)\n\t}\n}\n\nfunc TestChildFinishesFirst(t *testing.T) {\n\tcancelable, stop := WithCancel(Background())\n\tdefer stop()\n\tfor _, parent := range []Context{Background(), cancelable} {\n\t\tchild, cancel := WithCancel(parent)\n\n\t\tselect {\n\t\tcase x := <-parent.Done():\n\t\t\tt.Errorf(\"<-parent.Done() == %v want nothing (it should block)\", x)\n\t\tcase x := <-child.Done():\n\t\t\tt.Errorf(\"<-child.Done() == %v want nothing (it should block)\", x)\n\t\tdefault:\n\t\t}\n\n\t\tcc := child.(*cancelCtx)\n\t\tpc, pcok := parent.(*cancelCtx) // pcok == false when parent == Background()\n\t\tif p, ok := parentCancelCtx(cc.Context); ok != pcok || (ok && pc != p) {\n\t\t\tt.Errorf(\"bad linkage: parentCancelCtx(cc.Context) = %v, %v want %v, %v\", p, ok, pc, pcok)\n\t\t}\n\n\t\tif pcok {\n\t\t\tpc.mu.Lock()\n\t\t\tif len(pc.children) != 1 || !pc.children[cc] {\n\t\t\t\tt.Errorf(\"bad linkage: pc.children = %v, cc = %v\", pc.children, cc)\n\t\t\t}\n\t\t\tpc.mu.Unlock()\n\t\t}\n\n\t\tcancel()\n\n\t\tif pcok {\n\t\t\tpc.mu.Lock()\n\t\t\tif len(pc.children) != 0 {\n\t\t\t\tt.Errorf(\"child's cancel didn't remove self from pc.children = %v\", pc.children)\n\t\t\t}\n\t\t\tpc.mu.Unlock()\n\t\t}\n\n\t\t// child should be finished.\n\t\tselect {\n\t\tcase <-child.Done():\n\t\tdefault:\n\t\t\tt.Errorf(\"<-child.Done() blocked, but shouldn't have\")\n\t\t}\n\t\tif e := child.Err(); e != Canceled {\n\t\t\tt.Errorf(\"child.Err() == %v want %v\", e, Canceled)\n\t\t}\n\n\t\t// parent should not be finished.\n\t\tselect {\n\t\tcase x := <-parent.Done():\n\t\t\tt.Errorf(\"<-parent.Done() == %v want nothing (it should block)\", x)\n\t\tdefault:\n\t\t}\n\t\tif e := parent.Err(); e != nil {\n\t\t\tt.Errorf(\"parent.Err() == %v want nil\", e)\n\t\t}\n\t}\n}\n\nfunc testDeadline(c Context, wait time.Duration, t *testing.T) {\n\tselect {\n\tcase <-time.After(wait):\n\t\tt.Fatalf(\"context should have timed out\")\n\tcase <-c.Done():\n\t}\n\tif e := c.Err(); e != DeadlineExceeded {\n\t\tt.Errorf(\"c.Err() == %v want %v\", e, DeadlineExceeded)\n\t}\n}\n\nfunc TestDeadline(t *testing.T) {\n\tt.Parallel()\n\tconst timeUnit = 500 * time.Millisecond\n\tc, _ := WithDeadline(Background(), time.Now().Add(1*timeUnit))\n\tif got, prefix := fmt.Sprint(c), \"context.Background.WithDeadline(\"; !strings.HasPrefix(got, prefix) {\n\t\tt.Errorf(\"c.String() = %q want prefix %q\", got, prefix)\n\t}\n\ttestDeadline(c, 2*timeUnit, t)\n\n\tc, _ = WithDeadline(Background(), time.Now().Add(1*timeUnit))\n\to := otherContext{c}\n\ttestDeadline(o, 2*timeUnit, t)\n\n\tc, _ = WithDeadline(Background(), time.Now().Add(1*timeUnit))\n\to = otherContext{c}\n\tc, _ = WithDeadline(o, time.Now().Add(3*timeUnit))\n\ttestDeadline(c, 2*timeUnit, t)\n}\n\nfunc TestTimeout(t *testing.T) {\n\tt.Parallel()\n\tconst timeUnit = 500 * time.Millisecond\n\tc, _ := WithTimeout(Background(), 1*timeUnit)\n\tif got, prefix := fmt.Sprint(c), \"context.Background.WithDeadline(\"; !strings.HasPrefix(got, prefix) {\n\t\tt.Errorf(\"c.String() = %q want prefix %q\", got, prefix)\n\t}\n\ttestDeadline(c, 2*timeUnit, t)\n\n\tc, _ = WithTimeout(Background(), 1*timeUnit)\n\to := otherContext{c}\n\ttestDeadline(o, 2*timeUnit, t)\n\n\tc, _ = WithTimeout(Background(), 1*timeUnit)\n\to = otherContext{c}\n\tc, _ = WithTimeout(o, 3*timeUnit)\n\ttestDeadline(c, 2*timeUnit, t)\n}\n\nfunc TestCanceledTimeout(t *testing.T) {\n\tt.Parallel()\n\tconst timeUnit = 500 * time.Millisecond\n\tc, _ := WithTimeout(Background(), 2*timeUnit)\n\to := otherContext{c}\n\tc, cancel := WithTimeout(o, 4*timeUnit)\n\tcancel()\n\ttime.Sleep(1 * timeUnit) // let cancelation propagate\n\tselect {\n\tcase <-c.Done():\n\tdefault:\n\t\tt.Errorf(\"<-c.Done() blocked, but shouldn't have\")\n\t}\n\tif e := c.Err(); e != Canceled {\n\t\tt.Errorf(\"c.Err() == %v want %v\", e, Canceled)\n\t}\n}\n\ntype key1 int\ntype key2 int\n\nvar k1 = key1(1)\nvar k2 = key2(1) // same int as k1, different type\nvar k3 = key2(3) // same type as k2, different int\n\nfunc TestValues(t *testing.T) {\n\tcheck := func(c Context, nm, v1, v2, v3 string) {\n\t\tif v, ok := c.Value(k1).(string); ok == (len(v1) == 0) || v != v1 {\n\t\t\tt.Errorf(`%s.Value(k1).(string) = %q, %t want %q, %t`, nm, v, ok, v1, len(v1) != 0)\n\t\t}\n\t\tif v, ok := c.Value(k2).(string); ok == (len(v2) == 0) || v != v2 {\n\t\t\tt.Errorf(`%s.Value(k2).(string) = %q, %t want %q, %t`, nm, v, ok, v2, len(v2) != 0)\n\t\t}\n\t\tif v, ok := c.Value(k3).(string); ok == (len(v3) == 0) || v != v3 {\n\t\t\tt.Errorf(`%s.Value(k3).(string) = %q, %t want %q, %t`, nm, v, ok, v3, len(v3) != 0)\n\t\t}\n\t}\n\n\tc0 := Background()\n\tcheck(c0, \"c0\", \"\", \"\", \"\")\n\n\tc1 := WithValue(Background(), k1, \"c1k1\")\n\tcheck(c1, \"c1\", \"c1k1\", \"\", \"\")\n\n\tif got, want := fmt.Sprint(c1), `context.Background.WithValue(1, \"c1k1\")`; got != want {\n\t\tt.Errorf(\"c.String() = %q want %q\", got, want)\n\t}\n\n\tc2 := WithValue(c1, k2, \"c2k2\")\n\tcheck(c2, \"c2\", \"c1k1\", \"c2k2\", \"\")\n\n\tc3 := WithValue(c2, k3, \"c3k3\")\n\tcheck(c3, \"c2\", \"c1k1\", \"c2k2\", \"c3k3\")\n\n\tc4 := WithValue(c3, k1, nil)\n\tcheck(c4, \"c4\", \"\", \"c2k2\", \"c3k3\")\n\n\to0 := otherContext{Background()}\n\tcheck(o0, \"o0\", \"\", \"\", \"\")\n\n\to1 := otherContext{WithValue(Background(), k1, \"c1k1\")}\n\tcheck(o1, \"o1\", \"c1k1\", \"\", \"\")\n\n\to2 := WithValue(o1, k2, \"o2k2\")\n\tcheck(o2, \"o2\", \"c1k1\", \"o2k2\", \"\")\n\n\to3 := otherContext{c4}\n\tcheck(o3, \"o3\", \"\", \"c2k2\", \"c3k3\")\n\n\to4 := WithValue(o3, k3, nil)\n\tcheck(o4, \"o4\", \"\", \"c2k2\", \"\")\n}\n\nfunc TestAllocs(t *testing.T) {\n\tbg := Background()\n\tfor _, test := range []struct {\n\t\tdesc       string\n\t\tf          func()\n\t\tlimit      float64\n\t\tgccgoLimit float64\n\t}{\n\t\t{\n\t\t\tdesc:       \"Background()\",\n\t\t\tf:          func() { Background() },\n\t\t\tlimit:      0,\n\t\t\tgccgoLimit: 0,\n\t\t},\n\t\t{\n\t\t\tdesc: fmt.Sprintf(\"WithValue(bg, %v, nil)\", k1),\n\t\t\tf: func() {\n\t\t\t\tc := WithValue(bg, k1, nil)\n\t\t\t\tc.Value(k1)\n\t\t\t},\n\t\t\tlimit:      3,\n\t\t\tgccgoLimit: 3,\n\t\t},\n\t\t{\n\t\t\tdesc: \"WithTimeout(bg, 15*time.Millisecond)\",\n\t\t\tf: func() {\n\t\t\t\tc, _ := WithTimeout(bg, 15*time.Millisecond)\n\t\t\t\t<-c.Done()\n\t\t\t},\n\t\t\tlimit:      8,\n\t\t\tgccgoLimit: 16,\n\t\t},\n\t\t{\n\t\t\tdesc: \"WithCancel(bg)\",\n\t\t\tf: func() {\n\t\t\t\tc, cancel := WithCancel(bg)\n\t\t\t\tcancel()\n\t\t\t\t<-c.Done()\n\t\t\t},\n\t\t\tlimit:      5,\n\t\t\tgccgoLimit: 8,\n\t\t},\n\t\t{\n\t\t\tdesc: \"WithTimeout(bg, 100*time.Millisecond)\",\n\t\t\tf: func() {\n\t\t\t\tc, cancel := WithTimeout(bg, 100*time.Millisecond)\n\t\t\t\tcancel()\n\t\t\t\t<-c.Done()\n\t\t\t},\n\t\t\tlimit:      8,\n\t\t\tgccgoLimit: 25,\n\t\t},\n\t} {\n\t\tlimit := test.limit\n\t\tif runtime.Compiler == \"gccgo\" {\n\t\t\t// gccgo does not yet do escape analysis.\n\t\t\t// TODO(iant): Remove this when gccgo does do escape analysis.\n\t\t\tlimit = test.gccgoLimit\n\t\t}\n\t\tif n := testing.AllocsPerRun(100, test.f); n > limit {\n\t\t\tt.Errorf(\"%s allocs = %f want %d\", test.desc, n, int(limit))\n\t\t}\n\t}\n}\n\nfunc TestSimultaneousCancels(t *testing.T) {\n\troot, cancel := WithCancel(Background())\n\tm := map[Context]CancelFunc{root: cancel}\n\tq := []Context{root}\n\t// Create a tree of contexts.\n\tfor len(q) != 0 && len(m) < 100 {\n\t\tparent := q[0]\n\t\tq = q[1:]\n\t\tfor i := 0; i < 4; i++ {\n\t\t\tctx, cancel := WithCancel(parent)\n\t\t\tm[ctx] = cancel\n\t\t\tq = append(q, ctx)\n\t\t}\n\t}\n\t// Start all the cancels in a random order.\n\tvar wg sync.WaitGroup\n\twg.Add(len(m))\n\tfor _, cancel := range m {\n\t\tgo func(cancel CancelFunc) {\n\t\t\tcancel()\n\t\t\twg.Done()\n\t\t}(cancel)\n\t}\n\t// Wait on all the contexts in a random order.\n\tfor ctx := range m {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\tcase <-time.After(1 * time.Second):\n\t\t\tbuf := make([]byte, 10<<10)\n\t\t\tn := runtime.Stack(buf, true)\n\t\t\tt.Fatalf(\"timed out waiting for <-ctx.Done(); stacks:\\n%s\", buf[:n])\n\t\t}\n\t}\n\t// Wait for all the cancel functions to return.\n\tdone := make(chan struct{})\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(done)\n\t}()\n\tselect {\n\tcase <-done:\n\tcase <-time.After(1 * time.Second):\n\t\tbuf := make([]byte, 10<<10)\n\t\tn := runtime.Stack(buf, true)\n\t\tt.Fatalf(\"timed out waiting for cancel functions; stacks:\\n%s\", buf[:n])\n\t}\n}\n\nfunc TestInterlockedCancels(t *testing.T) {\n\tparent, cancelParent := WithCancel(Background())\n\tchild, cancelChild := WithCancel(parent)\n\tgo func() {\n\t\tparent.Done()\n\t\tcancelChild()\n\t}()\n\tcancelParent()\n\tselect {\n\tcase <-child.Done():\n\tcase <-time.After(1 * time.Second):\n\t\tbuf := make([]byte, 10<<10)\n\t\tn := runtime.Stack(buf, true)\n\t\tt.Fatalf(\"timed out waiting for child.Done(); stacks:\\n%s\", buf[:n])\n\t}\n}\n\nfunc TestLayersCancel(t *testing.T) {\n\ttestLayers(t, time.Now().UnixNano(), false)\n}\n\nfunc TestLayersTimeout(t *testing.T) {\n\ttestLayers(t, time.Now().UnixNano(), true)\n}\n\nfunc testLayers(t *testing.T, seed int64, testTimeout bool) {\n\trand.Seed(seed)\n\terrorf := func(format string, a ...interface{}) {\n\t\tt.Errorf(fmt.Sprintf(\"seed=%d: %s\", seed, format), a...)\n\t}\n\tconst (\n\t\ttimeout   = 200 * time.Millisecond\n\t\tminLayers = 30\n\t)\n\ttype value int\n\tvar (\n\t\tvals      []*value\n\t\tcancels   []CancelFunc\n\t\tnumTimers int\n\t\tctx       = Background()\n\t)\n\tfor i := 0; i < minLayers || numTimers == 0 || len(cancels) == 0 || len(vals) == 0; i++ {\n\t\tswitch rand.Intn(3) {\n\t\tcase 0:\n\t\t\tv := new(value)\n\t\t\tctx = WithValue(ctx, v, v)\n\t\t\tvals = append(vals, v)\n\t\tcase 1:\n\t\t\tvar cancel CancelFunc\n\t\t\tctx, cancel = WithCancel(ctx)\n\t\t\tcancels = append(cancels, cancel)\n\t\tcase 2:\n\t\t\tvar cancel CancelFunc\n\t\t\tctx, cancel = WithTimeout(ctx, timeout)\n\t\t\tcancels = append(cancels, cancel)\n\t\t\tnumTimers++\n\t\t}\n\t}\n\tcheckValues := func(when string) {\n\t\tfor _, key := range vals {\n\t\t\tif val := ctx.Value(key).(*value); key != val {\n\t\t\t\terrorf(\"%s: ctx.Value(%p) = %p want %p\", when, key, val, key)\n\t\t\t}\n\t\t}\n\t}\n\tselect {\n\tcase <-ctx.Done():\n\t\terrorf(\"ctx should not be canceled yet\")\n\tdefault:\n\t}\n\tif s, prefix := fmt.Sprint(ctx), \"context.Background.\"; !strings.HasPrefix(s, prefix) {\n\t\tt.Errorf(\"ctx.String() = %q want prefix %q\", s, prefix)\n\t}\n\tt.Log(ctx)\n\tcheckValues(\"before cancel\")\n\tif testTimeout {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\tcase <-time.After(timeout + 100*time.Millisecond):\n\t\t\terrorf(\"ctx should have timed out\")\n\t\t}\n\t\tcheckValues(\"after timeout\")\n\t} else {\n\t\tcancel := cancels[rand.Intn(len(cancels))]\n\t\tcancel()\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\tdefault:\n\t\t\terrorf(\"ctx should be canceled\")\n\t\t}\n\t\tcheckValues(\"after cancel\")\n\t}\n}\n\nfunc TestCancelRemoves(t *testing.T) {\n\tcheckChildren := func(when string, ctx Context, want int) {\n\t\tif got := len(ctx.(*cancelCtx).children); got != want {\n\t\t\tt.Errorf(\"%s: context has %d children, want %d\", when, got, want)\n\t\t}\n\t}\n\n\tctx, _ := WithCancel(Background())\n\tcheckChildren(\"after creation\", ctx, 0)\n\t_, cancel := WithCancel(ctx)\n\tcheckChildren(\"with WithCancel child \", ctx, 1)\n\tcancel()\n\tcheckChildren(\"after cancelling WithCancel child\", ctx, 0)\n\n\tctx, _ = WithCancel(Background())\n\tcheckChildren(\"after creation\", ctx, 0)\n\t_, cancel = WithTimeout(ctx, 60*time.Minute)\n\tcheckChildren(\"with WithTimeout child \", ctx, 1)\n\tcancel()\n\tcheckChildren(\"after cancelling WithTimeout child\", ctx, 0)\n}\n"
  },
  {
    "path": "vendor/golang.org/x/net/context/ctxhttp/ctxhttp.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\n// Package ctxhttp provides helper functions for performing context-aware HTTP requests.\npackage ctxhttp // import \"golang.org/x/net/context/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\n// Do sends an HTTP request with the provided http.Client and returns\n// an HTTP response.\n//\n// If the client is nil, http.DefaultClient is used.\n//\n// The provided ctx must be non-nil. If it is canceled or times out,\n// 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\tresp, err := client.Do(req.WithContext(ctx))\n\t// If we got an error, and the context has been canceled,\n\t// the context's error is probably more useful.\n\tif err != nil {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\terr = ctx.Err()\n\t\tdefault:\n\t\t}\n\t}\n\treturn resp, err\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"
  },
  {
    "path": "vendor/golang.org/x/net/context/ctxhttp/ctxhttp_17_test.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 !plan9,go1.7\n\npackage ctxhttp\n\nimport (\n\t\"io\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"testing\"\n\n\t\"context\"\n)\n\nfunc TestGo17Context(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tio.WriteString(w, \"ok\")\n\t}))\n\tdefer ts.Close()\n\tctx := context.Background()\n\tresp, err := Get(ctx, http.DefaultClient, ts.URL)\n\tif resp == nil || err != nil {\n\t\tt.Fatalf(\"error received from client: %v %v\", err, resp)\n\t}\n\tresp.Body.Close()\n}\n"
  },
  {
    "path": "vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.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.7\n\npackage ctxhttp // import \"golang.org/x/net/context/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// TODO(djd): Respect any existing value of req.Cancel.\n\tcancel := make(chan struct{})\n\treq.Cancel = cancel\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\tclose(cancel)\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\tclose(cancel)\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/ctxhttp/ctxhttp_pre17_test.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 !plan9,!go1.7\n\npackage ctxhttp\n\nimport (\n\t\"net\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"sync\"\n\t\"testing\"\n\t\"time\"\n\n\t\"golang.org/x/net/context\"\n)\n\n// golang.org/issue/14065\nfunc TestClosesResponseBodyOnCancel(t *testing.T) {\n\tdefer func() { testHookContextDoneBeforeHeaders = nop }()\n\tdefer func() { testHookDoReturned = nop }()\n\tdefer func() { testHookDidBodyClose = nop }()\n\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))\n\tdefer ts.Close()\n\n\tctx, cancel := context.WithCancel(context.Background())\n\n\t// closed when Do enters select case <-ctx.Done()\n\tenteredDonePath := make(chan struct{})\n\n\ttestHookContextDoneBeforeHeaders = func() {\n\t\tclose(enteredDonePath)\n\t}\n\n\ttestHookDoReturned = func() {\n\t\t// We now have the result (the Flush'd headers) at least,\n\t\t// so we can cancel the request.\n\t\tcancel()\n\n\t\t// But block the client.Do goroutine from sending\n\t\t// until Do enters into the <-ctx.Done() path, since\n\t\t// otherwise if both channels are readable, select\n\t\t// picks a random one.\n\t\t<-enteredDonePath\n\t}\n\n\tsawBodyClose := make(chan struct{})\n\ttestHookDidBodyClose = func() { close(sawBodyClose) }\n\n\ttr := &http.Transport{}\n\tdefer tr.CloseIdleConnections()\n\tc := &http.Client{Transport: tr}\n\treq, _ := http.NewRequest(\"GET\", ts.URL, nil)\n\t_, doErr := Do(ctx, c, req)\n\n\tselect {\n\tcase <-sawBodyClose:\n\tcase <-time.After(5 * time.Second):\n\t\tt.Fatal(\"timeout waiting for body to close\")\n\t}\n\n\tif doErr != ctx.Err() {\n\t\tt.Errorf(\"Do error = %v; want %v\", doErr, ctx.Err())\n\t}\n}\n\ntype noteCloseConn struct {\n\tnet.Conn\n\tonceClose sync.Once\n\tclosefn   func()\n}\n\nfunc (c *noteCloseConn) Close() error {\n\tc.onceClose.Do(c.closefn)\n\treturn c.Conn.Close()\n}\n"
  },
  {
    "path": "vendor/golang.org/x/net/context/ctxhttp/ctxhttp_test.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 !plan9\n\npackage ctxhttp\n\nimport (\n\t\"io\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"testing\"\n\t\"time\"\n\n\t\"golang.org/x/net/context\"\n)\n\nconst (\n\trequestDuration = 100 * time.Millisecond\n\trequestBody     = \"ok\"\n)\n\nfunc okHandler(w http.ResponseWriter, r *http.Request) {\n\ttime.Sleep(requestDuration)\n\tio.WriteString(w, requestBody)\n}\n\nfunc TestNoTimeout(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(okHandler))\n\tdefer ts.Close()\n\n\tctx := context.Background()\n\tres, err := Get(ctx, nil, ts.URL)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer res.Body.Close()\n\tslurp, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif string(slurp) != requestBody {\n\t\tt.Errorf(\"body = %q; want %q\", slurp, requestBody)\n\t}\n}\n\nfunc TestCancelBeforeHeaders(t *testing.T) {\n\tctx, cancel := context.WithCancel(context.Background())\n\n\tblockServer := make(chan struct{})\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tcancel()\n\t\t<-blockServer\n\t\tio.WriteString(w, requestBody)\n\t}))\n\tdefer ts.Close()\n\tdefer close(blockServer)\n\n\tres, err := Get(ctx, nil, ts.URL)\n\tif err == nil {\n\t\tres.Body.Close()\n\t\tt.Fatal(\"Get returned unexpected nil error\")\n\t}\n\tif err != context.Canceled {\n\t\tt.Errorf(\"err = %v; want %v\", err, context.Canceled)\n\t}\n}\n\nfunc TestCancelAfterHangingRequest(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.WriteHeader(http.StatusOK)\n\t\tw.(http.Flusher).Flush()\n\t\t<-w.(http.CloseNotifier).CloseNotify()\n\t}))\n\tdefer ts.Close()\n\n\tctx, cancel := context.WithCancel(context.Background())\n\tresp, err := Get(ctx, nil, ts.URL)\n\tif err != nil {\n\t\tt.Fatalf(\"unexpected error in Get: %v\", err)\n\t}\n\n\t// Cancel befer reading the body.\n\t// Reading Request.Body should fail, since the request was\n\t// canceled before anything was written.\n\tcancel()\n\n\tdone := make(chan struct{})\n\n\tgo func() {\n\t\tb, err := ioutil.ReadAll(resp.Body)\n\t\tif len(b) != 0 || err == nil {\n\t\t\tt.Errorf(`Read got (%q, %v); want (\"\", error)`, b, err)\n\t\t}\n\t\tclose(done)\n\t}()\n\n\tselect {\n\tcase <-time.After(1 * time.Second):\n\t\tt.Errorf(\"Test timed out\")\n\tcase <-done:\n\t}\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/go19.go",
    "content": "// Copyright 2017 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.9\n\npackage context\n\nimport \"context\" // standard library's context, as of Go 1.7\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 = context.Context\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 = context.CancelFunc\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/net/context/pre_go19.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.9\n\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// 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/withtimeout_test.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 context_test\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"golang.org/x/net/context\"\n)\n\n// This example passes a context with a timeout to tell a blocking function that\n// it should abandon its work after the timeout elapses.\nfunc ExampleWithTimeout() {\n\t// Pass a context with a timeout to tell a blocking function that it\n\t// should abandon its work after the timeout elapses.\n\tctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond)\n\tdefer cancel()\n\n\tselect {\n\tcase <-time.After(1 * time.Second):\n\t\tfmt.Println(\"overslept\")\n\tcase <-ctx.Done():\n\t\tfmt.Println(ctx.Err()) // prints \"context deadline exceeded\"\n\t}\n\n\t// Output:\n\t// context deadline exceeded\n}\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/.travis.yml",
    "content": "language: go\n\ngo:\n  - tip\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 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/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[![GoDoc](https://godoc.org/golang.org/x/oauth2?status.svg)](https://godoc.org/golang.org/x/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\nOr you can manually git clone the repository to\n`$(go env GOPATH)/src/golang.org/x/oauth2`.\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 it's 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```go\nimport (\n\t\"golang.org/x/net/context\"\n\t\"golang.org/x/oauth2\"\n\t\"golang.org/x/oauth2/google\"\n\tnewappengine \"google.golang.org/appengine\"\n\tnewurlfetch \"google.golang.org/appengine/urlfetch\"\n\n\t\"appengine\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tvar c appengine.Context = appengine.NewContext(r)\n\tc.Infof(\"Logging a message with the old package\")\n\n\tvar ctx context.Context = newappengine.NewContext(r)\n\tclient := &http.Client{\n\t\tTransport: &oauth2.Transport{\n\t\t\tSource: google.AppEngineTokenSource(ctx, \"scope\"),\n\t\t\tBase:   &newurlfetch.Transport{Context: ctx},\n\t\t},\n\t}\n\tclient.Get(\"...\")\n}\n```\n\n## Report Issues / Send Patches\n\nThis repository uses Gerrit for code changes. To learn how to submit changes to\nthis repository, see https://golang.org/doc/contribute.html.\n\nThe main issue tracker for the oauth2 repository is located at\nhttps://github.com/golang/oauth2/issues.\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/example_test.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_test\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\t\"time\"\n\n\t\"golang.org/x/oauth2\"\n)\n\nfunc ExampleConfig() {\n\tctx := context.Background()\n\tconf := &oauth2.Config{\n\t\tClientID:     \"YOUR_CLIENT_ID\",\n\t\tClientSecret: \"YOUR_CLIENT_SECRET\",\n\t\tScopes:       []string{\"SCOPE1\", \"SCOPE2\"},\n\t\tEndpoint: oauth2.Endpoint{\n\t\t\tAuthURL:  \"https://provider.com/o/oauth2/auth\",\n\t\t\tTokenURL: \"https://provider.com/o/oauth2/token\",\n\t\t},\n\t}\n\n\t// Redirect user to consent page to ask for permission\n\t// for the scopes specified above.\n\turl := conf.AuthCodeURL(\"state\", oauth2.AccessTypeOffline)\n\tfmt.Printf(\"Visit the URL for the auth dialog: %v\", url)\n\n\t// Use the authorization code that is pushed to the redirect\n\t// URL. Exchange will do the handshake to retrieve the\n\t// initial access token. The HTTP Client returned by\n\t// conf.Client will refresh the token as necessary.\n\tvar code string\n\tif _, err := fmt.Scan(&code); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\ttok, err := conf.Exchange(ctx, code)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tclient := conf.Client(ctx, tok)\n\tclient.Get(\"...\")\n}\n\nfunc ExampleConfig_customHTTP() {\n\tctx := context.Background()\n\n\tconf := &oauth2.Config{\n\t\tClientID:     \"YOUR_CLIENT_ID\",\n\t\tClientSecret: \"YOUR_CLIENT_SECRET\",\n\t\tScopes:       []string{\"SCOPE1\", \"SCOPE2\"},\n\t\tEndpoint: oauth2.Endpoint{\n\t\t\tTokenURL: \"https://provider.com/o/oauth2/token\",\n\t\t\tAuthURL:  \"https://provider.com/o/oauth2/auth\",\n\t\t},\n\t}\n\n\t// Redirect user to consent page to ask for permission\n\t// for the scopes specified above.\n\turl := conf.AuthCodeURL(\"state\", oauth2.AccessTypeOffline)\n\tfmt.Printf(\"Visit the URL for the auth dialog: %v\", url)\n\n\t// Use the authorization code that is pushed to the redirect\n\t// URL. Exchange will do the handshake to retrieve the\n\t// initial access token. The HTTP Client returned by\n\t// conf.Client will refresh the token as necessary.\n\tvar code string\n\tif _, err := fmt.Scan(&code); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Use the custom HTTP client when requesting a token.\n\thttpClient := &http.Client{Timeout: 2 * time.Second}\n\tctx = context.WithValue(ctx, oauth2.HTTPClient, httpClient)\n\n\ttok, err := conf.Exchange(ctx, code)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tclient := conf.Client(ctx, tok)\n\t_ = client\n}\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/internal/doc.go",
    "content": "// Copyright 2017 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"
  },
  {
    "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\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\"\": {}, // 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/oauth2_test.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 internal\n\nimport (\n\t\"reflect\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc TestParseINI(t *testing.T) {\n\ttests := []struct {\n\t\tini  string\n\t\twant map[string]map[string]string\n\t}{\n\t\t{\n\t\t\t`root = toor\n[foo]  \nbar = hop\nini = nin\n`,\n\t\t\tmap[string]map[string]string{\n\t\t\t\t\"\":    {\"root\": \"toor\"},\n\t\t\t\t\"foo\": {\"bar\": \"hop\", \"ini\": \"nin\"},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t`[empty]\n[section]\nempty=\n`,\n\t\t\tmap[string]map[string]string{\n\t\t\t\t\"\":        {},\n\t\t\t\t\"empty\":   {},\n\t\t\t\t\"section\": {\"empty\": \"\"},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t`ignore\n[invalid\n=stuff\n;comment=true\n`,\n\t\t\tmap[string]map[string]string{\n\t\t\t\t\"\": {},\n\t\t\t},\n\t\t},\n\t}\n\tfor _, tt := range tests {\n\t\tresult, err := ParseINI(strings.NewReader(tt.ini))\n\t\tif err != nil {\n\t\t\tt.Errorf(\"ParseINI(%q) error %v, want: no error\", tt.ini, err)\n\t\t\tcontinue\n\t\t}\n\t\tif !reflect.DeepEqual(result, tt.want) {\n\t\t\tt.Errorf(\"ParseINI(%q) = %#v, want: %#v\", tt.ini, result, tt.want)\n\t\t}\n\t}\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\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\t\"golang.org/x/net/context/ctxhttp\"\n)\n\n// Token represents the credentials 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.codeswholesale.com/oauth/token\",\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://graph.facebook.com\", // see https://github.com/golang/oauth2/issues/214\n\t\"https://login.microsoftonline.com/\",\n\t\"https://login.salesforce.com/\",\n\t\"https://login.windows.net\",\n\t\"https://login.live.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\t\"https://sandbox.codeswholesale.com/oauth/token\",\n\t\"https://api.sipgate.com/v1/authorization/oauth\",\n}\n\n// brokenAuthHeaderDomains lists broken providers that issue dynamic endpoints.\nvar brokenAuthHeaderDomains = []string{\n\t\".force.com\",\n\t\".myshopify.com\",\n\t\".okta.com\",\n\t\".oktapreview.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\tif u, err := url.Parse(tokenURL); err == nil {\n\t\tfor _, s := range brokenAuthHeaderDomains {\n\t\t\tif strings.HasSuffix(u.Host, s) {\n\t\t\t\treturn false\n\t\t\t}\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\tbustedAuth := !providerAuthHeaderWorks(tokenURL)\n\tif bustedAuth {\n\t\tif clientID != \"\" {\n\t\t\tv.Set(\"client_id\", clientID)\n\t\t}\n\t\tif clientSecret != \"\" {\n\t\t\tv.Set(\"client_secret\", clientSecret)\n\t\t}\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(url.QueryEscape(clientID), url.QueryEscape(clientSecret))\n\t}\n\tr, err := ctxhttp.Do(ctx, hc, 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, &RetrieveError{\n\t\t\tResponse: r,\n\t\t\tBody:     body,\n\t\t}\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\ntype RetrieveError struct {\n\tResponse *http.Response\n\tBody     []byte\n}\n\nfunc (r *RetrieveError) Error() string {\n\treturn fmt.Sprintf(\"oauth2: cannot fetch token: %v\\nResponse: %s\", r.Response.Status, r.Body)\n}\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/internal/token_test.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 internal\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"net/url\"\n\t\"testing\"\n\n\t\"golang.org/x/net/context\"\n)\n\nfunc TestRegisterBrokenAuthHeaderProvider(t *testing.T) {\n\tRegisterBrokenAuthHeaderProvider(\"https://aaa.com/\")\n\ttokenURL := \"https://aaa.com/token\"\n\tif providerAuthHeaderWorks(tokenURL) {\n\t\tt.Errorf(\"got %q as unbroken; want broken\", tokenURL)\n\t}\n}\n\nfunc TestRetrieveTokenBustedNoSecret(t *testing.T) {\n\tconst clientID = \"client-id\"\n\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif got, want := r.FormValue(\"client_id\"), clientID; got != want {\n\t\t\tt.Errorf(\"client_id = %q; want %q\", got, want)\n\t\t}\n\t\tif got, want := r.FormValue(\"client_secret\"), \"\"; got != want {\n\t\t\tt.Errorf(\"client_secret = %q; want empty\", got)\n\t\t}\n\t\tio.WriteString(w, \"{}\") // something non-empty, required to set a Content-Type in Go 1.10\n\t}))\n\tdefer ts.Close()\n\n\tRegisterBrokenAuthHeaderProvider(ts.URL)\n\t_, err := RetrieveToken(context.Background(), clientID, \"\", ts.URL, url.Values{})\n\tif err != nil {\n\t\tt.Errorf(\"RetrieveToken = %v; want no error\", err)\n\t}\n}\n\nfunc Test_providerAuthHeaderWorks(t *testing.T) {\n\tfor _, p := range brokenAuthHeaderProviders {\n\t\tif providerAuthHeaderWorks(p) {\n\t\t\tt.Errorf(\"got %q as unbroken; want broken\", p)\n\t\t}\n\t\tp := fmt.Sprintf(\"%ssomesuffix\", p)\n\t\tif providerAuthHeaderWorks(p) {\n\t\t\tt.Errorf(\"got %q as unbroken; want broken\", p)\n\t\t}\n\t}\n\tp := \"https://api.not-in-the-list-example.com/\"\n\tif !providerAuthHeaderWorks(p) {\n\t\tt.Errorf(\"got %q as unbroken; want broken\", p)\n\t}\n}\n\nfunc TestProviderAuthHeaderWorksDomain(t *testing.T) {\n\ttests := []struct {\n\t\ttokenURL  string\n\t\twantWorks bool\n\t}{\n\t\t{\"https://dev-12345.okta.com/token-url\", false},\n\t\t{\"https://dev-12345.oktapreview.com/token-url\", false},\n\t\t{\"https://dev-12345.okta.org/token-url\", true},\n\t\t{\"https://foo.bar.force.com/token-url\", false},\n\t\t{\"https://foo.force.com/token-url\", false},\n\t\t{\"https://force.com/token-url\", true},\n\t}\n\n\tfor _, test := range tests {\n\t\tgot := providerAuthHeaderWorks(test.tokenURL)\n\t\tif got != test.wantWorks {\n\t\t\tt.Errorf(\"providerAuthHeaderWorks(%q) = %v; want %v\", test.tokenURL, got, test.wantWorks)\n\t\t}\n\t}\n}\n\nfunc TestRetrieveTokenWithContexts(t *testing.T) {\n\tconst clientID = \"client-id\"\n\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tio.WriteString(w, \"{}\") // something non-empty, required to set a Content-Type in Go 1.10\n\t}))\n\tdefer ts.Close()\n\n\t_, err := RetrieveToken(context.Background(), clientID, \"\", ts.URL, url.Values{})\n\tif err != nil {\n\t\tt.Errorf(\"RetrieveToken (with background context) = %v; want no error\", err)\n\t}\n\n\tctx, cancelfunc := context.WithCancel(context.Background())\n\n\tcancellingts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tcancelfunc()\n\t}))\n\tdefer cancellingts.Close()\n\n\t_, err = RetrieveToken(ctx, clientID, \"\", cancellingts.URL, url.Values{})\n\tif err == nil {\n\t\tt.Errorf(\"RetrieveToken (with cancelled context) = nil; want error\")\n\t}\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\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/internal/transport_test.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 internal\n\nimport (\n\t\"net/http\"\n\t\"testing\"\n\n\t\"golang.org/x/net/context\"\n)\n\nfunc TestContextClient(t *testing.T) {\n\trc := &http.Client{}\n\tRegisterContextClientFunc(func(context.Context) (*http.Client, error) {\n\t\treturn rc, nil\n\t})\n\n\tc := &http.Client{}\n\tctx := context.WithValue(context.Background(), HTTPClient, c)\n\n\thc, err := ContextClient(ctx)\n\tif err != nil {\n\t\tt.Fatalf(\"want valid client; got err = %v\", err)\n\t}\n\tif hc != c {\n\t\tt.Fatalf(\"want context client = %p; got = %p\", c, hc)\n\t}\n\n\thc, err = ContextClient(context.TODO())\n\tif err != nil {\n\t\tt.Fatalf(\"want valid client; got err = %v\", err)\n\t}\n\tif hc != rc {\n\t\tt.Fatalf(\"want registered client = %p; got = %p\", c, hc)\n\t}\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 // import \"golang.org/x/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).\n//\n// Deprecated: Use context.Background() or context.TODO() instead.\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.\n// For the client credentials 2-legged OAuth2 flow, see the clientcredentials\n// package (https://golang.org/x/oauth2/clientcredentials).\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})\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// Note that if a custom *http.Client is provided via the Context it\n// is used only for token acquisition and is not used to configure the\n// *http.Client returned from NewClient.\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: 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/oauth2_test.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\"fmt\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"net/url\"\n\t\"testing\"\n\t\"time\"\n\n\t\"golang.org/x/net/context\"\n)\n\ntype mockTransport struct {\n\trt func(req *http.Request) (resp *http.Response, err error)\n}\n\nfunc (t *mockTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) {\n\treturn t.rt(req)\n}\n\nfunc newConf(url string) *Config {\n\treturn &Config{\n\t\tClientID:     \"CLIENT_ID\",\n\t\tClientSecret: \"CLIENT_SECRET\",\n\t\tRedirectURL:  \"REDIRECT_URL\",\n\t\tScopes:       []string{\"scope1\", \"scope2\"},\n\t\tEndpoint: Endpoint{\n\t\t\tAuthURL:  url + \"/auth\",\n\t\t\tTokenURL: url + \"/token\",\n\t\t},\n\t}\n}\n\nfunc TestAuthCodeURL(t *testing.T) {\n\tconf := newConf(\"server\")\n\turl := conf.AuthCodeURL(\"foo\", AccessTypeOffline, ApprovalForce)\n\tconst want = \"server/auth?access_type=offline&approval_prompt=force&client_id=CLIENT_ID&redirect_uri=REDIRECT_URL&response_type=code&scope=scope1+scope2&state=foo\"\n\tif got := url; got != want {\n\t\tt.Errorf(\"got auth code URL = %q; want %q\", got, want)\n\t}\n}\n\nfunc TestAuthCodeURL_CustomParam(t *testing.T) {\n\tconf := newConf(\"server\")\n\tparam := SetAuthURLParam(\"foo\", \"bar\")\n\turl := conf.AuthCodeURL(\"baz\", param)\n\tconst want = \"server/auth?client_id=CLIENT_ID&foo=bar&redirect_uri=REDIRECT_URL&response_type=code&scope=scope1+scope2&state=baz\"\n\tif got := url; got != want {\n\t\tt.Errorf(\"got auth code = %q; want %q\", got, want)\n\t}\n}\n\nfunc TestAuthCodeURL_Optional(t *testing.T) {\n\tconf := &Config{\n\t\tClientID: \"CLIENT_ID\",\n\t\tEndpoint: Endpoint{\n\t\t\tAuthURL:  \"/auth-url\",\n\t\t\tTokenURL: \"/token-url\",\n\t\t},\n\t}\n\turl := conf.AuthCodeURL(\"\")\n\tconst want = \"/auth-url?client_id=CLIENT_ID&response_type=code\"\n\tif got := url; got != want {\n\t\tt.Fatalf(\"got auth code = %q; want %q\", got, want)\n\t}\n}\n\nfunc TestURLUnsafeClientConfig(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif got, want := r.Header.Get(\"Authorization\"), \"Basic Q0xJRU5UX0lEJTNGJTNGOkNMSUVOVF9TRUNSRVQlM0YlM0Y=\"; got != want {\n\t\t\tt.Errorf(\"Authorization header = %q; want %q\", got, want)\n\t\t}\n\n\t\tw.Header().Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\t\tw.Write([]byte(\"access_token=90d64460d14870c08c81352a05dedd3465940a7c&scope=user&token_type=bearer\"))\n\t}))\n\tdefer ts.Close()\n\tconf := newConf(ts.URL)\n\tconf.ClientID = \"CLIENT_ID??\"\n\tconf.ClientSecret = \"CLIENT_SECRET??\"\n\t_, err := conf.Exchange(context.Background(), \"exchange-code\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n}\n\nfunc TestExchangeRequest(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif r.URL.String() != \"/token\" {\n\t\t\tt.Errorf(\"Unexpected exchange request URL, %v is found.\", r.URL)\n\t\t}\n\t\theaderAuth := r.Header.Get(\"Authorization\")\n\t\tif headerAuth != \"Basic Q0xJRU5UX0lEOkNMSUVOVF9TRUNSRVQ=\" {\n\t\t\tt.Errorf(\"Unexpected authorization header, %v is found.\", headerAuth)\n\t\t}\n\t\theaderContentType := r.Header.Get(\"Content-Type\")\n\t\tif headerContentType != \"application/x-www-form-urlencoded\" {\n\t\t\tt.Errorf(\"Unexpected Content-Type header, %v is found.\", headerContentType)\n\t\t}\n\t\tbody, err := ioutil.ReadAll(r.Body)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Failed reading request body: %s.\", err)\n\t\t}\n\t\tif string(body) != \"code=exchange-code&grant_type=authorization_code&redirect_uri=REDIRECT_URL\" {\n\t\t\tt.Errorf(\"Unexpected exchange payload, %v is found.\", string(body))\n\t\t}\n\t\tw.Header().Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\t\tw.Write([]byte(\"access_token=90d64460d14870c08c81352a05dedd3465940a7c&scope=user&token_type=bearer\"))\n\t}))\n\tdefer ts.Close()\n\tconf := newConf(ts.URL)\n\ttok, err := conf.Exchange(context.Background(), \"exchange-code\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif !tok.Valid() {\n\t\tt.Fatalf(\"Token invalid. Got: %#v\", tok)\n\t}\n\tif tok.AccessToken != \"90d64460d14870c08c81352a05dedd3465940a7c\" {\n\t\tt.Errorf(\"Unexpected access token, %#v.\", tok.AccessToken)\n\t}\n\tif tok.TokenType != \"bearer\" {\n\t\tt.Errorf(\"Unexpected token type, %#v.\", tok.TokenType)\n\t}\n\tscope := tok.Extra(\"scope\")\n\tif scope != \"user\" {\n\t\tt.Errorf(\"Unexpected value for scope: %v\", scope)\n\t}\n}\n\nfunc TestExchangeRequest_JSONResponse(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif r.URL.String() != \"/token\" {\n\t\t\tt.Errorf(\"Unexpected exchange request URL, %v is found.\", r.URL)\n\t\t}\n\t\theaderAuth := r.Header.Get(\"Authorization\")\n\t\tif headerAuth != \"Basic Q0xJRU5UX0lEOkNMSUVOVF9TRUNSRVQ=\" {\n\t\t\tt.Errorf(\"Unexpected authorization header, %v is found.\", headerAuth)\n\t\t}\n\t\theaderContentType := r.Header.Get(\"Content-Type\")\n\t\tif headerContentType != \"application/x-www-form-urlencoded\" {\n\t\t\tt.Errorf(\"Unexpected Content-Type header, %v is found.\", headerContentType)\n\t\t}\n\t\tbody, err := ioutil.ReadAll(r.Body)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Failed reading request body: %s.\", err)\n\t\t}\n\t\tif string(body) != \"code=exchange-code&grant_type=authorization_code&redirect_uri=REDIRECT_URL\" {\n\t\t\tt.Errorf(\"Unexpected exchange payload, %v is found.\", string(body))\n\t\t}\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Write([]byte(`{\"access_token\": \"90d64460d14870c08c81352a05dedd3465940a7c\", \"scope\": \"user\", \"token_type\": \"bearer\", \"expires_in\": 86400}`))\n\t}))\n\tdefer ts.Close()\n\tconf := newConf(ts.URL)\n\ttok, err := conf.Exchange(context.Background(), \"exchange-code\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif !tok.Valid() {\n\t\tt.Fatalf(\"Token invalid. Got: %#v\", tok)\n\t}\n\tif tok.AccessToken != \"90d64460d14870c08c81352a05dedd3465940a7c\" {\n\t\tt.Errorf(\"Unexpected access token, %#v.\", tok.AccessToken)\n\t}\n\tif tok.TokenType != \"bearer\" {\n\t\tt.Errorf(\"Unexpected token type, %#v.\", tok.TokenType)\n\t}\n\tscope := tok.Extra(\"scope\")\n\tif scope != \"user\" {\n\t\tt.Errorf(\"Unexpected value for scope: %v\", scope)\n\t}\n\texpiresIn := tok.Extra(\"expires_in\")\n\tif expiresIn != float64(86400) {\n\t\tt.Errorf(\"Unexpected non-numeric value for expires_in: %v\", expiresIn)\n\t}\n}\n\nfunc TestExtraValueRetrieval(t *testing.T) {\n\tvalues := url.Values{}\n\tkvmap := map[string]string{\n\t\t\"scope\": \"user\", \"token_type\": \"bearer\", \"expires_in\": \"86400.92\",\n\t\t\"server_time\": \"1443571905.5606415\", \"referer_ip\": \"10.0.0.1\",\n\t\t\"etag\": \"\\\"afZYj912P4alikMz_P11982\\\"\", \"request_id\": \"86400\",\n\t\t\"untrimmed\": \"  untrimmed  \",\n\t}\n\tfor key, value := range kvmap {\n\t\tvalues.Set(key, value)\n\t}\n\n\ttok := Token{raw: values}\n\tscope := tok.Extra(\"scope\")\n\tif got, want := scope, \"user\"; got != want {\n\t\tt.Errorf(\"got scope = %q; want %q\", got, want)\n\t}\n\tserverTime := tok.Extra(\"server_time\")\n\tif got, want := serverTime, 1443571905.5606415; got != want {\n\t\tt.Errorf(\"got server_time value = %v; want %v\", got, want)\n\t}\n\trefererIP := tok.Extra(\"referer_ip\")\n\tif got, want := refererIP, \"10.0.0.1\"; got != want {\n\t\tt.Errorf(\"got referer_ip value = %v, want %v\", got, want)\n\t}\n\texpiresIn := tok.Extra(\"expires_in\")\n\tif got, want := expiresIn, 86400.92; got != want {\n\t\tt.Errorf(\"got expires_in value = %v, want %v\", got, want)\n\t}\n\trequestID := tok.Extra(\"request_id\")\n\tif got, want := requestID, int64(86400); got != want {\n\t\tt.Errorf(\"got request_id value = %v, want %v\", got, want)\n\t}\n\tuntrimmed := tok.Extra(\"untrimmed\")\n\tif got, want := untrimmed, \"  untrimmed  \"; got != want {\n\t\tt.Errorf(\"got untrimmed = %q; want %q\", got, want)\n\t}\n}\n\nconst day = 24 * time.Hour\n\nfunc TestExchangeRequest_JSONResponse_Expiry(t *testing.T) {\n\tseconds := int32(day.Seconds())\n\tfor _, c := range []struct {\n\t\texpires string\n\t\twant    bool\n\t}{\n\t\t{fmt.Sprintf(`\"expires_in\": %d`, seconds), true},\n\t\t{fmt.Sprintf(`\"expires_in\": \"%d\"`, seconds), true}, // PayPal case\n\t\t{fmt.Sprintf(`\"expires\": %d`, seconds), true},      // Facebook case\n\t\t{`\"expires\": false`, false},                        // wrong type\n\t\t{`\"expires\": {}`, false},                           // wrong type\n\t\t{`\"expires\": \"zzz\"`, false},                        // wrong value\n\t} {\n\t\ttestExchangeRequest_JSONResponse_expiry(t, c.expires, c.want)\n\t}\n}\n\nfunc testExchangeRequest_JSONResponse_expiry(t *testing.T, exp string, want bool) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Write([]byte(fmt.Sprintf(`{\"access_token\": \"90d\", \"scope\": \"user\", \"token_type\": \"bearer\", %s}`, exp)))\n\t}))\n\tdefer ts.Close()\n\tconf := newConf(ts.URL)\n\tt1 := time.Now().Add(day)\n\ttok, err := conf.Exchange(context.Background(), \"exchange-code\")\n\tt2 := time.Now().Add(day)\n\n\tif got := (err == nil); got != want {\n\t\tif want {\n\t\t\tt.Errorf(\"unexpected error: got %v\", err)\n\t\t} else {\n\t\t\tt.Errorf(\"unexpected success\")\n\t\t}\n\t}\n\tif !want {\n\t\treturn\n\t}\n\tif !tok.Valid() {\n\t\tt.Fatalf(\"Token invalid. Got: %#v\", tok)\n\t}\n\texpiry := tok.Expiry\n\tif expiry.Before(t1) || expiry.After(t2) {\n\t\tt.Errorf(\"Unexpected value for Expiry: %v (shold be between %v and %v)\", expiry, t1, t2)\n\t}\n}\n\nfunc TestExchangeRequest_BadResponse(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Write([]byte(`{\"scope\": \"user\", \"token_type\": \"bearer\"}`))\n\t}))\n\tdefer ts.Close()\n\tconf := newConf(ts.URL)\n\ttok, err := conf.Exchange(context.Background(), \"code\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif tok.AccessToken != \"\" {\n\t\tt.Errorf(\"Unexpected access token, %#v.\", tok.AccessToken)\n\t}\n}\n\nfunc TestExchangeRequest_BadResponseType(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Write([]byte(`{\"access_token\":123,  \"scope\": \"user\", \"token_type\": \"bearer\"}`))\n\t}))\n\tdefer ts.Close()\n\tconf := newConf(ts.URL)\n\t_, err := conf.Exchange(context.Background(), \"exchange-code\")\n\tif err == nil {\n\t\tt.Error(\"expected error from invalid access_token type\")\n\t}\n}\n\nfunc TestExchangeRequest_NonBasicAuth(t *testing.T) {\n\ttr := &mockTransport{\n\t\trt: func(r *http.Request) (w *http.Response, err error) {\n\t\t\theaderAuth := r.Header.Get(\"Authorization\")\n\t\t\tif headerAuth != \"\" {\n\t\t\t\tt.Errorf(\"Unexpected authorization header, %v is found.\", headerAuth)\n\t\t\t}\n\t\t\treturn nil, errors.New(\"no response\")\n\t\t},\n\t}\n\tc := &http.Client{Transport: tr}\n\tconf := &Config{\n\t\tClientID: \"CLIENT_ID\",\n\t\tEndpoint: Endpoint{\n\t\t\tAuthURL:  \"https://accounts.google.com/auth\",\n\t\t\tTokenURL: \"https://accounts.google.com/token\",\n\t\t},\n\t}\n\n\tctx := context.WithValue(context.Background(), HTTPClient, c)\n\tconf.Exchange(ctx, \"code\")\n}\n\nfunc TestPasswordCredentialsTokenRequest(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tdefer r.Body.Close()\n\t\texpected := \"/token\"\n\t\tif r.URL.String() != expected {\n\t\t\tt.Errorf(\"URL = %q; want %q\", r.URL, expected)\n\t\t}\n\t\theaderAuth := r.Header.Get(\"Authorization\")\n\t\texpected = \"Basic Q0xJRU5UX0lEOkNMSUVOVF9TRUNSRVQ=\"\n\t\tif headerAuth != expected {\n\t\t\tt.Errorf(\"Authorization header = %q; want %q\", headerAuth, expected)\n\t\t}\n\t\theaderContentType := r.Header.Get(\"Content-Type\")\n\t\texpected = \"application/x-www-form-urlencoded\"\n\t\tif headerContentType != expected {\n\t\t\tt.Errorf(\"Content-Type header = %q; want %q\", headerContentType, expected)\n\t\t}\n\t\tbody, err := ioutil.ReadAll(r.Body)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Failed reading request body: %s.\", err)\n\t\t}\n\t\texpected = \"grant_type=password&password=password1&scope=scope1+scope2&username=user1\"\n\t\tif string(body) != expected {\n\t\t\tt.Errorf(\"res.Body = %q; want %q\", string(body), expected)\n\t\t}\n\t\tw.Header().Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\t\tw.Write([]byte(\"access_token=90d64460d14870c08c81352a05dedd3465940a7c&scope=user&token_type=bearer\"))\n\t}))\n\tdefer ts.Close()\n\tconf := newConf(ts.URL)\n\ttok, err := conf.PasswordCredentialsToken(context.Background(), \"user1\", \"password1\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif !tok.Valid() {\n\t\tt.Fatalf(\"Token invalid. Got: %#v\", tok)\n\t}\n\texpected := \"90d64460d14870c08c81352a05dedd3465940a7c\"\n\tif tok.AccessToken != expected {\n\t\tt.Errorf(\"AccessToken = %q; want %q\", tok.AccessToken, expected)\n\t}\n\texpected = \"bearer\"\n\tif tok.TokenType != expected {\n\t\tt.Errorf(\"TokenType = %q; want %q\", tok.TokenType, expected)\n\t}\n}\n\nfunc TestTokenRefreshRequest(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif r.URL.String() == \"/somethingelse\" {\n\t\t\treturn\n\t\t}\n\t\tif r.URL.String() != \"/token\" {\n\t\t\tt.Errorf(\"Unexpected token refresh request URL, %v is found.\", r.URL)\n\t\t}\n\t\theaderContentType := r.Header.Get(\"Content-Type\")\n\t\tif headerContentType != \"application/x-www-form-urlencoded\" {\n\t\t\tt.Errorf(\"Unexpected Content-Type header, %v is found.\", headerContentType)\n\t\t}\n\t\tbody, _ := ioutil.ReadAll(r.Body)\n\t\tif string(body) != \"grant_type=refresh_token&refresh_token=REFRESH_TOKEN\" {\n\t\t\tt.Errorf(\"Unexpected refresh token payload, %v is found.\", string(body))\n\t\t}\n\t}))\n\tdefer ts.Close()\n\tconf := newConf(ts.URL)\n\tc := conf.Client(context.Background(), &Token{RefreshToken: \"REFRESH_TOKEN\"})\n\tc.Get(ts.URL + \"/somethingelse\")\n}\n\nfunc TestFetchWithNoRefreshToken(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif r.URL.String() == \"/somethingelse\" {\n\t\t\treturn\n\t\t}\n\t\tif r.URL.String() != \"/token\" {\n\t\t\tt.Errorf(\"Unexpected token refresh request URL, %v is found.\", r.URL)\n\t\t}\n\t\theaderContentType := r.Header.Get(\"Content-Type\")\n\t\tif headerContentType != \"application/x-www-form-urlencoded\" {\n\t\t\tt.Errorf(\"Unexpected Content-Type header, %v is found.\", headerContentType)\n\t\t}\n\t\tbody, _ := ioutil.ReadAll(r.Body)\n\t\tif string(body) != \"client_id=CLIENT_ID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN\" {\n\t\t\tt.Errorf(\"Unexpected refresh token payload, %v is found.\", string(body))\n\t\t}\n\t}))\n\tdefer ts.Close()\n\tconf := newConf(ts.URL)\n\tc := conf.Client(context.Background(), nil)\n\t_, err := c.Get(ts.URL + \"/somethingelse\")\n\tif err == nil {\n\t\tt.Errorf(\"Fetch should return an error if no refresh token is set\")\n\t}\n}\n\nfunc TestTokenRetrieveError(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif r.URL.String() != \"/token\" {\n\t\t\tt.Errorf(\"Unexpected token refresh request URL, %v is found.\", r.URL)\n\t\t}\n\t\tw.Header().Set(\"Content-type\", \"application/json\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tw.Write([]byte(`{\"error\": \"invalid_grant\"}`))\n\t}))\n\tdefer ts.Close()\n\tconf := newConf(ts.URL)\n\t_, err := conf.Exchange(context.Background(), \"exchange-code\")\n\tif err == nil {\n\t\tt.Fatalf(\"got no error, expected one\")\n\t}\n\t_, ok := err.(*RetrieveError)\n\tif !ok {\n\t\tt.Fatalf(\"got %T error, expected *RetrieveError\", err)\n\t}\n\t// Test error string for backwards compatibility\n\texpected := fmt.Sprintf(\"oauth2: cannot fetch token: %v\\nResponse: %s\", \"400 Bad Request\", `{\"error\": \"invalid_grant\"}`)\n\tif errStr := err.Error(); errStr != expected {\n\t\tt.Fatalf(\"got %#v, expected %#v\", errStr, expected)\n\t}\n}\n\nfunc TestRefreshToken_RefreshTokenReplacement(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Write([]byte(`{\"access_token\":\"ACCESS_TOKEN\",  \"scope\": \"user\", \"token_type\": \"bearer\", \"refresh_token\": \"NEW_REFRESH_TOKEN\"}`))\n\t\treturn\n\t}))\n\tdefer ts.Close()\n\tconf := newConf(ts.URL)\n\ttkr := &tokenRefresher{\n\t\tconf:         conf,\n\t\tctx:          context.Background(),\n\t\trefreshToken: \"OLD_REFRESH_TOKEN\",\n\t}\n\ttk, err := tkr.Token()\n\tif err != nil {\n\t\tt.Errorf(\"got err = %v; want none\", err)\n\t\treturn\n\t}\n\tif tk.RefreshToken != tkr.refreshToken {\n\t\tt.Errorf(\"tokenRefresher.refresh_token = %q; want %q\", tkr.refreshToken, tk.RefreshToken)\n\t}\n}\n\nfunc TestRefreshToken_RefreshTokenPreservation(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Write([]byte(`{\"access_token\":\"ACCESS_TOKEN\",  \"scope\": \"user\", \"token_type\": \"bearer\"}`))\n\t\treturn\n\t}))\n\tdefer ts.Close()\n\tconf := newConf(ts.URL)\n\tconst oldRefreshToken = \"OLD_REFRESH_TOKEN\"\n\ttkr := &tokenRefresher{\n\t\tconf:         conf,\n\t\tctx:          context.Background(),\n\t\trefreshToken: oldRefreshToken,\n\t}\n\t_, err := tkr.Token()\n\tif err != nil {\n\t\tt.Fatalf(\"got err = %v; want none\", err)\n\t}\n\tif tkr.refreshToken != oldRefreshToken {\n\t\tt.Errorf(\"tokenRefresher.refreshToken = %q; want %q\", tkr.refreshToken, oldRefreshToken)\n\t}\n}\n\nfunc TestConfigClientWithToken(t *testing.T) {\n\ttok := &Token{\n\t\tAccessToken: \"abc123\",\n\t}\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif got, want := r.Header.Get(\"Authorization\"), fmt.Sprintf(\"Bearer %s\", tok.AccessToken); got != want {\n\t\t\tt.Errorf(\"Authorization header = %q; want %q\", got, want)\n\t\t}\n\t\treturn\n\t}))\n\tdefer ts.Close()\n\tconf := newConf(ts.URL)\n\n\tc := conf.Client(context.Background(), tok)\n\treq, err := http.NewRequest(\"GET\", ts.URL, nil)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\t_, err = c.Do(req)\n\tif err != nil {\n\t\tt.Error(err)\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\"fmt\"\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 credentials 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.Round(0).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\tif rErr, ok := err.(*internal.RetrieveError); ok {\n\t\t\treturn nil, (*RetrieveError)(rErr)\n\t\t}\n\t\treturn nil, err\n\t}\n\treturn tokenFromInternal(tk), nil\n}\n\n// RetrieveError is the error returned when the token endpoint returns a\n// non-2XX HTTP status code.\ntype RetrieveError struct {\n\tResponse *http.Response\n\t// Body is the body that was consumed by reading Response.Body.\n\t// It may be truncated.\n\tBody []byte\n}\n\nfunc (r *RetrieveError) Error() string {\n\treturn fmt.Sprintf(\"oauth2: cannot fetch token: %v\\nResponse: %s\", r.Response.Status, r.Body)\n}\n"
  },
  {
    "path": "vendor/golang.org/x/oauth2/token_test.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\"testing\"\n\t\"time\"\n)\n\nfunc TestTokenExtra(t *testing.T) {\n\ttype testCase struct {\n\t\tkey  string\n\t\tval  interface{}\n\t\twant interface{}\n\t}\n\tconst key = \"extra-key\"\n\tcases := []testCase{\n\t\t{key: key, val: \"abc\", want: \"abc\"},\n\t\t{key: key, val: 123, want: 123},\n\t\t{key: key, val: \"\", want: \"\"},\n\t\t{key: \"other-key\", val: \"def\", want: nil},\n\t}\n\tfor _, tc := range cases {\n\t\textra := make(map[string]interface{})\n\t\textra[tc.key] = tc.val\n\t\ttok := &Token{raw: extra}\n\t\tif got, want := tok.Extra(key), tc.want; got != want {\n\t\t\tt.Errorf(\"Extra(%q) = %q; want %q\", key, got, want)\n\t\t}\n\t}\n}\n\nfunc TestTokenExpiry(t *testing.T) {\n\tnow := time.Now()\n\tcases := []struct {\n\t\tname string\n\t\ttok  *Token\n\t\twant bool\n\t}{\n\t\t{name: \"12 seconds\", tok: &Token{Expiry: now.Add(12 * time.Second)}, want: false},\n\t\t{name: \"10 seconds\", tok: &Token{Expiry: now.Add(expiryDelta)}, want: true},\n\t\t{name: \"-1 hour\", tok: &Token{Expiry: now.Add(-1 * time.Hour)}, want: true},\n\t}\n\tfor _, tc := range cases {\n\t\tif got, want := tc.tok.expired(), tc.want; got != want {\n\t\t\tt.Errorf(\"expired (%q) = %v; want %v\", tc.name, got, want)\n\t\t}\n\t}\n}\n\nfunc TestTokenTypeMethod(t *testing.T) {\n\tcases := []struct {\n\t\tname string\n\t\ttok  *Token\n\t\twant string\n\t}{\n\t\t{name: \"bearer-mixed_case\", tok: &Token{TokenType: \"beAREr\"}, want: \"Bearer\"},\n\t\t{name: \"default-bearer\", tok: &Token{}, want: \"Bearer\"},\n\t\t{name: \"basic\", tok: &Token{TokenType: \"basic\"}, want: \"Basic\"},\n\t\t{name: \"basic-capitalized\", tok: &Token{TokenType: \"Basic\"}, want: \"Basic\"},\n\t\t{name: \"mac\", tok: &Token{TokenType: \"mac\"}, want: \"MAC\"},\n\t\t{name: \"mac-caps\", tok: &Token{TokenType: \"MAC\"}, want: \"MAC\"},\n\t\t{name: \"mac-mixed_case\", tok: &Token{TokenType: \"mAc\"}, want: \"MAC\"},\n\t}\n\tfor _, tc := range cases {\n\t\tif got, want := tc.tok.Type(), tc.want; got != want {\n\t\t\tt.Errorf(\"TokenType(%q) = %v; want %v\", tc.name, got, want)\n\t\t}\n\t}\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/golang.org/x/oauth2/transport_test.go",
    "content": "package oauth2\n\nimport (\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"testing\"\n\t\"time\"\n)\n\ntype tokenSource struct{ token *Token }\n\nfunc (t *tokenSource) Token() (*Token, error) {\n\treturn t.token, nil\n}\n\nfunc TestTransportNilTokenSource(t *testing.T) {\n\ttr := &Transport{}\n\tserver := newMockServer(func(w http.ResponseWriter, r *http.Request) {})\n\tdefer server.Close()\n\tclient := &http.Client{Transport: tr}\n\tresp, err := client.Get(server.URL)\n\tif err == nil {\n\t\tt.Errorf(\"got no errors, want an error with nil token source\")\n\t}\n\tif resp != nil {\n\t\tt.Errorf(\"Response = %v; want nil\", resp)\n\t}\n}\n\nfunc TestTransportTokenSource(t *testing.T) {\n\tts := &tokenSource{\n\t\ttoken: &Token{\n\t\t\tAccessToken: \"abc\",\n\t\t},\n\t}\n\ttr := &Transport{\n\t\tSource: ts,\n\t}\n\tserver := newMockServer(func(w http.ResponseWriter, r *http.Request) {\n\t\tif got, want := r.Header.Get(\"Authorization\"), \"Bearer abc\"; got != want {\n\t\t\tt.Errorf(\"Authorization header = %q; want %q\", got, want)\n\t\t}\n\t})\n\tdefer server.Close()\n\tclient := &http.Client{Transport: tr}\n\tres, err := client.Get(server.URL)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tres.Body.Close()\n}\n\n// Test for case-sensitive token types, per https://github.com/golang/oauth2/issues/113\nfunc TestTransportTokenSourceTypes(t *testing.T) {\n\tconst val = \"abc\"\n\ttests := []struct {\n\t\tkey  string\n\t\tval  string\n\t\twant string\n\t}{\n\t\t{key: \"bearer\", val: val, want: \"Bearer abc\"},\n\t\t{key: \"mac\", val: val, want: \"MAC abc\"},\n\t\t{key: \"basic\", val: val, want: \"Basic abc\"},\n\t}\n\tfor _, tc := range tests {\n\t\tts := &tokenSource{\n\t\t\ttoken: &Token{\n\t\t\t\tAccessToken: tc.val,\n\t\t\t\tTokenType:   tc.key,\n\t\t\t},\n\t\t}\n\t\ttr := &Transport{\n\t\t\tSource: ts,\n\t\t}\n\t\tserver := newMockServer(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tif got, want := r.Header.Get(\"Authorization\"), tc.want; got != want {\n\t\t\t\tt.Errorf(\"Authorization header (%q) = %q; want %q\", val, got, want)\n\t\t\t}\n\t\t})\n\t\tdefer server.Close()\n\t\tclient := &http.Client{Transport: tr}\n\t\tres, err := client.Get(server.URL)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tres.Body.Close()\n\t}\n}\n\nfunc TestTokenValidNoAccessToken(t *testing.T) {\n\ttoken := &Token{}\n\tif token.Valid() {\n\t\tt.Errorf(\"got valid with no access token; want invalid\")\n\t}\n}\n\nfunc TestExpiredWithExpiry(t *testing.T) {\n\ttoken := &Token{\n\t\tExpiry: time.Now().Add(-5 * time.Hour),\n\t}\n\tif token.Valid() {\n\t\tt.Errorf(\"got valid with expired token; want invalid\")\n\t}\n}\n\nfunc newMockServer(handler func(w http.ResponseWriter, r *http.Request)) *httptest.Server {\n\treturn httptest.NewServer(http.HandlerFunc(handler))\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/.travis.yml",
    "content": "language: go\n\ngo:\n  - 1.6.3\n  - 1.7.1\n\ninstall:\n  - go get -v -t -d google.golang.org/appengine/...\n  - mkdir sdk\n  - curl -o sdk.zip \"https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.40.zip\"\n  - unzip -q sdk.zip -d sdk\n  - export APPENGINE_DEV_APPSERVER=$(pwd)/sdk/go_appengine/dev_appserver.py\n\nscript:\n  - go version\n  - go test -v google.golang.org/appengine/...\n  - go test -v -race google.golang.org/appengine/...\n  - sdk/go_appengine/goapp test -v google.golang.org/appengine/...\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/LICENSE",
    "content": "\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/README.md",
    "content": "# Go App Engine packages\n\n[![Build Status](https://travis-ci.org/golang/appengine.svg)](https://travis-ci.org/golang/appengine)\n\nThis repository supports the Go runtime on App Engine,\nincluding both the standard App Engine and the\n\"App Engine flexible environment\" (formerly known as \"Managed VMs\").\nIt provides APIs for interacting with App Engine services.\nIts canonical import path is `google.golang.org/appengine`.\n\nSee https://cloud.google.com/appengine/docs/go/\nfor more information.\n\nFile issue reports and feature requests on the [Google App Engine issue\ntracker](https://code.google.com/p/googleappengine/issues/entry?template=Go%20defect).\n\n## Directory structure\nThe top level directory of this repository is the `appengine` package. It\ncontains the\nbasic APIs (e.g. `appengine.NewContext`) that apply across APIs. Specific API\npackages are in subdirectories (e.g. `datastore`).\n\nThere is an `internal` subdirectory that contains service protocol buffers,\nplus packages required for connectivity to make API calls. App Engine apps\nshould not directly import any package under `internal`.\n\n## Updating a Go App Engine app\n\nThis section describes how to update an older Go App Engine app to use\nthese packages. A provided tool, `aefix`, can help automate steps 2 and 3\n(run `go get google.golang.org/appengine/cmd/aefix` to install it), but\nread the details below since `aefix` can't perform all the changes.\n\n### 1. Update YAML files (App Engine flexible environment / Managed VMs only)\n\nThe `app.yaml` file (and YAML files for modules) should have these new lines added:\n```\nvm: true\n```\nSee https://cloud.google.com/appengine/docs/go/modules/#Go_Instance_scaling_and_class for details.\n\n### 2. Update import paths\n\nThe import paths for App Engine packages are now fully qualified, based at `google.golang.org/appengine`.\nYou will need to update your code to use import paths starting with that; for instance,\ncode importing `appengine/datastore` will now need to import `google.golang.org/appengine/datastore`.\n\n### 3. Update code using deprecated, removed or modified APIs\n\nMost App Engine services are available with exactly the same API.\nA few APIs were cleaned up, and some are not available yet.\nThis list summarises the differences:\n\n* `appengine.Context` has been replaced with the `Context` type from `golang.org/x/net/context`.\n* Logging methods that were on `appengine.Context` are now functions in `google.golang.org/appengine/log`.\n* `appengine.Timeout` has been removed. Use `context.WithTimeout` instead.\n* `appengine.Datacenter` now takes a `context.Context` argument.\n* `datastore.PropertyLoadSaver` has been simplified to use slices in place of channels.\n* `delay.Call` now returns an error.\n* `search.FieldLoadSaver` now handles document metadata.\n* `urlfetch.Transport` no longer has a Deadline field; set a deadline on the\n  `context.Context` instead.\n* `aetest` no longer declares its own Context type, and uses the standard one instead.\n* `taskqueue.QueueStats` no longer takes a maxTasks argument. That argument has been\n  deprecated and unused for a long time.\n* `appengine.BackendHostname` and `appengine.BackendInstance` were for the deprecated backends feature.\n  Use `appengine.ModuleHostname`and `appengine.ModuleName` instead.\n* Most of `appengine/file` and parts of `appengine/blobstore` are deprecated.\n  Use [Google Cloud Storage](https://godoc.org/cloud.google.com/go/storage) if the\n  feature you require is not present in the new\n  [blobstore package](https://google.golang.org/appengine/blobstore).\n* `appengine/socket` is not required on App Engine flexible environment / Managed VMs.\n  Use the standard `net` package instead.\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/appengine.go",
    "content": "// Copyright 2011 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// Package appengine provides basic functionality for Google App Engine.\n//\n// For more information on how to write Go apps for Google App Engine, see:\n// https://cloud.google.com/appengine/docs/go/\npackage appengine // import \"google.golang.org/appengine\"\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/golang/protobuf/proto\"\n\t\"golang.org/x/net/context\"\n\n\t\"google.golang.org/appengine/internal\"\n)\n\n// The gophers party all night; the rabbits provide the beats.\n\n// Main is the principal entry point for an app running in App Engine.\n//\n// On App Engine Flexible it installs a trivial health checker if one isn't\n// already registered, and starts listening on port 8080 (overridden by the\n// $PORT environment variable).\n//\n// See https://cloud.google.com/appengine/docs/flexible/custom-runtimes#health_check_requests\n// for details on how to do your own health checking.\n//\n// Main is not yet supported on App Engine Standard.\n//\n// Main never returns.\n//\n// Main is designed so that the app's main package looks like this:\n//\n//      package main\n//\n//      import (\n//              \"google.golang.org/appengine\"\n//\n//              _ \"myapp/package0\"\n//              _ \"myapp/package1\"\n//      )\n//\n//      func main() {\n//              appengine.Main()\n//      }\n//\n// The \"myapp/packageX\" packages are expected to register HTTP handlers\n// in their init functions.\nfunc Main() {\n\tinternal.Main()\n}\n\n// IsDevAppServer reports whether the App Engine app is running in the\n// development App Server.\nfunc IsDevAppServer() bool {\n\treturn internal.IsDevAppServer()\n}\n\n// NewContext returns a context for an in-flight HTTP request.\n// This function is cheap.\nfunc NewContext(req *http.Request) context.Context {\n\treturn WithContext(context.Background(), req)\n}\n\n// WithContext returns a copy of the parent context\n// and associates it with an in-flight HTTP request.\n// This function is cheap.\nfunc WithContext(parent context.Context, req *http.Request) context.Context {\n\treturn internal.WithContext(parent, req)\n}\n\n// TODO(dsymonds): Add a Call function here? Otherwise other packages can't access internal.Call.\n\n// BlobKey is a key for a blobstore blob.\n//\n// Conceptually, this type belongs in the blobstore package, but it lives in\n// the appengine package to avoid a circular dependency: blobstore depends on\n// datastore, and datastore needs to refer to the BlobKey type.\ntype BlobKey string\n\n// GeoPoint represents a location as latitude/longitude in degrees.\ntype GeoPoint struct {\n\tLat, Lng float64\n}\n\n// Valid returns whether a GeoPoint is within [-90, 90] latitude and [-180, 180] longitude.\nfunc (g GeoPoint) Valid() bool {\n\treturn -90 <= g.Lat && g.Lat <= 90 && -180 <= g.Lng && g.Lng <= 180\n}\n\n// APICallFunc defines a function type for handling an API call.\n// See WithCallOverride.\ntype APICallFunc func(ctx context.Context, service, method string, in, out proto.Message) error\n\n// WithAPICallFunc returns a copy of the parent context\n// that will cause API calls to invoke f instead of their normal operation.\n//\n// This is intended for advanced users only.\nfunc WithAPICallFunc(ctx context.Context, f APICallFunc) context.Context {\n\treturn internal.WithCallOverride(ctx, internal.CallOverrideFunc(f))\n}\n\n// APICall performs an API call.\n//\n// This is not intended for general use; it is exported for use in conjunction\n// with WithAPICallFunc.\nfunc APICall(ctx context.Context, service, method string, in, out proto.Message) error {\n\treturn internal.Call(ctx, service, method, in, out)\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/appengine_test.go",
    "content": "// Copyright 2014 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\npackage appengine\n\nimport (\n\t\"testing\"\n)\n\nfunc TestValidGeoPoint(t *testing.T) {\n\ttestCases := []struct {\n\t\tdesc string\n\t\tpt   GeoPoint\n\t\twant bool\n\t}{\n\t\t{\n\t\t\t\"valid\",\n\t\t\tGeoPoint{67.21, 13.37},\n\t\t\ttrue,\n\t\t},\n\t\t{\n\t\t\t\"high lat\",\n\t\t\tGeoPoint{-90.01, 13.37},\n\t\t\tfalse,\n\t\t},\n\t\t{\n\t\t\t\"low lat\",\n\t\t\tGeoPoint{90.01, 13.37},\n\t\t\tfalse,\n\t\t},\n\t\t{\n\t\t\t\"high lng\",\n\t\t\tGeoPoint{67.21, 182},\n\t\t\tfalse,\n\t\t},\n\t\t{\n\t\t\t\"low lng\",\n\t\t\tGeoPoint{67.21, -181},\n\t\t\tfalse,\n\t\t},\n\t}\n\n\tfor _, tc := range testCases {\n\t\tif got := tc.pt.Valid(); got != tc.want {\n\t\t\tt.Errorf(\"%s: got %v, want %v\", tc.desc, got, tc.want)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/appengine_vm.go",
    "content": "// Copyright 2015 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// +build !appengine\n\npackage appengine\n\nimport (\n\t\"golang.org/x/net/context\"\n\n\t\"google.golang.org/appengine/internal\"\n)\n\n// BackgroundContext returns a context not associated with a request.\n// This should only be used when not servicing a request.\n// This only works in App Engine \"flexible environment\".\nfunc BackgroundContext() context.Context {\n\treturn internal.BackgroundContext()\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/errors.go",
    "content": "// Copyright 2011 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// This file provides error functions for common API failure modes.\n\npackage appengine\n\nimport (\n\t\"fmt\"\n\n\t\"google.golang.org/appengine/internal\"\n)\n\n// IsOverQuota reports whether err represents an API call failure\n// due to insufficient available quota.\nfunc IsOverQuota(err error) bool {\n\tcallErr, ok := err.(*internal.CallError)\n\treturn ok && callErr.Code == 4\n}\n\n// MultiError is returned by batch operations when there are errors with\n// particular elements. Errors will be in a one-to-one correspondence with\n// the input elements; successful elements will have a nil entry.\ntype MultiError []error\n\nfunc (m MultiError) Error() string {\n\ts, n := \"\", 0\n\tfor _, e := range m {\n\t\tif e != nil {\n\t\t\tif n == 0 {\n\t\t\t\ts = e.Error()\n\t\t\t}\n\t\t\tn++\n\t\t}\n\t}\n\tswitch n {\n\tcase 0:\n\t\treturn \"(0 errors)\"\n\tcase 1:\n\t\treturn s\n\tcase 2:\n\t\treturn s + \" (and 1 other error)\"\n\t}\n\treturn fmt.Sprintf(\"%s (and %d other errors)\", s, n-1)\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/identity.go",
    "content": "// Copyright 2011 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\npackage appengine\n\nimport (\n\t\"time\"\n\n\t\"golang.org/x/net/context\"\n\n\t\"google.golang.org/appengine/internal\"\n\tpb \"google.golang.org/appengine/internal/app_identity\"\n\tmodpb \"google.golang.org/appengine/internal/modules\"\n)\n\n// AppID returns the application ID for the current application.\n// The string will be a plain application ID (e.g. \"appid\"), with a\n// domain prefix for custom domain deployments (e.g. \"example.com:appid\").\nfunc AppID(c context.Context) string { return internal.AppID(c) }\n\n// DefaultVersionHostname returns the standard hostname of the default version\n// of the current application (e.g. \"my-app.appspot.com\"). This is suitable for\n// use in constructing URLs.\nfunc DefaultVersionHostname(c context.Context) string {\n\treturn internal.DefaultVersionHostname(c)\n}\n\n// ModuleName returns the module name of the current instance.\nfunc ModuleName(c context.Context) string {\n\treturn internal.ModuleName(c)\n}\n\n// ModuleHostname returns a hostname of a module instance.\n// If module is the empty string, it refers to the module of the current instance.\n// If version is empty, it refers to the version of the current instance if valid,\n// or the default version of the module of the current instance.\n// If instance is empty, ModuleHostname returns the load-balancing hostname.\nfunc ModuleHostname(c context.Context, module, version, instance string) (string, error) {\n\treq := &modpb.GetHostnameRequest{}\n\tif module != \"\" {\n\t\treq.Module = &module\n\t}\n\tif version != \"\" {\n\t\treq.Version = &version\n\t}\n\tif instance != \"\" {\n\t\treq.Instance = &instance\n\t}\n\tres := &modpb.GetHostnameResponse{}\n\tif err := internal.Call(c, \"modules\", \"GetHostname\", req, res); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn *res.Hostname, nil\n}\n\n// VersionID returns the version ID for the current application.\n// It will be of the form \"X.Y\", where X is specified in app.yaml,\n// and Y is a number generated when each version of the app is uploaded.\n// It does not include a module name.\nfunc VersionID(c context.Context) string { return internal.VersionID(c) }\n\n// InstanceID returns a mostly-unique identifier for this instance.\nfunc InstanceID() string { return internal.InstanceID() }\n\n// Datacenter returns an identifier for the datacenter that the instance is running in.\nfunc Datacenter(c context.Context) string { return internal.Datacenter(c) }\n\n// ServerSoftware returns the App Engine release version.\n// In production, it looks like \"Google App Engine/X.Y.Z\".\n// In the development appserver, it looks like \"Development/X.Y\".\nfunc ServerSoftware() string { return internal.ServerSoftware() }\n\n// RequestID returns a string that uniquely identifies the request.\nfunc RequestID(c context.Context) string { return internal.RequestID(c) }\n\n// AccessToken generates an OAuth2 access token for the specified scopes on\n// behalf of service account of this application. This token will expire after\n// the returned time.\nfunc AccessToken(c context.Context, scopes ...string) (token string, expiry time.Time, err error) {\n\treq := &pb.GetAccessTokenRequest{Scope: scopes}\n\tres := &pb.GetAccessTokenResponse{}\n\n\terr = internal.Call(c, \"app_identity_service\", \"GetAccessToken\", req, res)\n\tif err != nil {\n\t\treturn \"\", time.Time{}, err\n\t}\n\treturn res.GetAccessToken(), time.Unix(res.GetExpirationTime(), 0), nil\n}\n\n// Certificate represents a public certificate for the app.\ntype Certificate struct {\n\tKeyName string\n\tData    []byte // PEM-encoded X.509 certificate\n}\n\n// PublicCertificates retrieves the public certificates for the app.\n// They can be used to verify a signature returned by SignBytes.\nfunc PublicCertificates(c context.Context) ([]Certificate, error) {\n\treq := &pb.GetPublicCertificateForAppRequest{}\n\tres := &pb.GetPublicCertificateForAppResponse{}\n\tif err := internal.Call(c, \"app_identity_service\", \"GetPublicCertificatesForApp\", req, res); err != nil {\n\t\treturn nil, err\n\t}\n\tvar cs []Certificate\n\tfor _, pc := range res.PublicCertificateList {\n\t\tcs = append(cs, Certificate{\n\t\t\tKeyName: pc.GetKeyName(),\n\t\t\tData:    []byte(pc.GetX509CertificatePem()),\n\t\t})\n\t}\n\treturn cs, nil\n}\n\n// ServiceAccount returns a string representing the service account name, in\n// the form of an email address (typically app_id@appspot.gserviceaccount.com).\nfunc ServiceAccount(c context.Context) (string, error) {\n\treq := &pb.GetServiceAccountNameRequest{}\n\tres := &pb.GetServiceAccountNameResponse{}\n\n\terr := internal.Call(c, \"app_identity_service\", \"GetServiceAccountName\", req, res)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn res.GetServiceAccountName(), err\n}\n\n// SignBytes signs bytes using a private key unique to your application.\nfunc SignBytes(c context.Context, bytes []byte) (keyName string, signature []byte, err error) {\n\treq := &pb.SignForAppRequest{BytesToSign: bytes}\n\tres := &pb.SignForAppResponse{}\n\n\tif err := internal.Call(c, \"app_identity_service\", \"SignForApp\", req, res); err != nil {\n\t\treturn \"\", nil, err\n\t}\n\treturn res.GetKeyName(), res.GetSignatureBytes(), nil\n}\n\nfunc init() {\n\tinternal.RegisterErrorCodeMap(\"app_identity_service\", pb.AppIdentityServiceError_ErrorCode_name)\n\tinternal.RegisterErrorCodeMap(\"modules\", modpb.ModulesServiceError_ErrorCode_name)\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/api.go",
    "content": "// Copyright 2011 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// +build !appengine\n\npackage internal\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"net\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"os\"\n\t\"runtime\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync\"\n\t\"sync/atomic\"\n\t\"time\"\n\n\t\"github.com/golang/protobuf/proto\"\n\tnetcontext \"golang.org/x/net/context\"\n\n\tbasepb \"google.golang.org/appengine/internal/base\"\n\tlogpb \"google.golang.org/appengine/internal/log\"\n\tremotepb \"google.golang.org/appengine/internal/remote_api\"\n)\n\nconst (\n\tapiPath = \"/rpc_http\"\n)\n\nvar (\n\t// Incoming headers.\n\tticketHeader       = http.CanonicalHeaderKey(\"X-AppEngine-API-Ticket\")\n\tdapperHeader       = http.CanonicalHeaderKey(\"X-Google-DapperTraceInfo\")\n\ttraceHeader        = http.CanonicalHeaderKey(\"X-Cloud-Trace-Context\")\n\tcurNamespaceHeader = http.CanonicalHeaderKey(\"X-AppEngine-Current-Namespace\")\n\tuserIPHeader       = http.CanonicalHeaderKey(\"X-AppEngine-User-IP\")\n\tremoteAddrHeader   = http.CanonicalHeaderKey(\"X-AppEngine-Remote-Addr\")\n\n\t// Outgoing headers.\n\tapiEndpointHeader      = http.CanonicalHeaderKey(\"X-Google-RPC-Service-Endpoint\")\n\tapiEndpointHeaderValue = []string{\"app-engine-apis\"}\n\tapiMethodHeader        = http.CanonicalHeaderKey(\"X-Google-RPC-Service-Method\")\n\tapiMethodHeaderValue   = []string{\"/VMRemoteAPI.CallRemoteAPI\"}\n\tapiDeadlineHeader      = http.CanonicalHeaderKey(\"X-Google-RPC-Service-Deadline\")\n\tapiContentType         = http.CanonicalHeaderKey(\"Content-Type\")\n\tapiContentTypeValue    = []string{\"application/octet-stream\"}\n\tlogFlushHeader         = http.CanonicalHeaderKey(\"X-AppEngine-Log-Flush-Count\")\n\n\tapiHTTPClient = &http.Client{\n\t\tTransport: &http.Transport{\n\t\t\tProxy: http.ProxyFromEnvironment,\n\t\t\tDial:  limitDial,\n\t\t},\n\t}\n)\n\nfunc apiURL() *url.URL {\n\thost, port := \"appengine.googleapis.internal\", \"10001\"\n\tif h := os.Getenv(\"API_HOST\"); h != \"\" {\n\t\thost = h\n\t}\n\tif p := os.Getenv(\"API_PORT\"); p != \"\" {\n\t\tport = p\n\t}\n\treturn &url.URL{\n\t\tScheme: \"http\",\n\t\tHost:   host + \":\" + port,\n\t\tPath:   apiPath,\n\t}\n}\n\nfunc handleHTTP(w http.ResponseWriter, r *http.Request) {\n\tc := &context{\n\t\treq:       r,\n\t\toutHeader: w.Header(),\n\t\tapiURL:    apiURL(),\n\t}\n\tstopFlushing := make(chan int)\n\n\tctxs.Lock()\n\tctxs.m[r] = c\n\tctxs.Unlock()\n\tdefer func() {\n\t\tctxs.Lock()\n\t\tdelete(ctxs.m, r)\n\t\tctxs.Unlock()\n\t}()\n\n\t// Patch up RemoteAddr so it looks reasonable.\n\tif addr := r.Header.Get(userIPHeader); addr != \"\" {\n\t\tr.RemoteAddr = addr\n\t} else if addr = r.Header.Get(remoteAddrHeader); addr != \"\" {\n\t\tr.RemoteAddr = addr\n\t} else {\n\t\t// Should not normally reach here, but pick a sensible default anyway.\n\t\tr.RemoteAddr = \"127.0.0.1\"\n\t}\n\t// The address in the headers will most likely be of these forms:\n\t//\t123.123.123.123\n\t//\t2001:db8::1\n\t// net/http.Request.RemoteAddr is specified to be in \"IP:port\" form.\n\tif _, _, err := net.SplitHostPort(r.RemoteAddr); err != nil {\n\t\t// Assume the remote address is only a host; add a default port.\n\t\tr.RemoteAddr = net.JoinHostPort(r.RemoteAddr, \"80\")\n\t}\n\n\t// Start goroutine responsible for flushing app logs.\n\t// This is done after adding c to ctx.m (and stopped before removing it)\n\t// because flushing logs requires making an API call.\n\tgo c.logFlusher(stopFlushing)\n\n\texecuteRequestSafely(c, r)\n\tc.outHeader = nil // make sure header changes aren't respected any more\n\n\tstopFlushing <- 1 // any logging beyond this point will be dropped\n\n\t// Flush any pending logs asynchronously.\n\tc.pendingLogs.Lock()\n\tflushes := c.pendingLogs.flushes\n\tif len(c.pendingLogs.lines) > 0 {\n\t\tflushes++\n\t}\n\tc.pendingLogs.Unlock()\n\tgo c.flushLog(false)\n\tw.Header().Set(logFlushHeader, strconv.Itoa(flushes))\n\n\t// Avoid nil Write call if c.Write is never called.\n\tif c.outCode != 0 {\n\t\tw.WriteHeader(c.outCode)\n\t}\n\tif c.outBody != nil {\n\t\tw.Write(c.outBody)\n\t}\n}\n\nfunc executeRequestSafely(c *context, r *http.Request) {\n\tdefer func() {\n\t\tif x := recover(); x != nil {\n\t\t\tlogf(c, 4, \"%s\", renderPanic(x)) // 4 == critical\n\t\t\tc.outCode = 500\n\t\t}\n\t}()\n\n\thttp.DefaultServeMux.ServeHTTP(c, r)\n}\n\nfunc renderPanic(x interface{}) string {\n\tbuf := make([]byte, 16<<10) // 16 KB should be plenty\n\tbuf = buf[:runtime.Stack(buf, false)]\n\n\t// Remove the first few stack frames:\n\t//   this func\n\t//   the recover closure in the caller\n\t// That will root the stack trace at the site of the panic.\n\tconst (\n\t\tskipStart  = \"internal.renderPanic\"\n\t\tskipFrames = 2\n\t)\n\tstart := bytes.Index(buf, []byte(skipStart))\n\tp := start\n\tfor i := 0; i < skipFrames*2 && p+1 < len(buf); i++ {\n\t\tp = bytes.IndexByte(buf[p+1:], '\\n') + p + 1\n\t\tif p < 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\tif p >= 0 {\n\t\t// buf[start:p+1] is the block to remove.\n\t\t// Copy buf[p+1:] over buf[start:] and shrink buf.\n\t\tcopy(buf[start:], buf[p+1:])\n\t\tbuf = buf[:len(buf)-(p+1-start)]\n\t}\n\n\t// Add panic heading.\n\thead := fmt.Sprintf(\"panic: %v\\n\\n\", x)\n\tif len(head) > len(buf) {\n\t\t// Extremely unlikely to happen.\n\t\treturn head\n\t}\n\tcopy(buf[len(head):], buf)\n\tcopy(buf, head)\n\n\treturn string(buf)\n}\n\nvar ctxs = struct {\n\tsync.Mutex\n\tm  map[*http.Request]*context\n\tbg *context // background context, lazily initialized\n\t// dec is used by tests to decorate the netcontext.Context returned\n\t// for a given request. This allows tests to add overrides (such as\n\t// WithAppIDOverride) to the context. The map is nil outside tests.\n\tdec map[*http.Request]func(netcontext.Context) netcontext.Context\n}{\n\tm: make(map[*http.Request]*context),\n}\n\n// context represents the context of an in-flight HTTP request.\n// It implements the appengine.Context and http.ResponseWriter interfaces.\ntype context struct {\n\treq *http.Request\n\n\toutCode   int\n\toutHeader http.Header\n\toutBody   []byte\n\n\tpendingLogs struct {\n\t\tsync.Mutex\n\t\tlines   []*logpb.UserAppLogLine\n\t\tflushes int\n\t}\n\n\tapiURL *url.URL\n}\n\nvar contextKey = \"holds a *context\"\n\nfunc fromContext(ctx netcontext.Context) *context {\n\tc, _ := ctx.Value(&contextKey).(*context)\n\treturn c\n}\n\nfunc withContext(parent netcontext.Context, c *context) netcontext.Context {\n\tctx := netcontext.WithValue(parent, &contextKey, c)\n\tif ns := c.req.Header.Get(curNamespaceHeader); ns != \"\" {\n\t\tctx = withNamespace(ctx, ns)\n\t}\n\treturn ctx\n}\n\nfunc toContext(c *context) netcontext.Context {\n\treturn withContext(netcontext.Background(), c)\n}\n\nfunc IncomingHeaders(ctx netcontext.Context) http.Header {\n\tif c := fromContext(ctx); c != nil {\n\t\treturn c.req.Header\n\t}\n\treturn nil\n}\n\nfunc WithContext(parent netcontext.Context, req *http.Request) netcontext.Context {\n\tctxs.Lock()\n\tc := ctxs.m[req]\n\td := ctxs.dec[req]\n\tctxs.Unlock()\n\n\tif d != nil {\n\t\tparent = d(parent)\n\t}\n\n\tif c == nil {\n\t\t// Someone passed in an http.Request that is not in-flight.\n\t\t// We panic here rather than panicking at a later point\n\t\t// so that stack traces will be more sensible.\n\t\tlog.Panic(\"appengine: NewContext passed an unknown http.Request\")\n\t}\n\treturn withContext(parent, c)\n}\n\nfunc BackgroundContext() netcontext.Context {\n\tctxs.Lock()\n\tdefer ctxs.Unlock()\n\n\tif ctxs.bg != nil {\n\t\treturn toContext(ctxs.bg)\n\t}\n\n\t// Compute background security ticket.\n\tappID := partitionlessAppID()\n\tescAppID := strings.Replace(strings.Replace(appID, \":\", \"_\", -1), \".\", \"_\", -1)\n\tmajVersion := VersionID(nil)\n\tif i := strings.Index(majVersion, \".\"); i > 0 {\n\t\tmajVersion = majVersion[:i]\n\t}\n\tticket := fmt.Sprintf(\"%s/%s.%s.%s\", escAppID, ModuleName(nil), majVersion, InstanceID())\n\n\tctxs.bg = &context{\n\t\treq: &http.Request{\n\t\t\tHeader: http.Header{\n\t\t\t\tticketHeader: []string{ticket},\n\t\t\t},\n\t\t},\n\t\tapiURL: apiURL(),\n\t}\n\n\t// TODO(dsymonds): Wire up the shutdown handler to do a final flush.\n\tgo ctxs.bg.logFlusher(make(chan int))\n\n\treturn toContext(ctxs.bg)\n}\n\n// RegisterTestRequest registers the HTTP request req for testing, such that\n// any API calls are sent to the provided URL. It returns a closure to delete\n// the registration.\n// It should only be used by aetest package.\nfunc RegisterTestRequest(req *http.Request, apiURL *url.URL, decorate func(netcontext.Context) netcontext.Context) func() {\n\tc := &context{\n\t\treq:    req,\n\t\tapiURL: apiURL,\n\t}\n\tctxs.Lock()\n\tdefer ctxs.Unlock()\n\tif _, ok := ctxs.m[req]; ok {\n\t\tlog.Panic(\"req already associated with context\")\n\t}\n\tif _, ok := ctxs.dec[req]; ok {\n\t\tlog.Panic(\"req already associated with context\")\n\t}\n\tif ctxs.dec == nil {\n\t\tctxs.dec = make(map[*http.Request]func(netcontext.Context) netcontext.Context)\n\t}\n\tctxs.m[req] = c\n\tctxs.dec[req] = decorate\n\n\treturn func() {\n\t\tctxs.Lock()\n\t\tdelete(ctxs.m, req)\n\t\tdelete(ctxs.dec, req)\n\t\tctxs.Unlock()\n\t}\n}\n\nvar errTimeout = &CallError{\n\tDetail:  \"Deadline exceeded\",\n\tCode:    int32(remotepb.RpcError_CANCELLED),\n\tTimeout: true,\n}\n\nfunc (c *context) Header() http.Header { return c.outHeader }\n\n// Copied from $GOROOT/src/pkg/net/http/transfer.go. Some response status\n// codes do not permit a response body (nor response entity headers such as\n// Content-Length, Content-Type, etc).\nfunc bodyAllowedForStatus(status int) bool {\n\tswitch {\n\tcase status >= 100 && status <= 199:\n\t\treturn false\n\tcase status == 204:\n\t\treturn false\n\tcase status == 304:\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc (c *context) Write(b []byte) (int, error) {\n\tif c.outCode == 0 {\n\t\tc.WriteHeader(http.StatusOK)\n\t}\n\tif len(b) > 0 && !bodyAllowedForStatus(c.outCode) {\n\t\treturn 0, http.ErrBodyNotAllowed\n\t}\n\tc.outBody = append(c.outBody, b...)\n\treturn len(b), nil\n}\n\nfunc (c *context) WriteHeader(code int) {\n\tif c.outCode != 0 {\n\t\tlogf(c, 3, \"WriteHeader called multiple times on request.\") // error level\n\t\treturn\n\t}\n\tc.outCode = code\n}\n\nfunc (c *context) post(body []byte, timeout time.Duration) (b []byte, err error) {\n\threq := &http.Request{\n\t\tMethod: \"POST\",\n\t\tURL:    c.apiURL,\n\t\tHeader: http.Header{\n\t\t\tapiEndpointHeader: apiEndpointHeaderValue,\n\t\t\tapiMethodHeader:   apiMethodHeaderValue,\n\t\t\tapiContentType:    apiContentTypeValue,\n\t\t\tapiDeadlineHeader: []string{strconv.FormatFloat(timeout.Seconds(), 'f', -1, 64)},\n\t\t},\n\t\tBody:          ioutil.NopCloser(bytes.NewReader(body)),\n\t\tContentLength: int64(len(body)),\n\t\tHost:          c.apiURL.Host,\n\t}\n\tif info := c.req.Header.Get(dapperHeader); info != \"\" {\n\t\threq.Header.Set(dapperHeader, info)\n\t}\n\tif info := c.req.Header.Get(traceHeader); info != \"\" {\n\t\threq.Header.Set(traceHeader, info)\n\t}\n\n\ttr := apiHTTPClient.Transport.(*http.Transport)\n\n\tvar timedOut int32 // atomic; set to 1 if timed out\n\tt := time.AfterFunc(timeout, func() {\n\t\tatomic.StoreInt32(&timedOut, 1)\n\t\ttr.CancelRequest(hreq)\n\t})\n\tdefer t.Stop()\n\tdefer func() {\n\t\t// Check if timeout was exceeded.\n\t\tif atomic.LoadInt32(&timedOut) != 0 {\n\t\t\terr = errTimeout\n\t\t}\n\t}()\n\n\thresp, err := apiHTTPClient.Do(hreq)\n\tif err != nil {\n\t\treturn nil, &CallError{\n\t\t\tDetail: fmt.Sprintf(\"service bridge HTTP failed: %v\", err),\n\t\t\tCode:   int32(remotepb.RpcError_UNKNOWN),\n\t\t}\n\t}\n\tdefer hresp.Body.Close()\n\threspBody, err := ioutil.ReadAll(hresp.Body)\n\tif hresp.StatusCode != 200 {\n\t\treturn nil, &CallError{\n\t\t\tDetail: fmt.Sprintf(\"service bridge returned HTTP %d (%q)\", hresp.StatusCode, hrespBody),\n\t\t\tCode:   int32(remotepb.RpcError_UNKNOWN),\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn nil, &CallError{\n\t\t\tDetail: fmt.Sprintf(\"service bridge response bad: %v\", err),\n\t\t\tCode:   int32(remotepb.RpcError_UNKNOWN),\n\t\t}\n\t}\n\treturn hrespBody, nil\n}\n\nfunc Call(ctx netcontext.Context, service, method string, in, out proto.Message) error {\n\tif ns := NamespaceFromContext(ctx); ns != \"\" {\n\t\tif fn, ok := NamespaceMods[service]; ok {\n\t\t\tfn(in, ns)\n\t\t}\n\t}\n\n\tif f, ctx, ok := callOverrideFromContext(ctx); ok {\n\t\treturn f(ctx, service, method, in, out)\n\t}\n\n\t// Handle already-done contexts quickly.\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tdefault:\n\t}\n\n\tc := fromContext(ctx)\n\tif c == nil {\n\t\t// Give a good error message rather than a panic lower down.\n\t\treturn errors.New(\"not an App Engine context\")\n\t}\n\n\t// Apply transaction modifications if we're in a transaction.\n\tif t := transactionFromContext(ctx); t != nil {\n\t\tif t.finished {\n\t\t\treturn errors.New(\"transaction context has expired\")\n\t\t}\n\t\tapplyTransaction(in, &t.transaction)\n\t}\n\n\t// Default RPC timeout is 60s.\n\ttimeout := 60 * time.Second\n\tif deadline, ok := ctx.Deadline(); ok {\n\t\ttimeout = deadline.Sub(time.Now())\n\t}\n\n\tdata, err := proto.Marshal(in)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tticket := c.req.Header.Get(ticketHeader)\n\treq := &remotepb.Request{\n\t\tServiceName: &service,\n\t\tMethod:      &method,\n\t\tRequest:     data,\n\t\tRequestId:   &ticket,\n\t}\n\threqBody, err := proto.Marshal(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\threspBody, err := c.post(hreqBody, timeout)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tres := &remotepb.Response{}\n\tif err := proto.Unmarshal(hrespBody, res); err != nil {\n\t\treturn err\n\t}\n\tif res.RpcError != nil {\n\t\tce := &CallError{\n\t\t\tDetail: res.RpcError.GetDetail(),\n\t\t\tCode:   *res.RpcError.Code,\n\t\t}\n\t\tswitch remotepb.RpcError_ErrorCode(ce.Code) {\n\t\tcase remotepb.RpcError_CANCELLED, remotepb.RpcError_DEADLINE_EXCEEDED:\n\t\t\tce.Timeout = true\n\t\t}\n\t\treturn ce\n\t}\n\tif res.ApplicationError != nil {\n\t\treturn &APIError{\n\t\t\tService: *req.ServiceName,\n\t\t\tDetail:  res.ApplicationError.GetDetail(),\n\t\t\tCode:    *res.ApplicationError.Code,\n\t\t}\n\t}\n\tif res.Exception != nil || res.JavaException != nil {\n\t\t// This shouldn't happen, but let's be defensive.\n\t\treturn &CallError{\n\t\t\tDetail: \"service bridge returned exception\",\n\t\t\tCode:   int32(remotepb.RpcError_UNKNOWN),\n\t\t}\n\t}\n\treturn proto.Unmarshal(res.Response, out)\n}\n\nfunc (c *context) Request() *http.Request {\n\treturn c.req\n}\n\nfunc (c *context) addLogLine(ll *logpb.UserAppLogLine) {\n\t// Truncate long log lines.\n\t// TODO(dsymonds): Check if this is still necessary.\n\tconst lim = 8 << 10\n\tif len(*ll.Message) > lim {\n\t\tsuffix := fmt.Sprintf(\"...(length %d)\", len(*ll.Message))\n\t\tll.Message = proto.String((*ll.Message)[:lim-len(suffix)] + suffix)\n\t}\n\n\tc.pendingLogs.Lock()\n\tc.pendingLogs.lines = append(c.pendingLogs.lines, ll)\n\tc.pendingLogs.Unlock()\n}\n\nvar logLevelName = map[int64]string{\n\t0: \"DEBUG\",\n\t1: \"INFO\",\n\t2: \"WARNING\",\n\t3: \"ERROR\",\n\t4: \"CRITICAL\",\n}\n\nfunc logf(c *context, level int64, format string, args ...interface{}) {\n\ts := fmt.Sprintf(format, args...)\n\ts = strings.TrimRight(s, \"\\n\") // Remove any trailing newline characters.\n\tc.addLogLine(&logpb.UserAppLogLine{\n\t\tTimestampUsec: proto.Int64(time.Now().UnixNano() / 1e3),\n\t\tLevel:         &level,\n\t\tMessage:       &s,\n\t})\n\tlog.Print(logLevelName[level] + \": \" + s)\n}\n\n// flushLog attempts to flush any pending logs to the appserver.\n// It should not be called concurrently.\nfunc (c *context) flushLog(force bool) (flushed bool) {\n\tc.pendingLogs.Lock()\n\t// Grab up to 30 MB. We can get away with up to 32 MB, but let's be cautious.\n\tn, rem := 0, 30<<20\n\tfor ; n < len(c.pendingLogs.lines); n++ {\n\t\tll := c.pendingLogs.lines[n]\n\t\t// Each log line will require about 3 bytes of overhead.\n\t\tnb := proto.Size(ll) + 3\n\t\tif nb > rem {\n\t\t\tbreak\n\t\t}\n\t\trem -= nb\n\t}\n\tlines := c.pendingLogs.lines[:n]\n\tc.pendingLogs.lines = c.pendingLogs.lines[n:]\n\tc.pendingLogs.Unlock()\n\n\tif len(lines) == 0 && !force {\n\t\t// Nothing to flush.\n\t\treturn false\n\t}\n\n\trescueLogs := false\n\tdefer func() {\n\t\tif rescueLogs {\n\t\t\tc.pendingLogs.Lock()\n\t\t\tc.pendingLogs.lines = append(lines, c.pendingLogs.lines...)\n\t\t\tc.pendingLogs.Unlock()\n\t\t}\n\t}()\n\n\tbuf, err := proto.Marshal(&logpb.UserAppLogGroup{\n\t\tLogLine: lines,\n\t})\n\tif err != nil {\n\t\tlog.Printf(\"internal.flushLog: marshaling UserAppLogGroup: %v\", err)\n\t\trescueLogs = true\n\t\treturn false\n\t}\n\n\treq := &logpb.FlushRequest{\n\t\tLogs: buf,\n\t}\n\tres := &basepb.VoidProto{}\n\tc.pendingLogs.Lock()\n\tc.pendingLogs.flushes++\n\tc.pendingLogs.Unlock()\n\tif err := Call(toContext(c), \"logservice\", \"Flush\", req, res); err != nil {\n\t\tlog.Printf(\"internal.flushLog: Flush RPC: %v\", err)\n\t\trescueLogs = true\n\t\treturn false\n\t}\n\treturn true\n}\n\nconst (\n\t// Log flushing parameters.\n\tflushInterval      = 1 * time.Second\n\tforceFlushInterval = 60 * time.Second\n)\n\nfunc (c *context) logFlusher(stop <-chan int) {\n\tlastFlush := time.Now()\n\ttick := time.NewTicker(flushInterval)\n\tfor {\n\t\tselect {\n\t\tcase <-stop:\n\t\t\t// Request finished.\n\t\t\ttick.Stop()\n\t\t\treturn\n\t\tcase <-tick.C:\n\t\t\tforce := time.Now().Sub(lastFlush) > forceFlushInterval\n\t\t\tif c.flushLog(force) {\n\t\t\t\tlastFlush = time.Now()\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc ContextForTesting(req *http.Request) netcontext.Context {\n\treturn toContext(&context{req: req})\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/api_classic.go",
    "content": "// Copyright 2015 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// +build appengine\n\npackage internal\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"time\"\n\n\t\"appengine\"\n\t\"appengine_internal\"\n\tbasepb \"appengine_internal/base\"\n\n\t\"github.com/golang/protobuf/proto\"\n\tnetcontext \"golang.org/x/net/context\"\n)\n\nvar contextKey = \"holds an appengine.Context\"\n\nfunc fromContext(ctx netcontext.Context) appengine.Context {\n\tc, _ := ctx.Value(&contextKey).(appengine.Context)\n\treturn c\n}\n\n// This is only for classic App Engine adapters.\nfunc ClassicContextFromContext(ctx netcontext.Context) appengine.Context {\n\treturn fromContext(ctx)\n}\n\nfunc withContext(parent netcontext.Context, c appengine.Context) netcontext.Context {\n\tctx := netcontext.WithValue(parent, &contextKey, c)\n\n\ts := &basepb.StringProto{}\n\tc.Call(\"__go__\", \"GetNamespace\", &basepb.VoidProto{}, s, nil)\n\tif ns := s.GetValue(); ns != \"\" {\n\t\tctx = NamespacedContext(ctx, ns)\n\t}\n\n\treturn ctx\n}\n\nfunc IncomingHeaders(ctx netcontext.Context) http.Header {\n\tif c := fromContext(ctx); c != nil {\n\t\tif req, ok := c.Request().(*http.Request); ok {\n\t\t\treturn req.Header\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc WithContext(parent netcontext.Context, req *http.Request) netcontext.Context {\n\tc := appengine.NewContext(req)\n\treturn withContext(parent, c)\n}\n\ntype testingContext struct {\n\tappengine.Context\n\n\treq *http.Request\n}\n\nfunc (t *testingContext) FullyQualifiedAppID() string { return \"dev~testcontext\" }\nfunc (t *testingContext) Call(service, method string, _, _ appengine_internal.ProtoMessage, _ *appengine_internal.CallOptions) error {\n\tif service == \"__go__\" && method == \"GetNamespace\" {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"testingContext: unsupported Call\")\n}\nfunc (t *testingContext) Request() interface{} { return t.req }\n\nfunc ContextForTesting(req *http.Request) netcontext.Context {\n\treturn withContext(netcontext.Background(), &testingContext{req: req})\n}\n\nfunc Call(ctx netcontext.Context, service, method string, in, out proto.Message) error {\n\tif ns := NamespaceFromContext(ctx); ns != \"\" {\n\t\tif fn, ok := NamespaceMods[service]; ok {\n\t\t\tfn(in, ns)\n\t\t}\n\t}\n\n\tif f, ctx, ok := callOverrideFromContext(ctx); ok {\n\t\treturn f(ctx, service, method, in, out)\n\t}\n\n\t// Handle already-done contexts quickly.\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tdefault:\n\t}\n\n\tc := fromContext(ctx)\n\tif c == nil {\n\t\t// Give a good error message rather than a panic lower down.\n\t\treturn errors.New(\"not an App Engine context\")\n\t}\n\n\t// Apply transaction modifications if we're in a transaction.\n\tif t := transactionFromContext(ctx); t != nil {\n\t\tif t.finished {\n\t\t\treturn errors.New(\"transaction context has expired\")\n\t\t}\n\t\tapplyTransaction(in, &t.transaction)\n\t}\n\n\tvar opts *appengine_internal.CallOptions\n\tif d, ok := ctx.Deadline(); ok {\n\t\topts = &appengine_internal.CallOptions{\n\t\t\tTimeout: d.Sub(time.Now()),\n\t\t}\n\t}\n\n\terr := c.Call(service, method, in, out, opts)\n\tswitch v := err.(type) {\n\tcase *appengine_internal.APIError:\n\t\treturn &APIError{\n\t\t\tService: v.Service,\n\t\t\tDetail:  v.Detail,\n\t\t\tCode:    v.Code,\n\t\t}\n\tcase *appengine_internal.CallError:\n\t\treturn &CallError{\n\t\t\tDetail:  v.Detail,\n\t\t\tCode:    v.Code,\n\t\t\tTimeout: v.Timeout,\n\t\t}\n\t}\n\treturn err\n}\n\nfunc handleHTTP(w http.ResponseWriter, r *http.Request) {\n\tpanic(\"handleHTTP called; this should be impossible\")\n}\n\nfunc logf(c appengine.Context, level int64, format string, args ...interface{}) {\n\tvar fn func(format string, args ...interface{})\n\tswitch level {\n\tcase 0:\n\t\tfn = c.Debugf\n\tcase 1:\n\t\tfn = c.Infof\n\tcase 2:\n\t\tfn = c.Warningf\n\tcase 3:\n\t\tfn = c.Errorf\n\tcase 4:\n\t\tfn = c.Criticalf\n\tdefault:\n\t\t// This shouldn't happen.\n\t\tfn = c.Criticalf\n\t}\n\tfn(format, args...)\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/api_common.go",
    "content": "// Copyright 2015 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\npackage internal\n\nimport (\n\t\"github.com/golang/protobuf/proto\"\n\tnetcontext \"golang.org/x/net/context\"\n)\n\ntype CallOverrideFunc func(ctx netcontext.Context, service, method string, in, out proto.Message) error\n\nvar callOverrideKey = \"holds []CallOverrideFunc\"\n\nfunc WithCallOverride(ctx netcontext.Context, f CallOverrideFunc) netcontext.Context {\n\t// We avoid appending to any existing call override\n\t// so we don't risk overwriting a popped stack below.\n\tvar cofs []CallOverrideFunc\n\tif uf, ok := ctx.Value(&callOverrideKey).([]CallOverrideFunc); ok {\n\t\tcofs = append(cofs, uf...)\n\t}\n\tcofs = append(cofs, f)\n\treturn netcontext.WithValue(ctx, &callOverrideKey, cofs)\n}\n\nfunc callOverrideFromContext(ctx netcontext.Context) (CallOverrideFunc, netcontext.Context, bool) {\n\tcofs, _ := ctx.Value(&callOverrideKey).([]CallOverrideFunc)\n\tif len(cofs) == 0 {\n\t\treturn nil, nil, false\n\t}\n\t// We found a list of overrides; grab the last, and reconstitute a\n\t// context that will hide it.\n\tf := cofs[len(cofs)-1]\n\tctx = netcontext.WithValue(ctx, &callOverrideKey, cofs[:len(cofs)-1])\n\treturn f, ctx, true\n}\n\ntype logOverrideFunc func(level int64, format string, args ...interface{})\n\nvar logOverrideKey = \"holds a logOverrideFunc\"\n\nfunc WithLogOverride(ctx netcontext.Context, f logOverrideFunc) netcontext.Context {\n\treturn netcontext.WithValue(ctx, &logOverrideKey, f)\n}\n\nvar appIDOverrideKey = \"holds a string, being the full app ID\"\n\nfunc WithAppIDOverride(ctx netcontext.Context, appID string) netcontext.Context {\n\treturn netcontext.WithValue(ctx, &appIDOverrideKey, appID)\n}\n\nvar namespaceKey = \"holds the namespace string\"\n\nfunc withNamespace(ctx netcontext.Context, ns string) netcontext.Context {\n\treturn netcontext.WithValue(ctx, &namespaceKey, ns)\n}\n\nfunc NamespaceFromContext(ctx netcontext.Context) string {\n\t// If there's no namespace, return the empty string.\n\tns, _ := ctx.Value(&namespaceKey).(string)\n\treturn ns\n}\n\n// FullyQualifiedAppID returns the fully-qualified application ID.\n// This may contain a partition prefix (e.g. \"s~\" for High Replication apps),\n// or a domain prefix (e.g. \"example.com:\").\nfunc FullyQualifiedAppID(ctx netcontext.Context) string {\n\tif id, ok := ctx.Value(&appIDOverrideKey).(string); ok {\n\t\treturn id\n\t}\n\treturn fullyQualifiedAppID(ctx)\n}\n\nfunc Logf(ctx netcontext.Context, level int64, format string, args ...interface{}) {\n\tif f, ok := ctx.Value(&logOverrideKey).(logOverrideFunc); ok {\n\t\tf(level, format, args...)\n\t\treturn\n\t}\n\tlogf(fromContext(ctx), level, format, args...)\n}\n\n// NamespacedContext wraps a Context to support namespaces.\nfunc NamespacedContext(ctx netcontext.Context, namespace string) netcontext.Context {\n\treturn withNamespace(ctx, namespace)\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/api_race_test.go",
    "content": "// Copyright 2014 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// +build race\n\npackage internal\n\nfunc init() { raceDetector = true }\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/api_test.go",
    "content": "// Copyright 2014 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// +build !appengine\n\npackage internal\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"net/url\"\n\t\"os\"\n\t\"os/exec\"\n\t\"strings\"\n\t\"sync/atomic\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/golang/protobuf/proto\"\n\tnetcontext \"golang.org/x/net/context\"\n\n\tbasepb \"google.golang.org/appengine/internal/base\"\n\tremotepb \"google.golang.org/appengine/internal/remote_api\"\n)\n\nconst testTicketHeader = \"X-Magic-Ticket-Header\"\n\nfunc init() {\n\tticketHeader = testTicketHeader\n}\n\ntype fakeAPIHandler struct {\n\thang chan int // used for RunSlowly RPC\n\n\tLogFlushes int32 // atomic\n}\n\nfunc (f *fakeAPIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\twriteResponse := func(res *remotepb.Response) {\n\t\thresBody, err := proto.Marshal(res)\n\t\tif err != nil {\n\t\t\thttp.Error(w, fmt.Sprintf(\"Failed encoding API response: %v\", err), 500)\n\t\t\treturn\n\t\t}\n\t\tw.Write(hresBody)\n\t}\n\n\tif r.URL.Path != \"/rpc_http\" {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\threqBody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Bad body: %v\", err), 500)\n\t\treturn\n\t}\n\tapiReq := &remotepb.Request{}\n\tif err := proto.Unmarshal(hreqBody, apiReq); err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Bad encoded API request: %v\", err), 500)\n\t\treturn\n\t}\n\tif *apiReq.RequestId != \"s3cr3t\" {\n\t\twriteResponse(&remotepb.Response{\n\t\t\tRpcError: &remotepb.RpcError{\n\t\t\t\tCode:   proto.Int32(int32(remotepb.RpcError_SECURITY_VIOLATION)),\n\t\t\t\tDetail: proto.String(\"bad security ticket\"),\n\t\t\t},\n\t\t})\n\t\treturn\n\t}\n\tif got, want := r.Header.Get(dapperHeader), \"trace-001\"; got != want {\n\t\twriteResponse(&remotepb.Response{\n\t\t\tRpcError: &remotepb.RpcError{\n\t\t\t\tCode:   proto.Int32(int32(remotepb.RpcError_BAD_REQUEST)),\n\t\t\t\tDetail: proto.String(fmt.Sprintf(\"trace info = %q, want %q\", got, want)),\n\t\t\t},\n\t\t})\n\t\treturn\n\t}\n\n\tservice, method := *apiReq.ServiceName, *apiReq.Method\n\tvar resOut proto.Message\n\tif service == \"actordb\" && method == \"LookupActor\" {\n\t\treq := &basepb.StringProto{}\n\t\tres := &basepb.StringProto{}\n\t\tif err := proto.Unmarshal(apiReq.Request, req); err != nil {\n\t\t\thttp.Error(w, fmt.Sprintf(\"Bad encoded request: %v\", err), 500)\n\t\t\treturn\n\t\t}\n\t\tif *req.Value == \"Doctor Who\" {\n\t\t\tres.Value = proto.String(\"David Tennant\")\n\t\t}\n\t\tresOut = res\n\t}\n\tif service == \"errors\" {\n\t\tswitch method {\n\t\tcase \"Non200\":\n\t\t\thttp.Error(w, \"I'm a little teapot.\", 418)\n\t\t\treturn\n\t\tcase \"ShortResponse\":\n\t\t\tw.Header().Set(\"Content-Length\", \"100\")\n\t\t\tw.Write([]byte(\"way too short\"))\n\t\t\treturn\n\t\tcase \"OverQuota\":\n\t\t\twriteResponse(&remotepb.Response{\n\t\t\t\tRpcError: &remotepb.RpcError{\n\t\t\t\t\tCode:   proto.Int32(int32(remotepb.RpcError_OVER_QUOTA)),\n\t\t\t\t\tDetail: proto.String(\"you are hogging the resources!\"),\n\t\t\t\t},\n\t\t\t})\n\t\t\treturn\n\t\tcase \"RunSlowly\":\n\t\t\t// TestAPICallRPCFailure creates f.hang, but does not strobe it\n\t\t\t// until Call returns with remotepb.RpcError_CANCELLED.\n\t\t\t// This is here to force a happens-before relationship between\n\t\t\t// the httptest server handler and shutdown.\n\t\t\t<-f.hang\n\t\t\tresOut = &basepb.VoidProto{}\n\t\t}\n\t}\n\tif service == \"logservice\" && method == \"Flush\" {\n\t\t// Pretend log flushing is slow.\n\t\ttime.Sleep(50 * time.Millisecond)\n\t\tatomic.AddInt32(&f.LogFlushes, 1)\n\t\tresOut = &basepb.VoidProto{}\n\t}\n\n\tencOut, err := proto.Marshal(resOut)\n\tif err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Failed encoding response: %v\", err), 500)\n\t\treturn\n\t}\n\twriteResponse(&remotepb.Response{\n\t\tResponse: encOut,\n\t})\n}\n\nfunc setup() (f *fakeAPIHandler, c *context, cleanup func()) {\n\tf = &fakeAPIHandler{}\n\tsrv := httptest.NewServer(f)\n\tu, err := url.Parse(srv.URL + apiPath)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"url.Parse(%q): %v\", srv.URL+apiPath, err))\n\t}\n\treturn f, &context{\n\t\treq: &http.Request{\n\t\t\tHeader: http.Header{\n\t\t\t\tticketHeader: []string{\"s3cr3t\"},\n\t\t\t\tdapperHeader: []string{\"trace-001\"},\n\t\t\t},\n\t\t},\n\t\tapiURL: u,\n\t}, srv.Close\n}\n\nfunc TestAPICall(t *testing.T) {\n\t_, c, cleanup := setup()\n\tdefer cleanup()\n\n\treq := &basepb.StringProto{\n\t\tValue: proto.String(\"Doctor Who\"),\n\t}\n\tres := &basepb.StringProto{}\n\terr := Call(toContext(c), \"actordb\", \"LookupActor\", req, res)\n\tif err != nil {\n\t\tt.Fatalf(\"API call failed: %v\", err)\n\t}\n\tif got, want := *res.Value, \"David Tennant\"; got != want {\n\t\tt.Errorf(\"Response is %q, want %q\", got, want)\n\t}\n}\n\nfunc TestAPICallRPCFailure(t *testing.T) {\n\tf, c, cleanup := setup()\n\tdefer cleanup()\n\n\ttestCases := []struct {\n\t\tmethod string\n\t\tcode   remotepb.RpcError_ErrorCode\n\t}{\n\t\t{\"Non200\", remotepb.RpcError_UNKNOWN},\n\t\t{\"ShortResponse\", remotepb.RpcError_UNKNOWN},\n\t\t{\"OverQuota\", remotepb.RpcError_OVER_QUOTA},\n\t\t{\"RunSlowly\", remotepb.RpcError_CANCELLED},\n\t}\n\tf.hang = make(chan int) // only for RunSlowly\n\tfor _, tc := range testCases {\n\t\tctx, _ := netcontext.WithTimeout(toContext(c), 100*time.Millisecond)\n\t\terr := Call(ctx, \"errors\", tc.method, &basepb.VoidProto{}, &basepb.VoidProto{})\n\t\tce, ok := err.(*CallError)\n\t\tif !ok {\n\t\t\tt.Errorf(\"%s: API call error is %T (%v), want *CallError\", tc.method, err, err)\n\t\t\tcontinue\n\t\t}\n\t\tif ce.Code != int32(tc.code) {\n\t\t\tt.Errorf(\"%s: ce.Code = %d, want %d\", tc.method, ce.Code, tc.code)\n\t\t}\n\t\tif tc.method == \"RunSlowly\" {\n\t\t\tf.hang <- 1 // release the HTTP handler\n\t\t}\n\t}\n}\n\nfunc TestAPICallDialFailure(t *testing.T) {\n\t// See what happens if the API host is unresponsive.\n\t// This should time out quickly, not hang forever.\n\t_, c, cleanup := setup()\n\tdefer cleanup()\n\t// Reset the URL to the production address so that dialing fails.\n\tc.apiURL = apiURL()\n\n\tstart := time.Now()\n\terr := Call(toContext(c), \"foo\", \"bar\", &basepb.VoidProto{}, &basepb.VoidProto{})\n\tconst max = 1 * time.Second\n\tif taken := time.Since(start); taken > max {\n\t\tt.Errorf(\"Dial hang took too long: %v > %v\", taken, max)\n\t}\n\tif err == nil {\n\t\tt.Error(\"Call did not fail\")\n\t}\n}\n\nfunc TestDelayedLogFlushing(t *testing.T) {\n\tf, c, cleanup := setup()\n\tdefer cleanup()\n\n\thttp.HandleFunc(\"/quick_log\", func(w http.ResponseWriter, r *http.Request) {\n\t\tlogC := WithContext(netcontext.Background(), r)\n\t\tfromContext(logC).apiURL = c.apiURL // Otherwise it will try to use the default URL.\n\t\tLogf(logC, 1, \"It's a lovely day.\")\n\t\tw.WriteHeader(200)\n\t\tw.Write(make([]byte, 100<<10)) // write 100 KB to force HTTP flush\n\t})\n\n\tr := &http.Request{\n\t\tMethod: \"GET\",\n\t\tURL: &url.URL{\n\t\t\tScheme: \"http\",\n\t\t\tPath:   \"/quick_log\",\n\t\t},\n\t\tHeader: c.req.Header,\n\t\tBody:   ioutil.NopCloser(bytes.NewReader(nil)),\n\t}\n\tw := httptest.NewRecorder()\n\n\t// Check that log flushing does not hold up the HTTP response.\n\tstart := time.Now()\n\thandleHTTP(w, r)\n\tif d := time.Since(start); d > 10*time.Millisecond {\n\t\tt.Errorf(\"handleHTTP took %v, want under 10ms\", d)\n\t}\n\tconst hdr = \"X-AppEngine-Log-Flush-Count\"\n\tif h := w.HeaderMap.Get(hdr); h != \"1\" {\n\t\tt.Errorf(\"%s header = %q, want %q\", hdr, h, \"1\")\n\t}\n\tif f := atomic.LoadInt32(&f.LogFlushes); f != 0 {\n\t\tt.Errorf(\"After HTTP response: f.LogFlushes = %d, want 0\", f)\n\t}\n\n\t// Check that the log flush eventually comes in.\n\ttime.Sleep(100 * time.Millisecond)\n\tif f := atomic.LoadInt32(&f.LogFlushes); f != 1 {\n\t\tt.Errorf(\"After 100ms: f.LogFlushes = %d, want 1\", f)\n\t}\n}\n\nfunc TestRemoteAddr(t *testing.T) {\n\tvar addr string\n\thttp.HandleFunc(\"/remote_addr\", func(w http.ResponseWriter, r *http.Request) {\n\t\taddr = r.RemoteAddr\n\t})\n\n\ttestCases := []struct {\n\t\theaders http.Header\n\t\taddr    string\n\t}{\n\t\t{http.Header{\"X-Appengine-User-Ip\": []string{\"10.5.2.1\"}}, \"10.5.2.1:80\"},\n\t\t{http.Header{\"X-Appengine-Remote-Addr\": []string{\"1.2.3.4\"}}, \"1.2.3.4:80\"},\n\t\t{http.Header{\"X-Appengine-Remote-Addr\": []string{\"1.2.3.4:8080\"}}, \"1.2.3.4:8080\"},\n\t\t{\n\t\t\thttp.Header{\"X-Appengine-Remote-Addr\": []string{\"2401:fa00:9:1:7646:a0ff:fe90:ca66\"}},\n\t\t\t\"[2401:fa00:9:1:7646:a0ff:fe90:ca66]:80\",\n\t\t},\n\t\t{\n\t\t\thttp.Header{\"X-Appengine-Remote-Addr\": []string{\"[::1]:http\"}},\n\t\t\t\"[::1]:http\",\n\t\t},\n\t\t{http.Header{}, \"127.0.0.1:80\"},\n\t}\n\n\tfor _, tc := range testCases {\n\t\tr := &http.Request{\n\t\t\tMethod: \"GET\",\n\t\t\tURL:    &url.URL{Scheme: \"http\", Path: \"/remote_addr\"},\n\t\t\tHeader: tc.headers,\n\t\t\tBody:   ioutil.NopCloser(bytes.NewReader(nil)),\n\t\t}\n\t\thandleHTTP(httptest.NewRecorder(), r)\n\t\tif addr != tc.addr {\n\t\t\tt.Errorf(\"Header %v, got %q, want %q\", tc.headers, addr, tc.addr)\n\t\t}\n\t}\n}\n\nfunc TestPanickingHandler(t *testing.T) {\n\thttp.HandleFunc(\"/panic\", func(http.ResponseWriter, *http.Request) {\n\t\tpanic(\"whoops!\")\n\t})\n\tr := &http.Request{\n\t\tMethod: \"GET\",\n\t\tURL:    &url.URL{Scheme: \"http\", Path: \"/panic\"},\n\t\tBody:   ioutil.NopCloser(bytes.NewReader(nil)),\n\t}\n\trec := httptest.NewRecorder()\n\thandleHTTP(rec, r)\n\tif rec.Code != 500 {\n\t\tt.Errorf(\"Panicking handler returned HTTP %d, want HTTP %d\", rec.Code, 500)\n\t}\n}\n\nvar raceDetector = false\n\nfunc TestAPICallAllocations(t *testing.T) {\n\tif raceDetector {\n\t\tt.Skip(\"not running under race detector\")\n\t}\n\n\t// Run the test API server in a subprocess so we aren't counting its allocations.\n\tu, cleanup := launchHelperProcess(t)\n\tdefer cleanup()\n\tc := &context{\n\t\treq: &http.Request{\n\t\t\tHeader: http.Header{\n\t\t\t\tticketHeader: []string{\"s3cr3t\"},\n\t\t\t\tdapperHeader: []string{\"trace-001\"},\n\t\t\t},\n\t\t},\n\t\tapiURL: u,\n\t}\n\n\treq := &basepb.StringProto{\n\t\tValue: proto.String(\"Doctor Who\"),\n\t}\n\tres := &basepb.StringProto{}\n\tvar apiErr error\n\tavg := testing.AllocsPerRun(100, func() {\n\t\tctx, _ := netcontext.WithTimeout(toContext(c), 100*time.Millisecond)\n\t\tif err := Call(ctx, \"actordb\", \"LookupActor\", req, res); err != nil && apiErr == nil {\n\t\t\tapiErr = err // get the first error only\n\t\t}\n\t})\n\tif apiErr != nil {\n\t\tt.Errorf(\"API call failed: %v\", apiErr)\n\t}\n\n\t// Lots of room for improvement...\n\t// TODO(djd): Reduce maximum to 85 once the App Engine SDK is based on 1.6.\n\tconst min, max float64 = 70, 90\n\tif avg < min || max < avg {\n\t\tt.Errorf(\"Allocations per API call = %g, want in [%g,%g]\", avg, min, max)\n\t}\n}\n\nfunc launchHelperProcess(t *testing.T) (apiURL *url.URL, cleanup func()) {\n\tcmd := exec.Command(os.Args[0], \"-test.run=TestHelperProcess\")\n\tcmd.Env = []string{\"GO_WANT_HELPER_PROCESS=1\"}\n\tstdin, err := cmd.StdinPipe()\n\tif err != nil {\n\t\tt.Fatalf(\"StdinPipe: %v\", err)\n\t}\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\tt.Fatalf(\"StdoutPipe: %v\", err)\n\t}\n\tif err := cmd.Start(); err != nil {\n\t\tt.Fatalf(\"Starting helper process: %v\", err)\n\t}\n\n\tscan := bufio.NewScanner(stdout)\n\tvar u *url.URL\n\tfor scan.Scan() {\n\t\tline := scan.Text()\n\t\tif hp := strings.TrimPrefix(line, helperProcessMagic); hp != line {\n\t\t\tvar err error\n\t\t\tu, err = url.Parse(hp)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"Failed to parse %q: %v\", hp, err)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\tif err := scan.Err(); err != nil {\n\t\tt.Fatalf(\"Scanning helper process stdout: %v\", err)\n\t}\n\tif u == nil {\n\t\tt.Fatal(\"Helper process never reported\")\n\t}\n\n\treturn u, func() {\n\t\tstdin.Close()\n\t\tif err := cmd.Wait(); err != nil {\n\t\t\tt.Errorf(\"Helper process did not exit cleanly: %v\", err)\n\t\t}\n\t}\n}\n\nconst helperProcessMagic = \"A lovely helper process is listening at \"\n\n// This isn't a real test. It's used as a helper process.\nfunc TestHelperProcess(*testing.T) {\n\tif os.Getenv(\"GO_WANT_HELPER_PROCESS\") != \"1\" {\n\t\treturn\n\t}\n\tdefer os.Exit(0)\n\n\tf := &fakeAPIHandler{}\n\tsrv := httptest.NewServer(f)\n\tdefer srv.Close()\n\tfmt.Println(helperProcessMagic + srv.URL + apiPath)\n\n\t// Wait for stdin to be closed.\n\tio.Copy(ioutil.Discard, os.Stdin)\n}\n\nfunc TestBackgroundContext(t *testing.T) {\n\tenviron := []struct {\n\t\tkey, value string\n\t}{\n\t\t{\"GAE_LONG_APP_ID\", \"my-app-id\"},\n\t\t{\"GAE_MINOR_VERSION\", \"067924799508853122\"},\n\t\t{\"GAE_MODULE_INSTANCE\", \"0\"},\n\t\t{\"GAE_MODULE_NAME\", \"default\"},\n\t\t{\"GAE_MODULE_VERSION\", \"20150612t184001\"},\n\t}\n\tfor _, v := range environ {\n\t\told := os.Getenv(v.key)\n\t\tos.Setenv(v.key, v.value)\n\t\tv.value = old\n\t}\n\tdefer func() { // Restore old environment after the test completes.\n\t\tfor _, v := range environ {\n\t\t\tif v.value == \"\" {\n\t\t\t\tos.Unsetenv(v.key)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tos.Setenv(v.key, v.value)\n\t\t}\n\t}()\n\n\tctx, key := fromContext(BackgroundContext()), \"X-Magic-Ticket-Header\"\n\tif g, w := ctx.req.Header.Get(key), \"my-app-id/default.20150612t184001.0\"; g != w {\n\t\tt.Errorf(\"%v = %q, want %q\", key, g, w)\n\t}\n\n\t// Check that using the background context doesn't panic.\n\treq := &basepb.StringProto{\n\t\tValue: proto.String(\"Doctor Who\"),\n\t}\n\tres := &basepb.StringProto{}\n\tCall(BackgroundContext(), \"actordb\", \"LookupActor\", req, res) // expected to fail\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/app_id.go",
    "content": "// Copyright 2011 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\npackage internal\n\nimport (\n\t\"strings\"\n)\n\nfunc parseFullAppID(appid string) (partition, domain, displayID string) {\n\tif i := strings.Index(appid, \"~\"); i != -1 {\n\t\tpartition, appid = appid[:i], appid[i+1:]\n\t}\n\tif i := strings.Index(appid, \":\"); i != -1 {\n\t\tdomain, appid = appid[:i], appid[i+1:]\n\t}\n\treturn partition, domain, appid\n}\n\n// appID returns \"appid\" or \"domain.com:appid\".\nfunc appID(fullAppID string) string {\n\t_, dom, dis := parseFullAppID(fullAppID)\n\tif dom != \"\" {\n\t\treturn dom + \":\" + dis\n\t}\n\treturn dis\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/app_id_test.go",
    "content": "// Copyright 2011 Google Inc. All Rights Reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\npackage internal\n\nimport (\n\t\"testing\"\n)\n\nfunc TestAppIDParsing(t *testing.T) {\n\ttestCases := []struct {\n\t\tin                           string\n\t\tpartition, domain, displayID string\n\t}{\n\t\t{\"simple-app-id\", \"\", \"\", \"simple-app-id\"},\n\t\t{\"domain.com:domain-app-id\", \"\", \"domain.com\", \"domain-app-id\"},\n\t\t{\"part~partition-app-id\", \"part\", \"\", \"partition-app-id\"},\n\t\t{\"part~domain.com:display\", \"part\", \"domain.com\", \"display\"},\n\t}\n\n\tfor _, tc := range testCases {\n\t\tpart, dom, dis := parseFullAppID(tc.in)\n\t\tif part != tc.partition {\n\t\t\tt.Errorf(\"partition of %q: got %q, want %q\", tc.in, part, tc.partition)\n\t\t}\n\t\tif dom != tc.domain {\n\t\t\tt.Errorf(\"domain of %q: got %q, want %q\", tc.in, dom, tc.domain)\n\t\t}\n\t\tif dis != tc.displayID {\n\t\t\tt.Errorf(\"displayID of %q: got %q, want %q\", tc.in, dis, tc.displayID)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/base/api_base.pb.go",
    "content": "// Code generated by protoc-gen-go.\n// source: google.golang.org/appengine/internal/base/api_base.proto\n// DO NOT EDIT!\n\n/*\nPackage base is a generated protocol buffer package.\n\nIt is generated from these files:\n\tgoogle.golang.org/appengine/internal/base/api_base.proto\n\nIt has these top-level messages:\n\tStringProto\n\tInteger32Proto\n\tInteger64Proto\n\tBoolProto\n\tDoubleProto\n\tBytesProto\n\tVoidProto\n*/\npackage base\n\nimport proto \"github.com/golang/protobuf/proto\"\nimport fmt \"fmt\"\nimport math \"math\"\n\n// Reference imports to suppress errors if they are not otherwise used.\nvar _ = proto.Marshal\nvar _ = fmt.Errorf\nvar _ = math.Inf\n\ntype StringProto struct {\n\tValue            *string `protobuf:\"bytes,1,req,name=value\" json:\"value,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *StringProto) Reset()         { *m = StringProto{} }\nfunc (m *StringProto) String() string { return proto.CompactTextString(m) }\nfunc (*StringProto) ProtoMessage()    {}\n\nfunc (m *StringProto) GetValue() string {\n\tif m != nil && m.Value != nil {\n\t\treturn *m.Value\n\t}\n\treturn \"\"\n}\n\ntype Integer32Proto struct {\n\tValue            *int32 `protobuf:\"varint,1,req,name=value\" json:\"value,omitempty\"`\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *Integer32Proto) Reset()         { *m = Integer32Proto{} }\nfunc (m *Integer32Proto) String() string { return proto.CompactTextString(m) }\nfunc (*Integer32Proto) ProtoMessage()    {}\n\nfunc (m *Integer32Proto) GetValue() int32 {\n\tif m != nil && m.Value != nil {\n\t\treturn *m.Value\n\t}\n\treturn 0\n}\n\ntype Integer64Proto struct {\n\tValue            *int64 `protobuf:\"varint,1,req,name=value\" json:\"value,omitempty\"`\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *Integer64Proto) Reset()         { *m = Integer64Proto{} }\nfunc (m *Integer64Proto) String() string { return proto.CompactTextString(m) }\nfunc (*Integer64Proto) ProtoMessage()    {}\n\nfunc (m *Integer64Proto) GetValue() int64 {\n\tif m != nil && m.Value != nil {\n\t\treturn *m.Value\n\t}\n\treturn 0\n}\n\ntype BoolProto struct {\n\tValue            *bool  `protobuf:\"varint,1,req,name=value\" json:\"value,omitempty\"`\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *BoolProto) Reset()         { *m = BoolProto{} }\nfunc (m *BoolProto) String() string { return proto.CompactTextString(m) }\nfunc (*BoolProto) ProtoMessage()    {}\n\nfunc (m *BoolProto) GetValue() bool {\n\tif m != nil && m.Value != nil {\n\t\treturn *m.Value\n\t}\n\treturn false\n}\n\ntype DoubleProto struct {\n\tValue            *float64 `protobuf:\"fixed64,1,req,name=value\" json:\"value,omitempty\"`\n\tXXX_unrecognized []byte   `json:\"-\"`\n}\n\nfunc (m *DoubleProto) Reset()         { *m = DoubleProto{} }\nfunc (m *DoubleProto) String() string { return proto.CompactTextString(m) }\nfunc (*DoubleProto) ProtoMessage()    {}\n\nfunc (m *DoubleProto) GetValue() float64 {\n\tif m != nil && m.Value != nil {\n\t\treturn *m.Value\n\t}\n\treturn 0\n}\n\ntype BytesProto struct {\n\tValue            []byte `protobuf:\"bytes,1,req,name=value\" json:\"value,omitempty\"`\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *BytesProto) Reset()         { *m = BytesProto{} }\nfunc (m *BytesProto) String() string { return proto.CompactTextString(m) }\nfunc (*BytesProto) ProtoMessage()    {}\n\nfunc (m *BytesProto) GetValue() []byte {\n\tif m != nil {\n\t\treturn m.Value\n\t}\n\treturn nil\n}\n\ntype VoidProto struct {\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *VoidProto) Reset()         { *m = VoidProto{} }\nfunc (m *VoidProto) String() string { return proto.CompactTextString(m) }\nfunc (*VoidProto) ProtoMessage()    {}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/base/api_base.proto",
    "content": "// Built-in base types for API calls. Primarily useful as return types.\n\nsyntax = \"proto2\";\noption go_package = \"base\";\n\npackage appengine.base;\n\nmessage StringProto {\n  required string value = 1;\n}\n\nmessage Integer32Proto {\n  required int32 value = 1;\n}\n\nmessage Integer64Proto {\n  required int64 value = 1;\n}\n\nmessage BoolProto {\n  required bool value = 1;\n}\n\nmessage DoubleProto {\n  required double value = 1;\n}\n\nmessage BytesProto {\n  required bytes value = 1 [ctype=CORD];\n}\n\nmessage VoidProto {\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go",
    "content": "// Code generated by protoc-gen-go.\n// source: google.golang.org/appengine/internal/datastore/datastore_v3.proto\n// DO NOT EDIT!\n\n/*\nPackage datastore is a generated protocol buffer package.\n\nIt is generated from these files:\n\tgoogle.golang.org/appengine/internal/datastore/datastore_v3.proto\n\nIt has these top-level messages:\n\tAction\n\tPropertyValue\n\tProperty\n\tPath\n\tReference\n\tUser\n\tEntityProto\n\tCompositeProperty\n\tIndex\n\tCompositeIndex\n\tIndexPostfix\n\tIndexPosition\n\tSnapshot\n\tInternalHeader\n\tTransaction\n\tQuery\n\tCompiledQuery\n\tCompiledCursor\n\tCursor\n\tError\n\tCost\n\tGetRequest\n\tGetResponse\n\tPutRequest\n\tPutResponse\n\tTouchRequest\n\tTouchResponse\n\tDeleteRequest\n\tDeleteResponse\n\tNextRequest\n\tQueryResult\n\tAllocateIdsRequest\n\tAllocateIdsResponse\n\tCompositeIndices\n\tAddActionsRequest\n\tAddActionsResponse\n\tBeginTransactionRequest\n\tCommitResponse\n*/\npackage datastore\n\nimport proto \"github.com/golang/protobuf/proto\"\nimport fmt \"fmt\"\nimport math \"math\"\n\n// Reference imports to suppress errors if they are not otherwise used.\nvar _ = proto.Marshal\nvar _ = fmt.Errorf\nvar _ = math.Inf\n\ntype Property_Meaning int32\n\nconst (\n\tProperty_NO_MEANING       Property_Meaning = 0\n\tProperty_BLOB             Property_Meaning = 14\n\tProperty_TEXT             Property_Meaning = 15\n\tProperty_BYTESTRING       Property_Meaning = 16\n\tProperty_ATOM_CATEGORY    Property_Meaning = 1\n\tProperty_ATOM_LINK        Property_Meaning = 2\n\tProperty_ATOM_TITLE       Property_Meaning = 3\n\tProperty_ATOM_CONTENT     Property_Meaning = 4\n\tProperty_ATOM_SUMMARY     Property_Meaning = 5\n\tProperty_ATOM_AUTHOR      Property_Meaning = 6\n\tProperty_GD_WHEN          Property_Meaning = 7\n\tProperty_GD_EMAIL         Property_Meaning = 8\n\tProperty_GEORSS_POINT     Property_Meaning = 9\n\tProperty_GD_IM            Property_Meaning = 10\n\tProperty_GD_PHONENUMBER   Property_Meaning = 11\n\tProperty_GD_POSTALADDRESS Property_Meaning = 12\n\tProperty_GD_RATING        Property_Meaning = 13\n\tProperty_BLOBKEY          Property_Meaning = 17\n\tProperty_ENTITY_PROTO     Property_Meaning = 19\n\tProperty_INDEX_VALUE      Property_Meaning = 18\n)\n\nvar Property_Meaning_name = map[int32]string{\n\t0:  \"NO_MEANING\",\n\t14: \"BLOB\",\n\t15: \"TEXT\",\n\t16: \"BYTESTRING\",\n\t1:  \"ATOM_CATEGORY\",\n\t2:  \"ATOM_LINK\",\n\t3:  \"ATOM_TITLE\",\n\t4:  \"ATOM_CONTENT\",\n\t5:  \"ATOM_SUMMARY\",\n\t6:  \"ATOM_AUTHOR\",\n\t7:  \"GD_WHEN\",\n\t8:  \"GD_EMAIL\",\n\t9:  \"GEORSS_POINT\",\n\t10: \"GD_IM\",\n\t11: \"GD_PHONENUMBER\",\n\t12: \"GD_POSTALADDRESS\",\n\t13: \"GD_RATING\",\n\t17: \"BLOBKEY\",\n\t19: \"ENTITY_PROTO\",\n\t18: \"INDEX_VALUE\",\n}\nvar Property_Meaning_value = map[string]int32{\n\t\"NO_MEANING\":       0,\n\t\"BLOB\":             14,\n\t\"TEXT\":             15,\n\t\"BYTESTRING\":       16,\n\t\"ATOM_CATEGORY\":    1,\n\t\"ATOM_LINK\":        2,\n\t\"ATOM_TITLE\":       3,\n\t\"ATOM_CONTENT\":     4,\n\t\"ATOM_SUMMARY\":     5,\n\t\"ATOM_AUTHOR\":      6,\n\t\"GD_WHEN\":          7,\n\t\"GD_EMAIL\":         8,\n\t\"GEORSS_POINT\":     9,\n\t\"GD_IM\":            10,\n\t\"GD_PHONENUMBER\":   11,\n\t\"GD_POSTALADDRESS\": 12,\n\t\"GD_RATING\":        13,\n\t\"BLOBKEY\":          17,\n\t\"ENTITY_PROTO\":     19,\n\t\"INDEX_VALUE\":      18,\n}\n\nfunc (x Property_Meaning) Enum() *Property_Meaning {\n\tp := new(Property_Meaning)\n\t*p = x\n\treturn p\n}\nfunc (x Property_Meaning) String() string {\n\treturn proto.EnumName(Property_Meaning_name, int32(x))\n}\nfunc (x *Property_Meaning) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(Property_Meaning_value, data, \"Property_Meaning\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = Property_Meaning(value)\n\treturn nil\n}\n\ntype Property_FtsTokenizationOption int32\n\nconst (\n\tProperty_HTML Property_FtsTokenizationOption = 1\n\tProperty_ATOM Property_FtsTokenizationOption = 2\n)\n\nvar Property_FtsTokenizationOption_name = map[int32]string{\n\t1: \"HTML\",\n\t2: \"ATOM\",\n}\nvar Property_FtsTokenizationOption_value = map[string]int32{\n\t\"HTML\": 1,\n\t\"ATOM\": 2,\n}\n\nfunc (x Property_FtsTokenizationOption) Enum() *Property_FtsTokenizationOption {\n\tp := new(Property_FtsTokenizationOption)\n\t*p = x\n\treturn p\n}\nfunc (x Property_FtsTokenizationOption) String() string {\n\treturn proto.EnumName(Property_FtsTokenizationOption_name, int32(x))\n}\nfunc (x *Property_FtsTokenizationOption) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(Property_FtsTokenizationOption_value, data, \"Property_FtsTokenizationOption\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = Property_FtsTokenizationOption(value)\n\treturn nil\n}\n\ntype EntityProto_Kind int32\n\nconst (\n\tEntityProto_GD_CONTACT EntityProto_Kind = 1\n\tEntityProto_GD_EVENT   EntityProto_Kind = 2\n\tEntityProto_GD_MESSAGE EntityProto_Kind = 3\n)\n\nvar EntityProto_Kind_name = map[int32]string{\n\t1: \"GD_CONTACT\",\n\t2: \"GD_EVENT\",\n\t3: \"GD_MESSAGE\",\n}\nvar EntityProto_Kind_value = map[string]int32{\n\t\"GD_CONTACT\": 1,\n\t\"GD_EVENT\":   2,\n\t\"GD_MESSAGE\": 3,\n}\n\nfunc (x EntityProto_Kind) Enum() *EntityProto_Kind {\n\tp := new(EntityProto_Kind)\n\t*p = x\n\treturn p\n}\nfunc (x EntityProto_Kind) String() string {\n\treturn proto.EnumName(EntityProto_Kind_name, int32(x))\n}\nfunc (x *EntityProto_Kind) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(EntityProto_Kind_value, data, \"EntityProto_Kind\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = EntityProto_Kind(value)\n\treturn nil\n}\n\ntype Index_Property_Direction int32\n\nconst (\n\tIndex_Property_ASCENDING  Index_Property_Direction = 1\n\tIndex_Property_DESCENDING Index_Property_Direction = 2\n)\n\nvar Index_Property_Direction_name = map[int32]string{\n\t1: \"ASCENDING\",\n\t2: \"DESCENDING\",\n}\nvar Index_Property_Direction_value = map[string]int32{\n\t\"ASCENDING\":  1,\n\t\"DESCENDING\": 2,\n}\n\nfunc (x Index_Property_Direction) Enum() *Index_Property_Direction {\n\tp := new(Index_Property_Direction)\n\t*p = x\n\treturn p\n}\nfunc (x Index_Property_Direction) String() string {\n\treturn proto.EnumName(Index_Property_Direction_name, int32(x))\n}\nfunc (x *Index_Property_Direction) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(Index_Property_Direction_value, data, \"Index_Property_Direction\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = Index_Property_Direction(value)\n\treturn nil\n}\n\ntype CompositeIndex_State int32\n\nconst (\n\tCompositeIndex_WRITE_ONLY CompositeIndex_State = 1\n\tCompositeIndex_READ_WRITE CompositeIndex_State = 2\n\tCompositeIndex_DELETED    CompositeIndex_State = 3\n\tCompositeIndex_ERROR      CompositeIndex_State = 4\n)\n\nvar CompositeIndex_State_name = map[int32]string{\n\t1: \"WRITE_ONLY\",\n\t2: \"READ_WRITE\",\n\t3: \"DELETED\",\n\t4: \"ERROR\",\n}\nvar CompositeIndex_State_value = map[string]int32{\n\t\"WRITE_ONLY\": 1,\n\t\"READ_WRITE\": 2,\n\t\"DELETED\":    3,\n\t\"ERROR\":      4,\n}\n\nfunc (x CompositeIndex_State) Enum() *CompositeIndex_State {\n\tp := new(CompositeIndex_State)\n\t*p = x\n\treturn p\n}\nfunc (x CompositeIndex_State) String() string {\n\treturn proto.EnumName(CompositeIndex_State_name, int32(x))\n}\nfunc (x *CompositeIndex_State) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(CompositeIndex_State_value, data, \"CompositeIndex_State\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = CompositeIndex_State(value)\n\treturn nil\n}\n\ntype Snapshot_Status int32\n\nconst (\n\tSnapshot_INACTIVE Snapshot_Status = 0\n\tSnapshot_ACTIVE   Snapshot_Status = 1\n)\n\nvar Snapshot_Status_name = map[int32]string{\n\t0: \"INACTIVE\",\n\t1: \"ACTIVE\",\n}\nvar Snapshot_Status_value = map[string]int32{\n\t\"INACTIVE\": 0,\n\t\"ACTIVE\":   1,\n}\n\nfunc (x Snapshot_Status) Enum() *Snapshot_Status {\n\tp := new(Snapshot_Status)\n\t*p = x\n\treturn p\n}\nfunc (x Snapshot_Status) String() string {\n\treturn proto.EnumName(Snapshot_Status_name, int32(x))\n}\nfunc (x *Snapshot_Status) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(Snapshot_Status_value, data, \"Snapshot_Status\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = Snapshot_Status(value)\n\treturn nil\n}\n\ntype Query_Hint int32\n\nconst (\n\tQuery_ORDER_FIRST    Query_Hint = 1\n\tQuery_ANCESTOR_FIRST Query_Hint = 2\n\tQuery_FILTER_FIRST   Query_Hint = 3\n)\n\nvar Query_Hint_name = map[int32]string{\n\t1: \"ORDER_FIRST\",\n\t2: \"ANCESTOR_FIRST\",\n\t3: \"FILTER_FIRST\",\n}\nvar Query_Hint_value = map[string]int32{\n\t\"ORDER_FIRST\":    1,\n\t\"ANCESTOR_FIRST\": 2,\n\t\"FILTER_FIRST\":   3,\n}\n\nfunc (x Query_Hint) Enum() *Query_Hint {\n\tp := new(Query_Hint)\n\t*p = x\n\treturn p\n}\nfunc (x Query_Hint) String() string {\n\treturn proto.EnumName(Query_Hint_name, int32(x))\n}\nfunc (x *Query_Hint) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(Query_Hint_value, data, \"Query_Hint\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = Query_Hint(value)\n\treturn nil\n}\n\ntype Query_Filter_Operator int32\n\nconst (\n\tQuery_Filter_LESS_THAN             Query_Filter_Operator = 1\n\tQuery_Filter_LESS_THAN_OR_EQUAL    Query_Filter_Operator = 2\n\tQuery_Filter_GREATER_THAN          Query_Filter_Operator = 3\n\tQuery_Filter_GREATER_THAN_OR_EQUAL Query_Filter_Operator = 4\n\tQuery_Filter_EQUAL                 Query_Filter_Operator = 5\n\tQuery_Filter_IN                    Query_Filter_Operator = 6\n\tQuery_Filter_EXISTS                Query_Filter_Operator = 7\n)\n\nvar Query_Filter_Operator_name = map[int32]string{\n\t1: \"LESS_THAN\",\n\t2: \"LESS_THAN_OR_EQUAL\",\n\t3: \"GREATER_THAN\",\n\t4: \"GREATER_THAN_OR_EQUAL\",\n\t5: \"EQUAL\",\n\t6: \"IN\",\n\t7: \"EXISTS\",\n}\nvar Query_Filter_Operator_value = map[string]int32{\n\t\"LESS_THAN\":             1,\n\t\"LESS_THAN_OR_EQUAL\":    2,\n\t\"GREATER_THAN\":          3,\n\t\"GREATER_THAN_OR_EQUAL\": 4,\n\t\"EQUAL\":                 5,\n\t\"IN\":                    6,\n\t\"EXISTS\":                7,\n}\n\nfunc (x Query_Filter_Operator) Enum() *Query_Filter_Operator {\n\tp := new(Query_Filter_Operator)\n\t*p = x\n\treturn p\n}\nfunc (x Query_Filter_Operator) String() string {\n\treturn proto.EnumName(Query_Filter_Operator_name, int32(x))\n}\nfunc (x *Query_Filter_Operator) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(Query_Filter_Operator_value, data, \"Query_Filter_Operator\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = Query_Filter_Operator(value)\n\treturn nil\n}\n\ntype Query_Order_Direction int32\n\nconst (\n\tQuery_Order_ASCENDING  Query_Order_Direction = 1\n\tQuery_Order_DESCENDING Query_Order_Direction = 2\n)\n\nvar Query_Order_Direction_name = map[int32]string{\n\t1: \"ASCENDING\",\n\t2: \"DESCENDING\",\n}\nvar Query_Order_Direction_value = map[string]int32{\n\t\"ASCENDING\":  1,\n\t\"DESCENDING\": 2,\n}\n\nfunc (x Query_Order_Direction) Enum() *Query_Order_Direction {\n\tp := new(Query_Order_Direction)\n\t*p = x\n\treturn p\n}\nfunc (x Query_Order_Direction) String() string {\n\treturn proto.EnumName(Query_Order_Direction_name, int32(x))\n}\nfunc (x *Query_Order_Direction) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(Query_Order_Direction_value, data, \"Query_Order_Direction\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = Query_Order_Direction(value)\n\treturn nil\n}\n\ntype Error_ErrorCode int32\n\nconst (\n\tError_BAD_REQUEST                  Error_ErrorCode = 1\n\tError_CONCURRENT_TRANSACTION       Error_ErrorCode = 2\n\tError_INTERNAL_ERROR               Error_ErrorCode = 3\n\tError_NEED_INDEX                   Error_ErrorCode = 4\n\tError_TIMEOUT                      Error_ErrorCode = 5\n\tError_PERMISSION_DENIED            Error_ErrorCode = 6\n\tError_BIGTABLE_ERROR               Error_ErrorCode = 7\n\tError_COMMITTED_BUT_STILL_APPLYING Error_ErrorCode = 8\n\tError_CAPABILITY_DISABLED          Error_ErrorCode = 9\n\tError_TRY_ALTERNATE_BACKEND        Error_ErrorCode = 10\n\tError_SAFE_TIME_TOO_OLD            Error_ErrorCode = 11\n)\n\nvar Error_ErrorCode_name = map[int32]string{\n\t1:  \"BAD_REQUEST\",\n\t2:  \"CONCURRENT_TRANSACTION\",\n\t3:  \"INTERNAL_ERROR\",\n\t4:  \"NEED_INDEX\",\n\t5:  \"TIMEOUT\",\n\t6:  \"PERMISSION_DENIED\",\n\t7:  \"BIGTABLE_ERROR\",\n\t8:  \"COMMITTED_BUT_STILL_APPLYING\",\n\t9:  \"CAPABILITY_DISABLED\",\n\t10: \"TRY_ALTERNATE_BACKEND\",\n\t11: \"SAFE_TIME_TOO_OLD\",\n}\nvar Error_ErrorCode_value = map[string]int32{\n\t\"BAD_REQUEST\":                  1,\n\t\"CONCURRENT_TRANSACTION\":       2,\n\t\"INTERNAL_ERROR\":               3,\n\t\"NEED_INDEX\":                   4,\n\t\"TIMEOUT\":                      5,\n\t\"PERMISSION_DENIED\":            6,\n\t\"BIGTABLE_ERROR\":               7,\n\t\"COMMITTED_BUT_STILL_APPLYING\": 8,\n\t\"CAPABILITY_DISABLED\":          9,\n\t\"TRY_ALTERNATE_BACKEND\":        10,\n\t\"SAFE_TIME_TOO_OLD\":            11,\n}\n\nfunc (x Error_ErrorCode) Enum() *Error_ErrorCode {\n\tp := new(Error_ErrorCode)\n\t*p = x\n\treturn p\n}\nfunc (x Error_ErrorCode) String() string {\n\treturn proto.EnumName(Error_ErrorCode_name, int32(x))\n}\nfunc (x *Error_ErrorCode) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(Error_ErrorCode_value, data, \"Error_ErrorCode\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = Error_ErrorCode(value)\n\treturn nil\n}\n\ntype PutRequest_AutoIdPolicy int32\n\nconst (\n\tPutRequest_CURRENT    PutRequest_AutoIdPolicy = 0\n\tPutRequest_SEQUENTIAL PutRequest_AutoIdPolicy = 1\n)\n\nvar PutRequest_AutoIdPolicy_name = map[int32]string{\n\t0: \"CURRENT\",\n\t1: \"SEQUENTIAL\",\n}\nvar PutRequest_AutoIdPolicy_value = map[string]int32{\n\t\"CURRENT\":    0,\n\t\"SEQUENTIAL\": 1,\n}\n\nfunc (x PutRequest_AutoIdPolicy) Enum() *PutRequest_AutoIdPolicy {\n\tp := new(PutRequest_AutoIdPolicy)\n\t*p = x\n\treturn p\n}\nfunc (x PutRequest_AutoIdPolicy) String() string {\n\treturn proto.EnumName(PutRequest_AutoIdPolicy_name, int32(x))\n}\nfunc (x *PutRequest_AutoIdPolicy) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(PutRequest_AutoIdPolicy_value, data, \"PutRequest_AutoIdPolicy\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = PutRequest_AutoIdPolicy(value)\n\treturn nil\n}\n\ntype Action struct {\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *Action) Reset()         { *m = Action{} }\nfunc (m *Action) String() string { return proto.CompactTextString(m) }\nfunc (*Action) ProtoMessage()    {}\n\ntype PropertyValue struct {\n\tInt64Value       *int64                        `protobuf:\"varint,1,opt,name=int64Value\" json:\"int64Value,omitempty\"`\n\tBooleanValue     *bool                         `protobuf:\"varint,2,opt,name=booleanValue\" json:\"booleanValue,omitempty\"`\n\tStringValue      *string                       `protobuf:\"bytes,3,opt,name=stringValue\" json:\"stringValue,omitempty\"`\n\tDoubleValue      *float64                      `protobuf:\"fixed64,4,opt,name=doubleValue\" json:\"doubleValue,omitempty\"`\n\tPointvalue       *PropertyValue_PointValue     `protobuf:\"group,5,opt,name=PointValue\" json:\"pointvalue,omitempty\"`\n\tUservalue        *PropertyValue_UserValue      `protobuf:\"group,8,opt,name=UserValue\" json:\"uservalue,omitempty\"`\n\tReferencevalue   *PropertyValue_ReferenceValue `protobuf:\"group,12,opt,name=ReferenceValue\" json:\"referencevalue,omitempty\"`\n\tXXX_unrecognized []byte                        `json:\"-\"`\n}\n\nfunc (m *PropertyValue) Reset()         { *m = PropertyValue{} }\nfunc (m *PropertyValue) String() string { return proto.CompactTextString(m) }\nfunc (*PropertyValue) ProtoMessage()    {}\n\nfunc (m *PropertyValue) GetInt64Value() int64 {\n\tif m != nil && m.Int64Value != nil {\n\t\treturn *m.Int64Value\n\t}\n\treturn 0\n}\n\nfunc (m *PropertyValue) GetBooleanValue() bool {\n\tif m != nil && m.BooleanValue != nil {\n\t\treturn *m.BooleanValue\n\t}\n\treturn false\n}\n\nfunc (m *PropertyValue) GetStringValue() string {\n\tif m != nil && m.StringValue != nil {\n\t\treturn *m.StringValue\n\t}\n\treturn \"\"\n}\n\nfunc (m *PropertyValue) GetDoubleValue() float64 {\n\tif m != nil && m.DoubleValue != nil {\n\t\treturn *m.DoubleValue\n\t}\n\treturn 0\n}\n\nfunc (m *PropertyValue) GetPointvalue() *PropertyValue_PointValue {\n\tif m != nil {\n\t\treturn m.Pointvalue\n\t}\n\treturn nil\n}\n\nfunc (m *PropertyValue) GetUservalue() *PropertyValue_UserValue {\n\tif m != nil {\n\t\treturn m.Uservalue\n\t}\n\treturn nil\n}\n\nfunc (m *PropertyValue) GetReferencevalue() *PropertyValue_ReferenceValue {\n\tif m != nil {\n\t\treturn m.Referencevalue\n\t}\n\treturn nil\n}\n\ntype PropertyValue_PointValue struct {\n\tX                *float64 `protobuf:\"fixed64,6,req,name=x\" json:\"x,omitempty\"`\n\tY                *float64 `protobuf:\"fixed64,7,req,name=y\" json:\"y,omitempty\"`\n\tXXX_unrecognized []byte   `json:\"-\"`\n}\n\nfunc (m *PropertyValue_PointValue) Reset()         { *m = PropertyValue_PointValue{} }\nfunc (m *PropertyValue_PointValue) String() string { return proto.CompactTextString(m) }\nfunc (*PropertyValue_PointValue) ProtoMessage()    {}\n\nfunc (m *PropertyValue_PointValue) GetX() float64 {\n\tif m != nil && m.X != nil {\n\t\treturn *m.X\n\t}\n\treturn 0\n}\n\nfunc (m *PropertyValue_PointValue) GetY() float64 {\n\tif m != nil && m.Y != nil {\n\t\treturn *m.Y\n\t}\n\treturn 0\n}\n\ntype PropertyValue_UserValue struct {\n\tEmail             *string `protobuf:\"bytes,9,req,name=email\" json:\"email,omitempty\"`\n\tAuthDomain        *string `protobuf:\"bytes,10,req,name=auth_domain\" json:\"auth_domain,omitempty\"`\n\tNickname          *string `protobuf:\"bytes,11,opt,name=nickname\" json:\"nickname,omitempty\"`\n\tFederatedIdentity *string `protobuf:\"bytes,21,opt,name=federated_identity\" json:\"federated_identity,omitempty\"`\n\tFederatedProvider *string `protobuf:\"bytes,22,opt,name=federated_provider\" json:\"federated_provider,omitempty\"`\n\tXXX_unrecognized  []byte  `json:\"-\"`\n}\n\nfunc (m *PropertyValue_UserValue) Reset()         { *m = PropertyValue_UserValue{} }\nfunc (m *PropertyValue_UserValue) String() string { return proto.CompactTextString(m) }\nfunc (*PropertyValue_UserValue) ProtoMessage()    {}\n\nfunc (m *PropertyValue_UserValue) GetEmail() string {\n\tif m != nil && m.Email != nil {\n\t\treturn *m.Email\n\t}\n\treturn \"\"\n}\n\nfunc (m *PropertyValue_UserValue) GetAuthDomain() string {\n\tif m != nil && m.AuthDomain != nil {\n\t\treturn *m.AuthDomain\n\t}\n\treturn \"\"\n}\n\nfunc (m *PropertyValue_UserValue) GetNickname() string {\n\tif m != nil && m.Nickname != nil {\n\t\treturn *m.Nickname\n\t}\n\treturn \"\"\n}\n\nfunc (m *PropertyValue_UserValue) GetFederatedIdentity() string {\n\tif m != nil && m.FederatedIdentity != nil {\n\t\treturn *m.FederatedIdentity\n\t}\n\treturn \"\"\n}\n\nfunc (m *PropertyValue_UserValue) GetFederatedProvider() string {\n\tif m != nil && m.FederatedProvider != nil {\n\t\treturn *m.FederatedProvider\n\t}\n\treturn \"\"\n}\n\ntype PropertyValue_ReferenceValue struct {\n\tApp              *string                                     `protobuf:\"bytes,13,req,name=app\" json:\"app,omitempty\"`\n\tNameSpace        *string                                     `protobuf:\"bytes,20,opt,name=name_space\" json:\"name_space,omitempty\"`\n\tPathelement      []*PropertyValue_ReferenceValue_PathElement `protobuf:\"group,14,rep,name=PathElement\" json:\"pathelement,omitempty\"`\n\tXXX_unrecognized []byte                                      `json:\"-\"`\n}\n\nfunc (m *PropertyValue_ReferenceValue) Reset()         { *m = PropertyValue_ReferenceValue{} }\nfunc (m *PropertyValue_ReferenceValue) String() string { return proto.CompactTextString(m) }\nfunc (*PropertyValue_ReferenceValue) ProtoMessage()    {}\n\nfunc (m *PropertyValue_ReferenceValue) GetApp() string {\n\tif m != nil && m.App != nil {\n\t\treturn *m.App\n\t}\n\treturn \"\"\n}\n\nfunc (m *PropertyValue_ReferenceValue) GetNameSpace() string {\n\tif m != nil && m.NameSpace != nil {\n\t\treturn *m.NameSpace\n\t}\n\treturn \"\"\n}\n\nfunc (m *PropertyValue_ReferenceValue) GetPathelement() []*PropertyValue_ReferenceValue_PathElement {\n\tif m != nil {\n\t\treturn m.Pathelement\n\t}\n\treturn nil\n}\n\ntype PropertyValue_ReferenceValue_PathElement struct {\n\tType             *string `protobuf:\"bytes,15,req,name=type\" json:\"type,omitempty\"`\n\tId               *int64  `protobuf:\"varint,16,opt,name=id\" json:\"id,omitempty\"`\n\tName             *string `protobuf:\"bytes,17,opt,name=name\" json:\"name,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *PropertyValue_ReferenceValue_PathElement) Reset() {\n\t*m = PropertyValue_ReferenceValue_PathElement{}\n}\nfunc (m *PropertyValue_ReferenceValue_PathElement) String() string { return proto.CompactTextString(m) }\nfunc (*PropertyValue_ReferenceValue_PathElement) ProtoMessage()    {}\n\nfunc (m *PropertyValue_ReferenceValue_PathElement) GetType() string {\n\tif m != nil && m.Type != nil {\n\t\treturn *m.Type\n\t}\n\treturn \"\"\n}\n\nfunc (m *PropertyValue_ReferenceValue_PathElement) GetId() int64 {\n\tif m != nil && m.Id != nil {\n\t\treturn *m.Id\n\t}\n\treturn 0\n}\n\nfunc (m *PropertyValue_ReferenceValue_PathElement) GetName() string {\n\tif m != nil && m.Name != nil {\n\t\treturn *m.Name\n\t}\n\treturn \"\"\n}\n\ntype Property struct {\n\tMeaning               *Property_Meaning               `protobuf:\"varint,1,opt,name=meaning,enum=appengine.Property_Meaning,def=0\" json:\"meaning,omitempty\"`\n\tMeaningUri            *string                         `protobuf:\"bytes,2,opt,name=meaning_uri\" json:\"meaning_uri,omitempty\"`\n\tName                  *string                         `protobuf:\"bytes,3,req,name=name\" json:\"name,omitempty\"`\n\tValue                 *PropertyValue                  `protobuf:\"bytes,5,req,name=value\" json:\"value,omitempty\"`\n\tMultiple              *bool                           `protobuf:\"varint,4,req,name=multiple\" json:\"multiple,omitempty\"`\n\tSearchable            *bool                           `protobuf:\"varint,6,opt,name=searchable,def=0\" json:\"searchable,omitempty\"`\n\tFtsTokenizationOption *Property_FtsTokenizationOption `protobuf:\"varint,8,opt,name=fts_tokenization_option,enum=appengine.Property_FtsTokenizationOption\" json:\"fts_tokenization_option,omitempty\"`\n\tLocale                *string                         `protobuf:\"bytes,9,opt,name=locale,def=en\" json:\"locale,omitempty\"`\n\tXXX_unrecognized      []byte                          `json:\"-\"`\n}\n\nfunc (m *Property) Reset()         { *m = Property{} }\nfunc (m *Property) String() string { return proto.CompactTextString(m) }\nfunc (*Property) ProtoMessage()    {}\n\nconst Default_Property_Meaning Property_Meaning = Property_NO_MEANING\nconst Default_Property_Searchable bool = false\nconst Default_Property_Locale string = \"en\"\n\nfunc (m *Property) GetMeaning() Property_Meaning {\n\tif m != nil && m.Meaning != nil {\n\t\treturn *m.Meaning\n\t}\n\treturn Default_Property_Meaning\n}\n\nfunc (m *Property) GetMeaningUri() string {\n\tif m != nil && m.MeaningUri != nil {\n\t\treturn *m.MeaningUri\n\t}\n\treturn \"\"\n}\n\nfunc (m *Property) GetName() string {\n\tif m != nil && m.Name != nil {\n\t\treturn *m.Name\n\t}\n\treturn \"\"\n}\n\nfunc (m *Property) GetValue() *PropertyValue {\n\tif m != nil {\n\t\treturn m.Value\n\t}\n\treturn nil\n}\n\nfunc (m *Property) GetMultiple() bool {\n\tif m != nil && m.Multiple != nil {\n\t\treturn *m.Multiple\n\t}\n\treturn false\n}\n\nfunc (m *Property) GetSearchable() bool {\n\tif m != nil && m.Searchable != nil {\n\t\treturn *m.Searchable\n\t}\n\treturn Default_Property_Searchable\n}\n\nfunc (m *Property) GetFtsTokenizationOption() Property_FtsTokenizationOption {\n\tif m != nil && m.FtsTokenizationOption != nil {\n\t\treturn *m.FtsTokenizationOption\n\t}\n\treturn Property_HTML\n}\n\nfunc (m *Property) GetLocale() string {\n\tif m != nil && m.Locale != nil {\n\t\treturn *m.Locale\n\t}\n\treturn Default_Property_Locale\n}\n\ntype Path struct {\n\tElement          []*Path_Element `protobuf:\"group,1,rep,name=Element\" json:\"element,omitempty\"`\n\tXXX_unrecognized []byte          `json:\"-\"`\n}\n\nfunc (m *Path) Reset()         { *m = Path{} }\nfunc (m *Path) String() string { return proto.CompactTextString(m) }\nfunc (*Path) ProtoMessage()    {}\n\nfunc (m *Path) GetElement() []*Path_Element {\n\tif m != nil {\n\t\treturn m.Element\n\t}\n\treturn nil\n}\n\ntype Path_Element struct {\n\tType             *string `protobuf:\"bytes,2,req,name=type\" json:\"type,omitempty\"`\n\tId               *int64  `protobuf:\"varint,3,opt,name=id\" json:\"id,omitempty\"`\n\tName             *string `protobuf:\"bytes,4,opt,name=name\" json:\"name,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *Path_Element) Reset()         { *m = Path_Element{} }\nfunc (m *Path_Element) String() string { return proto.CompactTextString(m) }\nfunc (*Path_Element) ProtoMessage()    {}\n\nfunc (m *Path_Element) GetType() string {\n\tif m != nil && m.Type != nil {\n\t\treturn *m.Type\n\t}\n\treturn \"\"\n}\n\nfunc (m *Path_Element) GetId() int64 {\n\tif m != nil && m.Id != nil {\n\t\treturn *m.Id\n\t}\n\treturn 0\n}\n\nfunc (m *Path_Element) GetName() string {\n\tif m != nil && m.Name != nil {\n\t\treturn *m.Name\n\t}\n\treturn \"\"\n}\n\ntype Reference struct {\n\tApp              *string `protobuf:\"bytes,13,req,name=app\" json:\"app,omitempty\"`\n\tNameSpace        *string `protobuf:\"bytes,20,opt,name=name_space\" json:\"name_space,omitempty\"`\n\tPath             *Path   `protobuf:\"bytes,14,req,name=path\" json:\"path,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *Reference) Reset()         { *m = Reference{} }\nfunc (m *Reference) String() string { return proto.CompactTextString(m) }\nfunc (*Reference) ProtoMessage()    {}\n\nfunc (m *Reference) GetApp() string {\n\tif m != nil && m.App != nil {\n\t\treturn *m.App\n\t}\n\treturn \"\"\n}\n\nfunc (m *Reference) GetNameSpace() string {\n\tif m != nil && m.NameSpace != nil {\n\t\treturn *m.NameSpace\n\t}\n\treturn \"\"\n}\n\nfunc (m *Reference) GetPath() *Path {\n\tif m != nil {\n\t\treturn m.Path\n\t}\n\treturn nil\n}\n\ntype User struct {\n\tEmail             *string `protobuf:\"bytes,1,req,name=email\" json:\"email,omitempty\"`\n\tAuthDomain        *string `protobuf:\"bytes,2,req,name=auth_domain\" json:\"auth_domain,omitempty\"`\n\tNickname          *string `protobuf:\"bytes,3,opt,name=nickname\" json:\"nickname,omitempty\"`\n\tFederatedIdentity *string `protobuf:\"bytes,6,opt,name=federated_identity\" json:\"federated_identity,omitempty\"`\n\tFederatedProvider *string `protobuf:\"bytes,7,opt,name=federated_provider\" json:\"federated_provider,omitempty\"`\n\tXXX_unrecognized  []byte  `json:\"-\"`\n}\n\nfunc (m *User) Reset()         { *m = User{} }\nfunc (m *User) String() string { return proto.CompactTextString(m) }\nfunc (*User) ProtoMessage()    {}\n\nfunc (m *User) GetEmail() string {\n\tif m != nil && m.Email != nil {\n\t\treturn *m.Email\n\t}\n\treturn \"\"\n}\n\nfunc (m *User) GetAuthDomain() string {\n\tif m != nil && m.AuthDomain != nil {\n\t\treturn *m.AuthDomain\n\t}\n\treturn \"\"\n}\n\nfunc (m *User) GetNickname() string {\n\tif m != nil && m.Nickname != nil {\n\t\treturn *m.Nickname\n\t}\n\treturn \"\"\n}\n\nfunc (m *User) GetFederatedIdentity() string {\n\tif m != nil && m.FederatedIdentity != nil {\n\t\treturn *m.FederatedIdentity\n\t}\n\treturn \"\"\n}\n\nfunc (m *User) GetFederatedProvider() string {\n\tif m != nil && m.FederatedProvider != nil {\n\t\treturn *m.FederatedProvider\n\t}\n\treturn \"\"\n}\n\ntype EntityProto struct {\n\tKey              *Reference        `protobuf:\"bytes,13,req,name=key\" json:\"key,omitempty\"`\n\tEntityGroup      *Path             `protobuf:\"bytes,16,req,name=entity_group\" json:\"entity_group,omitempty\"`\n\tOwner            *User             `protobuf:\"bytes,17,opt,name=owner\" json:\"owner,omitempty\"`\n\tKind             *EntityProto_Kind `protobuf:\"varint,4,opt,name=kind,enum=appengine.EntityProto_Kind\" json:\"kind,omitempty\"`\n\tKindUri          *string           `protobuf:\"bytes,5,opt,name=kind_uri\" json:\"kind_uri,omitempty\"`\n\tProperty         []*Property       `protobuf:\"bytes,14,rep,name=property\" json:\"property,omitempty\"`\n\tRawProperty      []*Property       `protobuf:\"bytes,15,rep,name=raw_property\" json:\"raw_property,omitempty\"`\n\tRank             *int32            `protobuf:\"varint,18,opt,name=rank\" json:\"rank,omitempty\"`\n\tXXX_unrecognized []byte            `json:\"-\"`\n}\n\nfunc (m *EntityProto) Reset()         { *m = EntityProto{} }\nfunc (m *EntityProto) String() string { return proto.CompactTextString(m) }\nfunc (*EntityProto) ProtoMessage()    {}\n\nfunc (m *EntityProto) GetKey() *Reference {\n\tif m != nil {\n\t\treturn m.Key\n\t}\n\treturn nil\n}\n\nfunc (m *EntityProto) GetEntityGroup() *Path {\n\tif m != nil {\n\t\treturn m.EntityGroup\n\t}\n\treturn nil\n}\n\nfunc (m *EntityProto) GetOwner() *User {\n\tif m != nil {\n\t\treturn m.Owner\n\t}\n\treturn nil\n}\n\nfunc (m *EntityProto) GetKind() EntityProto_Kind {\n\tif m != nil && m.Kind != nil {\n\t\treturn *m.Kind\n\t}\n\treturn EntityProto_GD_CONTACT\n}\n\nfunc (m *EntityProto) GetKindUri() string {\n\tif m != nil && m.KindUri != nil {\n\t\treturn *m.KindUri\n\t}\n\treturn \"\"\n}\n\nfunc (m *EntityProto) GetProperty() []*Property {\n\tif m != nil {\n\t\treturn m.Property\n\t}\n\treturn nil\n}\n\nfunc (m *EntityProto) GetRawProperty() []*Property {\n\tif m != nil {\n\t\treturn m.RawProperty\n\t}\n\treturn nil\n}\n\nfunc (m *EntityProto) GetRank() int32 {\n\tif m != nil && m.Rank != nil {\n\t\treturn *m.Rank\n\t}\n\treturn 0\n}\n\ntype CompositeProperty struct {\n\tIndexId          *int64   `protobuf:\"varint,1,req,name=index_id\" json:\"index_id,omitempty\"`\n\tValue            []string `protobuf:\"bytes,2,rep,name=value\" json:\"value,omitempty\"`\n\tXXX_unrecognized []byte   `json:\"-\"`\n}\n\nfunc (m *CompositeProperty) Reset()         { *m = CompositeProperty{} }\nfunc (m *CompositeProperty) String() string { return proto.CompactTextString(m) }\nfunc (*CompositeProperty) ProtoMessage()    {}\n\nfunc (m *CompositeProperty) GetIndexId() int64 {\n\tif m != nil && m.IndexId != nil {\n\t\treturn *m.IndexId\n\t}\n\treturn 0\n}\n\nfunc (m *CompositeProperty) GetValue() []string {\n\tif m != nil {\n\t\treturn m.Value\n\t}\n\treturn nil\n}\n\ntype Index struct {\n\tEntityType       *string           `protobuf:\"bytes,1,req,name=entity_type\" json:\"entity_type,omitempty\"`\n\tAncestor         *bool             `protobuf:\"varint,5,req,name=ancestor\" json:\"ancestor,omitempty\"`\n\tProperty         []*Index_Property `protobuf:\"group,2,rep,name=Property\" json:\"property,omitempty\"`\n\tXXX_unrecognized []byte            `json:\"-\"`\n}\n\nfunc (m *Index) Reset()         { *m = Index{} }\nfunc (m *Index) String() string { return proto.CompactTextString(m) }\nfunc (*Index) ProtoMessage()    {}\n\nfunc (m *Index) GetEntityType() string {\n\tif m != nil && m.EntityType != nil {\n\t\treturn *m.EntityType\n\t}\n\treturn \"\"\n}\n\nfunc (m *Index) GetAncestor() bool {\n\tif m != nil && m.Ancestor != nil {\n\t\treturn *m.Ancestor\n\t}\n\treturn false\n}\n\nfunc (m *Index) GetProperty() []*Index_Property {\n\tif m != nil {\n\t\treturn m.Property\n\t}\n\treturn nil\n}\n\ntype Index_Property struct {\n\tName             *string                   `protobuf:\"bytes,3,req,name=name\" json:\"name,omitempty\"`\n\tDirection        *Index_Property_Direction `protobuf:\"varint,4,opt,name=direction,enum=appengine.Index_Property_Direction,def=1\" json:\"direction,omitempty\"`\n\tXXX_unrecognized []byte                    `json:\"-\"`\n}\n\nfunc (m *Index_Property) Reset()         { *m = Index_Property{} }\nfunc (m *Index_Property) String() string { return proto.CompactTextString(m) }\nfunc (*Index_Property) ProtoMessage()    {}\n\nconst Default_Index_Property_Direction Index_Property_Direction = Index_Property_ASCENDING\n\nfunc (m *Index_Property) GetName() string {\n\tif m != nil && m.Name != nil {\n\t\treturn *m.Name\n\t}\n\treturn \"\"\n}\n\nfunc (m *Index_Property) GetDirection() Index_Property_Direction {\n\tif m != nil && m.Direction != nil {\n\t\treturn *m.Direction\n\t}\n\treturn Default_Index_Property_Direction\n}\n\ntype CompositeIndex struct {\n\tAppId             *string               `protobuf:\"bytes,1,req,name=app_id\" json:\"app_id,omitempty\"`\n\tId                *int64                `protobuf:\"varint,2,req,name=id\" json:\"id,omitempty\"`\n\tDefinition        *Index                `protobuf:\"bytes,3,req,name=definition\" json:\"definition,omitempty\"`\n\tState             *CompositeIndex_State `protobuf:\"varint,4,req,name=state,enum=appengine.CompositeIndex_State\" json:\"state,omitempty\"`\n\tOnlyUseIfRequired *bool                 `protobuf:\"varint,6,opt,name=only_use_if_required,def=0\" json:\"only_use_if_required,omitempty\"`\n\tXXX_unrecognized  []byte                `json:\"-\"`\n}\n\nfunc (m *CompositeIndex) Reset()         { *m = CompositeIndex{} }\nfunc (m *CompositeIndex) String() string { return proto.CompactTextString(m) }\nfunc (*CompositeIndex) ProtoMessage()    {}\n\nconst Default_CompositeIndex_OnlyUseIfRequired bool = false\n\nfunc (m *CompositeIndex) GetAppId() string {\n\tif m != nil && m.AppId != nil {\n\t\treturn *m.AppId\n\t}\n\treturn \"\"\n}\n\nfunc (m *CompositeIndex) GetId() int64 {\n\tif m != nil && m.Id != nil {\n\t\treturn *m.Id\n\t}\n\treturn 0\n}\n\nfunc (m *CompositeIndex) GetDefinition() *Index {\n\tif m != nil {\n\t\treturn m.Definition\n\t}\n\treturn nil\n}\n\nfunc (m *CompositeIndex) GetState() CompositeIndex_State {\n\tif m != nil && m.State != nil {\n\t\treturn *m.State\n\t}\n\treturn CompositeIndex_WRITE_ONLY\n}\n\nfunc (m *CompositeIndex) GetOnlyUseIfRequired() bool {\n\tif m != nil && m.OnlyUseIfRequired != nil {\n\t\treturn *m.OnlyUseIfRequired\n\t}\n\treturn Default_CompositeIndex_OnlyUseIfRequired\n}\n\ntype IndexPostfix struct {\n\tIndexValue       []*IndexPostfix_IndexValue `protobuf:\"bytes,1,rep,name=index_value\" json:\"index_value,omitempty\"`\n\tKey              *Reference                 `protobuf:\"bytes,2,opt,name=key\" json:\"key,omitempty\"`\n\tBefore           *bool                      `protobuf:\"varint,3,opt,name=before,def=1\" json:\"before,omitempty\"`\n\tXXX_unrecognized []byte                     `json:\"-\"`\n}\n\nfunc (m *IndexPostfix) Reset()         { *m = IndexPostfix{} }\nfunc (m *IndexPostfix) String() string { return proto.CompactTextString(m) }\nfunc (*IndexPostfix) ProtoMessage()    {}\n\nconst Default_IndexPostfix_Before bool = true\n\nfunc (m *IndexPostfix) GetIndexValue() []*IndexPostfix_IndexValue {\n\tif m != nil {\n\t\treturn m.IndexValue\n\t}\n\treturn nil\n}\n\nfunc (m *IndexPostfix) GetKey() *Reference {\n\tif m != nil {\n\t\treturn m.Key\n\t}\n\treturn nil\n}\n\nfunc (m *IndexPostfix) GetBefore() bool {\n\tif m != nil && m.Before != nil {\n\t\treturn *m.Before\n\t}\n\treturn Default_IndexPostfix_Before\n}\n\ntype IndexPostfix_IndexValue struct {\n\tPropertyName     *string        `protobuf:\"bytes,1,req,name=property_name\" json:\"property_name,omitempty\"`\n\tValue            *PropertyValue `protobuf:\"bytes,2,req,name=value\" json:\"value,omitempty\"`\n\tXXX_unrecognized []byte         `json:\"-\"`\n}\n\nfunc (m *IndexPostfix_IndexValue) Reset()         { *m = IndexPostfix_IndexValue{} }\nfunc (m *IndexPostfix_IndexValue) String() string { return proto.CompactTextString(m) }\nfunc (*IndexPostfix_IndexValue) ProtoMessage()    {}\n\nfunc (m *IndexPostfix_IndexValue) GetPropertyName() string {\n\tif m != nil && m.PropertyName != nil {\n\t\treturn *m.PropertyName\n\t}\n\treturn \"\"\n}\n\nfunc (m *IndexPostfix_IndexValue) GetValue() *PropertyValue {\n\tif m != nil {\n\t\treturn m.Value\n\t}\n\treturn nil\n}\n\ntype IndexPosition struct {\n\tKey              *string `protobuf:\"bytes,1,opt,name=key\" json:\"key,omitempty\"`\n\tBefore           *bool   `protobuf:\"varint,2,opt,name=before,def=1\" json:\"before,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *IndexPosition) Reset()         { *m = IndexPosition{} }\nfunc (m *IndexPosition) String() string { return proto.CompactTextString(m) }\nfunc (*IndexPosition) ProtoMessage()    {}\n\nconst Default_IndexPosition_Before bool = true\n\nfunc (m *IndexPosition) GetKey() string {\n\tif m != nil && m.Key != nil {\n\t\treturn *m.Key\n\t}\n\treturn \"\"\n}\n\nfunc (m *IndexPosition) GetBefore() bool {\n\tif m != nil && m.Before != nil {\n\t\treturn *m.Before\n\t}\n\treturn Default_IndexPosition_Before\n}\n\ntype Snapshot struct {\n\tTs               *int64 `protobuf:\"varint,1,req,name=ts\" json:\"ts,omitempty\"`\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *Snapshot) Reset()         { *m = Snapshot{} }\nfunc (m *Snapshot) String() string { return proto.CompactTextString(m) }\nfunc (*Snapshot) ProtoMessage()    {}\n\nfunc (m *Snapshot) GetTs() int64 {\n\tif m != nil && m.Ts != nil {\n\t\treturn *m.Ts\n\t}\n\treturn 0\n}\n\ntype InternalHeader struct {\n\tQos              *string `protobuf:\"bytes,1,opt,name=qos\" json:\"qos,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *InternalHeader) Reset()         { *m = InternalHeader{} }\nfunc (m *InternalHeader) String() string { return proto.CompactTextString(m) }\nfunc (*InternalHeader) ProtoMessage()    {}\n\nfunc (m *InternalHeader) GetQos() string {\n\tif m != nil && m.Qos != nil {\n\t\treturn *m.Qos\n\t}\n\treturn \"\"\n}\n\ntype Transaction struct {\n\tHeader           *InternalHeader `protobuf:\"bytes,4,opt,name=header\" json:\"header,omitempty\"`\n\tHandle           *uint64         `protobuf:\"fixed64,1,req,name=handle\" json:\"handle,omitempty\"`\n\tApp              *string         `protobuf:\"bytes,2,req,name=app\" json:\"app,omitempty\"`\n\tMarkChanges      *bool           `protobuf:\"varint,3,opt,name=mark_changes,def=0\" json:\"mark_changes,omitempty\"`\n\tXXX_unrecognized []byte          `json:\"-\"`\n}\n\nfunc (m *Transaction) Reset()         { *m = Transaction{} }\nfunc (m *Transaction) String() string { return proto.CompactTextString(m) }\nfunc (*Transaction) ProtoMessage()    {}\n\nconst Default_Transaction_MarkChanges bool = false\n\nfunc (m *Transaction) GetHeader() *InternalHeader {\n\tif m != nil {\n\t\treturn m.Header\n\t}\n\treturn nil\n}\n\nfunc (m *Transaction) GetHandle() uint64 {\n\tif m != nil && m.Handle != nil {\n\t\treturn *m.Handle\n\t}\n\treturn 0\n}\n\nfunc (m *Transaction) GetApp() string {\n\tif m != nil && m.App != nil {\n\t\treturn *m.App\n\t}\n\treturn \"\"\n}\n\nfunc (m *Transaction) GetMarkChanges() bool {\n\tif m != nil && m.MarkChanges != nil {\n\t\treturn *m.MarkChanges\n\t}\n\treturn Default_Transaction_MarkChanges\n}\n\ntype Query struct {\n\tHeader              *InternalHeader   `protobuf:\"bytes,39,opt,name=header\" json:\"header,omitempty\"`\n\tApp                 *string           `protobuf:\"bytes,1,req,name=app\" json:\"app,omitempty\"`\n\tNameSpace           *string           `protobuf:\"bytes,29,opt,name=name_space\" json:\"name_space,omitempty\"`\n\tKind                *string           `protobuf:\"bytes,3,opt,name=kind\" json:\"kind,omitempty\"`\n\tAncestor            *Reference        `protobuf:\"bytes,17,opt,name=ancestor\" json:\"ancestor,omitempty\"`\n\tFilter              []*Query_Filter   `protobuf:\"group,4,rep,name=Filter\" json:\"filter,omitempty\"`\n\tSearchQuery         *string           `protobuf:\"bytes,8,opt,name=search_query\" json:\"search_query,omitempty\"`\n\tOrder               []*Query_Order    `protobuf:\"group,9,rep,name=Order\" json:\"order,omitempty\"`\n\tHint                *Query_Hint       `protobuf:\"varint,18,opt,name=hint,enum=appengine.Query_Hint\" json:\"hint,omitempty\"`\n\tCount               *int32            `protobuf:\"varint,23,opt,name=count\" json:\"count,omitempty\"`\n\tOffset              *int32            `protobuf:\"varint,12,opt,name=offset,def=0\" json:\"offset,omitempty\"`\n\tLimit               *int32            `protobuf:\"varint,16,opt,name=limit\" json:\"limit,omitempty\"`\n\tCompiledCursor      *CompiledCursor   `protobuf:\"bytes,30,opt,name=compiled_cursor\" json:\"compiled_cursor,omitempty\"`\n\tEndCompiledCursor   *CompiledCursor   `protobuf:\"bytes,31,opt,name=end_compiled_cursor\" json:\"end_compiled_cursor,omitempty\"`\n\tCompositeIndex      []*CompositeIndex `protobuf:\"bytes,19,rep,name=composite_index\" json:\"composite_index,omitempty\"`\n\tRequirePerfectPlan  *bool             `protobuf:\"varint,20,opt,name=require_perfect_plan,def=0\" json:\"require_perfect_plan,omitempty\"`\n\tKeysOnly            *bool             `protobuf:\"varint,21,opt,name=keys_only,def=0\" json:\"keys_only,omitempty\"`\n\tTransaction         *Transaction      `protobuf:\"bytes,22,opt,name=transaction\" json:\"transaction,omitempty\"`\n\tCompile             *bool             `protobuf:\"varint,25,opt,name=compile,def=0\" json:\"compile,omitempty\"`\n\tFailoverMs          *int64            `protobuf:\"varint,26,opt,name=failover_ms\" json:\"failover_ms,omitempty\"`\n\tStrong              *bool             `protobuf:\"varint,32,opt,name=strong\" json:\"strong,omitempty\"`\n\tPropertyName        []string          `protobuf:\"bytes,33,rep,name=property_name\" json:\"property_name,omitempty\"`\n\tGroupByPropertyName []string          `protobuf:\"bytes,34,rep,name=group_by_property_name\" json:\"group_by_property_name,omitempty\"`\n\tDistinct            *bool             `protobuf:\"varint,24,opt,name=distinct\" json:\"distinct,omitempty\"`\n\tMinSafeTimeSeconds  *int64            `protobuf:\"varint,35,opt,name=min_safe_time_seconds\" json:\"min_safe_time_seconds,omitempty\"`\n\tSafeReplicaName     []string          `protobuf:\"bytes,36,rep,name=safe_replica_name\" json:\"safe_replica_name,omitempty\"`\n\tPersistOffset       *bool             `protobuf:\"varint,37,opt,name=persist_offset,def=0\" json:\"persist_offset,omitempty\"`\n\tXXX_unrecognized    []byte            `json:\"-\"`\n}\n\nfunc (m *Query) Reset()         { *m = Query{} }\nfunc (m *Query) String() string { return proto.CompactTextString(m) }\nfunc (*Query) ProtoMessage()    {}\n\nconst Default_Query_Offset int32 = 0\nconst Default_Query_RequirePerfectPlan bool = false\nconst Default_Query_KeysOnly bool = false\nconst Default_Query_Compile bool = false\nconst Default_Query_PersistOffset bool = false\n\nfunc (m *Query) GetHeader() *InternalHeader {\n\tif m != nil {\n\t\treturn m.Header\n\t}\n\treturn nil\n}\n\nfunc (m *Query) GetApp() string {\n\tif m != nil && m.App != nil {\n\t\treturn *m.App\n\t}\n\treturn \"\"\n}\n\nfunc (m *Query) GetNameSpace() string {\n\tif m != nil && m.NameSpace != nil {\n\t\treturn *m.NameSpace\n\t}\n\treturn \"\"\n}\n\nfunc (m *Query) GetKind() string {\n\tif m != nil && m.Kind != nil {\n\t\treturn *m.Kind\n\t}\n\treturn \"\"\n}\n\nfunc (m *Query) GetAncestor() *Reference {\n\tif m != nil {\n\t\treturn m.Ancestor\n\t}\n\treturn nil\n}\n\nfunc (m *Query) GetFilter() []*Query_Filter {\n\tif m != nil {\n\t\treturn m.Filter\n\t}\n\treturn nil\n}\n\nfunc (m *Query) GetSearchQuery() string {\n\tif m != nil && m.SearchQuery != nil {\n\t\treturn *m.SearchQuery\n\t}\n\treturn \"\"\n}\n\nfunc (m *Query) GetOrder() []*Query_Order {\n\tif m != nil {\n\t\treturn m.Order\n\t}\n\treturn nil\n}\n\nfunc (m *Query) GetHint() Query_Hint {\n\tif m != nil && m.Hint != nil {\n\t\treturn *m.Hint\n\t}\n\treturn Query_ORDER_FIRST\n}\n\nfunc (m *Query) GetCount() int32 {\n\tif m != nil && m.Count != nil {\n\t\treturn *m.Count\n\t}\n\treturn 0\n}\n\nfunc (m *Query) GetOffset() int32 {\n\tif m != nil && m.Offset != nil {\n\t\treturn *m.Offset\n\t}\n\treturn Default_Query_Offset\n}\n\nfunc (m *Query) GetLimit() int32 {\n\tif m != nil && m.Limit != nil {\n\t\treturn *m.Limit\n\t}\n\treturn 0\n}\n\nfunc (m *Query) GetCompiledCursor() *CompiledCursor {\n\tif m != nil {\n\t\treturn m.CompiledCursor\n\t}\n\treturn nil\n}\n\nfunc (m *Query) GetEndCompiledCursor() *CompiledCursor {\n\tif m != nil {\n\t\treturn m.EndCompiledCursor\n\t}\n\treturn nil\n}\n\nfunc (m *Query) GetCompositeIndex() []*CompositeIndex {\n\tif m != nil {\n\t\treturn m.CompositeIndex\n\t}\n\treturn nil\n}\n\nfunc (m *Query) GetRequirePerfectPlan() bool {\n\tif m != nil && m.RequirePerfectPlan != nil {\n\t\treturn *m.RequirePerfectPlan\n\t}\n\treturn Default_Query_RequirePerfectPlan\n}\n\nfunc (m *Query) GetKeysOnly() bool {\n\tif m != nil && m.KeysOnly != nil {\n\t\treturn *m.KeysOnly\n\t}\n\treturn Default_Query_KeysOnly\n}\n\nfunc (m *Query) GetTransaction() *Transaction {\n\tif m != nil {\n\t\treturn m.Transaction\n\t}\n\treturn nil\n}\n\nfunc (m *Query) GetCompile() bool {\n\tif m != nil && m.Compile != nil {\n\t\treturn *m.Compile\n\t}\n\treturn Default_Query_Compile\n}\n\nfunc (m *Query) GetFailoverMs() int64 {\n\tif m != nil && m.FailoverMs != nil {\n\t\treturn *m.FailoverMs\n\t}\n\treturn 0\n}\n\nfunc (m *Query) GetStrong() bool {\n\tif m != nil && m.Strong != nil {\n\t\treturn *m.Strong\n\t}\n\treturn false\n}\n\nfunc (m *Query) GetPropertyName() []string {\n\tif m != nil {\n\t\treturn m.PropertyName\n\t}\n\treturn nil\n}\n\nfunc (m *Query) GetGroupByPropertyName() []string {\n\tif m != nil {\n\t\treturn m.GroupByPropertyName\n\t}\n\treturn nil\n}\n\nfunc (m *Query) GetDistinct() bool {\n\tif m != nil && m.Distinct != nil {\n\t\treturn *m.Distinct\n\t}\n\treturn false\n}\n\nfunc (m *Query) GetMinSafeTimeSeconds() int64 {\n\tif m != nil && m.MinSafeTimeSeconds != nil {\n\t\treturn *m.MinSafeTimeSeconds\n\t}\n\treturn 0\n}\n\nfunc (m *Query) GetSafeReplicaName() []string {\n\tif m != nil {\n\t\treturn m.SafeReplicaName\n\t}\n\treturn nil\n}\n\nfunc (m *Query) GetPersistOffset() bool {\n\tif m != nil && m.PersistOffset != nil {\n\t\treturn *m.PersistOffset\n\t}\n\treturn Default_Query_PersistOffset\n}\n\ntype Query_Filter struct {\n\tOp               *Query_Filter_Operator `protobuf:\"varint,6,req,name=op,enum=appengine.Query_Filter_Operator\" json:\"op,omitempty\"`\n\tProperty         []*Property            `protobuf:\"bytes,14,rep,name=property\" json:\"property,omitempty\"`\n\tXXX_unrecognized []byte                 `json:\"-\"`\n}\n\nfunc (m *Query_Filter) Reset()         { *m = Query_Filter{} }\nfunc (m *Query_Filter) String() string { return proto.CompactTextString(m) }\nfunc (*Query_Filter) ProtoMessage()    {}\n\nfunc (m *Query_Filter) GetOp() Query_Filter_Operator {\n\tif m != nil && m.Op != nil {\n\t\treturn *m.Op\n\t}\n\treturn Query_Filter_LESS_THAN\n}\n\nfunc (m *Query_Filter) GetProperty() []*Property {\n\tif m != nil {\n\t\treturn m.Property\n\t}\n\treturn nil\n}\n\ntype Query_Order struct {\n\tProperty         *string                `protobuf:\"bytes,10,req,name=property\" json:\"property,omitempty\"`\n\tDirection        *Query_Order_Direction `protobuf:\"varint,11,opt,name=direction,enum=appengine.Query_Order_Direction,def=1\" json:\"direction,omitempty\"`\n\tXXX_unrecognized []byte                 `json:\"-\"`\n}\n\nfunc (m *Query_Order) Reset()         { *m = Query_Order{} }\nfunc (m *Query_Order) String() string { return proto.CompactTextString(m) }\nfunc (*Query_Order) ProtoMessage()    {}\n\nconst Default_Query_Order_Direction Query_Order_Direction = Query_Order_ASCENDING\n\nfunc (m *Query_Order) GetProperty() string {\n\tif m != nil && m.Property != nil {\n\t\treturn *m.Property\n\t}\n\treturn \"\"\n}\n\nfunc (m *Query_Order) GetDirection() Query_Order_Direction {\n\tif m != nil && m.Direction != nil {\n\t\treturn *m.Direction\n\t}\n\treturn Default_Query_Order_Direction\n}\n\ntype CompiledQuery struct {\n\tPrimaryscan       *CompiledQuery_PrimaryScan     `protobuf:\"group,1,req,name=PrimaryScan\" json:\"primaryscan,omitempty\"`\n\tMergejoinscan     []*CompiledQuery_MergeJoinScan `protobuf:\"group,7,rep,name=MergeJoinScan\" json:\"mergejoinscan,omitempty\"`\n\tIndexDef          *Index                         `protobuf:\"bytes,21,opt,name=index_def\" json:\"index_def,omitempty\"`\n\tOffset            *int32                         `protobuf:\"varint,10,opt,name=offset,def=0\" json:\"offset,omitempty\"`\n\tLimit             *int32                         `protobuf:\"varint,11,opt,name=limit\" json:\"limit,omitempty\"`\n\tKeysOnly          *bool                          `protobuf:\"varint,12,req,name=keys_only\" json:\"keys_only,omitempty\"`\n\tPropertyName      []string                       `protobuf:\"bytes,24,rep,name=property_name\" json:\"property_name,omitempty\"`\n\tDistinctInfixSize *int32                         `protobuf:\"varint,25,opt,name=distinct_infix_size\" json:\"distinct_infix_size,omitempty\"`\n\tEntityfilter      *CompiledQuery_EntityFilter    `protobuf:\"group,13,opt,name=EntityFilter\" json:\"entityfilter,omitempty\"`\n\tXXX_unrecognized  []byte                         `json:\"-\"`\n}\n\nfunc (m *CompiledQuery) Reset()         { *m = CompiledQuery{} }\nfunc (m *CompiledQuery) String() string { return proto.CompactTextString(m) }\nfunc (*CompiledQuery) ProtoMessage()    {}\n\nconst Default_CompiledQuery_Offset int32 = 0\n\nfunc (m *CompiledQuery) GetPrimaryscan() *CompiledQuery_PrimaryScan {\n\tif m != nil {\n\t\treturn m.Primaryscan\n\t}\n\treturn nil\n}\n\nfunc (m *CompiledQuery) GetMergejoinscan() []*CompiledQuery_MergeJoinScan {\n\tif m != nil {\n\t\treturn m.Mergejoinscan\n\t}\n\treturn nil\n}\n\nfunc (m *CompiledQuery) GetIndexDef() *Index {\n\tif m != nil {\n\t\treturn m.IndexDef\n\t}\n\treturn nil\n}\n\nfunc (m *CompiledQuery) GetOffset() int32 {\n\tif m != nil && m.Offset != nil {\n\t\treturn *m.Offset\n\t}\n\treturn Default_CompiledQuery_Offset\n}\n\nfunc (m *CompiledQuery) GetLimit() int32 {\n\tif m != nil && m.Limit != nil {\n\t\treturn *m.Limit\n\t}\n\treturn 0\n}\n\nfunc (m *CompiledQuery) GetKeysOnly() bool {\n\tif m != nil && m.KeysOnly != nil {\n\t\treturn *m.KeysOnly\n\t}\n\treturn false\n}\n\nfunc (m *CompiledQuery) GetPropertyName() []string {\n\tif m != nil {\n\t\treturn m.PropertyName\n\t}\n\treturn nil\n}\n\nfunc (m *CompiledQuery) GetDistinctInfixSize() int32 {\n\tif m != nil && m.DistinctInfixSize != nil {\n\t\treturn *m.DistinctInfixSize\n\t}\n\treturn 0\n}\n\nfunc (m *CompiledQuery) GetEntityfilter() *CompiledQuery_EntityFilter {\n\tif m != nil {\n\t\treturn m.Entityfilter\n\t}\n\treturn nil\n}\n\ntype CompiledQuery_PrimaryScan struct {\n\tIndexName                  *string  `protobuf:\"bytes,2,opt,name=index_name\" json:\"index_name,omitempty\"`\n\tStartKey                   *string  `protobuf:\"bytes,3,opt,name=start_key\" json:\"start_key,omitempty\"`\n\tStartInclusive             *bool    `protobuf:\"varint,4,opt,name=start_inclusive\" json:\"start_inclusive,omitempty\"`\n\tEndKey                     *string  `protobuf:\"bytes,5,opt,name=end_key\" json:\"end_key,omitempty\"`\n\tEndInclusive               *bool    `protobuf:\"varint,6,opt,name=end_inclusive\" json:\"end_inclusive,omitempty\"`\n\tStartPostfixValue          []string `protobuf:\"bytes,22,rep,name=start_postfix_value\" json:\"start_postfix_value,omitempty\"`\n\tEndPostfixValue            []string `protobuf:\"bytes,23,rep,name=end_postfix_value\" json:\"end_postfix_value,omitempty\"`\n\tEndUnappliedLogTimestampUs *int64   `protobuf:\"varint,19,opt,name=end_unapplied_log_timestamp_us\" json:\"end_unapplied_log_timestamp_us,omitempty\"`\n\tXXX_unrecognized           []byte   `json:\"-\"`\n}\n\nfunc (m *CompiledQuery_PrimaryScan) Reset()         { *m = CompiledQuery_PrimaryScan{} }\nfunc (m *CompiledQuery_PrimaryScan) String() string { return proto.CompactTextString(m) }\nfunc (*CompiledQuery_PrimaryScan) ProtoMessage()    {}\n\nfunc (m *CompiledQuery_PrimaryScan) GetIndexName() string {\n\tif m != nil && m.IndexName != nil {\n\t\treturn *m.IndexName\n\t}\n\treturn \"\"\n}\n\nfunc (m *CompiledQuery_PrimaryScan) GetStartKey() string {\n\tif m != nil && m.StartKey != nil {\n\t\treturn *m.StartKey\n\t}\n\treturn \"\"\n}\n\nfunc (m *CompiledQuery_PrimaryScan) GetStartInclusive() bool {\n\tif m != nil && m.StartInclusive != nil {\n\t\treturn *m.StartInclusive\n\t}\n\treturn false\n}\n\nfunc (m *CompiledQuery_PrimaryScan) GetEndKey() string {\n\tif m != nil && m.EndKey != nil {\n\t\treturn *m.EndKey\n\t}\n\treturn \"\"\n}\n\nfunc (m *CompiledQuery_PrimaryScan) GetEndInclusive() bool {\n\tif m != nil && m.EndInclusive != nil {\n\t\treturn *m.EndInclusive\n\t}\n\treturn false\n}\n\nfunc (m *CompiledQuery_PrimaryScan) GetStartPostfixValue() []string {\n\tif m != nil {\n\t\treturn m.StartPostfixValue\n\t}\n\treturn nil\n}\n\nfunc (m *CompiledQuery_PrimaryScan) GetEndPostfixValue() []string {\n\tif m != nil {\n\t\treturn m.EndPostfixValue\n\t}\n\treturn nil\n}\n\nfunc (m *CompiledQuery_PrimaryScan) GetEndUnappliedLogTimestampUs() int64 {\n\tif m != nil && m.EndUnappliedLogTimestampUs != nil {\n\t\treturn *m.EndUnappliedLogTimestampUs\n\t}\n\treturn 0\n}\n\ntype CompiledQuery_MergeJoinScan struct {\n\tIndexName        *string  `protobuf:\"bytes,8,req,name=index_name\" json:\"index_name,omitempty\"`\n\tPrefixValue      []string `protobuf:\"bytes,9,rep,name=prefix_value\" json:\"prefix_value,omitempty\"`\n\tValuePrefix      *bool    `protobuf:\"varint,20,opt,name=value_prefix,def=0\" json:\"value_prefix,omitempty\"`\n\tXXX_unrecognized []byte   `json:\"-\"`\n}\n\nfunc (m *CompiledQuery_MergeJoinScan) Reset()         { *m = CompiledQuery_MergeJoinScan{} }\nfunc (m *CompiledQuery_MergeJoinScan) String() string { return proto.CompactTextString(m) }\nfunc (*CompiledQuery_MergeJoinScan) ProtoMessage()    {}\n\nconst Default_CompiledQuery_MergeJoinScan_ValuePrefix bool = false\n\nfunc (m *CompiledQuery_MergeJoinScan) GetIndexName() string {\n\tif m != nil && m.IndexName != nil {\n\t\treturn *m.IndexName\n\t}\n\treturn \"\"\n}\n\nfunc (m *CompiledQuery_MergeJoinScan) GetPrefixValue() []string {\n\tif m != nil {\n\t\treturn m.PrefixValue\n\t}\n\treturn nil\n}\n\nfunc (m *CompiledQuery_MergeJoinScan) GetValuePrefix() bool {\n\tif m != nil && m.ValuePrefix != nil {\n\t\treturn *m.ValuePrefix\n\t}\n\treturn Default_CompiledQuery_MergeJoinScan_ValuePrefix\n}\n\ntype CompiledQuery_EntityFilter struct {\n\tDistinct         *bool      `protobuf:\"varint,14,opt,name=distinct,def=0\" json:\"distinct,omitempty\"`\n\tKind             *string    `protobuf:\"bytes,17,opt,name=kind\" json:\"kind,omitempty\"`\n\tAncestor         *Reference `protobuf:\"bytes,18,opt,name=ancestor\" json:\"ancestor,omitempty\"`\n\tXXX_unrecognized []byte     `json:\"-\"`\n}\n\nfunc (m *CompiledQuery_EntityFilter) Reset()         { *m = CompiledQuery_EntityFilter{} }\nfunc (m *CompiledQuery_EntityFilter) String() string { return proto.CompactTextString(m) }\nfunc (*CompiledQuery_EntityFilter) ProtoMessage()    {}\n\nconst Default_CompiledQuery_EntityFilter_Distinct bool = false\n\nfunc (m *CompiledQuery_EntityFilter) GetDistinct() bool {\n\tif m != nil && m.Distinct != nil {\n\t\treturn *m.Distinct\n\t}\n\treturn Default_CompiledQuery_EntityFilter_Distinct\n}\n\nfunc (m *CompiledQuery_EntityFilter) GetKind() string {\n\tif m != nil && m.Kind != nil {\n\t\treturn *m.Kind\n\t}\n\treturn \"\"\n}\n\nfunc (m *CompiledQuery_EntityFilter) GetAncestor() *Reference {\n\tif m != nil {\n\t\treturn m.Ancestor\n\t}\n\treturn nil\n}\n\ntype CompiledCursor struct {\n\tPosition         *CompiledCursor_Position `protobuf:\"group,2,opt,name=Position\" json:\"position,omitempty\"`\n\tXXX_unrecognized []byte                   `json:\"-\"`\n}\n\nfunc (m *CompiledCursor) Reset()         { *m = CompiledCursor{} }\nfunc (m *CompiledCursor) String() string { return proto.CompactTextString(m) }\nfunc (*CompiledCursor) ProtoMessage()    {}\n\nfunc (m *CompiledCursor) GetPosition() *CompiledCursor_Position {\n\tif m != nil {\n\t\treturn m.Position\n\t}\n\treturn nil\n}\n\ntype CompiledCursor_Position struct {\n\tStartKey         *string                               `protobuf:\"bytes,27,opt,name=start_key\" json:\"start_key,omitempty\"`\n\tIndexvalue       []*CompiledCursor_Position_IndexValue `protobuf:\"group,29,rep,name=IndexValue\" json:\"indexvalue,omitempty\"`\n\tKey              *Reference                            `protobuf:\"bytes,32,opt,name=key\" json:\"key,omitempty\"`\n\tStartInclusive   *bool                                 `protobuf:\"varint,28,opt,name=start_inclusive,def=1\" json:\"start_inclusive,omitempty\"`\n\tXXX_unrecognized []byte                                `json:\"-\"`\n}\n\nfunc (m *CompiledCursor_Position) Reset()         { *m = CompiledCursor_Position{} }\nfunc (m *CompiledCursor_Position) String() string { return proto.CompactTextString(m) }\nfunc (*CompiledCursor_Position) ProtoMessage()    {}\n\nconst Default_CompiledCursor_Position_StartInclusive bool = true\n\nfunc (m *CompiledCursor_Position) GetStartKey() string {\n\tif m != nil && m.StartKey != nil {\n\t\treturn *m.StartKey\n\t}\n\treturn \"\"\n}\n\nfunc (m *CompiledCursor_Position) GetIndexvalue() []*CompiledCursor_Position_IndexValue {\n\tif m != nil {\n\t\treturn m.Indexvalue\n\t}\n\treturn nil\n}\n\nfunc (m *CompiledCursor_Position) GetKey() *Reference {\n\tif m != nil {\n\t\treturn m.Key\n\t}\n\treturn nil\n}\n\nfunc (m *CompiledCursor_Position) GetStartInclusive() bool {\n\tif m != nil && m.StartInclusive != nil {\n\t\treturn *m.StartInclusive\n\t}\n\treturn Default_CompiledCursor_Position_StartInclusive\n}\n\ntype CompiledCursor_Position_IndexValue struct {\n\tProperty         *string        `protobuf:\"bytes,30,opt,name=property\" json:\"property,omitempty\"`\n\tValue            *PropertyValue `protobuf:\"bytes,31,req,name=value\" json:\"value,omitempty\"`\n\tXXX_unrecognized []byte         `json:\"-\"`\n}\n\nfunc (m *CompiledCursor_Position_IndexValue) Reset()         { *m = CompiledCursor_Position_IndexValue{} }\nfunc (m *CompiledCursor_Position_IndexValue) String() string { return proto.CompactTextString(m) }\nfunc (*CompiledCursor_Position_IndexValue) ProtoMessage()    {}\n\nfunc (m *CompiledCursor_Position_IndexValue) GetProperty() string {\n\tif m != nil && m.Property != nil {\n\t\treturn *m.Property\n\t}\n\treturn \"\"\n}\n\nfunc (m *CompiledCursor_Position_IndexValue) GetValue() *PropertyValue {\n\tif m != nil {\n\t\treturn m.Value\n\t}\n\treturn nil\n}\n\ntype Cursor struct {\n\tCursor           *uint64 `protobuf:\"fixed64,1,req,name=cursor\" json:\"cursor,omitempty\"`\n\tApp              *string `protobuf:\"bytes,2,opt,name=app\" json:\"app,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *Cursor) Reset()         { *m = Cursor{} }\nfunc (m *Cursor) String() string { return proto.CompactTextString(m) }\nfunc (*Cursor) ProtoMessage()    {}\n\nfunc (m *Cursor) GetCursor() uint64 {\n\tif m != nil && m.Cursor != nil {\n\t\treturn *m.Cursor\n\t}\n\treturn 0\n}\n\nfunc (m *Cursor) GetApp() string {\n\tif m != nil && m.App != nil {\n\t\treturn *m.App\n\t}\n\treturn \"\"\n}\n\ntype Error struct {\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *Error) Reset()         { *m = Error{} }\nfunc (m *Error) String() string { return proto.CompactTextString(m) }\nfunc (*Error) ProtoMessage()    {}\n\ntype Cost struct {\n\tIndexWrites             *int32           `protobuf:\"varint,1,opt,name=index_writes\" json:\"index_writes,omitempty\"`\n\tIndexWriteBytes         *int32           `protobuf:\"varint,2,opt,name=index_write_bytes\" json:\"index_write_bytes,omitempty\"`\n\tEntityWrites            *int32           `protobuf:\"varint,3,opt,name=entity_writes\" json:\"entity_writes,omitempty\"`\n\tEntityWriteBytes        *int32           `protobuf:\"varint,4,opt,name=entity_write_bytes\" json:\"entity_write_bytes,omitempty\"`\n\tCommitcost              *Cost_CommitCost `protobuf:\"group,5,opt,name=CommitCost\" json:\"commitcost,omitempty\"`\n\tApproximateStorageDelta *int32           `protobuf:\"varint,8,opt,name=approximate_storage_delta\" json:\"approximate_storage_delta,omitempty\"`\n\tIdSequenceUpdates       *int32           `protobuf:\"varint,9,opt,name=id_sequence_updates\" json:\"id_sequence_updates,omitempty\"`\n\tXXX_unrecognized        []byte           `json:\"-\"`\n}\n\nfunc (m *Cost) Reset()         { *m = Cost{} }\nfunc (m *Cost) String() string { return proto.CompactTextString(m) }\nfunc (*Cost) ProtoMessage()    {}\n\nfunc (m *Cost) GetIndexWrites() int32 {\n\tif m != nil && m.IndexWrites != nil {\n\t\treturn *m.IndexWrites\n\t}\n\treturn 0\n}\n\nfunc (m *Cost) GetIndexWriteBytes() int32 {\n\tif m != nil && m.IndexWriteBytes != nil {\n\t\treturn *m.IndexWriteBytes\n\t}\n\treturn 0\n}\n\nfunc (m *Cost) GetEntityWrites() int32 {\n\tif m != nil && m.EntityWrites != nil {\n\t\treturn *m.EntityWrites\n\t}\n\treturn 0\n}\n\nfunc (m *Cost) GetEntityWriteBytes() int32 {\n\tif m != nil && m.EntityWriteBytes != nil {\n\t\treturn *m.EntityWriteBytes\n\t}\n\treturn 0\n}\n\nfunc (m *Cost) GetCommitcost() *Cost_CommitCost {\n\tif m != nil {\n\t\treturn m.Commitcost\n\t}\n\treturn nil\n}\n\nfunc (m *Cost) GetApproximateStorageDelta() int32 {\n\tif m != nil && m.ApproximateStorageDelta != nil {\n\t\treturn *m.ApproximateStorageDelta\n\t}\n\treturn 0\n}\n\nfunc (m *Cost) GetIdSequenceUpdates() int32 {\n\tif m != nil && m.IdSequenceUpdates != nil {\n\t\treturn *m.IdSequenceUpdates\n\t}\n\treturn 0\n}\n\ntype Cost_CommitCost struct {\n\tRequestedEntityPuts    *int32 `protobuf:\"varint,6,opt,name=requested_entity_puts\" json:\"requested_entity_puts,omitempty\"`\n\tRequestedEntityDeletes *int32 `protobuf:\"varint,7,opt,name=requested_entity_deletes\" json:\"requested_entity_deletes,omitempty\"`\n\tXXX_unrecognized       []byte `json:\"-\"`\n}\n\nfunc (m *Cost_CommitCost) Reset()         { *m = Cost_CommitCost{} }\nfunc (m *Cost_CommitCost) String() string { return proto.CompactTextString(m) }\nfunc (*Cost_CommitCost) ProtoMessage()    {}\n\nfunc (m *Cost_CommitCost) GetRequestedEntityPuts() int32 {\n\tif m != nil && m.RequestedEntityPuts != nil {\n\t\treturn *m.RequestedEntityPuts\n\t}\n\treturn 0\n}\n\nfunc (m *Cost_CommitCost) GetRequestedEntityDeletes() int32 {\n\tif m != nil && m.RequestedEntityDeletes != nil {\n\t\treturn *m.RequestedEntityDeletes\n\t}\n\treturn 0\n}\n\ntype GetRequest struct {\n\tHeader           *InternalHeader `protobuf:\"bytes,6,opt,name=header\" json:\"header,omitempty\"`\n\tKey              []*Reference    `protobuf:\"bytes,1,rep,name=key\" json:\"key,omitempty\"`\n\tTransaction      *Transaction    `protobuf:\"bytes,2,opt,name=transaction\" json:\"transaction,omitempty\"`\n\tFailoverMs       *int64          `protobuf:\"varint,3,opt,name=failover_ms\" json:\"failover_ms,omitempty\"`\n\tStrong           *bool           `protobuf:\"varint,4,opt,name=strong\" json:\"strong,omitempty\"`\n\tAllowDeferred    *bool           `protobuf:\"varint,5,opt,name=allow_deferred,def=0\" json:\"allow_deferred,omitempty\"`\n\tXXX_unrecognized []byte          `json:\"-\"`\n}\n\nfunc (m *GetRequest) Reset()         { *m = GetRequest{} }\nfunc (m *GetRequest) String() string { return proto.CompactTextString(m) }\nfunc (*GetRequest) ProtoMessage()    {}\n\nconst Default_GetRequest_AllowDeferred bool = false\n\nfunc (m *GetRequest) GetHeader() *InternalHeader {\n\tif m != nil {\n\t\treturn m.Header\n\t}\n\treturn nil\n}\n\nfunc (m *GetRequest) GetKey() []*Reference {\n\tif m != nil {\n\t\treturn m.Key\n\t}\n\treturn nil\n}\n\nfunc (m *GetRequest) GetTransaction() *Transaction {\n\tif m != nil {\n\t\treturn m.Transaction\n\t}\n\treturn nil\n}\n\nfunc (m *GetRequest) GetFailoverMs() int64 {\n\tif m != nil && m.FailoverMs != nil {\n\t\treturn *m.FailoverMs\n\t}\n\treturn 0\n}\n\nfunc (m *GetRequest) GetStrong() bool {\n\tif m != nil && m.Strong != nil {\n\t\treturn *m.Strong\n\t}\n\treturn false\n}\n\nfunc (m *GetRequest) GetAllowDeferred() bool {\n\tif m != nil && m.AllowDeferred != nil {\n\t\treturn *m.AllowDeferred\n\t}\n\treturn Default_GetRequest_AllowDeferred\n}\n\ntype GetResponse struct {\n\tEntity           []*GetResponse_Entity `protobuf:\"group,1,rep,name=Entity\" json:\"entity,omitempty\"`\n\tDeferred         []*Reference          `protobuf:\"bytes,5,rep,name=deferred\" json:\"deferred,omitempty\"`\n\tInOrder          *bool                 `protobuf:\"varint,6,opt,name=in_order,def=1\" json:\"in_order,omitempty\"`\n\tXXX_unrecognized []byte                `json:\"-\"`\n}\n\nfunc (m *GetResponse) Reset()         { *m = GetResponse{} }\nfunc (m *GetResponse) String() string { return proto.CompactTextString(m) }\nfunc (*GetResponse) ProtoMessage()    {}\n\nconst Default_GetResponse_InOrder bool = true\n\nfunc (m *GetResponse) GetEntity() []*GetResponse_Entity {\n\tif m != nil {\n\t\treturn m.Entity\n\t}\n\treturn nil\n}\n\nfunc (m *GetResponse) GetDeferred() []*Reference {\n\tif m != nil {\n\t\treturn m.Deferred\n\t}\n\treturn nil\n}\n\nfunc (m *GetResponse) GetInOrder() bool {\n\tif m != nil && m.InOrder != nil {\n\t\treturn *m.InOrder\n\t}\n\treturn Default_GetResponse_InOrder\n}\n\ntype GetResponse_Entity struct {\n\tEntity           *EntityProto `protobuf:\"bytes,2,opt,name=entity\" json:\"entity,omitempty\"`\n\tKey              *Reference   `protobuf:\"bytes,4,opt,name=key\" json:\"key,omitempty\"`\n\tVersion          *int64       `protobuf:\"varint,3,opt,name=version\" json:\"version,omitempty\"`\n\tXXX_unrecognized []byte       `json:\"-\"`\n}\n\nfunc (m *GetResponse_Entity) Reset()         { *m = GetResponse_Entity{} }\nfunc (m *GetResponse_Entity) String() string { return proto.CompactTextString(m) }\nfunc (*GetResponse_Entity) ProtoMessage()    {}\n\nfunc (m *GetResponse_Entity) GetEntity() *EntityProto {\n\tif m != nil {\n\t\treturn m.Entity\n\t}\n\treturn nil\n}\n\nfunc (m *GetResponse_Entity) GetKey() *Reference {\n\tif m != nil {\n\t\treturn m.Key\n\t}\n\treturn nil\n}\n\nfunc (m *GetResponse_Entity) GetVersion() int64 {\n\tif m != nil && m.Version != nil {\n\t\treturn *m.Version\n\t}\n\treturn 0\n}\n\ntype PutRequest struct {\n\tHeader           *InternalHeader          `protobuf:\"bytes,11,opt,name=header\" json:\"header,omitempty\"`\n\tEntity           []*EntityProto           `protobuf:\"bytes,1,rep,name=entity\" json:\"entity,omitempty\"`\n\tTransaction      *Transaction             `protobuf:\"bytes,2,opt,name=transaction\" json:\"transaction,omitempty\"`\n\tCompositeIndex   []*CompositeIndex        `protobuf:\"bytes,3,rep,name=composite_index\" json:\"composite_index,omitempty\"`\n\tTrusted          *bool                    `protobuf:\"varint,4,opt,name=trusted,def=0\" json:\"trusted,omitempty\"`\n\tForce            *bool                    `protobuf:\"varint,7,opt,name=force,def=0\" json:\"force,omitempty\"`\n\tMarkChanges      *bool                    `protobuf:\"varint,8,opt,name=mark_changes,def=0\" json:\"mark_changes,omitempty\"`\n\tSnapshot         []*Snapshot              `protobuf:\"bytes,9,rep,name=snapshot\" json:\"snapshot,omitempty\"`\n\tAutoIdPolicy     *PutRequest_AutoIdPolicy `protobuf:\"varint,10,opt,name=auto_id_policy,enum=appengine.PutRequest_AutoIdPolicy,def=0\" json:\"auto_id_policy,omitempty\"`\n\tXXX_unrecognized []byte                   `json:\"-\"`\n}\n\nfunc (m *PutRequest) Reset()         { *m = PutRequest{} }\nfunc (m *PutRequest) String() string { return proto.CompactTextString(m) }\nfunc (*PutRequest) ProtoMessage()    {}\n\nconst Default_PutRequest_Trusted bool = false\nconst Default_PutRequest_Force bool = false\nconst Default_PutRequest_MarkChanges bool = false\nconst Default_PutRequest_AutoIdPolicy PutRequest_AutoIdPolicy = PutRequest_CURRENT\n\nfunc (m *PutRequest) GetHeader() *InternalHeader {\n\tif m != nil {\n\t\treturn m.Header\n\t}\n\treturn nil\n}\n\nfunc (m *PutRequest) GetEntity() []*EntityProto {\n\tif m != nil {\n\t\treturn m.Entity\n\t}\n\treturn nil\n}\n\nfunc (m *PutRequest) GetTransaction() *Transaction {\n\tif m != nil {\n\t\treturn m.Transaction\n\t}\n\treturn nil\n}\n\nfunc (m *PutRequest) GetCompositeIndex() []*CompositeIndex {\n\tif m != nil {\n\t\treturn m.CompositeIndex\n\t}\n\treturn nil\n}\n\nfunc (m *PutRequest) GetTrusted() bool {\n\tif m != nil && m.Trusted != nil {\n\t\treturn *m.Trusted\n\t}\n\treturn Default_PutRequest_Trusted\n}\n\nfunc (m *PutRequest) GetForce() bool {\n\tif m != nil && m.Force != nil {\n\t\treturn *m.Force\n\t}\n\treturn Default_PutRequest_Force\n}\n\nfunc (m *PutRequest) GetMarkChanges() bool {\n\tif m != nil && m.MarkChanges != nil {\n\t\treturn *m.MarkChanges\n\t}\n\treturn Default_PutRequest_MarkChanges\n}\n\nfunc (m *PutRequest) GetSnapshot() []*Snapshot {\n\tif m != nil {\n\t\treturn m.Snapshot\n\t}\n\treturn nil\n}\n\nfunc (m *PutRequest) GetAutoIdPolicy() PutRequest_AutoIdPolicy {\n\tif m != nil && m.AutoIdPolicy != nil {\n\t\treturn *m.AutoIdPolicy\n\t}\n\treturn Default_PutRequest_AutoIdPolicy\n}\n\ntype PutResponse struct {\n\tKey              []*Reference `protobuf:\"bytes,1,rep,name=key\" json:\"key,omitempty\"`\n\tCost             *Cost        `protobuf:\"bytes,2,opt,name=cost\" json:\"cost,omitempty\"`\n\tVersion          []int64      `protobuf:\"varint,3,rep,name=version\" json:\"version,omitempty\"`\n\tXXX_unrecognized []byte       `json:\"-\"`\n}\n\nfunc (m *PutResponse) Reset()         { *m = PutResponse{} }\nfunc (m *PutResponse) String() string { return proto.CompactTextString(m) }\nfunc (*PutResponse) ProtoMessage()    {}\n\nfunc (m *PutResponse) GetKey() []*Reference {\n\tif m != nil {\n\t\treturn m.Key\n\t}\n\treturn nil\n}\n\nfunc (m *PutResponse) GetCost() *Cost {\n\tif m != nil {\n\t\treturn m.Cost\n\t}\n\treturn nil\n}\n\nfunc (m *PutResponse) GetVersion() []int64 {\n\tif m != nil {\n\t\treturn m.Version\n\t}\n\treturn nil\n}\n\ntype TouchRequest struct {\n\tHeader           *InternalHeader   `protobuf:\"bytes,10,opt,name=header\" json:\"header,omitempty\"`\n\tKey              []*Reference      `protobuf:\"bytes,1,rep,name=key\" json:\"key,omitempty\"`\n\tCompositeIndex   []*CompositeIndex `protobuf:\"bytes,2,rep,name=composite_index\" json:\"composite_index,omitempty\"`\n\tForce            *bool             `protobuf:\"varint,3,opt,name=force,def=0\" json:\"force,omitempty\"`\n\tSnapshot         []*Snapshot       `protobuf:\"bytes,9,rep,name=snapshot\" json:\"snapshot,omitempty\"`\n\tXXX_unrecognized []byte            `json:\"-\"`\n}\n\nfunc (m *TouchRequest) Reset()         { *m = TouchRequest{} }\nfunc (m *TouchRequest) String() string { return proto.CompactTextString(m) }\nfunc (*TouchRequest) ProtoMessage()    {}\n\nconst Default_TouchRequest_Force bool = false\n\nfunc (m *TouchRequest) GetHeader() *InternalHeader {\n\tif m != nil {\n\t\treturn m.Header\n\t}\n\treturn nil\n}\n\nfunc (m *TouchRequest) GetKey() []*Reference {\n\tif m != nil {\n\t\treturn m.Key\n\t}\n\treturn nil\n}\n\nfunc (m *TouchRequest) GetCompositeIndex() []*CompositeIndex {\n\tif m != nil {\n\t\treturn m.CompositeIndex\n\t}\n\treturn nil\n}\n\nfunc (m *TouchRequest) GetForce() bool {\n\tif m != nil && m.Force != nil {\n\t\treturn *m.Force\n\t}\n\treturn Default_TouchRequest_Force\n}\n\nfunc (m *TouchRequest) GetSnapshot() []*Snapshot {\n\tif m != nil {\n\t\treturn m.Snapshot\n\t}\n\treturn nil\n}\n\ntype TouchResponse struct {\n\tCost             *Cost  `protobuf:\"bytes,1,opt,name=cost\" json:\"cost,omitempty\"`\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *TouchResponse) Reset()         { *m = TouchResponse{} }\nfunc (m *TouchResponse) String() string { return proto.CompactTextString(m) }\nfunc (*TouchResponse) ProtoMessage()    {}\n\nfunc (m *TouchResponse) GetCost() *Cost {\n\tif m != nil {\n\t\treturn m.Cost\n\t}\n\treturn nil\n}\n\ntype DeleteRequest struct {\n\tHeader           *InternalHeader `protobuf:\"bytes,10,opt,name=header\" json:\"header,omitempty\"`\n\tKey              []*Reference    `protobuf:\"bytes,6,rep,name=key\" json:\"key,omitempty\"`\n\tTransaction      *Transaction    `protobuf:\"bytes,5,opt,name=transaction\" json:\"transaction,omitempty\"`\n\tTrusted          *bool           `protobuf:\"varint,4,opt,name=trusted,def=0\" json:\"trusted,omitempty\"`\n\tForce            *bool           `protobuf:\"varint,7,opt,name=force,def=0\" json:\"force,omitempty\"`\n\tMarkChanges      *bool           `protobuf:\"varint,8,opt,name=mark_changes,def=0\" json:\"mark_changes,omitempty\"`\n\tSnapshot         []*Snapshot     `protobuf:\"bytes,9,rep,name=snapshot\" json:\"snapshot,omitempty\"`\n\tXXX_unrecognized []byte          `json:\"-\"`\n}\n\nfunc (m *DeleteRequest) Reset()         { *m = DeleteRequest{} }\nfunc (m *DeleteRequest) String() string { return proto.CompactTextString(m) }\nfunc (*DeleteRequest) ProtoMessage()    {}\n\nconst Default_DeleteRequest_Trusted bool = false\nconst Default_DeleteRequest_Force bool = false\nconst Default_DeleteRequest_MarkChanges bool = false\n\nfunc (m *DeleteRequest) GetHeader() *InternalHeader {\n\tif m != nil {\n\t\treturn m.Header\n\t}\n\treturn nil\n}\n\nfunc (m *DeleteRequest) GetKey() []*Reference {\n\tif m != nil {\n\t\treturn m.Key\n\t}\n\treturn nil\n}\n\nfunc (m *DeleteRequest) GetTransaction() *Transaction {\n\tif m != nil {\n\t\treturn m.Transaction\n\t}\n\treturn nil\n}\n\nfunc (m *DeleteRequest) GetTrusted() bool {\n\tif m != nil && m.Trusted != nil {\n\t\treturn *m.Trusted\n\t}\n\treturn Default_DeleteRequest_Trusted\n}\n\nfunc (m *DeleteRequest) GetForce() bool {\n\tif m != nil && m.Force != nil {\n\t\treturn *m.Force\n\t}\n\treturn Default_DeleteRequest_Force\n}\n\nfunc (m *DeleteRequest) GetMarkChanges() bool {\n\tif m != nil && m.MarkChanges != nil {\n\t\treturn *m.MarkChanges\n\t}\n\treturn Default_DeleteRequest_MarkChanges\n}\n\nfunc (m *DeleteRequest) GetSnapshot() []*Snapshot {\n\tif m != nil {\n\t\treturn m.Snapshot\n\t}\n\treturn nil\n}\n\ntype DeleteResponse struct {\n\tCost             *Cost   `protobuf:\"bytes,1,opt,name=cost\" json:\"cost,omitempty\"`\n\tVersion          []int64 `protobuf:\"varint,3,rep,name=version\" json:\"version,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *DeleteResponse) Reset()         { *m = DeleteResponse{} }\nfunc (m *DeleteResponse) String() string { return proto.CompactTextString(m) }\nfunc (*DeleteResponse) ProtoMessage()    {}\n\nfunc (m *DeleteResponse) GetCost() *Cost {\n\tif m != nil {\n\t\treturn m.Cost\n\t}\n\treturn nil\n}\n\nfunc (m *DeleteResponse) GetVersion() []int64 {\n\tif m != nil {\n\t\treturn m.Version\n\t}\n\treturn nil\n}\n\ntype NextRequest struct {\n\tHeader           *InternalHeader `protobuf:\"bytes,5,opt,name=header\" json:\"header,omitempty\"`\n\tCursor           *Cursor         `protobuf:\"bytes,1,req,name=cursor\" json:\"cursor,omitempty\"`\n\tCount            *int32          `protobuf:\"varint,2,opt,name=count\" json:\"count,omitempty\"`\n\tOffset           *int32          `protobuf:\"varint,4,opt,name=offset,def=0\" json:\"offset,omitempty\"`\n\tCompile          *bool           `protobuf:\"varint,3,opt,name=compile,def=0\" json:\"compile,omitempty\"`\n\tXXX_unrecognized []byte          `json:\"-\"`\n}\n\nfunc (m *NextRequest) Reset()         { *m = NextRequest{} }\nfunc (m *NextRequest) String() string { return proto.CompactTextString(m) }\nfunc (*NextRequest) ProtoMessage()    {}\n\nconst Default_NextRequest_Offset int32 = 0\nconst Default_NextRequest_Compile bool = false\n\nfunc (m *NextRequest) GetHeader() *InternalHeader {\n\tif m != nil {\n\t\treturn m.Header\n\t}\n\treturn nil\n}\n\nfunc (m *NextRequest) GetCursor() *Cursor {\n\tif m != nil {\n\t\treturn m.Cursor\n\t}\n\treturn nil\n}\n\nfunc (m *NextRequest) GetCount() int32 {\n\tif m != nil && m.Count != nil {\n\t\treturn *m.Count\n\t}\n\treturn 0\n}\n\nfunc (m *NextRequest) GetOffset() int32 {\n\tif m != nil && m.Offset != nil {\n\t\treturn *m.Offset\n\t}\n\treturn Default_NextRequest_Offset\n}\n\nfunc (m *NextRequest) GetCompile() bool {\n\tif m != nil && m.Compile != nil {\n\t\treturn *m.Compile\n\t}\n\treturn Default_NextRequest_Compile\n}\n\ntype QueryResult struct {\n\tCursor           *Cursor           `protobuf:\"bytes,1,opt,name=cursor\" json:\"cursor,omitempty\"`\n\tResult           []*EntityProto    `protobuf:\"bytes,2,rep,name=result\" json:\"result,omitempty\"`\n\tSkippedResults   *int32            `protobuf:\"varint,7,opt,name=skipped_results\" json:\"skipped_results,omitempty\"`\n\tMoreResults      *bool             `protobuf:\"varint,3,req,name=more_results\" json:\"more_results,omitempty\"`\n\tKeysOnly         *bool             `protobuf:\"varint,4,opt,name=keys_only\" json:\"keys_only,omitempty\"`\n\tIndexOnly        *bool             `protobuf:\"varint,9,opt,name=index_only\" json:\"index_only,omitempty\"`\n\tSmallOps         *bool             `protobuf:\"varint,10,opt,name=small_ops\" json:\"small_ops,omitempty\"`\n\tCompiledQuery    *CompiledQuery    `protobuf:\"bytes,5,opt,name=compiled_query\" json:\"compiled_query,omitempty\"`\n\tCompiledCursor   *CompiledCursor   `protobuf:\"bytes,6,opt,name=compiled_cursor\" json:\"compiled_cursor,omitempty\"`\n\tIndex            []*CompositeIndex `protobuf:\"bytes,8,rep,name=index\" json:\"index,omitempty\"`\n\tVersion          []int64           `protobuf:\"varint,11,rep,name=version\" json:\"version,omitempty\"`\n\tXXX_unrecognized []byte            `json:\"-\"`\n}\n\nfunc (m *QueryResult) Reset()         { *m = QueryResult{} }\nfunc (m *QueryResult) String() string { return proto.CompactTextString(m) }\nfunc (*QueryResult) ProtoMessage()    {}\n\nfunc (m *QueryResult) GetCursor() *Cursor {\n\tif m != nil {\n\t\treturn m.Cursor\n\t}\n\treturn nil\n}\n\nfunc (m *QueryResult) GetResult() []*EntityProto {\n\tif m != nil {\n\t\treturn m.Result\n\t}\n\treturn nil\n}\n\nfunc (m *QueryResult) GetSkippedResults() int32 {\n\tif m != nil && m.SkippedResults != nil {\n\t\treturn *m.SkippedResults\n\t}\n\treturn 0\n}\n\nfunc (m *QueryResult) GetMoreResults() bool {\n\tif m != nil && m.MoreResults != nil {\n\t\treturn *m.MoreResults\n\t}\n\treturn false\n}\n\nfunc (m *QueryResult) GetKeysOnly() bool {\n\tif m != nil && m.KeysOnly != nil {\n\t\treturn *m.KeysOnly\n\t}\n\treturn false\n}\n\nfunc (m *QueryResult) GetIndexOnly() bool {\n\tif m != nil && m.IndexOnly != nil {\n\t\treturn *m.IndexOnly\n\t}\n\treturn false\n}\n\nfunc (m *QueryResult) GetSmallOps() bool {\n\tif m != nil && m.SmallOps != nil {\n\t\treturn *m.SmallOps\n\t}\n\treturn false\n}\n\nfunc (m *QueryResult) GetCompiledQuery() *CompiledQuery {\n\tif m != nil {\n\t\treturn m.CompiledQuery\n\t}\n\treturn nil\n}\n\nfunc (m *QueryResult) GetCompiledCursor() *CompiledCursor {\n\tif m != nil {\n\t\treturn m.CompiledCursor\n\t}\n\treturn nil\n}\n\nfunc (m *QueryResult) GetIndex() []*CompositeIndex {\n\tif m != nil {\n\t\treturn m.Index\n\t}\n\treturn nil\n}\n\nfunc (m *QueryResult) GetVersion() []int64 {\n\tif m != nil {\n\t\treturn m.Version\n\t}\n\treturn nil\n}\n\ntype AllocateIdsRequest struct {\n\tHeader           *InternalHeader `protobuf:\"bytes,4,opt,name=header\" json:\"header,omitempty\"`\n\tModelKey         *Reference      `protobuf:\"bytes,1,opt,name=model_key\" json:\"model_key,omitempty\"`\n\tSize             *int64          `protobuf:\"varint,2,opt,name=size\" json:\"size,omitempty\"`\n\tMax              *int64          `protobuf:\"varint,3,opt,name=max\" json:\"max,omitempty\"`\n\tReserve          []*Reference    `protobuf:\"bytes,5,rep,name=reserve\" json:\"reserve,omitempty\"`\n\tXXX_unrecognized []byte          `json:\"-\"`\n}\n\nfunc (m *AllocateIdsRequest) Reset()         { *m = AllocateIdsRequest{} }\nfunc (m *AllocateIdsRequest) String() string { return proto.CompactTextString(m) }\nfunc (*AllocateIdsRequest) ProtoMessage()    {}\n\nfunc (m *AllocateIdsRequest) GetHeader() *InternalHeader {\n\tif m != nil {\n\t\treturn m.Header\n\t}\n\treturn nil\n}\n\nfunc (m *AllocateIdsRequest) GetModelKey() *Reference {\n\tif m != nil {\n\t\treturn m.ModelKey\n\t}\n\treturn nil\n}\n\nfunc (m *AllocateIdsRequest) GetSize() int64 {\n\tif m != nil && m.Size != nil {\n\t\treturn *m.Size\n\t}\n\treturn 0\n}\n\nfunc (m *AllocateIdsRequest) GetMax() int64 {\n\tif m != nil && m.Max != nil {\n\t\treturn *m.Max\n\t}\n\treturn 0\n}\n\nfunc (m *AllocateIdsRequest) GetReserve() []*Reference {\n\tif m != nil {\n\t\treturn m.Reserve\n\t}\n\treturn nil\n}\n\ntype AllocateIdsResponse struct {\n\tStart            *int64 `protobuf:\"varint,1,req,name=start\" json:\"start,omitempty\"`\n\tEnd              *int64 `protobuf:\"varint,2,req,name=end\" json:\"end,omitempty\"`\n\tCost             *Cost  `protobuf:\"bytes,3,opt,name=cost\" json:\"cost,omitempty\"`\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *AllocateIdsResponse) Reset()         { *m = AllocateIdsResponse{} }\nfunc (m *AllocateIdsResponse) String() string { return proto.CompactTextString(m) }\nfunc (*AllocateIdsResponse) ProtoMessage()    {}\n\nfunc (m *AllocateIdsResponse) GetStart() int64 {\n\tif m != nil && m.Start != nil {\n\t\treturn *m.Start\n\t}\n\treturn 0\n}\n\nfunc (m *AllocateIdsResponse) GetEnd() int64 {\n\tif m != nil && m.End != nil {\n\t\treturn *m.End\n\t}\n\treturn 0\n}\n\nfunc (m *AllocateIdsResponse) GetCost() *Cost {\n\tif m != nil {\n\t\treturn m.Cost\n\t}\n\treturn nil\n}\n\ntype CompositeIndices struct {\n\tIndex            []*CompositeIndex `protobuf:\"bytes,1,rep,name=index\" json:\"index,omitempty\"`\n\tXXX_unrecognized []byte            `json:\"-\"`\n}\n\nfunc (m *CompositeIndices) Reset()         { *m = CompositeIndices{} }\nfunc (m *CompositeIndices) String() string { return proto.CompactTextString(m) }\nfunc (*CompositeIndices) ProtoMessage()    {}\n\nfunc (m *CompositeIndices) GetIndex() []*CompositeIndex {\n\tif m != nil {\n\t\treturn m.Index\n\t}\n\treturn nil\n}\n\ntype AddActionsRequest struct {\n\tHeader           *InternalHeader `protobuf:\"bytes,3,opt,name=header\" json:\"header,omitempty\"`\n\tTransaction      *Transaction    `protobuf:\"bytes,1,req,name=transaction\" json:\"transaction,omitempty\"`\n\tAction           []*Action       `protobuf:\"bytes,2,rep,name=action\" json:\"action,omitempty\"`\n\tXXX_unrecognized []byte          `json:\"-\"`\n}\n\nfunc (m *AddActionsRequest) Reset()         { *m = AddActionsRequest{} }\nfunc (m *AddActionsRequest) String() string { return proto.CompactTextString(m) }\nfunc (*AddActionsRequest) ProtoMessage()    {}\n\nfunc (m *AddActionsRequest) GetHeader() *InternalHeader {\n\tif m != nil {\n\t\treturn m.Header\n\t}\n\treturn nil\n}\n\nfunc (m *AddActionsRequest) GetTransaction() *Transaction {\n\tif m != nil {\n\t\treturn m.Transaction\n\t}\n\treturn nil\n}\n\nfunc (m *AddActionsRequest) GetAction() []*Action {\n\tif m != nil {\n\t\treturn m.Action\n\t}\n\treturn nil\n}\n\ntype AddActionsResponse struct {\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *AddActionsResponse) Reset()         { *m = AddActionsResponse{} }\nfunc (m *AddActionsResponse) String() string { return proto.CompactTextString(m) }\nfunc (*AddActionsResponse) ProtoMessage()    {}\n\ntype BeginTransactionRequest struct {\n\tHeader           *InternalHeader `protobuf:\"bytes,3,opt,name=header\" json:\"header,omitempty\"`\n\tApp              *string         `protobuf:\"bytes,1,req,name=app\" json:\"app,omitempty\"`\n\tAllowMultipleEg  *bool           `protobuf:\"varint,2,opt,name=allow_multiple_eg,def=0\" json:\"allow_multiple_eg,omitempty\"`\n\tXXX_unrecognized []byte          `json:\"-\"`\n}\n\nfunc (m *BeginTransactionRequest) Reset()         { *m = BeginTransactionRequest{} }\nfunc (m *BeginTransactionRequest) String() string { return proto.CompactTextString(m) }\nfunc (*BeginTransactionRequest) ProtoMessage()    {}\n\nconst Default_BeginTransactionRequest_AllowMultipleEg bool = false\n\nfunc (m *BeginTransactionRequest) GetHeader() *InternalHeader {\n\tif m != nil {\n\t\treturn m.Header\n\t}\n\treturn nil\n}\n\nfunc (m *BeginTransactionRequest) GetApp() string {\n\tif m != nil && m.App != nil {\n\t\treturn *m.App\n\t}\n\treturn \"\"\n}\n\nfunc (m *BeginTransactionRequest) GetAllowMultipleEg() bool {\n\tif m != nil && m.AllowMultipleEg != nil {\n\t\treturn *m.AllowMultipleEg\n\t}\n\treturn Default_BeginTransactionRequest_AllowMultipleEg\n}\n\ntype CommitResponse struct {\n\tCost             *Cost                     `protobuf:\"bytes,1,opt,name=cost\" json:\"cost,omitempty\"`\n\tVersion          []*CommitResponse_Version `protobuf:\"group,3,rep,name=Version\" json:\"version,omitempty\"`\n\tXXX_unrecognized []byte                    `json:\"-\"`\n}\n\nfunc (m *CommitResponse) Reset()         { *m = CommitResponse{} }\nfunc (m *CommitResponse) String() string { return proto.CompactTextString(m) }\nfunc (*CommitResponse) ProtoMessage()    {}\n\nfunc (m *CommitResponse) GetCost() *Cost {\n\tif m != nil {\n\t\treturn m.Cost\n\t}\n\treturn nil\n}\n\nfunc (m *CommitResponse) GetVersion() []*CommitResponse_Version {\n\tif m != nil {\n\t\treturn m.Version\n\t}\n\treturn nil\n}\n\ntype CommitResponse_Version struct {\n\tRootEntityKey    *Reference `protobuf:\"bytes,4,req,name=root_entity_key\" json:\"root_entity_key,omitempty\"`\n\tVersion          *int64     `protobuf:\"varint,5,req,name=version\" json:\"version,omitempty\"`\n\tXXX_unrecognized []byte     `json:\"-\"`\n}\n\nfunc (m *CommitResponse_Version) Reset()         { *m = CommitResponse_Version{} }\nfunc (m *CommitResponse_Version) String() string { return proto.CompactTextString(m) }\nfunc (*CommitResponse_Version) ProtoMessage()    {}\n\nfunc (m *CommitResponse_Version) GetRootEntityKey() *Reference {\n\tif m != nil {\n\t\treturn m.RootEntityKey\n\t}\n\treturn nil\n}\n\nfunc (m *CommitResponse_Version) GetVersion() int64 {\n\tif m != nil && m.Version != nil {\n\t\treturn *m.Version\n\t}\n\treturn 0\n}\n\nfunc init() {\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto",
    "content": "syntax = \"proto2\";\noption go_package = \"datastore\";\n\npackage appengine;\n\nmessage Action{}\n\nmessage PropertyValue {\n  optional int64 int64Value = 1;\n  optional bool booleanValue = 2;\n  optional string stringValue = 3;\n  optional double doubleValue = 4;\n\n  optional group PointValue = 5 {\n    required double x = 6;\n    required double y = 7;\n  }\n\n  optional group UserValue = 8 {\n    required string email = 9;\n    required string auth_domain = 10;\n    optional string nickname = 11;\n    optional string federated_identity = 21;\n    optional string federated_provider = 22;\n  }\n\n  optional group ReferenceValue = 12 {\n    required string app = 13;\n    optional string name_space = 20;\n    repeated group PathElement = 14 {\n      required string type = 15;\n      optional int64 id = 16;\n      optional string name = 17;\n    }\n  }\n}\n\nmessage Property {\n  enum Meaning {\n    NO_MEANING = 0;\n    BLOB = 14;\n    TEXT = 15;\n    BYTESTRING = 16;\n\n    ATOM_CATEGORY = 1;\n    ATOM_LINK = 2;\n    ATOM_TITLE = 3;\n    ATOM_CONTENT = 4;\n    ATOM_SUMMARY = 5;\n    ATOM_AUTHOR = 6;\n\n    GD_WHEN = 7;\n    GD_EMAIL = 8;\n    GEORSS_POINT = 9;\n    GD_IM = 10;\n\n    GD_PHONENUMBER = 11;\n    GD_POSTALADDRESS = 12;\n\n    GD_RATING = 13;\n\n    BLOBKEY = 17;\n    ENTITY_PROTO = 19;\n\n    INDEX_VALUE = 18;\n  };\n\n  optional Meaning meaning = 1 [default = NO_MEANING];\n  optional string meaning_uri = 2;\n\n  required string name = 3;\n\n  required PropertyValue value = 5;\n\n  required bool multiple = 4;\n\n  optional bool searchable = 6 [default=false];\n\n  enum FtsTokenizationOption {\n    HTML = 1;\n    ATOM = 2;\n  }\n\n  optional FtsTokenizationOption fts_tokenization_option = 8;\n\n  optional string locale = 9 [default = \"en\"];\n}\n\nmessage Path {\n  repeated group Element = 1 {\n    required string type = 2;\n    optional int64 id = 3;\n    optional string name = 4;\n  }\n}\n\nmessage Reference {\n  required string app = 13;\n  optional string name_space = 20;\n  required Path path = 14;\n}\n\nmessage User {\n  required string email = 1;\n  required string auth_domain = 2;\n  optional string nickname = 3;\n  optional string federated_identity = 6;\n  optional string federated_provider = 7;\n}\n\nmessage EntityProto {\n  required Reference key = 13;\n  required Path entity_group = 16;\n  optional User owner = 17;\n\n  enum Kind {\n    GD_CONTACT = 1;\n    GD_EVENT = 2;\n    GD_MESSAGE = 3;\n  }\n  optional Kind kind = 4;\n  optional string kind_uri = 5;\n\n  repeated Property property = 14;\n  repeated Property raw_property = 15;\n\n  optional int32 rank = 18;\n}\n\nmessage CompositeProperty {\n  required int64 index_id = 1;\n  repeated string value = 2;\n}\n\nmessage Index {\n  required string entity_type = 1;\n  required bool ancestor = 5;\n  repeated group Property = 2 {\n    required string name = 3;\n    enum Direction {\n      ASCENDING = 1;\n      DESCENDING = 2;\n    }\n    optional Direction direction = 4 [default = ASCENDING];\n  }\n}\n\nmessage CompositeIndex {\n  required string app_id = 1;\n  required int64 id = 2;\n  required Index definition = 3;\n\n  enum State {\n    WRITE_ONLY = 1;\n    READ_WRITE = 2;\n    DELETED = 3;\n    ERROR = 4;\n  }\n  required State state = 4;\n\n  optional bool only_use_if_required = 6 [default = false];\n}\n\nmessage IndexPostfix {\n  message IndexValue {\n    required string property_name = 1;\n    required PropertyValue value = 2;\n  }\n\n  repeated IndexValue index_value = 1;\n\n  optional Reference key = 2;\n\n  optional bool before = 3 [default=true];\n}\n\nmessage IndexPosition {\n  optional string key = 1;\n\n  optional bool before = 2 [default=true];\n}\n\nmessage Snapshot {\n  enum Status {\n    INACTIVE = 0;\n    ACTIVE = 1;\n  }\n\n  required int64 ts = 1;\n}\n\nmessage InternalHeader {\n  optional string qos = 1;\n}\n\nmessage Transaction {\n  optional InternalHeader header = 4;\n  required fixed64 handle = 1;\n  required string app = 2;\n  optional bool mark_changes = 3 [default = false];\n}\n\nmessage Query {\n  optional InternalHeader header = 39;\n\n  required string app = 1;\n  optional string name_space = 29;\n\n  optional string kind = 3;\n  optional Reference ancestor = 17;\n\n  repeated group Filter = 4 {\n    enum Operator {\n      LESS_THAN = 1;\n      LESS_THAN_OR_EQUAL = 2;\n      GREATER_THAN = 3;\n      GREATER_THAN_OR_EQUAL = 4;\n      EQUAL = 5;\n      IN = 6;\n      EXISTS = 7;\n    }\n\n    required Operator op = 6;\n    repeated Property property = 14;\n  }\n\n  optional string search_query = 8;\n\n  repeated group Order = 9 {\n    enum Direction {\n      ASCENDING = 1;\n      DESCENDING = 2;\n    }\n\n    required string property = 10;\n    optional Direction direction = 11 [default = ASCENDING];\n  }\n\n  enum Hint {\n    ORDER_FIRST = 1;\n    ANCESTOR_FIRST = 2;\n    FILTER_FIRST = 3;\n  }\n  optional Hint hint = 18;\n\n  optional int32 count = 23;\n\n  optional int32 offset = 12 [default = 0];\n\n  optional int32 limit = 16;\n\n  optional CompiledCursor compiled_cursor = 30;\n  optional CompiledCursor end_compiled_cursor = 31;\n\n  repeated CompositeIndex composite_index = 19;\n\n  optional bool require_perfect_plan = 20 [default = false];\n\n  optional bool keys_only = 21 [default = false];\n\n  optional Transaction transaction = 22;\n\n  optional bool compile = 25 [default = false];\n\n  optional int64 failover_ms = 26;\n\n  optional bool strong = 32;\n\n  repeated string property_name = 33;\n\n  repeated string group_by_property_name = 34;\n\n  optional bool distinct = 24;\n\n  optional int64 min_safe_time_seconds = 35;\n\n  repeated string safe_replica_name = 36;\n\n  optional bool persist_offset = 37 [default=false];\n}\n\nmessage CompiledQuery {\n  required group PrimaryScan = 1 {\n    optional string index_name = 2;\n\n    optional string start_key = 3;\n    optional bool start_inclusive = 4;\n    optional string end_key = 5;\n    optional bool end_inclusive = 6;\n\n    repeated string start_postfix_value = 22;\n    repeated string end_postfix_value = 23;\n\n    optional int64 end_unapplied_log_timestamp_us = 19;\n  }\n\n  repeated group MergeJoinScan = 7 {\n    required string index_name = 8;\n\n    repeated string prefix_value = 9;\n\n    optional bool value_prefix = 20 [default=false];\n  }\n\n  optional Index index_def = 21;\n\n  optional int32 offset = 10 [default = 0];\n\n  optional int32 limit = 11;\n\n  required bool keys_only = 12;\n\n  repeated string property_name = 24;\n\n  optional int32 distinct_infix_size = 25;\n\n  optional group EntityFilter = 13 {\n    optional bool distinct = 14 [default=false];\n\n    optional string kind = 17;\n    optional Reference ancestor = 18;\n  }\n}\n\nmessage CompiledCursor {\n  optional group Position = 2 {\n    optional string start_key = 27;\n\n    repeated group IndexValue = 29 {\n      optional string property = 30;\n      required PropertyValue value = 31;\n    }\n\n    optional Reference key = 32;\n\n    optional bool start_inclusive = 28 [default=true];\n  }\n}\n\nmessage Cursor {\n  required fixed64 cursor = 1;\n\n  optional string app = 2;\n}\n\nmessage Error {\n  enum ErrorCode {\n    BAD_REQUEST = 1;\n    CONCURRENT_TRANSACTION = 2;\n    INTERNAL_ERROR = 3;\n    NEED_INDEX = 4;\n    TIMEOUT = 5;\n    PERMISSION_DENIED = 6;\n    BIGTABLE_ERROR = 7;\n    COMMITTED_BUT_STILL_APPLYING = 8;\n    CAPABILITY_DISABLED = 9;\n    TRY_ALTERNATE_BACKEND = 10;\n    SAFE_TIME_TOO_OLD = 11;\n  }\n}\n\nmessage Cost {\n  optional int32 index_writes = 1;\n  optional int32 index_write_bytes = 2;\n  optional int32 entity_writes = 3;\n  optional int32 entity_write_bytes = 4;\n  optional group CommitCost = 5 {\n    optional int32 requested_entity_puts = 6;\n    optional int32 requested_entity_deletes = 7;\n  };\n  optional int32 approximate_storage_delta = 8;\n  optional int32 id_sequence_updates = 9;\n}\n\nmessage GetRequest {\n  optional InternalHeader header = 6;\n\n  repeated Reference key = 1;\n  optional Transaction transaction = 2;\n\n  optional int64 failover_ms = 3;\n\n  optional bool strong = 4;\n\n  optional bool allow_deferred = 5 [default=false];\n}\n\nmessage GetResponse {\n  repeated group Entity = 1 {\n    optional EntityProto entity = 2;\n    optional Reference key = 4;\n\n    optional int64 version = 3;\n  }\n\n  repeated Reference deferred = 5;\n\n  optional bool in_order = 6 [default=true];\n}\n\nmessage PutRequest {\n  optional InternalHeader header = 11;\n\n  repeated EntityProto entity = 1;\n  optional Transaction transaction = 2;\n  repeated CompositeIndex composite_index = 3;\n\n  optional bool trusted = 4 [default = false];\n\n  optional bool force = 7 [default = false];\n\n  optional bool mark_changes = 8 [default = false];\n  repeated Snapshot snapshot = 9;\n\n  enum AutoIdPolicy {\n    CURRENT = 0;\n    SEQUENTIAL = 1;\n  }\n  optional AutoIdPolicy auto_id_policy = 10 [default = CURRENT];\n}\n\nmessage PutResponse {\n  repeated Reference key = 1;\n  optional Cost cost = 2;\n  repeated int64 version = 3;\n}\n\nmessage TouchRequest {\n  optional InternalHeader header = 10;\n\n  repeated Reference key = 1;\n  repeated CompositeIndex composite_index = 2;\n  optional bool force = 3 [default = false];\n  repeated Snapshot snapshot = 9;\n}\n\nmessage TouchResponse {\n  optional Cost cost = 1;\n}\n\nmessage DeleteRequest {\n  optional InternalHeader header = 10;\n\n  repeated Reference key = 6;\n  optional Transaction transaction = 5;\n\n  optional bool trusted = 4 [default = false];\n\n  optional bool force = 7 [default = false];\n\n  optional bool mark_changes = 8 [default = false];\n  repeated Snapshot snapshot = 9;\n}\n\nmessage DeleteResponse {\n  optional Cost cost = 1;\n  repeated int64 version = 3;\n}\n\nmessage NextRequest {\n  optional InternalHeader header = 5;\n\n  required Cursor cursor = 1;\n  optional int32 count = 2;\n\n  optional int32 offset = 4 [default = 0];\n\n  optional bool compile = 3 [default = false];\n}\n\nmessage QueryResult {\n  optional Cursor cursor = 1;\n\n  repeated EntityProto result = 2;\n\n  optional int32 skipped_results = 7;\n\n  required bool more_results = 3;\n\n  optional bool keys_only = 4;\n\n  optional bool index_only = 9;\n\n  optional bool small_ops = 10;\n\n  optional CompiledQuery compiled_query = 5;\n\n  optional CompiledCursor compiled_cursor = 6;\n\n  repeated CompositeIndex index = 8;\n\n  repeated int64 version = 11;\n}\n\nmessage AllocateIdsRequest {\n  optional InternalHeader header = 4;\n\n  optional Reference model_key = 1;\n\n  optional int64 size = 2;\n\n  optional int64 max = 3;\n\n  repeated Reference reserve = 5;\n}\n\nmessage AllocateIdsResponse {\n  required int64 start = 1;\n  required int64 end = 2;\n  optional Cost cost = 3;\n}\n\nmessage CompositeIndices {\n  repeated CompositeIndex index = 1;\n}\n\nmessage AddActionsRequest {\n  optional InternalHeader header = 3;\n\n  required Transaction transaction = 1;\n  repeated Action action = 2;\n}\n\nmessage AddActionsResponse {\n}\n\nmessage BeginTransactionRequest {\n  optional InternalHeader header = 3;\n\n  required string app = 1;\n  optional bool allow_multiple_eg = 2 [default = false];\n}\n\nmessage CommitResponse {\n  optional Cost cost = 1;\n\n  repeated group Version = 3 {\n    required Reference root_entity_key = 4;\n    required int64 version = 5;\n  }\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/identity.go",
    "content": "// Copyright 2011 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\npackage internal\n\nimport netcontext \"golang.org/x/net/context\"\n\n// These functions are implementations of the wrapper functions\n// in ../appengine/identity.go. See that file for commentary.\n\nfunc AppID(c netcontext.Context) string {\n\treturn appID(FullyQualifiedAppID(c))\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/identity_classic.go",
    "content": "// Copyright 2015 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// +build appengine\n\npackage internal\n\nimport (\n\t\"appengine\"\n\n\tnetcontext \"golang.org/x/net/context\"\n)\n\nfunc DefaultVersionHostname(ctx netcontext.Context) string {\n\treturn appengine.DefaultVersionHostname(fromContext(ctx))\n}\n\nfunc RequestID(ctx netcontext.Context) string  { return appengine.RequestID(fromContext(ctx)) }\nfunc Datacenter(_ netcontext.Context) string   { return appengine.Datacenter() }\nfunc ServerSoftware() string                   { return appengine.ServerSoftware() }\nfunc ModuleName(ctx netcontext.Context) string { return appengine.ModuleName(fromContext(ctx)) }\nfunc VersionID(ctx netcontext.Context) string  { return appengine.VersionID(fromContext(ctx)) }\nfunc InstanceID() string                       { return appengine.InstanceID() }\nfunc IsDevAppServer() bool                     { return appengine.IsDevAppServer() }\n\nfunc fullyQualifiedAppID(ctx netcontext.Context) string { return fromContext(ctx).FullyQualifiedAppID() }\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/identity_vm.go",
    "content": "// Copyright 2011 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// +build !appengine\n\npackage internal\n\nimport (\n\t\"net/http\"\n\t\"os\"\n\n\tnetcontext \"golang.org/x/net/context\"\n)\n\n// These functions are implementations of the wrapper functions\n// in ../appengine/identity.go. See that file for commentary.\n\nconst (\n\thDefaultVersionHostname = \"X-AppEngine-Default-Version-Hostname\"\n\thRequestLogId           = \"X-AppEngine-Request-Log-Id\"\n\thDatacenter             = \"X-AppEngine-Datacenter\"\n)\n\nfunc ctxHeaders(ctx netcontext.Context) http.Header {\n\treturn fromContext(ctx).Request().Header\n}\n\nfunc DefaultVersionHostname(ctx netcontext.Context) string {\n\treturn ctxHeaders(ctx).Get(hDefaultVersionHostname)\n}\n\nfunc RequestID(ctx netcontext.Context) string {\n\treturn ctxHeaders(ctx).Get(hRequestLogId)\n}\n\nfunc Datacenter(ctx netcontext.Context) string {\n\treturn ctxHeaders(ctx).Get(hDatacenter)\n}\n\nfunc ServerSoftware() string {\n\t// TODO(dsymonds): Remove fallback when we've verified this.\n\tif s := os.Getenv(\"SERVER_SOFTWARE\"); s != \"\" {\n\t\treturn s\n\t}\n\treturn \"Google App Engine/1.x.x\"\n}\n\n// TODO(dsymonds): Remove the metadata fetches.\n\nfunc ModuleName(_ netcontext.Context) string {\n\tif s := os.Getenv(\"GAE_MODULE_NAME\"); s != \"\" {\n\t\treturn s\n\t}\n\treturn string(mustGetMetadata(\"instance/attributes/gae_backend_name\"))\n}\n\nfunc VersionID(_ netcontext.Context) string {\n\tif s1, s2 := os.Getenv(\"GAE_MODULE_VERSION\"), os.Getenv(\"GAE_MINOR_VERSION\"); s1 != \"\" && s2 != \"\" {\n\t\treturn s1 + \".\" + s2\n\t}\n\treturn string(mustGetMetadata(\"instance/attributes/gae_backend_version\")) + \".\" + string(mustGetMetadata(\"instance/attributes/gae_backend_minor_version\"))\n}\n\nfunc InstanceID() string {\n\tif s := os.Getenv(\"GAE_MODULE_INSTANCE\"); s != \"\" {\n\t\treturn s\n\t}\n\treturn string(mustGetMetadata(\"instance/attributes/gae_backend_instance\"))\n}\n\nfunc partitionlessAppID() string {\n\t// gae_project has everything except the partition prefix.\n\tappID := os.Getenv(\"GAE_LONG_APP_ID\")\n\tif appID == \"\" {\n\t\tappID = string(mustGetMetadata(\"instance/attributes/gae_project\"))\n\t}\n\treturn appID\n}\n\nfunc fullyQualifiedAppID(_ netcontext.Context) string {\n\tappID := partitionlessAppID()\n\n\tpart := os.Getenv(\"GAE_PARTITION\")\n\tif part == \"\" {\n\t\tpart = string(mustGetMetadata(\"instance/attributes/gae_partition\"))\n\t}\n\n\tif part != \"\" {\n\t\tappID = part + \"~\" + appID\n\t}\n\treturn appID\n}\n\nfunc IsDevAppServer() bool {\n\treturn os.Getenv(\"RUN_WITH_DEVAPPSERVER\") != \"\"\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/internal.go",
    "content": "// Copyright 2011 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// Package internal provides support for package appengine.\n//\n// Programs should not use this package directly. Its API is not stable.\n// Use packages appengine and appengine/* instead.\npackage internal\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/golang/protobuf/proto\"\n\n\tremotepb \"google.golang.org/appengine/internal/remote_api\"\n)\n\n// errorCodeMaps is a map of service name to the error code map for the service.\nvar errorCodeMaps = make(map[string]map[int32]string)\n\n// RegisterErrorCodeMap is called from API implementations to register their\n// error code map. This should only be called from init functions.\nfunc RegisterErrorCodeMap(service string, m map[int32]string) {\n\terrorCodeMaps[service] = m\n}\n\ntype timeoutCodeKey struct {\n\tservice string\n\tcode    int32\n}\n\n// timeoutCodes is the set of service+code pairs that represent timeouts.\nvar timeoutCodes = make(map[timeoutCodeKey]bool)\n\nfunc RegisterTimeoutErrorCode(service string, code int32) {\n\ttimeoutCodes[timeoutCodeKey{service, code}] = true\n}\n\n// APIError is the type returned by appengine.Context's Call method\n// when an API call fails in an API-specific way. This may be, for instance,\n// a taskqueue API call failing with TaskQueueServiceError::UNKNOWN_QUEUE.\ntype APIError struct {\n\tService string\n\tDetail  string\n\tCode    int32 // API-specific error code\n}\n\nfunc (e *APIError) Error() string {\n\tif e.Code == 0 {\n\t\tif e.Detail == \"\" {\n\t\t\treturn \"APIError <empty>\"\n\t\t}\n\t\treturn e.Detail\n\t}\n\ts := fmt.Sprintf(\"API error %d\", e.Code)\n\tif m, ok := errorCodeMaps[e.Service]; ok {\n\t\ts += \" (\" + e.Service + \": \" + m[e.Code] + \")\"\n\t} else {\n\t\t// Shouldn't happen, but provide a bit more detail if it does.\n\t\ts = e.Service + \" \" + s\n\t}\n\tif e.Detail != \"\" {\n\t\ts += \": \" + e.Detail\n\t}\n\treturn s\n}\n\nfunc (e *APIError) IsTimeout() bool {\n\treturn timeoutCodes[timeoutCodeKey{e.Service, e.Code}]\n}\n\n// CallError is the type returned by appengine.Context's Call method when an\n// API call fails in a generic way, such as RpcError::CAPABILITY_DISABLED.\ntype CallError struct {\n\tDetail string\n\tCode   int32\n\t// TODO: Remove this if we get a distinguishable error code.\n\tTimeout bool\n}\n\nfunc (e *CallError) Error() string {\n\tvar msg string\n\tswitch remotepb.RpcError_ErrorCode(e.Code) {\n\tcase remotepb.RpcError_UNKNOWN:\n\t\treturn e.Detail\n\tcase remotepb.RpcError_OVER_QUOTA:\n\t\tmsg = \"Over quota\"\n\tcase remotepb.RpcError_CAPABILITY_DISABLED:\n\t\tmsg = \"Capability disabled\"\n\tcase remotepb.RpcError_CANCELLED:\n\t\tmsg = \"Canceled\"\n\tdefault:\n\t\tmsg = fmt.Sprintf(\"Call error %d\", e.Code)\n\t}\n\ts := msg + \": \" + e.Detail\n\tif e.Timeout {\n\t\ts += \" (timeout)\"\n\t}\n\treturn s\n}\n\nfunc (e *CallError) IsTimeout() bool {\n\treturn e.Timeout\n}\n\n// NamespaceMods is a map from API service to a function that will mutate an RPC request to attach a namespace.\n// The function should be prepared to be called on the same message more than once; it should only modify the\n// RPC request the first time.\nvar NamespaceMods = make(map[string]func(m proto.Message, namespace string))\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/internal_vm_test.go",
    "content": "// Copyright 2014 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// +build !appengine\n\npackage internal\n\nimport (\n\t\"io\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"testing\"\n)\n\nfunc TestInstallingHealthChecker(t *testing.T) {\n\ttry := func(desc string, mux *http.ServeMux, wantCode int, wantBody string) {\n\t\tinstallHealthChecker(mux)\n\t\tsrv := httptest.NewServer(mux)\n\t\tdefer srv.Close()\n\n\t\tresp, err := http.Get(srv.URL + \"/_ah/health\")\n\t\tif err != nil {\n\t\t\tt.Errorf(\"%s: http.Get: %v\", desc, err)\n\t\t\treturn\n\t\t}\n\t\tdefer resp.Body.Close()\n\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"%s: reading body: %v\", desc, err)\n\t\t\treturn\n\t\t}\n\n\t\tif resp.StatusCode != wantCode {\n\t\t\tt.Errorf(\"%s: got HTTP %d, want %d\", desc, resp.StatusCode, wantCode)\n\t\t\treturn\n\t\t}\n\t\tif wantBody != \"\" && string(body) != wantBody {\n\t\t\tt.Errorf(\"%s: got HTTP body %q, want %q\", desc, body, wantBody)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// If there's no handlers, or only a root handler, a health checker should be installed.\n\ttry(\"empty mux\", http.NewServeMux(), 200, \"ok\")\n\tmux := http.NewServeMux()\n\tmux.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tio.WriteString(w, \"root handler\")\n\t})\n\ttry(\"mux with root handler\", mux, 200, \"ok\")\n\n\t// If there's a custom health check handler, one should not be installed.\n\tmux = http.NewServeMux()\n\tmux.HandleFunc(\"/_ah/health\", func(w http.ResponseWriter, r *http.Request) {\n\t\tw.WriteHeader(418)\n\t\tio.WriteString(w, \"I'm short and stout!\")\n\t})\n\ttry(\"mux with custom health checker\", mux, 418, \"I'm short and stout!\")\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/log/log_service.pb.go",
    "content": "// Code generated by protoc-gen-go.\n// source: google.golang.org/appengine/internal/log/log_service.proto\n// DO NOT EDIT!\n\n/*\nPackage log is a generated protocol buffer package.\n\nIt is generated from these files:\n\tgoogle.golang.org/appengine/internal/log/log_service.proto\n\nIt has these top-level messages:\n\tLogServiceError\n\tUserAppLogLine\n\tUserAppLogGroup\n\tFlushRequest\n\tSetStatusRequest\n\tLogOffset\n\tLogLine\n\tRequestLog\n\tLogModuleVersion\n\tLogReadRequest\n\tLogReadResponse\n\tLogUsageRecord\n\tLogUsageRequest\n\tLogUsageResponse\n*/\npackage log\n\nimport proto \"github.com/golang/protobuf/proto\"\nimport fmt \"fmt\"\nimport math \"math\"\n\n// Reference imports to suppress errors if they are not otherwise used.\nvar _ = proto.Marshal\nvar _ = fmt.Errorf\nvar _ = math.Inf\n\ntype LogServiceError_ErrorCode int32\n\nconst (\n\tLogServiceError_OK              LogServiceError_ErrorCode = 0\n\tLogServiceError_INVALID_REQUEST LogServiceError_ErrorCode = 1\n\tLogServiceError_STORAGE_ERROR   LogServiceError_ErrorCode = 2\n)\n\nvar LogServiceError_ErrorCode_name = map[int32]string{\n\t0: \"OK\",\n\t1: \"INVALID_REQUEST\",\n\t2: \"STORAGE_ERROR\",\n}\nvar LogServiceError_ErrorCode_value = map[string]int32{\n\t\"OK\":              0,\n\t\"INVALID_REQUEST\": 1,\n\t\"STORAGE_ERROR\":   2,\n}\n\nfunc (x LogServiceError_ErrorCode) Enum() *LogServiceError_ErrorCode {\n\tp := new(LogServiceError_ErrorCode)\n\t*p = x\n\treturn p\n}\nfunc (x LogServiceError_ErrorCode) String() string {\n\treturn proto.EnumName(LogServiceError_ErrorCode_name, int32(x))\n}\nfunc (x *LogServiceError_ErrorCode) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(LogServiceError_ErrorCode_value, data, \"LogServiceError_ErrorCode\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = LogServiceError_ErrorCode(value)\n\treturn nil\n}\n\ntype LogServiceError struct {\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *LogServiceError) Reset()         { *m = LogServiceError{} }\nfunc (m *LogServiceError) String() string { return proto.CompactTextString(m) }\nfunc (*LogServiceError) ProtoMessage()    {}\n\ntype UserAppLogLine struct {\n\tTimestampUsec    *int64  `protobuf:\"varint,1,req,name=timestamp_usec\" json:\"timestamp_usec,omitempty\"`\n\tLevel            *int64  `protobuf:\"varint,2,req,name=level\" json:\"level,omitempty\"`\n\tMessage          *string `protobuf:\"bytes,3,req,name=message\" json:\"message,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *UserAppLogLine) Reset()         { *m = UserAppLogLine{} }\nfunc (m *UserAppLogLine) String() string { return proto.CompactTextString(m) }\nfunc (*UserAppLogLine) ProtoMessage()    {}\n\nfunc (m *UserAppLogLine) GetTimestampUsec() int64 {\n\tif m != nil && m.TimestampUsec != nil {\n\t\treturn *m.TimestampUsec\n\t}\n\treturn 0\n}\n\nfunc (m *UserAppLogLine) GetLevel() int64 {\n\tif m != nil && m.Level != nil {\n\t\treturn *m.Level\n\t}\n\treturn 0\n}\n\nfunc (m *UserAppLogLine) GetMessage() string {\n\tif m != nil && m.Message != nil {\n\t\treturn *m.Message\n\t}\n\treturn \"\"\n}\n\ntype UserAppLogGroup struct {\n\tLogLine          []*UserAppLogLine `protobuf:\"bytes,2,rep,name=log_line\" json:\"log_line,omitempty\"`\n\tXXX_unrecognized []byte            `json:\"-\"`\n}\n\nfunc (m *UserAppLogGroup) Reset()         { *m = UserAppLogGroup{} }\nfunc (m *UserAppLogGroup) String() string { return proto.CompactTextString(m) }\nfunc (*UserAppLogGroup) ProtoMessage()    {}\n\nfunc (m *UserAppLogGroup) GetLogLine() []*UserAppLogLine {\n\tif m != nil {\n\t\treturn m.LogLine\n\t}\n\treturn nil\n}\n\ntype FlushRequest struct {\n\tLogs             []byte `protobuf:\"bytes,1,opt,name=logs\" json:\"logs,omitempty\"`\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *FlushRequest) Reset()         { *m = FlushRequest{} }\nfunc (m *FlushRequest) String() string { return proto.CompactTextString(m) }\nfunc (*FlushRequest) ProtoMessage()    {}\n\nfunc (m *FlushRequest) GetLogs() []byte {\n\tif m != nil {\n\t\treturn m.Logs\n\t}\n\treturn nil\n}\n\ntype SetStatusRequest struct {\n\tStatus           *string `protobuf:\"bytes,1,req,name=status\" json:\"status,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *SetStatusRequest) Reset()         { *m = SetStatusRequest{} }\nfunc (m *SetStatusRequest) String() string { return proto.CompactTextString(m) }\nfunc (*SetStatusRequest) ProtoMessage()    {}\n\nfunc (m *SetStatusRequest) GetStatus() string {\n\tif m != nil && m.Status != nil {\n\t\treturn *m.Status\n\t}\n\treturn \"\"\n}\n\ntype LogOffset struct {\n\tRequestId        []byte `protobuf:\"bytes,1,opt,name=request_id\" json:\"request_id,omitempty\"`\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *LogOffset) Reset()         { *m = LogOffset{} }\nfunc (m *LogOffset) String() string { return proto.CompactTextString(m) }\nfunc (*LogOffset) ProtoMessage()    {}\n\nfunc (m *LogOffset) GetRequestId() []byte {\n\tif m != nil {\n\t\treturn m.RequestId\n\t}\n\treturn nil\n}\n\ntype LogLine struct {\n\tTime             *int64  `protobuf:\"varint,1,req,name=time\" json:\"time,omitempty\"`\n\tLevel            *int32  `protobuf:\"varint,2,req,name=level\" json:\"level,omitempty\"`\n\tLogMessage       *string `protobuf:\"bytes,3,req,name=log_message\" json:\"log_message,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *LogLine) Reset()         { *m = LogLine{} }\nfunc (m *LogLine) String() string { return proto.CompactTextString(m) }\nfunc (*LogLine) ProtoMessage()    {}\n\nfunc (m *LogLine) GetTime() int64 {\n\tif m != nil && m.Time != nil {\n\t\treturn *m.Time\n\t}\n\treturn 0\n}\n\nfunc (m *LogLine) GetLevel() int32 {\n\tif m != nil && m.Level != nil {\n\t\treturn *m.Level\n\t}\n\treturn 0\n}\n\nfunc (m *LogLine) GetLogMessage() string {\n\tif m != nil && m.LogMessage != nil {\n\t\treturn *m.LogMessage\n\t}\n\treturn \"\"\n}\n\ntype RequestLog struct {\n\tAppId                   *string    `protobuf:\"bytes,1,req,name=app_id\" json:\"app_id,omitempty\"`\n\tModuleId                *string    `protobuf:\"bytes,37,opt,name=module_id,def=default\" json:\"module_id,omitempty\"`\n\tVersionId               *string    `protobuf:\"bytes,2,req,name=version_id\" json:\"version_id,omitempty\"`\n\tRequestId               []byte     `protobuf:\"bytes,3,req,name=request_id\" json:\"request_id,omitempty\"`\n\tOffset                  *LogOffset `protobuf:\"bytes,35,opt,name=offset\" json:\"offset,omitempty\"`\n\tIp                      *string    `protobuf:\"bytes,4,req,name=ip\" json:\"ip,omitempty\"`\n\tNickname                *string    `protobuf:\"bytes,5,opt,name=nickname\" json:\"nickname,omitempty\"`\n\tStartTime               *int64     `protobuf:\"varint,6,req,name=start_time\" json:\"start_time,omitempty\"`\n\tEndTime                 *int64     `protobuf:\"varint,7,req,name=end_time\" json:\"end_time,omitempty\"`\n\tLatency                 *int64     `protobuf:\"varint,8,req,name=latency\" json:\"latency,omitempty\"`\n\tMcycles                 *int64     `protobuf:\"varint,9,req,name=mcycles\" json:\"mcycles,omitempty\"`\n\tMethod                  *string    `protobuf:\"bytes,10,req,name=method\" json:\"method,omitempty\"`\n\tResource                *string    `protobuf:\"bytes,11,req,name=resource\" json:\"resource,omitempty\"`\n\tHttpVersion             *string    `protobuf:\"bytes,12,req,name=http_version\" json:\"http_version,omitempty\"`\n\tStatus                  *int32     `protobuf:\"varint,13,req,name=status\" json:\"status,omitempty\"`\n\tResponseSize            *int64     `protobuf:\"varint,14,req,name=response_size\" json:\"response_size,omitempty\"`\n\tReferrer                *string    `protobuf:\"bytes,15,opt,name=referrer\" json:\"referrer,omitempty\"`\n\tUserAgent               *string    `protobuf:\"bytes,16,opt,name=user_agent\" json:\"user_agent,omitempty\"`\n\tUrlMapEntry             *string    `protobuf:\"bytes,17,req,name=url_map_entry\" json:\"url_map_entry,omitempty\"`\n\tCombined                *string    `protobuf:\"bytes,18,req,name=combined\" json:\"combined,omitempty\"`\n\tApiMcycles              *int64     `protobuf:\"varint,19,opt,name=api_mcycles\" json:\"api_mcycles,omitempty\"`\n\tHost                    *string    `protobuf:\"bytes,20,opt,name=host\" json:\"host,omitempty\"`\n\tCost                    *float64   `protobuf:\"fixed64,21,opt,name=cost\" json:\"cost,omitempty\"`\n\tTaskQueueName           *string    `protobuf:\"bytes,22,opt,name=task_queue_name\" json:\"task_queue_name,omitempty\"`\n\tTaskName                *string    `protobuf:\"bytes,23,opt,name=task_name\" json:\"task_name,omitempty\"`\n\tWasLoadingRequest       *bool      `protobuf:\"varint,24,opt,name=was_loading_request\" json:\"was_loading_request,omitempty\"`\n\tPendingTime             *int64     `protobuf:\"varint,25,opt,name=pending_time\" json:\"pending_time,omitempty\"`\n\tReplicaIndex            *int32     `protobuf:\"varint,26,opt,name=replica_index,def=-1\" json:\"replica_index,omitempty\"`\n\tFinished                *bool      `protobuf:\"varint,27,opt,name=finished,def=1\" json:\"finished,omitempty\"`\n\tCloneKey                []byte     `protobuf:\"bytes,28,opt,name=clone_key\" json:\"clone_key,omitempty\"`\n\tLine                    []*LogLine `protobuf:\"bytes,29,rep,name=line\" json:\"line,omitempty\"`\n\tLinesIncomplete         *bool      `protobuf:\"varint,36,opt,name=lines_incomplete\" json:\"lines_incomplete,omitempty\"`\n\tAppEngineRelease        []byte     `protobuf:\"bytes,38,opt,name=app_engine_release\" json:\"app_engine_release,omitempty\"`\n\tExitReason              *int32     `protobuf:\"varint,30,opt,name=exit_reason\" json:\"exit_reason,omitempty\"`\n\tWasThrottledForTime     *bool      `protobuf:\"varint,31,opt,name=was_throttled_for_time\" json:\"was_throttled_for_time,omitempty\"`\n\tWasThrottledForRequests *bool      `protobuf:\"varint,32,opt,name=was_throttled_for_requests\" json:\"was_throttled_for_requests,omitempty\"`\n\tThrottledTime           *int64     `protobuf:\"varint,33,opt,name=throttled_time\" json:\"throttled_time,omitempty\"`\n\tServerName              []byte     `protobuf:\"bytes,34,opt,name=server_name\" json:\"server_name,omitempty\"`\n\tXXX_unrecognized        []byte     `json:\"-\"`\n}\n\nfunc (m *RequestLog) Reset()         { *m = RequestLog{} }\nfunc (m *RequestLog) String() string { return proto.CompactTextString(m) }\nfunc (*RequestLog) ProtoMessage()    {}\n\nconst Default_RequestLog_ModuleId string = \"default\"\nconst Default_RequestLog_ReplicaIndex int32 = -1\nconst Default_RequestLog_Finished bool = true\n\nfunc (m *RequestLog) GetAppId() string {\n\tif m != nil && m.AppId != nil {\n\t\treturn *m.AppId\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetModuleId() string {\n\tif m != nil && m.ModuleId != nil {\n\t\treturn *m.ModuleId\n\t}\n\treturn Default_RequestLog_ModuleId\n}\n\nfunc (m *RequestLog) GetVersionId() string {\n\tif m != nil && m.VersionId != nil {\n\t\treturn *m.VersionId\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetRequestId() []byte {\n\tif m != nil {\n\t\treturn m.RequestId\n\t}\n\treturn nil\n}\n\nfunc (m *RequestLog) GetOffset() *LogOffset {\n\tif m != nil {\n\t\treturn m.Offset\n\t}\n\treturn nil\n}\n\nfunc (m *RequestLog) GetIp() string {\n\tif m != nil && m.Ip != nil {\n\t\treturn *m.Ip\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetNickname() string {\n\tif m != nil && m.Nickname != nil {\n\t\treturn *m.Nickname\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetStartTime() int64 {\n\tif m != nil && m.StartTime != nil {\n\t\treturn *m.StartTime\n\t}\n\treturn 0\n}\n\nfunc (m *RequestLog) GetEndTime() int64 {\n\tif m != nil && m.EndTime != nil {\n\t\treturn *m.EndTime\n\t}\n\treturn 0\n}\n\nfunc (m *RequestLog) GetLatency() int64 {\n\tif m != nil && m.Latency != nil {\n\t\treturn *m.Latency\n\t}\n\treturn 0\n}\n\nfunc (m *RequestLog) GetMcycles() int64 {\n\tif m != nil && m.Mcycles != nil {\n\t\treturn *m.Mcycles\n\t}\n\treturn 0\n}\n\nfunc (m *RequestLog) GetMethod() string {\n\tif m != nil && m.Method != nil {\n\t\treturn *m.Method\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetResource() string {\n\tif m != nil && m.Resource != nil {\n\t\treturn *m.Resource\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetHttpVersion() string {\n\tif m != nil && m.HttpVersion != nil {\n\t\treturn *m.HttpVersion\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetStatus() int32 {\n\tif m != nil && m.Status != nil {\n\t\treturn *m.Status\n\t}\n\treturn 0\n}\n\nfunc (m *RequestLog) GetResponseSize() int64 {\n\tif m != nil && m.ResponseSize != nil {\n\t\treturn *m.ResponseSize\n\t}\n\treturn 0\n}\n\nfunc (m *RequestLog) GetReferrer() string {\n\tif m != nil && m.Referrer != nil {\n\t\treturn *m.Referrer\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetUserAgent() string {\n\tif m != nil && m.UserAgent != nil {\n\t\treturn *m.UserAgent\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetUrlMapEntry() string {\n\tif m != nil && m.UrlMapEntry != nil {\n\t\treturn *m.UrlMapEntry\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetCombined() string {\n\tif m != nil && m.Combined != nil {\n\t\treturn *m.Combined\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetApiMcycles() int64 {\n\tif m != nil && m.ApiMcycles != nil {\n\t\treturn *m.ApiMcycles\n\t}\n\treturn 0\n}\n\nfunc (m *RequestLog) GetHost() string {\n\tif m != nil && m.Host != nil {\n\t\treturn *m.Host\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetCost() float64 {\n\tif m != nil && m.Cost != nil {\n\t\treturn *m.Cost\n\t}\n\treturn 0\n}\n\nfunc (m *RequestLog) GetTaskQueueName() string {\n\tif m != nil && m.TaskQueueName != nil {\n\t\treturn *m.TaskQueueName\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetTaskName() string {\n\tif m != nil && m.TaskName != nil {\n\t\treturn *m.TaskName\n\t}\n\treturn \"\"\n}\n\nfunc (m *RequestLog) GetWasLoadingRequest() bool {\n\tif m != nil && m.WasLoadingRequest != nil {\n\t\treturn *m.WasLoadingRequest\n\t}\n\treturn false\n}\n\nfunc (m *RequestLog) GetPendingTime() int64 {\n\tif m != nil && m.PendingTime != nil {\n\t\treturn *m.PendingTime\n\t}\n\treturn 0\n}\n\nfunc (m *RequestLog) GetReplicaIndex() int32 {\n\tif m != nil && m.ReplicaIndex != nil {\n\t\treturn *m.ReplicaIndex\n\t}\n\treturn Default_RequestLog_ReplicaIndex\n}\n\nfunc (m *RequestLog) GetFinished() bool {\n\tif m != nil && m.Finished != nil {\n\t\treturn *m.Finished\n\t}\n\treturn Default_RequestLog_Finished\n}\n\nfunc (m *RequestLog) GetCloneKey() []byte {\n\tif m != nil {\n\t\treturn m.CloneKey\n\t}\n\treturn nil\n}\n\nfunc (m *RequestLog) GetLine() []*LogLine {\n\tif m != nil {\n\t\treturn m.Line\n\t}\n\treturn nil\n}\n\nfunc (m *RequestLog) GetLinesIncomplete() bool {\n\tif m != nil && m.LinesIncomplete != nil {\n\t\treturn *m.LinesIncomplete\n\t}\n\treturn false\n}\n\nfunc (m *RequestLog) GetAppEngineRelease() []byte {\n\tif m != nil {\n\t\treturn m.AppEngineRelease\n\t}\n\treturn nil\n}\n\nfunc (m *RequestLog) GetExitReason() int32 {\n\tif m != nil && m.ExitReason != nil {\n\t\treturn *m.ExitReason\n\t}\n\treturn 0\n}\n\nfunc (m *RequestLog) GetWasThrottledForTime() bool {\n\tif m != nil && m.WasThrottledForTime != nil {\n\t\treturn *m.WasThrottledForTime\n\t}\n\treturn false\n}\n\nfunc (m *RequestLog) GetWasThrottledForRequests() bool {\n\tif m != nil && m.WasThrottledForRequests != nil {\n\t\treturn *m.WasThrottledForRequests\n\t}\n\treturn false\n}\n\nfunc (m *RequestLog) GetThrottledTime() int64 {\n\tif m != nil && m.ThrottledTime != nil {\n\t\treturn *m.ThrottledTime\n\t}\n\treturn 0\n}\n\nfunc (m *RequestLog) GetServerName() []byte {\n\tif m != nil {\n\t\treturn m.ServerName\n\t}\n\treturn nil\n}\n\ntype LogModuleVersion struct {\n\tModuleId         *string `protobuf:\"bytes,1,opt,name=module_id,def=default\" json:\"module_id,omitempty\"`\n\tVersionId        *string `protobuf:\"bytes,2,opt,name=version_id\" json:\"version_id,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *LogModuleVersion) Reset()         { *m = LogModuleVersion{} }\nfunc (m *LogModuleVersion) String() string { return proto.CompactTextString(m) }\nfunc (*LogModuleVersion) ProtoMessage()    {}\n\nconst Default_LogModuleVersion_ModuleId string = \"default\"\n\nfunc (m *LogModuleVersion) GetModuleId() string {\n\tif m != nil && m.ModuleId != nil {\n\t\treturn *m.ModuleId\n\t}\n\treturn Default_LogModuleVersion_ModuleId\n}\n\nfunc (m *LogModuleVersion) GetVersionId() string {\n\tif m != nil && m.VersionId != nil {\n\t\treturn *m.VersionId\n\t}\n\treturn \"\"\n}\n\ntype LogReadRequest struct {\n\tAppId             *string             `protobuf:\"bytes,1,req,name=app_id\" json:\"app_id,omitempty\"`\n\tVersionId         []string            `protobuf:\"bytes,2,rep,name=version_id\" json:\"version_id,omitempty\"`\n\tModuleVersion     []*LogModuleVersion `protobuf:\"bytes,19,rep,name=module_version\" json:\"module_version,omitempty\"`\n\tStartTime         *int64              `protobuf:\"varint,3,opt,name=start_time\" json:\"start_time,omitempty\"`\n\tEndTime           *int64              `protobuf:\"varint,4,opt,name=end_time\" json:\"end_time,omitempty\"`\n\tOffset            *LogOffset          `protobuf:\"bytes,5,opt,name=offset\" json:\"offset,omitempty\"`\n\tRequestId         [][]byte            `protobuf:\"bytes,6,rep,name=request_id\" json:\"request_id,omitempty\"`\n\tMinimumLogLevel   *int32              `protobuf:\"varint,7,opt,name=minimum_log_level\" json:\"minimum_log_level,omitempty\"`\n\tIncludeIncomplete *bool               `protobuf:\"varint,8,opt,name=include_incomplete\" json:\"include_incomplete,omitempty\"`\n\tCount             *int64              `protobuf:\"varint,9,opt,name=count\" json:\"count,omitempty\"`\n\tCombinedLogRegex  *string             `protobuf:\"bytes,14,opt,name=combined_log_regex\" json:\"combined_log_regex,omitempty\"`\n\tHostRegex         *string             `protobuf:\"bytes,15,opt,name=host_regex\" json:\"host_regex,omitempty\"`\n\tReplicaIndex      *int32              `protobuf:\"varint,16,opt,name=replica_index\" json:\"replica_index,omitempty\"`\n\tIncludeAppLogs    *bool               `protobuf:\"varint,10,opt,name=include_app_logs\" json:\"include_app_logs,omitempty\"`\n\tAppLogsPerRequest *int32              `protobuf:\"varint,17,opt,name=app_logs_per_request\" json:\"app_logs_per_request,omitempty\"`\n\tIncludeHost       *bool               `protobuf:\"varint,11,opt,name=include_host\" json:\"include_host,omitempty\"`\n\tIncludeAll        *bool               `protobuf:\"varint,12,opt,name=include_all\" json:\"include_all,omitempty\"`\n\tCacheIterator     *bool               `protobuf:\"varint,13,opt,name=cache_iterator\" json:\"cache_iterator,omitempty\"`\n\tNumShards         *int32              `protobuf:\"varint,18,opt,name=num_shards\" json:\"num_shards,omitempty\"`\n\tXXX_unrecognized  []byte              `json:\"-\"`\n}\n\nfunc (m *LogReadRequest) Reset()         { *m = LogReadRequest{} }\nfunc (m *LogReadRequest) String() string { return proto.CompactTextString(m) }\nfunc (*LogReadRequest) ProtoMessage()    {}\n\nfunc (m *LogReadRequest) GetAppId() string {\n\tif m != nil && m.AppId != nil {\n\t\treturn *m.AppId\n\t}\n\treturn \"\"\n}\n\nfunc (m *LogReadRequest) GetVersionId() []string {\n\tif m != nil {\n\t\treturn m.VersionId\n\t}\n\treturn nil\n}\n\nfunc (m *LogReadRequest) GetModuleVersion() []*LogModuleVersion {\n\tif m != nil {\n\t\treturn m.ModuleVersion\n\t}\n\treturn nil\n}\n\nfunc (m *LogReadRequest) GetStartTime() int64 {\n\tif m != nil && m.StartTime != nil {\n\t\treturn *m.StartTime\n\t}\n\treturn 0\n}\n\nfunc (m *LogReadRequest) GetEndTime() int64 {\n\tif m != nil && m.EndTime != nil {\n\t\treturn *m.EndTime\n\t}\n\treturn 0\n}\n\nfunc (m *LogReadRequest) GetOffset() *LogOffset {\n\tif m != nil {\n\t\treturn m.Offset\n\t}\n\treturn nil\n}\n\nfunc (m *LogReadRequest) GetRequestId() [][]byte {\n\tif m != nil {\n\t\treturn m.RequestId\n\t}\n\treturn nil\n}\n\nfunc (m *LogReadRequest) GetMinimumLogLevel() int32 {\n\tif m != nil && m.MinimumLogLevel != nil {\n\t\treturn *m.MinimumLogLevel\n\t}\n\treturn 0\n}\n\nfunc (m *LogReadRequest) GetIncludeIncomplete() bool {\n\tif m != nil && m.IncludeIncomplete != nil {\n\t\treturn *m.IncludeIncomplete\n\t}\n\treturn false\n}\n\nfunc (m *LogReadRequest) GetCount() int64 {\n\tif m != nil && m.Count != nil {\n\t\treturn *m.Count\n\t}\n\treturn 0\n}\n\nfunc (m *LogReadRequest) GetCombinedLogRegex() string {\n\tif m != nil && m.CombinedLogRegex != nil {\n\t\treturn *m.CombinedLogRegex\n\t}\n\treturn \"\"\n}\n\nfunc (m *LogReadRequest) GetHostRegex() string {\n\tif m != nil && m.HostRegex != nil {\n\t\treturn *m.HostRegex\n\t}\n\treturn \"\"\n}\n\nfunc (m *LogReadRequest) GetReplicaIndex() int32 {\n\tif m != nil && m.ReplicaIndex != nil {\n\t\treturn *m.ReplicaIndex\n\t}\n\treturn 0\n}\n\nfunc (m *LogReadRequest) GetIncludeAppLogs() bool {\n\tif m != nil && m.IncludeAppLogs != nil {\n\t\treturn *m.IncludeAppLogs\n\t}\n\treturn false\n}\n\nfunc (m *LogReadRequest) GetAppLogsPerRequest() int32 {\n\tif m != nil && m.AppLogsPerRequest != nil {\n\t\treturn *m.AppLogsPerRequest\n\t}\n\treturn 0\n}\n\nfunc (m *LogReadRequest) GetIncludeHost() bool {\n\tif m != nil && m.IncludeHost != nil {\n\t\treturn *m.IncludeHost\n\t}\n\treturn false\n}\n\nfunc (m *LogReadRequest) GetIncludeAll() bool {\n\tif m != nil && m.IncludeAll != nil {\n\t\treturn *m.IncludeAll\n\t}\n\treturn false\n}\n\nfunc (m *LogReadRequest) GetCacheIterator() bool {\n\tif m != nil && m.CacheIterator != nil {\n\t\treturn *m.CacheIterator\n\t}\n\treturn false\n}\n\nfunc (m *LogReadRequest) GetNumShards() int32 {\n\tif m != nil && m.NumShards != nil {\n\t\treturn *m.NumShards\n\t}\n\treturn 0\n}\n\ntype LogReadResponse struct {\n\tLog              []*RequestLog `protobuf:\"bytes,1,rep,name=log\" json:\"log,omitempty\"`\n\tOffset           *LogOffset    `protobuf:\"bytes,2,opt,name=offset\" json:\"offset,omitempty\"`\n\tLastEndTime      *int64        `protobuf:\"varint,3,opt,name=last_end_time\" json:\"last_end_time,omitempty\"`\n\tXXX_unrecognized []byte        `json:\"-\"`\n}\n\nfunc (m *LogReadResponse) Reset()         { *m = LogReadResponse{} }\nfunc (m *LogReadResponse) String() string { return proto.CompactTextString(m) }\nfunc (*LogReadResponse) ProtoMessage()    {}\n\nfunc (m *LogReadResponse) GetLog() []*RequestLog {\n\tif m != nil {\n\t\treturn m.Log\n\t}\n\treturn nil\n}\n\nfunc (m *LogReadResponse) GetOffset() *LogOffset {\n\tif m != nil {\n\t\treturn m.Offset\n\t}\n\treturn nil\n}\n\nfunc (m *LogReadResponse) GetLastEndTime() int64 {\n\tif m != nil && m.LastEndTime != nil {\n\t\treturn *m.LastEndTime\n\t}\n\treturn 0\n}\n\ntype LogUsageRecord struct {\n\tVersionId        *string `protobuf:\"bytes,1,opt,name=version_id\" json:\"version_id,omitempty\"`\n\tStartTime        *int32  `protobuf:\"varint,2,opt,name=start_time\" json:\"start_time,omitempty\"`\n\tEndTime          *int32  `protobuf:\"varint,3,opt,name=end_time\" json:\"end_time,omitempty\"`\n\tCount            *int64  `protobuf:\"varint,4,opt,name=count\" json:\"count,omitempty\"`\n\tTotalSize        *int64  `protobuf:\"varint,5,opt,name=total_size\" json:\"total_size,omitempty\"`\n\tRecords          *int32  `protobuf:\"varint,6,opt,name=records\" json:\"records,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *LogUsageRecord) Reset()         { *m = LogUsageRecord{} }\nfunc (m *LogUsageRecord) String() string { return proto.CompactTextString(m) }\nfunc (*LogUsageRecord) ProtoMessage()    {}\n\nfunc (m *LogUsageRecord) GetVersionId() string {\n\tif m != nil && m.VersionId != nil {\n\t\treturn *m.VersionId\n\t}\n\treturn \"\"\n}\n\nfunc (m *LogUsageRecord) GetStartTime() int32 {\n\tif m != nil && m.StartTime != nil {\n\t\treturn *m.StartTime\n\t}\n\treturn 0\n}\n\nfunc (m *LogUsageRecord) GetEndTime() int32 {\n\tif m != nil && m.EndTime != nil {\n\t\treturn *m.EndTime\n\t}\n\treturn 0\n}\n\nfunc (m *LogUsageRecord) GetCount() int64 {\n\tif m != nil && m.Count != nil {\n\t\treturn *m.Count\n\t}\n\treturn 0\n}\n\nfunc (m *LogUsageRecord) GetTotalSize() int64 {\n\tif m != nil && m.TotalSize != nil {\n\t\treturn *m.TotalSize\n\t}\n\treturn 0\n}\n\nfunc (m *LogUsageRecord) GetRecords() int32 {\n\tif m != nil && m.Records != nil {\n\t\treturn *m.Records\n\t}\n\treturn 0\n}\n\ntype LogUsageRequest struct {\n\tAppId            *string  `protobuf:\"bytes,1,req,name=app_id\" json:\"app_id,omitempty\"`\n\tVersionId        []string `protobuf:\"bytes,2,rep,name=version_id\" json:\"version_id,omitempty\"`\n\tStartTime        *int32   `protobuf:\"varint,3,opt,name=start_time\" json:\"start_time,omitempty\"`\n\tEndTime          *int32   `protobuf:\"varint,4,opt,name=end_time\" json:\"end_time,omitempty\"`\n\tResolutionHours  *uint32  `protobuf:\"varint,5,opt,name=resolution_hours,def=1\" json:\"resolution_hours,omitempty\"`\n\tCombineVersions  *bool    `protobuf:\"varint,6,opt,name=combine_versions\" json:\"combine_versions,omitempty\"`\n\tUsageVersion     *int32   `protobuf:\"varint,7,opt,name=usage_version\" json:\"usage_version,omitempty\"`\n\tVersionsOnly     *bool    `protobuf:\"varint,8,opt,name=versions_only\" json:\"versions_only,omitempty\"`\n\tXXX_unrecognized []byte   `json:\"-\"`\n}\n\nfunc (m *LogUsageRequest) Reset()         { *m = LogUsageRequest{} }\nfunc (m *LogUsageRequest) String() string { return proto.CompactTextString(m) }\nfunc (*LogUsageRequest) ProtoMessage()    {}\n\nconst Default_LogUsageRequest_ResolutionHours uint32 = 1\n\nfunc (m *LogUsageRequest) GetAppId() string {\n\tif m != nil && m.AppId != nil {\n\t\treturn *m.AppId\n\t}\n\treturn \"\"\n}\n\nfunc (m *LogUsageRequest) GetVersionId() []string {\n\tif m != nil {\n\t\treturn m.VersionId\n\t}\n\treturn nil\n}\n\nfunc (m *LogUsageRequest) GetStartTime() int32 {\n\tif m != nil && m.StartTime != nil {\n\t\treturn *m.StartTime\n\t}\n\treturn 0\n}\n\nfunc (m *LogUsageRequest) GetEndTime() int32 {\n\tif m != nil && m.EndTime != nil {\n\t\treturn *m.EndTime\n\t}\n\treturn 0\n}\n\nfunc (m *LogUsageRequest) GetResolutionHours() uint32 {\n\tif m != nil && m.ResolutionHours != nil {\n\t\treturn *m.ResolutionHours\n\t}\n\treturn Default_LogUsageRequest_ResolutionHours\n}\n\nfunc (m *LogUsageRequest) GetCombineVersions() bool {\n\tif m != nil && m.CombineVersions != nil {\n\t\treturn *m.CombineVersions\n\t}\n\treturn false\n}\n\nfunc (m *LogUsageRequest) GetUsageVersion() int32 {\n\tif m != nil && m.UsageVersion != nil {\n\t\treturn *m.UsageVersion\n\t}\n\treturn 0\n}\n\nfunc (m *LogUsageRequest) GetVersionsOnly() bool {\n\tif m != nil && m.VersionsOnly != nil {\n\t\treturn *m.VersionsOnly\n\t}\n\treturn false\n}\n\ntype LogUsageResponse struct {\n\tUsage            []*LogUsageRecord `protobuf:\"bytes,1,rep,name=usage\" json:\"usage,omitempty\"`\n\tSummary          *LogUsageRecord   `protobuf:\"bytes,2,opt,name=summary\" json:\"summary,omitempty\"`\n\tXXX_unrecognized []byte            `json:\"-\"`\n}\n\nfunc (m *LogUsageResponse) Reset()         { *m = LogUsageResponse{} }\nfunc (m *LogUsageResponse) String() string { return proto.CompactTextString(m) }\nfunc (*LogUsageResponse) ProtoMessage()    {}\n\nfunc (m *LogUsageResponse) GetUsage() []*LogUsageRecord {\n\tif m != nil {\n\t\treturn m.Usage\n\t}\n\treturn nil\n}\n\nfunc (m *LogUsageResponse) GetSummary() *LogUsageRecord {\n\tif m != nil {\n\t\treturn m.Summary\n\t}\n\treturn nil\n}\n\nfunc init() {\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/log/log_service.proto",
    "content": "syntax = \"proto2\";\noption go_package = \"log\";\n\npackage appengine;\n\nmessage LogServiceError {\n  enum ErrorCode {\n    OK  = 0;\n    INVALID_REQUEST = 1;\n    STORAGE_ERROR = 2;\n  }\n}\n\nmessage UserAppLogLine {\n  required int64 timestamp_usec = 1;\n  required int64 level = 2;\n  required string message = 3;\n}\n\nmessage UserAppLogGroup {\n  repeated UserAppLogLine log_line = 2;\n}\n\nmessage FlushRequest {\n  optional bytes logs = 1;\n}\n\nmessage SetStatusRequest {\n  required string status = 1;\n}\n\n\nmessage LogOffset {\n  optional bytes request_id = 1;\n}\n\nmessage LogLine {\n  required int64 time = 1;\n  required int32 level = 2;\n  required string log_message = 3;\n}\n\nmessage RequestLog {\n  required string app_id = 1;\n  optional string module_id = 37 [default=\"default\"];\n  required string version_id = 2;\n  required bytes request_id = 3;\n  optional LogOffset offset = 35;\n  required string ip = 4;\n  optional string nickname = 5;\n  required int64 start_time = 6;\n  required int64 end_time = 7;\n  required int64 latency = 8;\n  required int64 mcycles = 9;\n  required string method = 10;\n  required string resource = 11;\n  required string http_version = 12;\n  required int32 status = 13;\n  required int64 response_size = 14;\n  optional string referrer = 15;\n  optional string user_agent = 16;\n  required string url_map_entry = 17;\n  required string combined = 18;\n  optional int64 api_mcycles = 19;\n  optional string host = 20;\n  optional double cost = 21;\n\n  optional string task_queue_name = 22;\n  optional string task_name = 23;\n\n  optional bool was_loading_request = 24;\n  optional int64 pending_time = 25;\n  optional int32 replica_index = 26 [default = -1];\n  optional bool finished = 27 [default = true];\n  optional bytes clone_key = 28;\n\n  repeated LogLine line = 29;\n\n  optional bool lines_incomplete = 36;\n  optional bytes app_engine_release = 38;\n\n  optional int32 exit_reason = 30;\n  optional bool was_throttled_for_time = 31;\n  optional bool was_throttled_for_requests = 32;\n  optional int64 throttled_time = 33;\n\n  optional bytes server_name = 34;\n}\n\nmessage LogModuleVersion {\n  optional string module_id = 1 [default=\"default\"];\n  optional string version_id = 2;\n}\n\nmessage LogReadRequest {\n  required string app_id = 1;\n  repeated string version_id = 2;\n  repeated LogModuleVersion module_version = 19;\n\n  optional int64 start_time = 3;\n  optional int64 end_time = 4;\n  optional LogOffset offset = 5;\n  repeated bytes request_id = 6;\n\n  optional int32 minimum_log_level = 7;\n  optional bool include_incomplete = 8;\n  optional int64 count = 9;\n\n  optional string combined_log_regex = 14;\n  optional string host_regex = 15;\n  optional int32 replica_index = 16;\n\n  optional bool include_app_logs = 10;\n  optional int32 app_logs_per_request = 17;\n  optional bool include_host = 11;\n  optional bool include_all = 12;\n  optional bool cache_iterator = 13;\n  optional int32 num_shards = 18;\n}\n\nmessage LogReadResponse {\n  repeated RequestLog log = 1;\n  optional LogOffset offset = 2;\n  optional int64 last_end_time = 3;\n}\n\nmessage LogUsageRecord {\n  optional string version_id = 1;\n  optional int32 start_time = 2;\n  optional int32 end_time = 3;\n  optional int64 count = 4;\n  optional int64 total_size = 5;\n  optional int32 records = 6;\n}\n\nmessage LogUsageRequest {\n  required string app_id = 1;\n  repeated string version_id = 2;\n  optional int32 start_time = 3;\n  optional int32 end_time = 4;\n  optional uint32 resolution_hours = 5 [default = 1];\n  optional bool combine_versions = 6;\n  optional int32 usage_version = 7;\n  optional bool versions_only = 8;\n}\n\nmessage LogUsageResponse {\n  repeated LogUsageRecord usage = 1;\n  optional LogUsageRecord summary = 2;\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/main.go",
    "content": "// Copyright 2011 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// +build appengine\n\npackage internal\n\nimport (\n\t\"appengine_internal\"\n)\n\nfunc Main() {\n\tappengine_internal.Main()\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/main_vm.go",
    "content": "// Copyright 2011 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// +build !appengine\n\npackage internal\n\nimport (\n\t\"io\"\n\t\"log\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"os\"\n)\n\nfunc Main() {\n\tinstallHealthChecker(http.DefaultServeMux)\n\n\tport := \"8080\"\n\tif s := os.Getenv(\"PORT\"); s != \"\" {\n\t\tport = s\n\t}\n\n\tif err := http.ListenAndServe(\":\"+port, http.HandlerFunc(handleHTTP)); err != nil {\n\t\tlog.Fatalf(\"http.ListenAndServe: %v\", err)\n\t}\n}\n\nfunc installHealthChecker(mux *http.ServeMux) {\n\t// If no health check handler has been installed by this point, add a trivial one.\n\tconst healthPath = \"/_ah/health\"\n\threq := &http.Request{\n\t\tMethod: \"GET\",\n\t\tURL: &url.URL{\n\t\t\tPath: healthPath,\n\t\t},\n\t}\n\tif _, pat := mux.Handler(hreq); pat != healthPath {\n\t\tmux.HandleFunc(healthPath, func(w http.ResponseWriter, r *http.Request) {\n\t\t\tio.WriteString(w, \"ok\")\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/metadata.go",
    "content": "// Copyright 2014 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\npackage internal\n\n// This file has code for accessing metadata.\n//\n// References:\n//\thttps://cloud.google.com/compute/docs/metadata\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"net/http\"\n\t\"net/url\"\n)\n\nconst (\n\tmetadataHost = \"metadata\"\n\tmetadataPath = \"/computeMetadata/v1/\"\n)\n\nvar (\n\tmetadataRequestHeaders = http.Header{\n\t\t\"Metadata-Flavor\": []string{\"Google\"},\n\t}\n)\n\n// TODO(dsymonds): Do we need to support default values, like Python?\nfunc mustGetMetadata(key string) []byte {\n\tb, err := getMetadata(key)\n\tif err != nil {\n\t\tlog.Fatalf(\"Metadata fetch failed: %v\", err)\n\t}\n\treturn b\n}\n\nfunc getMetadata(key string) ([]byte, error) {\n\t// TODO(dsymonds): May need to use url.Parse to support keys with query args.\n\treq := &http.Request{\n\t\tMethod: \"GET\",\n\t\tURL: &url.URL{\n\t\t\tScheme: \"http\",\n\t\t\tHost:   metadataHost,\n\t\t\tPath:   metadataPath + key,\n\t\t},\n\t\tHeader: metadataRequestHeaders,\n\t\tHost:   metadataHost,\n\t}\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"metadata server returned HTTP %d\", resp.StatusCode)\n\t}\n\treturn ioutil.ReadAll(resp.Body)\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/net.go",
    "content": "// Copyright 2014 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\npackage internal\n\n// This file implements a network dialer that limits the number of concurrent connections.\n// It is only used for API calls.\n\nimport (\n\t\"log\"\n\t\"net\"\n\t\"runtime\"\n\t\"sync\"\n\t\"time\"\n)\n\nvar limitSem = make(chan int, 100) // TODO(dsymonds): Use environment variable.\n\nfunc limitRelease() {\n\t// non-blocking\n\tselect {\n\tcase <-limitSem:\n\tdefault:\n\t\t// This should not normally happen.\n\t\tlog.Print(\"appengine: unbalanced limitSem release!\")\n\t}\n}\n\nfunc limitDial(network, addr string) (net.Conn, error) {\n\tlimitSem <- 1\n\n\t// Dial with a timeout in case the API host is MIA.\n\t// The connection should normally be very fast.\n\tconn, err := net.DialTimeout(network, addr, 500*time.Millisecond)\n\tif err != nil {\n\t\tlimitRelease()\n\t\treturn nil, err\n\t}\n\tlc := &limitConn{Conn: conn}\n\truntime.SetFinalizer(lc, (*limitConn).Close) // shouldn't usually be required\n\treturn lc, nil\n}\n\ntype limitConn struct {\n\tclose sync.Once\n\tnet.Conn\n}\n\nfunc (lc *limitConn) Close() error {\n\tdefer lc.close.Do(func() {\n\t\tlimitRelease()\n\t\truntime.SetFinalizer(lc, nil)\n\t})\n\treturn lc.Conn.Close()\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/net_test.go",
    "content": "// Copyright 2014 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// +build !appengine\n\npackage internal\n\nimport (\n\t\"sync\"\n\t\"testing\"\n\t\"time\"\n\n\tnetcontext \"golang.org/x/net/context\"\n\n\tbasepb \"google.golang.org/appengine/internal/base\"\n)\n\nfunc TestDialLimit(t *testing.T) {\n\t// Fill up semaphore with false acquisitions to permit only two TCP connections at a time.\n\t// We don't replace limitSem because that results in a data race when net/http lazily closes connections.\n\tnFake := cap(limitSem) - 2\n\tfor i := 0; i < nFake; i++ {\n\t\tlimitSem <- 1\n\t}\n\tdefer func() {\n\t\tfor i := 0; i < nFake; i++ {\n\t\t\t<-limitSem\n\t\t}\n\t}()\n\n\tf, c, cleanup := setup() // setup is in api_test.go\n\tdefer cleanup()\n\tf.hang = make(chan int)\n\n\t// If we make two RunSlowly RPCs (which will wait for f.hang to be strobed),\n\t// then the simple Non200 RPC should hang.\n\tvar wg sync.WaitGroup\n\twg.Add(2)\n\tfor i := 0; i < 2; i++ {\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tCall(toContext(c), \"errors\", \"RunSlowly\", &basepb.VoidProto{}, &basepb.VoidProto{})\n\t\t}()\n\t}\n\ttime.Sleep(50 * time.Millisecond) // let those two RPCs start\n\n\tctx, _ := netcontext.WithTimeout(toContext(c), 50*time.Millisecond)\n\terr := Call(ctx, \"errors\", \"Non200\", &basepb.VoidProto{}, &basepb.VoidProto{})\n\tif err != errTimeout {\n\t\tt.Errorf(\"Non200 RPC returned with err %v, want errTimeout\", err)\n\t}\n\n\t// Drain the two RunSlowly calls.\n\tf.hang <- 1\n\tf.hang <- 1\n\twg.Wait()\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/regen.sh",
    "content": "#!/bin/bash -e\n#\n# This script rebuilds the generated code for the protocol buffers.\n# To run this you will need protoc and goprotobuf installed;\n# see https://github.com/golang/protobuf for instructions.\n\nPKG=google.golang.org/appengine\n\nfunction die() {\n\techo 1>&2 $*\n\texit 1\n}\n\n# Sanity check that the right tools are accessible.\nfor tool in go protoc protoc-gen-go; do\n\tq=$(which $tool) || die \"didn't find $tool\"\n\techo 1>&2 \"$tool: $q\"\ndone\n\necho -n 1>&2 \"finding package dir... \"\npkgdir=$(go list -f '{{.Dir}}' $PKG)\necho 1>&2 $pkgdir\nbase=$(echo $pkgdir | sed \"s,/$PKG\\$,,\")\necho 1>&2 \"base: $base\"\ncd $base\n\n# Run protoc once per package.\nfor dir in $(find $PKG/internal -name '*.proto' | xargs dirname | sort | uniq); do\n\techo 1>&2 \"* $dir\"\n\tprotoc --go_out=. $dir/*.proto\ndone\n\nfor f in $(find $PKG/internal -name '*.pb.go'); do\n  # Remove proto.RegisterEnum calls.\n  # These cause duplicate registration panics when these packages\n  # are used on classic App Engine. proto.RegisterEnum only affects\n  # parsing the text format; we don't care about that.\n  # https://code.google.com/p/googleappengine/issues/detail?id=11670#c17\n  sed -i '/proto.RegisterEnum/d' $f\ndone\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go",
    "content": "// Code generated by protoc-gen-go.\n// source: google.golang.org/appengine/internal/remote_api/remote_api.proto\n// DO NOT EDIT!\n\n/*\nPackage remote_api is a generated protocol buffer package.\n\nIt is generated from these files:\n\tgoogle.golang.org/appengine/internal/remote_api/remote_api.proto\n\nIt has these top-level messages:\n\tRequest\n\tApplicationError\n\tRpcError\n\tResponse\n*/\npackage remote_api\n\nimport proto \"github.com/golang/protobuf/proto\"\nimport fmt \"fmt\"\nimport math \"math\"\n\n// Reference imports to suppress errors if they are not otherwise used.\nvar _ = proto.Marshal\nvar _ = fmt.Errorf\nvar _ = math.Inf\n\ntype RpcError_ErrorCode int32\n\nconst (\n\tRpcError_UNKNOWN             RpcError_ErrorCode = 0\n\tRpcError_CALL_NOT_FOUND      RpcError_ErrorCode = 1\n\tRpcError_PARSE_ERROR         RpcError_ErrorCode = 2\n\tRpcError_SECURITY_VIOLATION  RpcError_ErrorCode = 3\n\tRpcError_OVER_QUOTA          RpcError_ErrorCode = 4\n\tRpcError_REQUEST_TOO_LARGE   RpcError_ErrorCode = 5\n\tRpcError_CAPABILITY_DISABLED RpcError_ErrorCode = 6\n\tRpcError_FEATURE_DISABLED    RpcError_ErrorCode = 7\n\tRpcError_BAD_REQUEST         RpcError_ErrorCode = 8\n\tRpcError_RESPONSE_TOO_LARGE  RpcError_ErrorCode = 9\n\tRpcError_CANCELLED           RpcError_ErrorCode = 10\n\tRpcError_REPLAY_ERROR        RpcError_ErrorCode = 11\n\tRpcError_DEADLINE_EXCEEDED   RpcError_ErrorCode = 12\n)\n\nvar RpcError_ErrorCode_name = map[int32]string{\n\t0:  \"UNKNOWN\",\n\t1:  \"CALL_NOT_FOUND\",\n\t2:  \"PARSE_ERROR\",\n\t3:  \"SECURITY_VIOLATION\",\n\t4:  \"OVER_QUOTA\",\n\t5:  \"REQUEST_TOO_LARGE\",\n\t6:  \"CAPABILITY_DISABLED\",\n\t7:  \"FEATURE_DISABLED\",\n\t8:  \"BAD_REQUEST\",\n\t9:  \"RESPONSE_TOO_LARGE\",\n\t10: \"CANCELLED\",\n\t11: \"REPLAY_ERROR\",\n\t12: \"DEADLINE_EXCEEDED\",\n}\nvar RpcError_ErrorCode_value = map[string]int32{\n\t\"UNKNOWN\":             0,\n\t\"CALL_NOT_FOUND\":      1,\n\t\"PARSE_ERROR\":         2,\n\t\"SECURITY_VIOLATION\":  3,\n\t\"OVER_QUOTA\":          4,\n\t\"REQUEST_TOO_LARGE\":   5,\n\t\"CAPABILITY_DISABLED\": 6,\n\t\"FEATURE_DISABLED\":    7,\n\t\"BAD_REQUEST\":         8,\n\t\"RESPONSE_TOO_LARGE\":  9,\n\t\"CANCELLED\":           10,\n\t\"REPLAY_ERROR\":        11,\n\t\"DEADLINE_EXCEEDED\":   12,\n}\n\nfunc (x RpcError_ErrorCode) Enum() *RpcError_ErrorCode {\n\tp := new(RpcError_ErrorCode)\n\t*p = x\n\treturn p\n}\nfunc (x RpcError_ErrorCode) String() string {\n\treturn proto.EnumName(RpcError_ErrorCode_name, int32(x))\n}\nfunc (x *RpcError_ErrorCode) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(RpcError_ErrorCode_value, data, \"RpcError_ErrorCode\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = RpcError_ErrorCode(value)\n\treturn nil\n}\n\ntype Request struct {\n\tServiceName      *string `protobuf:\"bytes,2,req,name=service_name\" json:\"service_name,omitempty\"`\n\tMethod           *string `protobuf:\"bytes,3,req,name=method\" json:\"method,omitempty\"`\n\tRequest          []byte  `protobuf:\"bytes,4,req,name=request\" json:\"request,omitempty\"`\n\tRequestId        *string `protobuf:\"bytes,5,opt,name=request_id\" json:\"request_id,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *Request) Reset()         { *m = Request{} }\nfunc (m *Request) String() string { return proto.CompactTextString(m) }\nfunc (*Request) ProtoMessage()    {}\n\nfunc (m *Request) GetServiceName() string {\n\tif m != nil && m.ServiceName != nil {\n\t\treturn *m.ServiceName\n\t}\n\treturn \"\"\n}\n\nfunc (m *Request) GetMethod() string {\n\tif m != nil && m.Method != nil {\n\t\treturn *m.Method\n\t}\n\treturn \"\"\n}\n\nfunc (m *Request) GetRequest() []byte {\n\tif m != nil {\n\t\treturn m.Request\n\t}\n\treturn nil\n}\n\nfunc (m *Request) GetRequestId() string {\n\tif m != nil && m.RequestId != nil {\n\t\treturn *m.RequestId\n\t}\n\treturn \"\"\n}\n\ntype ApplicationError struct {\n\tCode             *int32  `protobuf:\"varint,1,req,name=code\" json:\"code,omitempty\"`\n\tDetail           *string `protobuf:\"bytes,2,req,name=detail\" json:\"detail,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *ApplicationError) Reset()         { *m = ApplicationError{} }\nfunc (m *ApplicationError) String() string { return proto.CompactTextString(m) }\nfunc (*ApplicationError) ProtoMessage()    {}\n\nfunc (m *ApplicationError) GetCode() int32 {\n\tif m != nil && m.Code != nil {\n\t\treturn *m.Code\n\t}\n\treturn 0\n}\n\nfunc (m *ApplicationError) GetDetail() string {\n\tif m != nil && m.Detail != nil {\n\t\treturn *m.Detail\n\t}\n\treturn \"\"\n}\n\ntype RpcError struct {\n\tCode             *int32  `protobuf:\"varint,1,req,name=code\" json:\"code,omitempty\"`\n\tDetail           *string `protobuf:\"bytes,2,opt,name=detail\" json:\"detail,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *RpcError) Reset()         { *m = RpcError{} }\nfunc (m *RpcError) String() string { return proto.CompactTextString(m) }\nfunc (*RpcError) ProtoMessage()    {}\n\nfunc (m *RpcError) GetCode() int32 {\n\tif m != nil && m.Code != nil {\n\t\treturn *m.Code\n\t}\n\treturn 0\n}\n\nfunc (m *RpcError) GetDetail() string {\n\tif m != nil && m.Detail != nil {\n\t\treturn *m.Detail\n\t}\n\treturn \"\"\n}\n\ntype Response struct {\n\tResponse         []byte            `protobuf:\"bytes,1,opt,name=response\" json:\"response,omitempty\"`\n\tException        []byte            `protobuf:\"bytes,2,opt,name=exception\" json:\"exception,omitempty\"`\n\tApplicationError *ApplicationError `protobuf:\"bytes,3,opt,name=application_error\" json:\"application_error,omitempty\"`\n\tJavaException    []byte            `protobuf:\"bytes,4,opt,name=java_exception\" json:\"java_exception,omitempty\"`\n\tRpcError         *RpcError         `protobuf:\"bytes,5,opt,name=rpc_error\" json:\"rpc_error,omitempty\"`\n\tXXX_unrecognized []byte            `json:\"-\"`\n}\n\nfunc (m *Response) Reset()         { *m = Response{} }\nfunc (m *Response) String() string { return proto.CompactTextString(m) }\nfunc (*Response) ProtoMessage()    {}\n\nfunc (m *Response) GetResponse() []byte {\n\tif m != nil {\n\t\treturn m.Response\n\t}\n\treturn nil\n}\n\nfunc (m *Response) GetException() []byte {\n\tif m != nil {\n\t\treturn m.Exception\n\t}\n\treturn nil\n}\n\nfunc (m *Response) GetApplicationError() *ApplicationError {\n\tif m != nil {\n\t\treturn m.ApplicationError\n\t}\n\treturn nil\n}\n\nfunc (m *Response) GetJavaException() []byte {\n\tif m != nil {\n\t\treturn m.JavaException\n\t}\n\treturn nil\n}\n\nfunc (m *Response) GetRpcError() *RpcError {\n\tif m != nil {\n\t\treturn m.RpcError\n\t}\n\treturn nil\n}\n\nfunc init() {\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto",
    "content": "syntax = \"proto2\";\noption go_package = \"remote_api\";\n\npackage remote_api;\n\nmessage Request {\n  required string service_name = 2;\n  required string method = 3;\n  required bytes request = 4;\n  optional string request_id = 5;\n}\n\nmessage ApplicationError {\n  required int32 code = 1;\n  required string detail = 2;\n}\n\nmessage RpcError {\n  enum ErrorCode {\n    UNKNOWN = 0;\n    CALL_NOT_FOUND = 1;\n    PARSE_ERROR = 2;\n    SECURITY_VIOLATION = 3;\n    OVER_QUOTA = 4;\n    REQUEST_TOO_LARGE = 5;\n    CAPABILITY_DISABLED = 6;\n    FEATURE_DISABLED = 7;\n    BAD_REQUEST = 8;\n    RESPONSE_TOO_LARGE = 9;\n    CANCELLED = 10;\n    REPLAY_ERROR = 11;\n    DEADLINE_EXCEEDED = 12;\n  }\n  required int32 code = 1;\n  optional string detail = 2;\n}\n\nmessage Response {\n  optional bytes response = 1;\n  optional bytes exception = 2;\n  optional ApplicationError application_error = 3;\n  optional bytes java_exception = 4;\n  optional RpcError rpc_error = 5;\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/transaction.go",
    "content": "// Copyright 2014 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\npackage internal\n\n// This file implements hooks for applying datastore transactions.\n\nimport (\n\t\"errors\"\n\t\"reflect\"\n\n\t\"github.com/golang/protobuf/proto\"\n\tnetcontext \"golang.org/x/net/context\"\n\n\tbasepb \"google.golang.org/appengine/internal/base\"\n\tpb \"google.golang.org/appengine/internal/datastore\"\n)\n\nvar transactionSetters = make(map[reflect.Type]reflect.Value)\n\n// RegisterTransactionSetter registers a function that sets transaction information\n// in a protocol buffer message. f should be a function with two arguments,\n// the first being a protocol buffer type, and the second being *datastore.Transaction.\nfunc RegisterTransactionSetter(f interface{}) {\n\tv := reflect.ValueOf(f)\n\ttransactionSetters[v.Type().In(0)] = v\n}\n\n// applyTransaction applies the transaction t to message pb\n// by using the relevant setter passed to RegisterTransactionSetter.\nfunc applyTransaction(pb proto.Message, t *pb.Transaction) {\n\tv := reflect.ValueOf(pb)\n\tif f, ok := transactionSetters[v.Type()]; ok {\n\t\tf.Call([]reflect.Value{v, reflect.ValueOf(t)})\n\t}\n}\n\nvar transactionKey = \"used for *Transaction\"\n\nfunc transactionFromContext(ctx netcontext.Context) *transaction {\n\tt, _ := ctx.Value(&transactionKey).(*transaction)\n\treturn t\n}\n\nfunc withTransaction(ctx netcontext.Context, t *transaction) netcontext.Context {\n\treturn netcontext.WithValue(ctx, &transactionKey, t)\n}\n\ntype transaction struct {\n\ttransaction pb.Transaction\n\tfinished    bool\n}\n\nvar ErrConcurrentTransaction = errors.New(\"internal: concurrent transaction\")\n\nfunc RunTransactionOnce(c netcontext.Context, f func(netcontext.Context) error, xg bool) error {\n\tif transactionFromContext(c) != nil {\n\t\treturn errors.New(\"nested transactions are not supported\")\n\t}\n\n\t// Begin the transaction.\n\tt := &transaction{}\n\treq := &pb.BeginTransactionRequest{\n\t\tApp: proto.String(FullyQualifiedAppID(c)),\n\t}\n\tif xg {\n\t\treq.AllowMultipleEg = proto.Bool(true)\n\t}\n\tif err := Call(c, \"datastore_v3\", \"BeginTransaction\", req, &t.transaction); err != nil {\n\t\treturn err\n\t}\n\n\t// Call f, rolling back the transaction if f returns a non-nil error, or panics.\n\t// The panic is not recovered.\n\tdefer func() {\n\t\tif t.finished {\n\t\t\treturn\n\t\t}\n\t\tt.finished = true\n\t\t// Ignore the error return value, since we are already returning a non-nil\n\t\t// error (or we're panicking).\n\t\tCall(c, \"datastore_v3\", \"Rollback\", &t.transaction, &basepb.VoidProto{})\n\t}()\n\tif err := f(withTransaction(c, t)); err != nil {\n\t\treturn err\n\t}\n\tt.finished = true\n\n\t// Commit the transaction.\n\tres := &pb.CommitResponse{}\n\terr := Call(c, \"datastore_v3\", \"Commit\", &t.transaction, res)\n\tif ae, ok := err.(*APIError); ok {\n\t\t/* TODO: restore this conditional\n\t\tif appengine.IsDevAppServer() {\n\t\t*/\n\t\t// The Python Dev AppServer raises an ApplicationError with error code 2 (which is\n\t\t// Error.CONCURRENT_TRANSACTION) and message \"Concurrency exception.\".\n\t\tif ae.Code == int32(pb.Error_BAD_REQUEST) && ae.Detail == \"ApplicationError: 2 Concurrency exception.\" {\n\t\t\treturn ErrConcurrentTransaction\n\t\t}\n\t\tif ae.Code == int32(pb.Error_CONCURRENT_TRANSACTION) {\n\t\t\treturn ErrConcurrentTransaction\n\t\t}\n\t}\n\treturn err\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.pb.go",
    "content": "// Code generated by protoc-gen-go.\n// source: google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto\n// DO NOT EDIT!\n\n/*\nPackage urlfetch is a generated protocol buffer package.\n\nIt is generated from these files:\n\tgoogle.golang.org/appengine/internal/urlfetch/urlfetch_service.proto\n\nIt has these top-level messages:\n\tURLFetchServiceError\n\tURLFetchRequest\n\tURLFetchResponse\n*/\npackage urlfetch\n\nimport proto \"github.com/golang/protobuf/proto\"\nimport fmt \"fmt\"\nimport math \"math\"\n\n// Reference imports to suppress errors if they are not otherwise used.\nvar _ = proto.Marshal\nvar _ = fmt.Errorf\nvar _ = math.Inf\n\ntype URLFetchServiceError_ErrorCode int32\n\nconst (\n\tURLFetchServiceError_OK                       URLFetchServiceError_ErrorCode = 0\n\tURLFetchServiceError_INVALID_URL              URLFetchServiceError_ErrorCode = 1\n\tURLFetchServiceError_FETCH_ERROR              URLFetchServiceError_ErrorCode = 2\n\tURLFetchServiceError_UNSPECIFIED_ERROR        URLFetchServiceError_ErrorCode = 3\n\tURLFetchServiceError_RESPONSE_TOO_LARGE       URLFetchServiceError_ErrorCode = 4\n\tURLFetchServiceError_DEADLINE_EXCEEDED        URLFetchServiceError_ErrorCode = 5\n\tURLFetchServiceError_SSL_CERTIFICATE_ERROR    URLFetchServiceError_ErrorCode = 6\n\tURLFetchServiceError_DNS_ERROR                URLFetchServiceError_ErrorCode = 7\n\tURLFetchServiceError_CLOSED                   URLFetchServiceError_ErrorCode = 8\n\tURLFetchServiceError_INTERNAL_TRANSIENT_ERROR URLFetchServiceError_ErrorCode = 9\n\tURLFetchServiceError_TOO_MANY_REDIRECTS       URLFetchServiceError_ErrorCode = 10\n\tURLFetchServiceError_MALFORMED_REPLY          URLFetchServiceError_ErrorCode = 11\n\tURLFetchServiceError_CONNECTION_ERROR         URLFetchServiceError_ErrorCode = 12\n)\n\nvar URLFetchServiceError_ErrorCode_name = map[int32]string{\n\t0:  \"OK\",\n\t1:  \"INVALID_URL\",\n\t2:  \"FETCH_ERROR\",\n\t3:  \"UNSPECIFIED_ERROR\",\n\t4:  \"RESPONSE_TOO_LARGE\",\n\t5:  \"DEADLINE_EXCEEDED\",\n\t6:  \"SSL_CERTIFICATE_ERROR\",\n\t7:  \"DNS_ERROR\",\n\t8:  \"CLOSED\",\n\t9:  \"INTERNAL_TRANSIENT_ERROR\",\n\t10: \"TOO_MANY_REDIRECTS\",\n\t11: \"MALFORMED_REPLY\",\n\t12: \"CONNECTION_ERROR\",\n}\nvar URLFetchServiceError_ErrorCode_value = map[string]int32{\n\t\"OK\":                       0,\n\t\"INVALID_URL\":              1,\n\t\"FETCH_ERROR\":              2,\n\t\"UNSPECIFIED_ERROR\":        3,\n\t\"RESPONSE_TOO_LARGE\":       4,\n\t\"DEADLINE_EXCEEDED\":        5,\n\t\"SSL_CERTIFICATE_ERROR\":    6,\n\t\"DNS_ERROR\":                7,\n\t\"CLOSED\":                   8,\n\t\"INTERNAL_TRANSIENT_ERROR\": 9,\n\t\"TOO_MANY_REDIRECTS\":       10,\n\t\"MALFORMED_REPLY\":          11,\n\t\"CONNECTION_ERROR\":         12,\n}\n\nfunc (x URLFetchServiceError_ErrorCode) Enum() *URLFetchServiceError_ErrorCode {\n\tp := new(URLFetchServiceError_ErrorCode)\n\t*p = x\n\treturn p\n}\nfunc (x URLFetchServiceError_ErrorCode) String() string {\n\treturn proto.EnumName(URLFetchServiceError_ErrorCode_name, int32(x))\n}\nfunc (x *URLFetchServiceError_ErrorCode) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(URLFetchServiceError_ErrorCode_value, data, \"URLFetchServiceError_ErrorCode\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = URLFetchServiceError_ErrorCode(value)\n\treturn nil\n}\n\ntype URLFetchRequest_RequestMethod int32\n\nconst (\n\tURLFetchRequest_GET    URLFetchRequest_RequestMethod = 1\n\tURLFetchRequest_POST   URLFetchRequest_RequestMethod = 2\n\tURLFetchRequest_HEAD   URLFetchRequest_RequestMethod = 3\n\tURLFetchRequest_PUT    URLFetchRequest_RequestMethod = 4\n\tURLFetchRequest_DELETE URLFetchRequest_RequestMethod = 5\n\tURLFetchRequest_PATCH  URLFetchRequest_RequestMethod = 6\n)\n\nvar URLFetchRequest_RequestMethod_name = map[int32]string{\n\t1: \"GET\",\n\t2: \"POST\",\n\t3: \"HEAD\",\n\t4: \"PUT\",\n\t5: \"DELETE\",\n\t6: \"PATCH\",\n}\nvar URLFetchRequest_RequestMethod_value = map[string]int32{\n\t\"GET\":    1,\n\t\"POST\":   2,\n\t\"HEAD\":   3,\n\t\"PUT\":    4,\n\t\"DELETE\": 5,\n\t\"PATCH\":  6,\n}\n\nfunc (x URLFetchRequest_RequestMethod) Enum() *URLFetchRequest_RequestMethod {\n\tp := new(URLFetchRequest_RequestMethod)\n\t*p = x\n\treturn p\n}\nfunc (x URLFetchRequest_RequestMethod) String() string {\n\treturn proto.EnumName(URLFetchRequest_RequestMethod_name, int32(x))\n}\nfunc (x *URLFetchRequest_RequestMethod) UnmarshalJSON(data []byte) error {\n\tvalue, err := proto.UnmarshalJSONEnum(URLFetchRequest_RequestMethod_value, data, \"URLFetchRequest_RequestMethod\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = URLFetchRequest_RequestMethod(value)\n\treturn nil\n}\n\ntype URLFetchServiceError struct {\n\tXXX_unrecognized []byte `json:\"-\"`\n}\n\nfunc (m *URLFetchServiceError) Reset()         { *m = URLFetchServiceError{} }\nfunc (m *URLFetchServiceError) String() string { return proto.CompactTextString(m) }\nfunc (*URLFetchServiceError) ProtoMessage()    {}\n\ntype URLFetchRequest struct {\n\tMethod                        *URLFetchRequest_RequestMethod `protobuf:\"varint,1,req,name=Method,enum=appengine.URLFetchRequest_RequestMethod\" json:\"Method,omitempty\"`\n\tUrl                           *string                        `protobuf:\"bytes,2,req,name=Url\" json:\"Url,omitempty\"`\n\tHeader                        []*URLFetchRequest_Header      `protobuf:\"group,3,rep,name=Header\" json:\"header,omitempty\"`\n\tPayload                       []byte                         `protobuf:\"bytes,6,opt,name=Payload\" json:\"Payload,omitempty\"`\n\tFollowRedirects               *bool                          `protobuf:\"varint,7,opt,name=FollowRedirects,def=1\" json:\"FollowRedirects,omitempty\"`\n\tDeadline                      *float64                       `protobuf:\"fixed64,8,opt,name=Deadline\" json:\"Deadline,omitempty\"`\n\tMustValidateServerCertificate *bool                          `protobuf:\"varint,9,opt,name=MustValidateServerCertificate,def=1\" json:\"MustValidateServerCertificate,omitempty\"`\n\tXXX_unrecognized              []byte                         `json:\"-\"`\n}\n\nfunc (m *URLFetchRequest) Reset()         { *m = URLFetchRequest{} }\nfunc (m *URLFetchRequest) String() string { return proto.CompactTextString(m) }\nfunc (*URLFetchRequest) ProtoMessage()    {}\n\nconst Default_URLFetchRequest_FollowRedirects bool = true\nconst Default_URLFetchRequest_MustValidateServerCertificate bool = true\n\nfunc (m *URLFetchRequest) GetMethod() URLFetchRequest_RequestMethod {\n\tif m != nil && m.Method != nil {\n\t\treturn *m.Method\n\t}\n\treturn URLFetchRequest_GET\n}\n\nfunc (m *URLFetchRequest) GetUrl() string {\n\tif m != nil && m.Url != nil {\n\t\treturn *m.Url\n\t}\n\treturn \"\"\n}\n\nfunc (m *URLFetchRequest) GetHeader() []*URLFetchRequest_Header {\n\tif m != nil {\n\t\treturn m.Header\n\t}\n\treturn nil\n}\n\nfunc (m *URLFetchRequest) GetPayload() []byte {\n\tif m != nil {\n\t\treturn m.Payload\n\t}\n\treturn nil\n}\n\nfunc (m *URLFetchRequest) GetFollowRedirects() bool {\n\tif m != nil && m.FollowRedirects != nil {\n\t\treturn *m.FollowRedirects\n\t}\n\treturn Default_URLFetchRequest_FollowRedirects\n}\n\nfunc (m *URLFetchRequest) GetDeadline() float64 {\n\tif m != nil && m.Deadline != nil {\n\t\treturn *m.Deadline\n\t}\n\treturn 0\n}\n\nfunc (m *URLFetchRequest) GetMustValidateServerCertificate() bool {\n\tif m != nil && m.MustValidateServerCertificate != nil {\n\t\treturn *m.MustValidateServerCertificate\n\t}\n\treturn Default_URLFetchRequest_MustValidateServerCertificate\n}\n\ntype URLFetchRequest_Header struct {\n\tKey              *string `protobuf:\"bytes,4,req,name=Key\" json:\"Key,omitempty\"`\n\tValue            *string `protobuf:\"bytes,5,req,name=Value\" json:\"Value,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *URLFetchRequest_Header) Reset()         { *m = URLFetchRequest_Header{} }\nfunc (m *URLFetchRequest_Header) String() string { return proto.CompactTextString(m) }\nfunc (*URLFetchRequest_Header) ProtoMessage()    {}\n\nfunc (m *URLFetchRequest_Header) GetKey() string {\n\tif m != nil && m.Key != nil {\n\t\treturn *m.Key\n\t}\n\treturn \"\"\n}\n\nfunc (m *URLFetchRequest_Header) GetValue() string {\n\tif m != nil && m.Value != nil {\n\t\treturn *m.Value\n\t}\n\treturn \"\"\n}\n\ntype URLFetchResponse struct {\n\tContent               []byte                     `protobuf:\"bytes,1,opt,name=Content\" json:\"Content,omitempty\"`\n\tStatusCode            *int32                     `protobuf:\"varint,2,req,name=StatusCode\" json:\"StatusCode,omitempty\"`\n\tHeader                []*URLFetchResponse_Header `protobuf:\"group,3,rep,name=Header\" json:\"header,omitempty\"`\n\tContentWasTruncated   *bool                      `protobuf:\"varint,6,opt,name=ContentWasTruncated,def=0\" json:\"ContentWasTruncated,omitempty\"`\n\tExternalBytesSent     *int64                     `protobuf:\"varint,7,opt,name=ExternalBytesSent\" json:\"ExternalBytesSent,omitempty\"`\n\tExternalBytesReceived *int64                     `protobuf:\"varint,8,opt,name=ExternalBytesReceived\" json:\"ExternalBytesReceived,omitempty\"`\n\tFinalUrl              *string                    `protobuf:\"bytes,9,opt,name=FinalUrl\" json:\"FinalUrl,omitempty\"`\n\tApiCpuMilliseconds    *int64                     `protobuf:\"varint,10,opt,name=ApiCpuMilliseconds,def=0\" json:\"ApiCpuMilliseconds,omitempty\"`\n\tApiBytesSent          *int64                     `protobuf:\"varint,11,opt,name=ApiBytesSent,def=0\" json:\"ApiBytesSent,omitempty\"`\n\tApiBytesReceived      *int64                     `protobuf:\"varint,12,opt,name=ApiBytesReceived,def=0\" json:\"ApiBytesReceived,omitempty\"`\n\tXXX_unrecognized      []byte                     `json:\"-\"`\n}\n\nfunc (m *URLFetchResponse) Reset()         { *m = URLFetchResponse{} }\nfunc (m *URLFetchResponse) String() string { return proto.CompactTextString(m) }\nfunc (*URLFetchResponse) ProtoMessage()    {}\n\nconst Default_URLFetchResponse_ContentWasTruncated bool = false\nconst Default_URLFetchResponse_ApiCpuMilliseconds int64 = 0\nconst Default_URLFetchResponse_ApiBytesSent int64 = 0\nconst Default_URLFetchResponse_ApiBytesReceived int64 = 0\n\nfunc (m *URLFetchResponse) GetContent() []byte {\n\tif m != nil {\n\t\treturn m.Content\n\t}\n\treturn nil\n}\n\nfunc (m *URLFetchResponse) GetStatusCode() int32 {\n\tif m != nil && m.StatusCode != nil {\n\t\treturn *m.StatusCode\n\t}\n\treturn 0\n}\n\nfunc (m *URLFetchResponse) GetHeader() []*URLFetchResponse_Header {\n\tif m != nil {\n\t\treturn m.Header\n\t}\n\treturn nil\n}\n\nfunc (m *URLFetchResponse) GetContentWasTruncated() bool {\n\tif m != nil && m.ContentWasTruncated != nil {\n\t\treturn *m.ContentWasTruncated\n\t}\n\treturn Default_URLFetchResponse_ContentWasTruncated\n}\n\nfunc (m *URLFetchResponse) GetExternalBytesSent() int64 {\n\tif m != nil && m.ExternalBytesSent != nil {\n\t\treturn *m.ExternalBytesSent\n\t}\n\treturn 0\n}\n\nfunc (m *URLFetchResponse) GetExternalBytesReceived() int64 {\n\tif m != nil && m.ExternalBytesReceived != nil {\n\t\treturn *m.ExternalBytesReceived\n\t}\n\treturn 0\n}\n\nfunc (m *URLFetchResponse) GetFinalUrl() string {\n\tif m != nil && m.FinalUrl != nil {\n\t\treturn *m.FinalUrl\n\t}\n\treturn \"\"\n}\n\nfunc (m *URLFetchResponse) GetApiCpuMilliseconds() int64 {\n\tif m != nil && m.ApiCpuMilliseconds != nil {\n\t\treturn *m.ApiCpuMilliseconds\n\t}\n\treturn Default_URLFetchResponse_ApiCpuMilliseconds\n}\n\nfunc (m *URLFetchResponse) GetApiBytesSent() int64 {\n\tif m != nil && m.ApiBytesSent != nil {\n\t\treturn *m.ApiBytesSent\n\t}\n\treturn Default_URLFetchResponse_ApiBytesSent\n}\n\nfunc (m *URLFetchResponse) GetApiBytesReceived() int64 {\n\tif m != nil && m.ApiBytesReceived != nil {\n\t\treturn *m.ApiBytesReceived\n\t}\n\treturn Default_URLFetchResponse_ApiBytesReceived\n}\n\ntype URLFetchResponse_Header struct {\n\tKey              *string `protobuf:\"bytes,4,req,name=Key\" json:\"Key,omitempty\"`\n\tValue            *string `protobuf:\"bytes,5,req,name=Value\" json:\"Value,omitempty\"`\n\tXXX_unrecognized []byte  `json:\"-\"`\n}\n\nfunc (m *URLFetchResponse_Header) Reset()         { *m = URLFetchResponse_Header{} }\nfunc (m *URLFetchResponse_Header) String() string { return proto.CompactTextString(m) }\nfunc (*URLFetchResponse_Header) ProtoMessage()    {}\n\nfunc (m *URLFetchResponse_Header) GetKey() string {\n\tif m != nil && m.Key != nil {\n\t\treturn *m.Key\n\t}\n\treturn \"\"\n}\n\nfunc (m *URLFetchResponse_Header) GetValue() string {\n\tif m != nil && m.Value != nil {\n\t\treturn *m.Value\n\t}\n\treturn \"\"\n}\n\nfunc init() {\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto",
    "content": "syntax = \"proto2\";\noption go_package = \"urlfetch\";\n\npackage appengine;\n\nmessage URLFetchServiceError {\n  enum ErrorCode {\n    OK = 0;\n    INVALID_URL = 1;\n    FETCH_ERROR = 2;\n    UNSPECIFIED_ERROR = 3;\n    RESPONSE_TOO_LARGE = 4;\n    DEADLINE_EXCEEDED = 5;\n    SSL_CERTIFICATE_ERROR = 6;\n    DNS_ERROR = 7;\n    CLOSED = 8;\n    INTERNAL_TRANSIENT_ERROR = 9;\n    TOO_MANY_REDIRECTS = 10;\n    MALFORMED_REPLY = 11;\n    CONNECTION_ERROR = 12;\n  }\n}\n\nmessage URLFetchRequest {\n  enum RequestMethod {\n    GET = 1;\n    POST = 2;\n    HEAD = 3;\n    PUT = 4;\n    DELETE = 5;\n    PATCH = 6;\n  }\n  required RequestMethod Method = 1;\n  required string Url = 2;\n  repeated group Header = 3 {\n    required string Key = 4;\n    required string Value = 5;\n  }\n  optional bytes Payload = 6 [ctype=CORD];\n\n  optional bool FollowRedirects = 7 [default=true];\n\n  optional double Deadline = 8;\n\n  optional bool MustValidateServerCertificate = 9 [default=true];\n}\n\nmessage URLFetchResponse {\n  optional bytes Content = 1;\n  required int32 StatusCode = 2;\n  repeated group Header = 3 {\n    required string Key = 4;\n    required string Value = 5;\n  }\n  optional bool ContentWasTruncated = 6 [default=false];\n  optional int64 ExternalBytesSent = 7;\n  optional int64 ExternalBytesReceived = 8;\n\n  optional string FinalUrl = 9;\n\n  optional int64 ApiCpuMilliseconds = 10 [default=0];\n  optional int64 ApiBytesSent = 11 [default=0];\n  optional int64 ApiBytesReceived = 12 [default=0];\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/namespace.go",
    "content": "// Copyright 2012 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\npackage appengine\n\nimport (\n\t\"fmt\"\n\t\"regexp\"\n\n\t\"golang.org/x/net/context\"\n\n\t\"google.golang.org/appengine/internal\"\n)\n\n// Namespace returns a replacement context that operates within the given namespace.\nfunc Namespace(c context.Context, namespace string) (context.Context, error) {\n\tif !validNamespace.MatchString(namespace) {\n\t\treturn nil, fmt.Errorf(\"appengine: namespace %q does not match /%s/\", namespace, validNamespace)\n\t}\n\treturn internal.NamespacedContext(c, namespace), nil\n}\n\n// validNamespace matches valid namespace names.\nvar validNamespace = regexp.MustCompile(`^[0-9A-Za-z._-]{0,100}$`)\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/namespace_test.go",
    "content": "// Copyright 2014 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\npackage appengine\n\nimport (\n\t\"testing\"\n\n\t\"golang.org/x/net/context\"\n)\n\nfunc TestNamespaceValidity(t *testing.T) {\n\ttestCases := []struct {\n\t\tnamespace string\n\t\tok        bool\n\t}{\n\t\t// data from Python's namespace_manager_test.py\n\t\t{\"\", true},\n\t\t{\"__a.namespace.123__\", true},\n\t\t{\"-_A....NAMESPACE-_\", true},\n\t\t{\"-\", true},\n\t\t{\".\", true},\n\t\t{\".-\", true},\n\n\t\t{\"?\", false},\n\t\t{\"+\", false},\n\t\t{\"!\", false},\n\t\t{\" \", false},\n\t}\n\tfor _, tc := range testCases {\n\t\t_, err := Namespace(context.Background(), tc.namespace)\n\t\tif err == nil && !tc.ok {\n\t\t\tt.Errorf(\"Namespace %q should be rejected, but wasn't\", tc.namespace)\n\t\t} else if err != nil && tc.ok {\n\t\t\tt.Errorf(\"Namespace %q should be accepted, but wasn't\", tc.namespace)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/timeout.go",
    "content": "// Copyright 2013 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\npackage appengine\n\nimport \"golang.org/x/net/context\"\n\n// IsTimeoutError reports whether err is a timeout error.\nfunc IsTimeoutError(err error) bool {\n\tif err == context.DeadlineExceeded {\n\t\treturn true\n\t}\n\tif t, ok := err.(interface {\n\t\tIsTimeout() bool\n\t}); ok {\n\t\treturn t.IsTimeout()\n\t}\n\treturn false\n}\n"
  },
  {
    "path": "vendor/google.golang.org/appengine/urlfetch/urlfetch.go",
    "content": "// Copyright 2011 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// Package urlfetch provides an http.RoundTripper implementation\n// for fetching URLs via App Engine's urlfetch service.\npackage urlfetch // import \"google.golang.org/appengine/urlfetch\"\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/golang/protobuf/proto\"\n\t\"golang.org/x/net/context\"\n\n\t\"google.golang.org/appengine/internal\"\n\tpb \"google.golang.org/appengine/internal/urlfetch\"\n)\n\n// Transport is an implementation of http.RoundTripper for\n// App Engine. Users should generally create an http.Client using\n// this transport and use the Client rather than using this transport\n// directly.\ntype Transport struct {\n\tContext context.Context\n\n\t// Controls whether the application checks the validity of SSL certificates\n\t// over HTTPS connections. A value of false (the default) instructs the\n\t// application to send a request to the server only if the certificate is\n\t// valid and signed by a trusted certificate authority (CA), and also\n\t// includes a hostname that matches the certificate. A value of true\n\t// instructs the application to perform no certificate validation.\n\tAllowInvalidServerCertificate bool\n}\n\n// Verify statically that *Transport implements http.RoundTripper.\nvar _ http.RoundTripper = (*Transport)(nil)\n\n// Client returns an *http.Client using a default urlfetch Transport. This\n// client will have the default deadline of 5 seconds, and will check the\n// validity of SSL certificates.\n//\n// Any deadline of the provided context will be used for requests through this client;\n// if the client does not have a deadline then a 5 second default is used.\nfunc Client(ctx context.Context) *http.Client {\n\treturn &http.Client{\n\t\tTransport: &Transport{\n\t\t\tContext: ctx,\n\t\t},\n\t}\n}\n\ntype bodyReader struct {\n\tcontent   []byte\n\ttruncated bool\n\tclosed    bool\n}\n\n// ErrTruncatedBody is the error returned after the final Read() from a\n// response's Body if the body has been truncated by App Engine's proxy.\nvar ErrTruncatedBody = errors.New(\"urlfetch: truncated body\")\n\nfunc statusCodeToText(code int) string {\n\tif t := http.StatusText(code); t != \"\" {\n\t\treturn t\n\t}\n\treturn strconv.Itoa(code)\n}\n\nfunc (br *bodyReader) Read(p []byte) (n int, err error) {\n\tif br.closed {\n\t\tif br.truncated {\n\t\t\treturn 0, ErrTruncatedBody\n\t\t}\n\t\treturn 0, io.EOF\n\t}\n\tn = copy(p, br.content)\n\tif n > 0 {\n\t\tbr.content = br.content[n:]\n\t\treturn\n\t}\n\tif br.truncated {\n\t\tbr.closed = true\n\t\treturn 0, ErrTruncatedBody\n\t}\n\treturn 0, io.EOF\n}\n\nfunc (br *bodyReader) Close() error {\n\tbr.closed = true\n\tbr.content = nil\n\treturn nil\n}\n\n// A map of the URL Fetch-accepted methods that take a request body.\nvar methodAcceptsRequestBody = map[string]bool{\n\t\"POST\":  true,\n\t\"PUT\":   true,\n\t\"PATCH\": true,\n}\n\n// urlString returns a valid string given a URL. This function is necessary because\n// the String method of URL doesn't correctly handle URLs with non-empty Opaque values.\n// See http://code.google.com/p/go/issues/detail?id=4860.\nfunc urlString(u *url.URL) string {\n\tif u.Opaque == \"\" || strings.HasPrefix(u.Opaque, \"//\") {\n\t\treturn u.String()\n\t}\n\taux := *u\n\taux.Opaque = \"//\" + aux.Host + aux.Opaque\n\treturn aux.String()\n}\n\n// RoundTrip issues a single HTTP request and returns its response. Per the\n// http.RoundTripper interface, RoundTrip only returns an error if there\n// was an unsupported request or the URL Fetch proxy fails.\n// Note that HTTP response codes such as 5xx, 403, 404, etc are not\n// errors as far as the transport is concerned and will be returned\n// with err set to nil.\nfunc (t *Transport) RoundTrip(req *http.Request) (res *http.Response, err error) {\n\tmethNum, ok := pb.URLFetchRequest_RequestMethod_value[req.Method]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"urlfetch: unsupported HTTP method %q\", req.Method)\n\t}\n\n\tmethod := pb.URLFetchRequest_RequestMethod(methNum)\n\n\tfreq := &pb.URLFetchRequest{\n\t\tMethod:                        &method,\n\t\tUrl:                           proto.String(urlString(req.URL)),\n\t\tFollowRedirects:               proto.Bool(false), // http.Client's responsibility\n\t\tMustValidateServerCertificate: proto.Bool(!t.AllowInvalidServerCertificate),\n\t}\n\tif deadline, ok := t.Context.Deadline(); ok {\n\t\tfreq.Deadline = proto.Float64(deadline.Sub(time.Now()).Seconds())\n\t}\n\n\tfor k, vals := range req.Header {\n\t\tfor _, val := range vals {\n\t\t\tfreq.Header = append(freq.Header, &pb.URLFetchRequest_Header{\n\t\t\t\tKey:   proto.String(k),\n\t\t\t\tValue: proto.String(val),\n\t\t\t})\n\t\t}\n\t}\n\tif methodAcceptsRequestBody[req.Method] && req.Body != nil {\n\t\t// Avoid a []byte copy if req.Body has a Bytes method.\n\t\tswitch b := req.Body.(type) {\n\t\tcase interface {\n\t\t\tBytes() []byte\n\t\t}:\n\t\t\tfreq.Payload = b.Bytes()\n\t\tdefault:\n\t\t\tfreq.Payload, err = ioutil.ReadAll(req.Body)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\tfres := &pb.URLFetchResponse{}\n\tif err := internal.Call(t.Context, \"urlfetch\", \"Fetch\", freq, fres); err != nil {\n\t\treturn nil, err\n\t}\n\n\tres = &http.Response{}\n\tres.StatusCode = int(*fres.StatusCode)\n\tres.Status = fmt.Sprintf(\"%d %s\", res.StatusCode, statusCodeToText(res.StatusCode))\n\tres.Header = make(http.Header)\n\tres.Request = req\n\n\t// Faked:\n\tres.ProtoMajor = 1\n\tres.ProtoMinor = 1\n\tres.Proto = \"HTTP/1.1\"\n\tres.Close = true\n\n\tfor _, h := range fres.Header {\n\t\thkey := http.CanonicalHeaderKey(*h.Key)\n\t\thval := *h.Value\n\t\tif hkey == \"Content-Length\" {\n\t\t\t// Will get filled in below for all but HEAD requests.\n\t\t\tif req.Method == \"HEAD\" {\n\t\t\t\tres.ContentLength, _ = strconv.ParseInt(hval, 10, 64)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tres.Header.Add(hkey, hval)\n\t}\n\n\tif req.Method != \"HEAD\" {\n\t\tres.ContentLength = int64(len(fres.Content))\n\t}\n\n\ttruncated := fres.GetContentWasTruncated()\n\tres.Body = &bodyReader{content: fres.Content, truncated: truncated}\n\treturn\n}\n\nfunc init() {\n\tinternal.RegisterErrorCodeMap(\"urlfetch\", pb.URLFetchServiceError_ErrorCode_name)\n\tinternal.RegisterTimeoutErrorCode(\"urlfetch\", int32(pb.URLFetchServiceError_DEADLINE_EXCEEDED))\n}\n"
  }
]