├── .gitignore ├── vendor ├── github.com │ ├── spf13 │ │ ├── pflag │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── export_test.go │ │ │ ├── example_test.go │ │ │ ├── golangflag_test.go │ │ │ ├── count_test.go │ │ │ ├── LICENSE │ │ │ ├── ip_test.go │ │ │ ├── ipnet_test.go │ │ │ └── int.go │ │ └── cobra │ │ │ ├── command_notwin.go │ │ │ ├── .mailmap │ │ │ ├── command_win.go │ │ │ ├── .travis.yml │ │ │ ├── .gitignore │ │ │ ├── cobra_test.go │ │ │ ├── zsh_completions_test.go │ │ │ └── args.go │ ├── zmb3 │ │ └── spotify │ │ │ ├── .travis.yml │ │ │ ├── full_tests.bat │ │ │ ├── countries.go │ │ │ ├── cursor.go │ │ │ ├── track_test.go │ │ │ ├── library_test.go │ │ │ ├── library.go │ │ │ ├── recommendation_test.go │ │ │ └── page.go │ ├── gizak │ │ └── termui │ │ │ ├── .travis.yml │ │ │ ├── glide.yaml │ │ │ ├── linechart_others.go │ │ │ ├── linechart_windows.go │ │ │ ├── .gitignore │ │ │ ├── block_windows.go │ │ │ ├── block_common.go │ │ │ ├── mkdocs.yml │ │ │ ├── par_test.go │ │ │ ├── buffer_test.go │ │ │ ├── doc.go │ │ │ ├── events_test.go │ │ │ ├── theme_test.go │ │ │ ├── pos_test.go │ │ │ ├── glide.lock │ │ │ ├── canvas_test.go │ │ │ ├── LICENSE │ │ │ ├── config.py │ │ │ ├── canvas.go │ │ │ ├── block_test.go │ │ │ ├── par.go │ │ │ ├── grid_test.go │ │ │ ├── helper_test.go │ │ │ ├── pos.go │ │ │ ├── widget.go │ │ │ ├── textbuilder_test.go │ │ │ ├── list.go │ │ │ ├── gauge.go │ │ │ └── buffer.go │ ├── nsf │ │ └── termbox-go │ │ │ ├── AUTHORS │ │ │ ├── syscalls_freebsd.go │ │ │ ├── syscalls_netbsd.go │ │ │ ├── syscalls_openbsd.go │ │ │ ├── syscalls_dragonfly.go │ │ │ ├── syscalls.go │ │ │ ├── syscalls_darwin.go │ │ │ ├── syscalls_darwin_amd64.go │ │ │ ├── syscalls_linux.go │ │ │ ├── LICENSE │ │ │ ├── termbox_common.go │ │ │ ├── syscalls_windows.go │ │ │ └── collect_terminfo.py │ ├── golang │ │ └── protobuf │ │ │ ├── AUTHORS │ │ │ ├── CONTRIBUTORS │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── proto │ │ │ ├── map_test.go │ │ │ ├── Makefile │ │ │ ├── size2_test.go │ │ │ ├── message_set_test.go │ │ │ └── encode_test.go │ │ │ ├── LICENSE │ │ │ ├── Make.protobuf │ │ │ └── Makefile │ ├── mattn │ │ └── go-runewidth │ │ │ ├── runewidth_js.go │ │ │ ├── .travis.yml │ │ │ ├── runewidth_windows.go │ │ │ ├── README.mkd │ │ │ ├── LICENSE │ │ │ └── runewidth_posix.go │ ├── maruel │ │ └── panicparse │ │ │ ├── .travis.yml │ │ │ ├── main.go │ │ │ ├── Gopkg.toml │ │ │ └── Gopkg.lock │ ├── inconshreveable │ │ └── mousetrap │ │ │ ├── trap_others.go │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── trap_windows_1.4.go │ │ │ └── trap_windows.go │ └── mitchellh │ │ └── go-wordwrap │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── wordwrap.go │ │ └── wordwrap_test.go ├── golang.org │ └── x │ │ ├── net │ │ ├── codereview.cfg │ │ ├── .gitignore │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── .gitattributes │ │ ├── README.md │ │ ├── context │ │ │ ├── go19.go │ │ │ ├── ctxhttp │ │ │ │ ├── ctxhttp_17_test.go │ │ │ │ ├── ctxhttp_pre17_test.go │ │ │ │ ├── ctxhttp.go │ │ │ │ └── ctxhttp_test.go │ │ │ ├── withtimeout_test.go │ │ │ ├── context.go │ │ │ └── go17.go │ │ ├── CONTRIBUTING.md │ │ ├── PATENTS │ │ └── LICENSE │ │ └── oauth2 │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── internal │ │ ├── doc.go │ │ ├── transport_test.go │ │ ├── oauth2_test.go │ │ ├── transport.go │ │ └── oauth2.go │ │ ├── .travis.yml │ │ ├── client_appengine.go │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── token_test.go │ │ ├── example_test.go │ │ ├── README.md │ │ └── transport_test.go └── google.golang.org │ └── appengine │ ├── internal │ ├── api_race_test.go │ ├── main.go │ ├── identity.go │ ├── base │ │ └── api_base.proto │ ├── app_id.go │ ├── app_id_test.go │ ├── main_vm.go │ ├── remote_api │ │ └── remote_api.proto │ ├── identity_classic.go │ ├── regen.sh │ ├── net.go │ ├── metadata.go │ ├── net_test.go │ ├── urlfetch │ │ └── urlfetch_service.proto │ ├── internal_vm_test.go │ └── identity_vm.go │ ├── timeout.go │ ├── .travis.yml │ ├── appengine_vm.go │ ├── namespace.go │ ├── appengine_test.go │ ├── namespace_test.go │ └── errors.go ├── cmd └── spotctl │ ├── version.go │ └── auth.go ├── bin ├── build └── package ├── Formula └── spotctl.rb ├── Gopkg.toml ├── LICENSE ├── README.md └── Gopkg.lock /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | release 3 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | 3 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/codereview.cfg: -------------------------------------------------------------------------------- 1 | issuerepo: golang/go 2 | -------------------------------------------------------------------------------- /cmd/spotctl/version.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var ( 4 | version = "1.0.1" 5 | ) 6 | -------------------------------------------------------------------------------- /vendor/github.com/zmb3/spotify/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.8 5 | - 1.9 6 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - tip 5 | 6 | script: go test -v ./ -------------------------------------------------------------------------------- /vendor/golang.org/x/net/.gitignore: -------------------------------------------------------------------------------- 1 | # Add no patterns to .hgignore except for files generated by the build. 2 | last-change 3 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/command_notwin.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package cobra 4 | 5 | var preExecHookFn func(*Command) 6 | -------------------------------------------------------------------------------- /vendor/github.com/nsf/termbox-go/AUTHORS: -------------------------------------------------------------------------------- 1 | # Please keep this file sorted. 2 | 3 | Georg Reinke 4 | nsf 5 | -------------------------------------------------------------------------------- /bin/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | go build -o build/spotctl \ 4 | -ldflags "-X main.spotifyClientID=$SPOTIFY_CLIENT_ID -X main.spotifyClientSecret=$SPOTIFY_CLIENT_SECRET" \ 5 | ./cmd/spotctl/... 6 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.mailmap: -------------------------------------------------------------------------------- 1 | Steve Francia 2 | Bjørn Erik Pedersen 3 | Fabiano Franz 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_js.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package runewidth 4 | 5 | func IsEastAsian() bool { 6 | // TODO: Implement this for the web. Detect east asian in a compatible way, and return true. 7 | return false 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/zmb3/spotify/full_tests.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM - The tests that actually hit the Spotify Web API don't run by default. 3 | REM - Use this script to run them in addition to the standard unit tests. 4 | 5 | cmd /C "set FULLTEST=y && go test %*" 6 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.[568ao] 3 | *.ao 4 | *.so 5 | *.pyc 6 | ._* 7 | .nfs.* 8 | [568a].out 9 | *~ 10 | *.orig 11 | core 12 | _obj 13 | _test 14 | _testmain.go 15 | protoc-gen-go/testdata/multi/*.pb.go 16 | _conformance/_conformance 17 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - tip 4 | before_install: 5 | - go get github.com/mattn/goveralls 6 | - go get golang.org/x/tools/cmd/cover 7 | script: 8 | - $HOME/gopath/bin/goveralls -repotoken lAKAWPzcGsD3A8yBX3BGGtRUdJ6CaGERL 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/internal/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package internal contains support packages for oauth2 package. 6 | package internal 7 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/api_race_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build race 6 | 7 | package internal 8 | 9 | func init() { raceDetector = true } 10 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/glide.yaml: -------------------------------------------------------------------------------- 1 | package: github.com/gizak/termui 2 | import: 3 | - package: github.com/mattn/go-runewidth 4 | - package: github.com/mitchellh/go-wordwrap 5 | - package: github.com/nsf/termbox-go 6 | - package: golang.org/x/net 7 | subpackages: 8 | - websocket 9 | - package: github.com/maruel/panicparse 10 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/linechart_others.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | // +build !windows 6 | 7 | package termui 8 | 9 | const VDASH = '┊' 10 | const HDASH = '┈' 11 | const ORIGIN = '└' 12 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/linechart_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package termui 8 | 9 | const VDASH = '|' 10 | const HDASH = '-' 11 | const ORIGIN = '+' 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - tip 5 | 6 | install: 7 | - export GOPATH="$HOME/gopath" 8 | - mkdir -p "$GOPATH/src/golang.org/x" 9 | - mv "$TRAVIS_BUILD_DIR" "$GOPATH/src/golang.org/x/oauth2" 10 | - go get -v -t -d golang.org/x/oauth2/... 11 | 12 | script: 13 | - go test -v golang.org/x/oauth2/... 14 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: go 4 | 5 | go: 6 | - 1.7.3 7 | - 1.8.1 8 | - tip 9 | 10 | matrix: 11 | allow_failures: 12 | - go: tip 13 | 14 | install: 15 | - go get github.com/golang/lint/golint 16 | - export PATH=$GOPATH/bin:$PATH 17 | - go install ./... 18 | 19 | script: 20 | - verify/all.sh -v 21 | - go test ./... 22 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build appengine 6 | 7 | package internal 8 | 9 | import ( 10 | "appengine_internal" 11 | ) 12 | 13 | func Main() { 14 | appengine_internal.Main() 15 | } 16 | -------------------------------------------------------------------------------- /Formula/spotctl.rb: -------------------------------------------------------------------------------- 1 | class Spotctl < Formula 2 | desc "A CLI to Spotify" 3 | homepage "https://github.com/jingweno/spotctl" 4 | version "1.0.1" 5 | sha256 "a0276bd0c0fb65e7b24885f17d3547276dcf9b059b9507abe51edfa5f5388f89" 6 | url "https://github.com/jingweno/spotctl/releases/download/v1.0.1/darwin-amd64-1.0.1.tar.gz" 7 | 8 | def install 9 | bin.install "spotctl" 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /vendor/github.com/maruel/panicparse/.travis.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Marc-Antoine Ruel. All rights reserved. 2 | # Use of this source code is governed under the Apache License, Version 2.0 3 | # that can be found in the LICENSE file. 4 | 5 | sudo: false 6 | language: go 7 | 8 | go: 9 | - 1.8.x 10 | - 1.x 11 | 12 | before_install: 13 | - go get github.com/maruel/pre-commit-go/cmd/pcg 14 | 15 | script: 16 | - pcg 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/.gitattributes: -------------------------------------------------------------------------------- 1 | # Treat all files in this repo as binary, with no git magic updating 2 | # line endings. Windows users contributing to Go will need to use a 3 | # modern version of git and editors capable of LF line endings. 4 | # 5 | # We'll prevent accidental CRLF line endings from entering the repo 6 | # via the git-review gofmt checks. 7 | # 8 | # See golang.org/issue/9281 9 | 10 | * -text 11 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/command_win.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package cobra 4 | 5 | import ( 6 | "os" 7 | "time" 8 | 9 | "github.com/inconshreveable/mousetrap" 10 | ) 11 | 12 | var preExecHookFn = preExecHook 13 | 14 | func preExecHook(c *Command) { 15 | if MousetrapHelpText != "" && mousetrap.StartedByExplorer() { 16 | c.Print(MousetrapHelpText) 17 | time.Sleep(5 * time.Second) 18 | os.Exit(1) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | .DS_Store 26 | /vendor 27 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/block_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package termui 8 | 9 | const TOP_RIGHT = '+' 10 | const VERTICAL_LINE = '|' 11 | const HORIZONTAL_LINE = '-' 12 | const TOP_LEFT = '+' 13 | const BOTTOM_RIGHT = '+' 14 | const BOTTOM_LEFT = '+' 15 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.6.x 5 | - 1.7.x 6 | - 1.8.x 7 | - 1.9.x 8 | 9 | install: 10 | - go get -v -d -t github.com/golang/protobuf/... 11 | - curl -L https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip -o /tmp/protoc.zip 12 | - unzip /tmp/protoc.zip -d $HOME/protoc 13 | 14 | env: 15 | - PATH=$HOME/protoc/bin:$PATH 16 | 17 | script: 18 | - make all test 19 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/identity.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | import netcontext "golang.org/x/net/context" 8 | 9 | // These functions are implementations of the wrapper functions 10 | // in ../appengine/identity.go. See that file for commentary. 11 | 12 | func AppID(c netcontext.Context) string { 13 | return appID(FullyQualifiedAppID(c)) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_windows.go: -------------------------------------------------------------------------------- 1 | package runewidth 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | var ( 8 | kernel32 = syscall.NewLazyDLL("kernel32") 9 | procGetConsoleOutputCP = kernel32.NewProc("GetConsoleOutputCP") 10 | ) 11 | 12 | // IsEastAsian return true if the current locale is CJK 13 | func IsEastAsian() bool { 14 | r1, _, _ := procGetConsoleOutputCP.Call() 15 | if r1 == 0 { 16 | return false 17 | } 18 | 19 | switch int(r1) { 20 | case 932, 51932, 936, 949, 950: 21 | return true 22 | } 23 | 24 | return false 25 | } 26 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/timeout.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package appengine 6 | 7 | import "golang.org/x/net/context" 8 | 9 | // IsTimeoutError reports whether err is a timeout error. 10 | func IsTimeoutError(err error) bool { 11 | if err == context.DeadlineExceeded { 12 | return true 13 | } 14 | if t, ok := err.(interface { 15 | IsTimeout() bool 16 | }); ok { 17 | return t.IsTimeout() 18 | } 19 | return false 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/trap_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package mousetrap 4 | 5 | // StartedByExplorer returns true if the program was invoked by the user 6 | // double-clicking on the executable from explorer.exe 7 | // 8 | // It is conservative and returns false if any of the internal calls fail. 9 | // It does not guarantee that the program was run from a terminal. It only can tell you 10 | // whether it was launched from explorer.exe 11 | // 12 | // On non-Windows platforms, it always returns false. 13 | func StartedByExplorer() bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/block_common.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | // +build !windows 6 | 7 | package termui 8 | 9 | const TOP_RIGHT = '┐' 10 | const VERTICAL_LINE = '│' 11 | const HORIZONTAL_LINE = '─' 12 | const TOP_LEFT = '┌' 13 | const BOTTOM_RIGHT = '┘' 14 | const BOTTOM_LEFT = '└' 15 | const VERTICAL_LEFT = '┤' 16 | const VERTICAL_RIGHT = '├' 17 | const HORIZONTAL_DOWN = '┬' 18 | const HORIZONTAL_UP = '┴' 19 | const QUOTA_LEFT = '«' 20 | const QUOTA_RIGHT = '»' 21 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.6.3 5 | - 1.7.1 6 | 7 | install: 8 | - go get -v -t -d google.golang.org/appengine/... 9 | - mkdir sdk 10 | - curl -o sdk.zip "https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.40.zip" 11 | - unzip -q sdk.zip -d sdk 12 | - export APPENGINE_DEV_APPSERVER=$(pwd)/sdk/go_appengine/dev_appserver.py 13 | 14 | script: 15 | - go version 16 | - go test -v google.golang.org/appengine/... 17 | - go test -v -race google.golang.org/appengine/... 18 | - sdk/go_appengine/goapp test -v google.golang.org/appengine/... 19 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Alan Shreve 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | matrix: 4 | include: 5 | - go: 1.7.6 6 | - go: 1.8.3 7 | - go: tip 8 | allow_failures: 9 | - go: tip 10 | 11 | before_install: 12 | - mkdir -p bin 13 | - curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.3/shellcheck 14 | - chmod +x bin/shellcheck 15 | script: 16 | - PATH=$PATH:$PWD/bin go test -v ./... 17 | - go build 18 | - diff -u <(echo -n) <(gofmt -d -s .) 19 | - if [ -z $NOVET ]; then 20 | diff -u <(echo -n) <(go tool vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint'); 21 | fi 22 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/mkdocs.yml: -------------------------------------------------------------------------------- 1 | pages: 2 | - Home: 'index.md' 3 | - Quickstart: 'quickstart.md' 4 | - Recipes: 'recipes.md' 5 | - References: 6 | - Layouts: 'layouts.md' 7 | - Components: 'components.md' 8 | - Events: 'events.md' 9 | - Themes: 'themes.md' 10 | - Versions: 'versions.md' 11 | - About: 'about.md' 12 | 13 | site_name: termui 14 | repo_url: https://github.com/gizak/termui/ 15 | site_description: 'termui user guide' 16 | site_author: gizak 17 | 18 | docs_dir: '_docs' 19 | 20 | theme: readthedocs 21 | 22 | markdown_extensions: 23 | - smarty 24 | - admonition 25 | - toc 26 | 27 | extra: 28 | version: 1.0 29 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | # Vim files https://github.com/github/gitignore/blob/master/Global/Vim.gitignore 23 | # swap 24 | [._]*.s[a-w][a-z] 25 | [._]s[a-w][a-z] 26 | # session 27 | Session.vim 28 | # temporary 29 | .netrwhist 30 | *~ 31 | # auto-generated tag files 32 | tags 33 | 34 | *.exe 35 | 36 | cobra.test 37 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/par_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import "testing" 8 | 9 | func TestPar_NoBorderBackground(t *testing.T) { 10 | par := NewPar("a") 11 | par.Border = false 12 | par.Bg = ColorBlue 13 | par.TextBgColor = ColorBlue 14 | par.Width = 2 15 | par.Height = 2 16 | 17 | pts := par.Buffer() 18 | for _, p := range pts.CellMap { 19 | t.Log(p) 20 | if p.Bg != par.Bg { 21 | t.Errorf("expected color to be %v but got %v", par.Bg, p.Bg) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/cobra_test.go: -------------------------------------------------------------------------------- 1 | package cobra 2 | 3 | import ( 4 | "testing" 5 | "text/template" 6 | ) 7 | 8 | func TestAddTemplateFunctions(t *testing.T) { 9 | AddTemplateFunc("t", func() bool { return true }) 10 | AddTemplateFuncs(template.FuncMap{ 11 | "f": func() bool { return false }, 12 | "h": func() string { return "Hello," }, 13 | "w": func() string { return "world." }}) 14 | 15 | c := &Command{} 16 | c.SetUsageTemplate(`{{if t}}{{h}}{{end}}{{if f}}{{h}}{{end}} {{w}}`) 17 | 18 | const expected = "Hello, world." 19 | if got := c.UsageString(); got != expected { 20 | t.Errorf("Expected UsageString: %v\nGot: %v", expected, got) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/client_appengine.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build appengine 6 | 7 | // App Engine hooks. 8 | 9 | package oauth2 10 | 11 | import ( 12 | "net/http" 13 | 14 | "golang.org/x/net/context" 15 | "golang.org/x/oauth2/internal" 16 | "google.golang.org/appengine/urlfetch" 17 | ) 18 | 19 | func init() { 20 | internal.RegisterContextClientFunc(contextClientAppEngine) 21 | } 22 | 23 | func contextClientAppEngine(ctx context.Context) (*http.Client, error) { 24 | return urlfetch.Client(ctx), nil 25 | } 26 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/appengine_vm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | 7 | package appengine 8 | 9 | import ( 10 | "golang.org/x/net/context" 11 | 12 | "google.golang.org/appengine/internal" 13 | ) 14 | 15 | // BackgroundContext returns a context not associated with a request. 16 | // This should only be used when not servicing a request. 17 | // This only works in App Engine "flexible environment". 18 | func BackgroundContext() context.Context { 19 | return internal.BackgroundContext() 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/buffer_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import ( 8 | "image" 9 | "testing" 10 | ) 11 | 12 | func TestBufferUnion(t *testing.T) { 13 | b0 := NewBuffer() 14 | b1 := NewBuffer() 15 | 16 | b1.Area.Max.X = 100 17 | b1.Area.Max.Y = 100 18 | b0.Area.Max.X = 50 19 | b0.Merge(b1) 20 | if b0.Area.Max.X != 100 { 21 | t.Errorf("Buffer.Merge unions Area failed: should:%v, actual %v,%v", image.Rect(0, 0, 50, 0).Union(image.Rect(0, 0, 100, 100)), b1.Area, b0.Area) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/README.md: -------------------------------------------------------------------------------- 1 | # Go Networking 2 | 3 | This repository holds supplementary Go networking libraries. 4 | 5 | ## Download/Install 6 | 7 | The easiest way to install is to run `go get -u golang.org/x/net`. You can 8 | also manually git clone the repository to `$GOPATH/src/golang.org/x/net`. 9 | 10 | ## Report Issues / Send Patches 11 | 12 | This repository uses Gerrit for code changes. To learn how to submit 13 | changes to this repository, see https://golang.org/doc/contribute.html. 14 | The main issue tracker for the net repository is located at 15 | https://github.com/golang/go/issues. Prefix your issue with "x/net:" in the 16 | subject line, so it is easy to find. 17 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/base/api_base.proto: -------------------------------------------------------------------------------- 1 | // Built-in base types for API calls. Primarily useful as return types. 2 | 3 | syntax = "proto2"; 4 | option go_package = "base"; 5 | 6 | package appengine.base; 7 | 8 | message StringProto { 9 | required string value = 1; 10 | } 11 | 12 | message Integer32Proto { 13 | required int32 value = 1; 14 | } 15 | 16 | message Integer64Proto { 17 | required int64 value = 1; 18 | } 19 | 20 | message BoolProto { 21 | required bool value = 1; 22 | } 23 | 24 | message DoubleProto { 25 | required double value = 1; 26 | } 27 | 28 | message BytesProto { 29 | required bytes value = 1 [ctype=CORD]; 30 | } 31 | 32 | message VoidProto { 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/go19.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.9 6 | 7 | package context 8 | 9 | import "context" // standard library's context, as of Go 1.7 10 | 11 | // A Context carries a deadline, a cancelation signal, and other values across 12 | // API boundaries. 13 | // 14 | // Context's methods may be called by multiple goroutines simultaneously. 15 | type Context = context.Context 16 | 17 | // A CancelFunc tells an operation to abandon its work. 18 | // A CancelFunc does not wait for the work to stop. 19 | // After the first call, subsequent calls to a CancelFunc do nothing. 20 | type CancelFunc = context.CancelFunc 21 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | /* 6 | Package termui is a library designed for creating command line UI. For more info, goto http://github.com/gizak/termui 7 | 8 | A simplest example: 9 | package main 10 | 11 | import ui "github.com/gizak/termui" 12 | 13 | func main() { 14 | if err:=ui.Init(); err != nil { 15 | panic(err) 16 | } 17 | defer ui.Close() 18 | 19 | g := ui.NewGauge() 20 | g.Percent = 50 21 | g.Width = 50 22 | g.BorderLabel = "Gauge" 23 | 24 | ui.Render(g) 25 | 26 | ui.Loop() 27 | } 28 | */ 29 | package termui 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/ctxhttp/ctxhttp_17_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !plan9,go1.7 6 | 7 | package ctxhttp 8 | 9 | import ( 10 | "io" 11 | "net/http" 12 | "net/http/httptest" 13 | "testing" 14 | 15 | "context" 16 | ) 17 | 18 | func TestGo17Context(t *testing.T) { 19 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 20 | io.WriteString(w, "ok") 21 | })) 22 | defer ts.Close() 23 | ctx := context.Background() 24 | resp, err := Get(ctx, http.DefaultClient, ts.URL) 25 | if resp == nil || err != nil { 26 | t.Fatalf("error received from client: %v %v", err, resp) 27 | } 28 | resp.Body.Close() 29 | } 30 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/app_id.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | import ( 8 | "strings" 9 | ) 10 | 11 | func parseFullAppID(appid string) (partition, domain, displayID string) { 12 | if i := strings.Index(appid, "~"); i != -1 { 13 | partition, appid = appid[:i], appid[i+1:] 14 | } 15 | if i := strings.Index(appid, ":"); i != -1 { 16 | domain, appid = appid[:i], appid[i+1:] 17 | } 18 | return partition, domain, appid 19 | } 20 | 21 | // appID returns "appid" or "domain.com:appid". 22 | func appID(fullAppID string) string { 23 | _, dom, dis := parseFullAppID(fullAppID) 24 | if dom != "" { 25 | return dom + ":" + dis 26 | } 27 | return dis 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/events_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import "testing" 8 | 9 | var ps = []string{ 10 | "", 11 | "/", 12 | "/a", 13 | "/b", 14 | "/a/c", 15 | "/a/b", 16 | "/a/b/c", 17 | "/a/b/c/d", 18 | "/a/b/c/d/"} 19 | 20 | func TestMatchScore(t *testing.T) { 21 | chk := func(a, b string, s bool) { 22 | if c := isPathMatch(a, b); c != s { 23 | t.Errorf("\na:%s\nb:%s\nshould:%t\nactual:%t", a, b, s, c) 24 | } 25 | } 26 | 27 | chk(ps[1], ps[1], true) 28 | chk(ps[1], ps[2], true) 29 | chk(ps[2], ps[1], false) 30 | chk(ps[4], ps[1], false) 31 | chk(ps[6], ps[2], false) 32 | chk(ps[4], ps[5], false) 33 | } 34 | 35 | func TestCrtEvt(t *testing.T) { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | # Gopkg.toml example 3 | # 4 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 5 | # for detailed Gopkg.toml documentation. 6 | # 7 | # required = ["github.com/user/thing/cmd/thing"] 8 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 9 | # 10 | # [[constraint]] 11 | # name = "github.com/user/project" 12 | # version = "1.0.0" 13 | # 14 | # [[constraint]] 15 | # name = "github.com/user/project2" 16 | # branch = "dev" 17 | # source = "github.com/myfork/project2" 18 | # 19 | # [[override]] 20 | # name = "github.com/x/y" 21 | # version = "2.4.0" 22 | 23 | 24 | [[constraint]] 25 | name = "github.com/spf13/cobra" 26 | branch = "master" 27 | 28 | [[constraint]] 29 | branch = "master" 30 | name = "github.com/zmb3/spotify" 31 | 32 | [[constraint]] 33 | branch = "master" 34 | name = "github.com/gizak/termui" 35 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/export_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package pflag 6 | 7 | import ( 8 | "io/ioutil" 9 | "os" 10 | ) 11 | 12 | // Additional routines compiled into the package only during testing. 13 | 14 | // ResetForTesting clears all flag state and sets the usage function as directed. 15 | // After calling ResetForTesting, parse errors in flag handling will not 16 | // exit the program. 17 | func ResetForTesting(usage func()) { 18 | CommandLine = &FlagSet{ 19 | name: os.Args[0], 20 | errorHandling: ContinueOnError, 21 | output: ioutil.Discard, 22 | } 23 | Usage = usage 24 | } 25 | 26 | // GetCommandLine returns the default FlagSet. 27 | func GetCommandLine() *FlagSet { 28 | return CommandLine 29 | } 30 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/namespace.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package appengine 6 | 7 | import ( 8 | "fmt" 9 | "regexp" 10 | 11 | "golang.org/x/net/context" 12 | 13 | "google.golang.org/appengine/internal" 14 | ) 15 | 16 | // Namespace returns a replacement context that operates within the given namespace. 17 | func Namespace(c context.Context, namespace string) (context.Context, error) { 18 | if !validNamespace.MatchString(namespace) { 19 | return nil, fmt.Errorf("appengine: namespace %q does not match /%s/", namespace, validNamespace) 20 | } 21 | return internal.NamespacedContext(c, namespace), nil 22 | } 23 | 24 | // validNamespace matches valid namespace names. 25 | var validNamespace = regexp.MustCompile(`^[0-9A-Za-z._-]{0,100}$`) 26 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package pflag_test 6 | 7 | import ( 8 | "fmt" 9 | 10 | "github.com/spf13/pflag" 11 | ) 12 | 13 | func ExampleShorthandLookup() { 14 | name := "verbose" 15 | short := name[:1] 16 | 17 | pflag.BoolP(name, short, false, "verbose output") 18 | 19 | // len(short) must be == 1 20 | flag := pflag.ShorthandLookup(short) 21 | 22 | fmt.Println(flag.Name) 23 | } 24 | 25 | func ExampleFlagSet_ShorthandLookup() { 26 | name := "verbose" 27 | short := name[:1] 28 | 29 | fs := pflag.NewFlagSet("Example", pflag.ContinueOnError) 30 | fs.BoolP(name, short, false, "verbose output") 31 | 32 | // len(short) must be == 1 33 | flag := fs.ShorthandLookup(short) 34 | 35 | fmt.Println(flag.Name) 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/README.mkd: -------------------------------------------------------------------------------- 1 | go-runewidth 2 | ============ 3 | 4 | [![Build Status](https://travis-ci.org/mattn/go-runewidth.png?branch=master)](https://travis-ci.org/mattn/go-runewidth) 5 | [![Coverage Status](https://coveralls.io/repos/mattn/go-runewidth/badge.png?branch=HEAD)](https://coveralls.io/r/mattn/go-runewidth?branch=HEAD) 6 | [![GoDoc](https://godoc.org/github.com/mattn/go-runewidth?status.svg)](http://godoc.org/github.com/mattn/go-runewidth) 7 | [![Go Report Card](https://goreportcard.com/badge/github.com/mattn/go-runewidth)](https://goreportcard.com/report/github.com/mattn/go-runewidth) 8 | 9 | Provides functions to get fixed width of the character or string. 10 | 11 | Usage 12 | ----- 13 | 14 | ```go 15 | runewidth.StringWidth("つのだ☆HIRO") == 12 16 | ``` 17 | 18 | 19 | Author 20 | ------ 21 | 22 | Yasuhiro Matsumoto 23 | 24 | License 25 | ------- 26 | 27 | under the MIT License: http://mattn.mit-license.org/2013 28 | -------------------------------------------------------------------------------- /vendor/github.com/nsf/termbox-go/syscalls_freebsd.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs syscalls.go 3 | 4 | package termbox 5 | 6 | type syscall_Termios struct { 7 | Iflag uint32 8 | Oflag uint32 9 | Cflag uint32 10 | Lflag uint32 11 | Cc [20]uint8 12 | Ispeed uint32 13 | Ospeed uint32 14 | } 15 | 16 | const ( 17 | syscall_IGNBRK = 0x1 18 | syscall_BRKINT = 0x2 19 | syscall_PARMRK = 0x8 20 | syscall_ISTRIP = 0x20 21 | syscall_INLCR = 0x40 22 | syscall_IGNCR = 0x80 23 | syscall_ICRNL = 0x100 24 | syscall_IXON = 0x200 25 | syscall_OPOST = 0x1 26 | syscall_ECHO = 0x8 27 | syscall_ECHONL = 0x10 28 | syscall_ICANON = 0x100 29 | syscall_ISIG = 0x80 30 | syscall_IEXTEN = 0x400 31 | syscall_CSIZE = 0x300 32 | syscall_PARENB = 0x1000 33 | syscall_CS8 = 0x300 34 | syscall_VMIN = 0x10 35 | syscall_VTIME = 0x11 36 | 37 | syscall_TCGETS = 0x402c7413 38 | syscall_TCSETS = 0x802c7414 39 | ) 40 | -------------------------------------------------------------------------------- /vendor/github.com/nsf/termbox-go/syscalls_netbsd.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs syscalls.go 3 | 4 | package termbox 5 | 6 | type syscall_Termios struct { 7 | Iflag uint32 8 | Oflag uint32 9 | Cflag uint32 10 | Lflag uint32 11 | Cc [20]uint8 12 | Ispeed int32 13 | Ospeed int32 14 | } 15 | 16 | const ( 17 | syscall_IGNBRK = 0x1 18 | syscall_BRKINT = 0x2 19 | syscall_PARMRK = 0x8 20 | syscall_ISTRIP = 0x20 21 | syscall_INLCR = 0x40 22 | syscall_IGNCR = 0x80 23 | syscall_ICRNL = 0x100 24 | syscall_IXON = 0x200 25 | syscall_OPOST = 0x1 26 | syscall_ECHO = 0x8 27 | syscall_ECHONL = 0x10 28 | syscall_ICANON = 0x100 29 | syscall_ISIG = 0x80 30 | syscall_IEXTEN = 0x400 31 | syscall_CSIZE = 0x300 32 | syscall_PARENB = 0x1000 33 | syscall_CS8 = 0x300 34 | syscall_VMIN = 0x10 35 | syscall_VTIME = 0x11 36 | 37 | syscall_TCGETS = 0x402c7413 38 | syscall_TCSETS = 0x802c7414 39 | ) 40 | -------------------------------------------------------------------------------- /vendor/github.com/nsf/termbox-go/syscalls_openbsd.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs syscalls.go 3 | 4 | package termbox 5 | 6 | type syscall_Termios struct { 7 | Iflag uint32 8 | Oflag uint32 9 | Cflag uint32 10 | Lflag uint32 11 | Cc [20]uint8 12 | Ispeed int32 13 | Ospeed int32 14 | } 15 | 16 | const ( 17 | syscall_IGNBRK = 0x1 18 | syscall_BRKINT = 0x2 19 | syscall_PARMRK = 0x8 20 | syscall_ISTRIP = 0x20 21 | syscall_INLCR = 0x40 22 | syscall_IGNCR = 0x80 23 | syscall_ICRNL = 0x100 24 | syscall_IXON = 0x200 25 | syscall_OPOST = 0x1 26 | syscall_ECHO = 0x8 27 | syscall_ECHONL = 0x10 28 | syscall_ICANON = 0x100 29 | syscall_ISIG = 0x80 30 | syscall_IEXTEN = 0x400 31 | syscall_CSIZE = 0x300 32 | syscall_PARENB = 0x1000 33 | syscall_CS8 = 0x300 34 | syscall_VMIN = 0x10 35 | syscall_VTIME = 0x11 36 | 37 | syscall_TCGETS = 0x402c7413 38 | syscall_TCSETS = 0x802c7414 39 | ) 40 | -------------------------------------------------------------------------------- /vendor/github.com/maruel/panicparse/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Marc-Antoine Ruel. All rights reserved. 2 | // Use of this source code is governed under the Apache License, Version 2.0 3 | // that can be found in the LICENSE file. 4 | 5 | // panicparse: analyzes stack dump of Go processes and simplifies it. 6 | // 7 | // It is mostly useful on servers will large number of identical goroutines, 8 | // making the crash dump harder to read than strictly necesary. 9 | // 10 | // Colors: 11 | // - Magenta: first goroutine to be listed. 12 | // - Yellow: main package. 13 | // - Green: standard library. 14 | // - Red: other packages. 15 | // 16 | // Bright colors are used for exported symbols. 17 | package main 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | 23 | "github.com/maruel/panicparse/internal" 24 | ) 25 | 26 | func main() { 27 | if err := internal.Main(); err != nil { 28 | fmt.Fprintf(os.Stderr, "Failed: %s\n", err) 29 | os.Exit(1) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/nsf/termbox-go/syscalls_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs syscalls.go 3 | 4 | package termbox 5 | 6 | type syscall_Termios struct { 7 | Iflag uint32 8 | Oflag uint32 9 | Cflag uint32 10 | Lflag uint32 11 | Cc [20]uint8 12 | Ispeed uint32 13 | Ospeed uint32 14 | } 15 | 16 | const ( 17 | syscall_IGNBRK = 0x1 18 | syscall_BRKINT = 0x2 19 | syscall_PARMRK = 0x8 20 | syscall_ISTRIP = 0x20 21 | syscall_INLCR = 0x40 22 | syscall_IGNCR = 0x80 23 | syscall_ICRNL = 0x100 24 | syscall_IXON = 0x200 25 | syscall_OPOST = 0x1 26 | syscall_ECHO = 0x8 27 | syscall_ECHONL = 0x10 28 | syscall_ICANON = 0x100 29 | syscall_ISIG = 0x80 30 | syscall_IEXTEN = 0x400 31 | syscall_CSIZE = 0x300 32 | syscall_PARENB = 0x1000 33 | syscall_CS8 = 0x300 34 | syscall_VMIN = 0x10 35 | syscall_VTIME = 0x11 36 | 37 | syscall_TCGETS = 0x402c7413 38 | syscall_TCSETS = 0x802c7414 39 | ) 40 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/theme_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import "testing" 8 | 9 | var cmap = map[string]Attribute{ 10 | "fg": ColorWhite, 11 | "bg": ColorDefault, 12 | "border.fg": ColorWhite, 13 | "label.fg": ColorGreen, 14 | "par.fg": ColorYellow, 15 | "par.label.bg": ColorWhite, 16 | } 17 | 18 | func TestLoopUpAttr(t *testing.T) { 19 | tbl := []struct { 20 | name string 21 | should Attribute 22 | }{ 23 | {"par.label.bg", ColorWhite}, 24 | {"par.label.fg", ColorGreen}, 25 | {"par.bg", ColorDefault}, 26 | {"bar.border.fg", ColorWhite}, 27 | {"bar.label.bg", ColorDefault}, 28 | } 29 | 30 | for _, v := range tbl { 31 | if lookUpAttr(cmap, v.name) != v.should { 32 | t.Error(v.name) 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/nsf/termbox-go/syscalls.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package termbox 4 | 5 | /* 6 | #include 7 | #include 8 | */ 9 | import "C" 10 | 11 | type syscall_Termios C.struct_termios 12 | 13 | const ( 14 | syscall_IGNBRK = C.IGNBRK 15 | syscall_BRKINT = C.BRKINT 16 | syscall_PARMRK = C.PARMRK 17 | syscall_ISTRIP = C.ISTRIP 18 | syscall_INLCR = C.INLCR 19 | syscall_IGNCR = C.IGNCR 20 | syscall_ICRNL = C.ICRNL 21 | syscall_IXON = C.IXON 22 | syscall_OPOST = C.OPOST 23 | syscall_ECHO = C.ECHO 24 | syscall_ECHONL = C.ECHONL 25 | syscall_ICANON = C.ICANON 26 | syscall_ISIG = C.ISIG 27 | syscall_IEXTEN = C.IEXTEN 28 | syscall_CSIZE = C.CSIZE 29 | syscall_PARENB = C.PARENB 30 | syscall_CS8 = C.CS8 31 | syscall_VMIN = C.VMIN 32 | syscall_VTIME = C.VTIME 33 | 34 | // on darwin change these to (on *bsd too?): 35 | // C.TIOCGETA 36 | // C.TIOCSETA 37 | syscall_TCGETS = C.TCGETS 38 | syscall_TCSETS = C.TCSETS 39 | ) 40 | -------------------------------------------------------------------------------- /vendor/github.com/nsf/termbox-go/syscalls_darwin.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs syscalls.go 3 | 4 | // +build !amd64 5 | 6 | package termbox 7 | 8 | type syscall_Termios struct { 9 | Iflag uint32 10 | Oflag uint32 11 | Cflag uint32 12 | Lflag uint32 13 | Cc [20]uint8 14 | Ispeed uint32 15 | Ospeed uint32 16 | } 17 | 18 | const ( 19 | syscall_IGNBRK = 0x1 20 | syscall_BRKINT = 0x2 21 | syscall_PARMRK = 0x8 22 | syscall_ISTRIP = 0x20 23 | syscall_INLCR = 0x40 24 | syscall_IGNCR = 0x80 25 | syscall_ICRNL = 0x100 26 | syscall_IXON = 0x200 27 | syscall_OPOST = 0x1 28 | syscall_ECHO = 0x8 29 | syscall_ECHONL = 0x10 30 | syscall_ICANON = 0x100 31 | syscall_ISIG = 0x80 32 | syscall_IEXTEN = 0x400 33 | syscall_CSIZE = 0x300 34 | syscall_PARENB = 0x1000 35 | syscall_CS8 = 0x300 36 | syscall_VMIN = 0x10 37 | syscall_VTIME = 0x11 38 | 39 | syscall_TCGETS = 0x402c7413 40 | syscall_TCSETS = 0x802c7414 41 | ) 42 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/README.md: -------------------------------------------------------------------------------- 1 | # mousetrap 2 | 3 | mousetrap is a tiny library that answers a single question. 4 | 5 | On a Windows machine, was the process invoked by someone double clicking on 6 | the executable file while browsing in explorer? 7 | 8 | ### Motivation 9 | 10 | Windows developers unfamiliar with command line tools will often "double-click" 11 | the executable for a tool. Because most CLI tools print the help and then exit 12 | when invoked without arguments, this is often very frustrating for those users. 13 | 14 | mousetrap provides a way to detect these invocations so that you can provide 15 | more helpful behavior and instructions on how to run the CLI tool. To see what 16 | this looks like, both from an organizational and a technical perspective, see 17 | https://inconshreveable.com/09-09-2014/sweat-the-small-stuff/ 18 | 19 | ### The interface 20 | 21 | The library exposes a single interface: 22 | 23 | func StartedByExplorer() (bool) 24 | -------------------------------------------------------------------------------- /vendor/github.com/nsf/termbox-go/syscalls_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs syscalls.go 3 | 4 | package termbox 5 | 6 | type syscall_Termios struct { 7 | Iflag uint64 8 | Oflag uint64 9 | Cflag uint64 10 | Lflag uint64 11 | Cc [20]uint8 12 | Pad_cgo_0 [4]byte 13 | Ispeed uint64 14 | Ospeed uint64 15 | } 16 | 17 | const ( 18 | syscall_IGNBRK = 0x1 19 | syscall_BRKINT = 0x2 20 | syscall_PARMRK = 0x8 21 | syscall_ISTRIP = 0x20 22 | syscall_INLCR = 0x40 23 | syscall_IGNCR = 0x80 24 | syscall_ICRNL = 0x100 25 | syscall_IXON = 0x200 26 | syscall_OPOST = 0x1 27 | syscall_ECHO = 0x8 28 | syscall_ECHONL = 0x10 29 | syscall_ICANON = 0x100 30 | syscall_ISIG = 0x80 31 | syscall_IEXTEN = 0x400 32 | syscall_CSIZE = 0x300 33 | syscall_PARENB = 0x1000 34 | syscall_CS8 = 0x300 35 | syscall_VMIN = 0x10 36 | syscall_VTIME = 0x11 37 | 38 | syscall_TCGETS = 0x40487413 39 | syscall_TCSETS = 0x80487414 40 | ) 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/withtimeout_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package context_test 6 | 7 | import ( 8 | "fmt" 9 | "time" 10 | 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | // This example passes a context with a timeout to tell a blocking function that 15 | // it should abandon its work after the timeout elapses. 16 | func ExampleWithTimeout() { 17 | // Pass a context with a timeout to tell a blocking function that it 18 | // should abandon its work after the timeout elapses. 19 | ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond) 20 | defer cancel() 21 | 22 | select { 23 | case <-time.After(1 * time.Second): 24 | fmt.Println("overslept") 25 | case <-ctx.Done(): 26 | fmt.Println(ctx.Err()) // prints "context deadline exceeded" 27 | } 28 | 29 | // Output: 30 | // context deadline exceeded 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/nsf/termbox-go/syscalls_linux.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs syscalls.go 3 | 4 | package termbox 5 | 6 | import "syscall" 7 | 8 | type syscall_Termios syscall.Termios 9 | 10 | const ( 11 | syscall_IGNBRK = syscall.IGNBRK 12 | syscall_BRKINT = syscall.BRKINT 13 | syscall_PARMRK = syscall.PARMRK 14 | syscall_ISTRIP = syscall.ISTRIP 15 | syscall_INLCR = syscall.INLCR 16 | syscall_IGNCR = syscall.IGNCR 17 | syscall_ICRNL = syscall.ICRNL 18 | syscall_IXON = syscall.IXON 19 | syscall_OPOST = syscall.OPOST 20 | syscall_ECHO = syscall.ECHO 21 | syscall_ECHONL = syscall.ECHONL 22 | syscall_ICANON = syscall.ICANON 23 | syscall_ISIG = syscall.ISIG 24 | syscall_IEXTEN = syscall.IEXTEN 25 | syscall_CSIZE = syscall.CSIZE 26 | syscall_PARENB = syscall.PARENB 27 | syscall_CS8 = syscall.CS8 28 | syscall_VMIN = syscall.VMIN 29 | syscall_VTIME = syscall.VTIME 30 | 31 | syscall_TCGETS = syscall.TCGETS 32 | syscall_TCSETS = syscall.TCSETS 33 | ) 34 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/appengine_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package appengine 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestValidGeoPoint(t *testing.T) { 12 | testCases := []struct { 13 | desc string 14 | pt GeoPoint 15 | want bool 16 | }{ 17 | { 18 | "valid", 19 | GeoPoint{67.21, 13.37}, 20 | true, 21 | }, 22 | { 23 | "high lat", 24 | GeoPoint{-90.01, 13.37}, 25 | false, 26 | }, 27 | { 28 | "low lat", 29 | GeoPoint{90.01, 13.37}, 30 | false, 31 | }, 32 | { 33 | "high lng", 34 | GeoPoint{67.21, 182}, 35 | false, 36 | }, 37 | { 38 | "low lng", 39 | GeoPoint{67.21, -181}, 40 | false, 41 | }, 42 | } 43 | 44 | for _, tc := range testCases { 45 | if got := tc.pt.Valid(); got != tc.want { 46 | t.Errorf("%s: got %v, want %v", tc.desc, got, tc.want) 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/maruel/panicparse/Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | # Gopkg.toml example 3 | # 4 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 5 | # for detailed Gopkg.toml documentation. 6 | # 7 | # required = ["github.com/user/thing/cmd/thing"] 8 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 9 | # 10 | # [[constraint]] 11 | # name = "github.com/user/project" 12 | # version = "1.0.0" 13 | # 14 | # [[constraint]] 15 | # name = "github.com/user/project2" 16 | # branch = "dev" 17 | # source = "github.com/myfork/project2" 18 | # 19 | # [[override]] 20 | # name = "github.com/x/y" 21 | # version = "2.4.0" 22 | 23 | 24 | [[constraint]] 25 | name = "github.com/maruel/ut" 26 | version = "1.0.0" 27 | 28 | [[constraint]] 29 | name = "github.com/mattn/go-colorable" 30 | version = "0.0.9" 31 | 32 | [[constraint]] 33 | name = "github.com/mattn/go-isatty" 34 | version = "0.0.2" 35 | 36 | [[constraint]] 37 | branch = "master" 38 | name = "github.com/mgutz/ansi" 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/internal/transport_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | import ( 8 | "net/http" 9 | "testing" 10 | 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | func TestContextClient(t *testing.T) { 15 | rc := &http.Client{} 16 | RegisterContextClientFunc(func(context.Context) (*http.Client, error) { 17 | return rc, nil 18 | }) 19 | 20 | c := &http.Client{} 21 | ctx := context.WithValue(context.Background(), HTTPClient, c) 22 | 23 | hc, err := ContextClient(ctx) 24 | if err != nil { 25 | t.Fatalf("want valid client; got err = %v", err) 26 | } 27 | if hc != c { 28 | t.Fatalf("want context client = %p; got = %p", c, hc) 29 | } 30 | 31 | hc, err = ContextClient(context.TODO()) 32 | if err != nil { 33 | t.Fatalf("want valid client; got err = %v", err) 34 | } 35 | if hc != rc { 36 | t.Fatalf("want registered client = %p; got = %p", c, hc) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/pos_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import ( 8 | "image" 9 | "testing" 10 | ) 11 | 12 | func TestAlignArea(t *testing.T) { 13 | p := image.Rect(0, 0, 100, 100) 14 | c := image.Rect(10, 10, 20, 20) 15 | 16 | nc := AlignArea(p, c, AlignLeft) 17 | if nc.Min.X != 0 || nc.Max.Y != 20 { 18 | t.Errorf("AlignLeft failed:\n%+v", nc) 19 | } 20 | 21 | nc = AlignArea(p, c, AlignCenter) 22 | if nc.Min.X != 45 || nc.Max.Y != 55 { 23 | t.Error("AlignCenter failed") 24 | } 25 | 26 | nc = AlignArea(p, c, AlignBottom|AlignRight) 27 | if nc.Min.X != 90 || nc.Max.Y != 100 { 28 | t.Errorf("AlignBottom|AlignRight failed\n%+v", nc) 29 | } 30 | } 31 | 32 | func TestMoveArea(t *testing.T) { 33 | a := image.Rect(10, 10, 20, 20) 34 | a = MoveArea(a, 5, 10) 35 | if a.Min.X != 15 || a.Min.Y != 20 || a.Max.X != 25 || a.Max.Y != 30 { 36 | t.Error("MoveArea failed") 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/namespace_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package appengine 6 | 7 | import ( 8 | "testing" 9 | 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | func TestNamespaceValidity(t *testing.T) { 14 | testCases := []struct { 15 | namespace string 16 | ok bool 17 | }{ 18 | // data from Python's namespace_manager_test.py 19 | {"", true}, 20 | {"__a.namespace.123__", true}, 21 | {"-_A....NAMESPACE-_", true}, 22 | {"-", true}, 23 | {".", true}, 24 | {".-", true}, 25 | 26 | {"?", false}, 27 | {"+", false}, 28 | {"!", false}, 29 | {" ", false}, 30 | } 31 | for _, tc := range testCases { 32 | _, err := Namespace(context.Background(), tc.namespace) 33 | if err == nil && !tc.ok { 34 | t.Errorf("Namespace %q should be rejected, but wasn't", tc.namespace) 35 | } else if err != nil && tc.ok { 36 | t.Errorf("Namespace %q should be accepted, but wasn't", tc.namespace) 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/glide.lock: -------------------------------------------------------------------------------- 1 | hash: 7a754ba100256404a978b2fc8738aee337beb822458e4b6060399fb89ebd215c 2 | updated: 2016-11-03T17:39:24.323773674-04:00 3 | imports: 4 | - name: github.com/maruel/panicparse 5 | version: ad661195ed0e88491e0f14be6613304e3b1141d6 6 | subpackages: 7 | - stack 8 | - name: github.com/mattn/go-runewidth 9 | version: 737072b4e32b7a5018b4a7125da8d12de90e8045 10 | - name: github.com/mitchellh/go-wordwrap 11 | version: ad45545899c7b13c020ea92b2072220eefad42b8 12 | - name: github.com/nsf/termbox-go 13 | version: b6acae516ace002cb8105a89024544a1480655a5 14 | - name: golang.org/x/net 15 | version: 569280fa63be4e201b975e5411e30a92178f0118 16 | subpackages: 17 | - websocket 18 | testImports: 19 | - name: github.com/davecgh/go-spew 20 | version: 346938d642f2ec3594ed81d874461961cd0faa76 21 | subpackages: 22 | - spew 23 | - name: github.com/pmezard/go-difflib 24 | version: d8ed2627bdf02c080bf22230dbb337003b7aba2d 25 | subpackages: 26 | - difflib 27 | - name: github.com/stretchr/testify 28 | version: 976c720a22c8eb4eb6a0b4348ad85ad12491a506 29 | subpackages: 30 | - assert 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Jingwen Owen Ou 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/zmb3/spotify/countries.go: -------------------------------------------------------------------------------- 1 | package spotify 2 | 3 | // ISO 3166-1 alpha 2 country codes. 4 | // 5 | // see: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 6 | const ( 7 | CountryArgentina = "AR" 8 | CountryAustralia = "AU" 9 | CountryAustria = "AT" 10 | CountryBelarus = "BY" 11 | CountryBelgium = "BE" 12 | CountryBrazil = "BR" 13 | CountryCanada = "CA" 14 | CountryChile = "CL" 15 | CountryChina = "CN" 16 | CountryGermany = "DE" 17 | CountryHongKong = "HK" 18 | CountryIreland = "IE" 19 | CountryIndia = "IN" 20 | CountryItaly = "IT" 21 | CountryJapan = "JP" 22 | CountrySpain = "ES" 23 | CountryFinland = "FI" 24 | CountryFrance = "FR" 25 | CountryMexico = "MX" 26 | CountryNewZealand = "NZ" 27 | CountryRussia = "RU" 28 | CountrySwitzerland = "CH" 29 | CountryUnitedArabEmirates = "AE" 30 | CountryUnitedKingdom = "GB" 31 | CountryUSA = "US" 32 | ) 33 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/golangflag_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package pflag 6 | 7 | import ( 8 | goflag "flag" 9 | "testing" 10 | ) 11 | 12 | func TestGoflags(t *testing.T) { 13 | goflag.String("stringFlag", "stringFlag", "stringFlag") 14 | goflag.Bool("boolFlag", false, "boolFlag") 15 | 16 | f := NewFlagSet("test", ContinueOnError) 17 | 18 | f.AddGoFlagSet(goflag.CommandLine) 19 | err := f.Parse([]string{"--stringFlag=bob", "--boolFlag"}) 20 | if err != nil { 21 | t.Fatal("expected no error; get", err) 22 | } 23 | 24 | getString, err := f.GetString("stringFlag") 25 | if err != nil { 26 | t.Fatal("expected no error; get", err) 27 | } 28 | if getString != "bob" { 29 | t.Fatalf("expected getString=bob but got getString=%s", getString) 30 | } 31 | 32 | getBool, err := f.GetBool("boolFlag") 33 | if err != nil { 34 | t.Fatal("expected no error; get", err) 35 | } 36 | if getBool != true { 37 | t.Fatalf("expected getBool=true but got getBool=%v", getBool) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /bin/package: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | version() { 4 | ver="$(git describe --tags HEAD 2>/dev/null || true)" 5 | 6 | if [ -z "$ver" ]; then 7 | ver="$(grep version version.go | head -1 | cut -d '"' -f2)" 8 | sha="$(git rev-parse --short HEAD 2>/dev/null || true)" 9 | [ -z "$sha" ] || ver="${ver}-g${sha}" 10 | fi 11 | 12 | echo "${ver#v}" 13 | } 14 | 15 | compress() { 16 | cd release 17 | 18 | for dir in */ 19 | do 20 | base=$(basename "$dir") 21 | cp ../README.md ../LICENSE $dir 22 | 23 | echo "Compressing $base" 24 | 25 | tar -zcf "${base}.tar.gz" "$dir" 26 | rm -rf $dir 27 | done 28 | 29 | echo 30 | 31 | ls -all 32 | } 33 | 34 | OSARCH="darwin/amd64 linux/amd64 linux/386 windows/amd64 windows/386" 35 | 36 | cd cmd/spotctl 37 | echo "Packaging spotctl $(version)" 38 | 39 | go get -u github.com/mitchellh/gox 40 | 41 | gox -osarch="$OSARCH" \ 42 | -ldflags "-X main.spotifyClientID=$SPOTIFY_CLIENT_ID -X main.spotifyClientSecret=$SPOTIFY_CLIENT_SECRET -X main.version=$(version)" \ 43 | -output="../../release/{{.OS}}-{{.Arch}}-$(version)/{{.Dir}}" 44 | 45 | echo 46 | 47 | cd - 48 | 49 | compress 50 | -------------------------------------------------------------------------------- /vendor/github.com/nsf/termbox-go/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2012 termbox-go authors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/canvas_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package termui 8 | 9 | import ( 10 | "testing" 11 | 12 | "github.com/davecgh/go-spew/spew" 13 | ) 14 | 15 | func TestCanvasSet(t *testing.T) { 16 | c := NewCanvas() 17 | c.Set(0, 0) 18 | c.Set(0, 1) 19 | c.Set(0, 2) 20 | c.Set(0, 3) 21 | c.Set(1, 3) 22 | c.Set(2, 3) 23 | c.Set(3, 3) 24 | c.Set(4, 3) 25 | c.Set(5, 3) 26 | spew.Dump(c) 27 | } 28 | 29 | func TestCanvasUnset(t *testing.T) { 30 | c := NewCanvas() 31 | c.Set(0, 0) 32 | c.Set(0, 1) 33 | c.Set(0, 2) 34 | c.Unset(0, 2) 35 | spew.Dump(c) 36 | c.Unset(0, 3) 37 | spew.Dump(c) 38 | } 39 | 40 | func TestCanvasBuffer(t *testing.T) { 41 | c := NewCanvas() 42 | c.Set(0, 0) 43 | c.Set(0, 1) 44 | c.Set(0, 2) 45 | c.Set(0, 3) 46 | c.Set(1, 3) 47 | c.Set(2, 3) 48 | c.Set(3, 3) 49 | c.Set(4, 3) 50 | c.Set(5, 3) 51 | c.Set(6, 3) 52 | c.Set(7, 2) 53 | c.Set(8, 1) 54 | c.Set(9, 0) 55 | bufs := c.Buffer() 56 | spew.Dump(bufs) 57 | } 58 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/app_id_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestAppIDParsing(t *testing.T) { 12 | testCases := []struct { 13 | in string 14 | partition, domain, displayID string 15 | }{ 16 | {"simple-app-id", "", "", "simple-app-id"}, 17 | {"domain.com:domain-app-id", "", "domain.com", "domain-app-id"}, 18 | {"part~partition-app-id", "part", "", "partition-app-id"}, 19 | {"part~domain.com:display", "part", "domain.com", "display"}, 20 | } 21 | 22 | for _, tc := range testCases { 23 | part, dom, dis := parseFullAppID(tc.in) 24 | if part != tc.partition { 25 | t.Errorf("partition of %q: got %q, want %q", tc.in, part, tc.partition) 26 | } 27 | if dom != tc.domain { 28 | t.Errorf("domain of %q: got %q, want %q", tc.in, dom, tc.domain) 29 | } 30 | if dis != tc.displayID { 31 | t.Errorf("displayID of %q: got %q, want %q", tc.in, dis, tc.displayID) 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/main_vm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | 7 | package internal 8 | 9 | import ( 10 | "io" 11 | "log" 12 | "net/http" 13 | "net/url" 14 | "os" 15 | ) 16 | 17 | func Main() { 18 | installHealthChecker(http.DefaultServeMux) 19 | 20 | port := "8080" 21 | if s := os.Getenv("PORT"); s != "" { 22 | port = s 23 | } 24 | 25 | if err := http.ListenAndServe(":"+port, http.HandlerFunc(handleHTTP)); err != nil { 26 | log.Fatalf("http.ListenAndServe: %v", err) 27 | } 28 | } 29 | 30 | func installHealthChecker(mux *http.ServeMux) { 31 | // If no health check handler has been installed by this point, add a trivial one. 32 | const healthPath = "/_ah/health" 33 | hreq := &http.Request{ 34 | Method: "GET", 35 | URL: &url.URL{ 36 | Path: healthPath, 37 | }, 38 | } 39 | if _, pat := mux.Handler(hreq); pat != healthPath { 40 | mux.HandleFunc(healthPath, func(w http.ResponseWriter, r *http.Request) { 41 | io.WriteString(w, "ok") 42 | }) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/map_test.go: -------------------------------------------------------------------------------- 1 | package proto_test 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/golang/protobuf/proto" 8 | ppb "github.com/golang/protobuf/proto/proto3_proto" 9 | ) 10 | 11 | func marshalled() []byte { 12 | m := &ppb.IntMaps{} 13 | for i := 0; i < 1000; i++ { 14 | m.Maps = append(m.Maps, &ppb.IntMap{ 15 | Rtt: map[int32]int32{1: 2}, 16 | }) 17 | } 18 | b, err := proto.Marshal(m) 19 | if err != nil { 20 | panic(fmt.Sprintf("Can't marshal %+v: %v", m, err)) 21 | } 22 | return b 23 | } 24 | 25 | func BenchmarkConcurrentMapUnmarshal(b *testing.B) { 26 | in := marshalled() 27 | b.RunParallel(func(pb *testing.PB) { 28 | for pb.Next() { 29 | var out ppb.IntMaps 30 | if err := proto.Unmarshal(in, &out); err != nil { 31 | b.Errorf("Can't unmarshal ppb.IntMaps: %v", err) 32 | } 33 | } 34 | }) 35 | } 36 | 37 | func BenchmarkSequentialMapUnmarshal(b *testing.B) { 38 | in := marshalled() 39 | b.ResetTimer() 40 | for i := 0; i < b.N; i++ { 41 | var out ppb.IntMaps 42 | if err := proto.Unmarshal(in, &out); err != nil { 43 | b.Errorf("Can't unmarshal ppb.IntMaps: %v", err) 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Zack Guo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Go 2 | 3 | Go is an open source project. 4 | 5 | It is the work of hundreds of contributors. We appreciate your help! 6 | 7 | 8 | ## Filing issues 9 | 10 | When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions: 11 | 12 | 1. What version of Go are you using (`go version`)? 13 | 2. What operating system and processor architecture are you using? 14 | 3. What did you do? 15 | 4. What did you expect to see? 16 | 5. What did you see instead? 17 | 18 | General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. 19 | The gophers there will answer or ask you to file an issue if you've tripped over a bug. 20 | 21 | ## Contributing code 22 | 23 | Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) 24 | before sending patches. 25 | 26 | **We do not accept GitHub pull requests** 27 | (we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review). 28 | 29 | Unless otherwise noted, the Go source files are distributed under 30 | the BSD-style license found in the LICENSE file. 31 | 32 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option go_package = "remote_api"; 3 | 4 | package remote_api; 5 | 6 | message Request { 7 | required string service_name = 2; 8 | required string method = 3; 9 | required bytes request = 4; 10 | optional string request_id = 5; 11 | } 12 | 13 | message ApplicationError { 14 | required int32 code = 1; 15 | required string detail = 2; 16 | } 17 | 18 | message RpcError { 19 | enum ErrorCode { 20 | UNKNOWN = 0; 21 | CALL_NOT_FOUND = 1; 22 | PARSE_ERROR = 2; 23 | SECURITY_VIOLATION = 3; 24 | OVER_QUOTA = 4; 25 | REQUEST_TOO_LARGE = 5; 26 | CAPABILITY_DISABLED = 6; 27 | FEATURE_DISABLED = 7; 28 | BAD_REQUEST = 8; 29 | RESPONSE_TOO_LARGE = 9; 30 | CANCELLED = 10; 31 | REPLAY_ERROR = 11; 32 | DEADLINE_EXCEEDED = 12; 33 | } 34 | required int32 code = 1; 35 | optional string detail = 2; 36 | } 37 | 38 | message Response { 39 | optional bytes response = 1; 40 | optional bytes exception = 2; 41 | optional ApplicationError application_error = 3; 42 | optional bytes java_exception = 4; 43 | optional RpcError rpc_error = 5; 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/go-wordwrap/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Mitchell Hashimoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Go 2 | 3 | Go is an open source project. 4 | 5 | It is the work of hundreds of contributors. We appreciate your help! 6 | 7 | 8 | ## Filing issues 9 | 10 | When [filing an issue](https://github.com/golang/oauth2/issues), make sure to answer these five questions: 11 | 12 | 1. What version of Go are you using (`go version`)? 13 | 2. What operating system and processor architecture are you using? 14 | 3. What did you do? 15 | 4. What did you expect to see? 16 | 5. What did you see instead? 17 | 18 | General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. 19 | The gophers there will answer or ask you to file an issue if you've tripped over a bug. 20 | 21 | ## Contributing code 22 | 23 | Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) 24 | before sending patches. 25 | 26 | **We do not accept GitHub pull requests** 27 | (we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review). 28 | 29 | Unless otherwise noted, the Go source files are distributed under 30 | the BSD-style license found in the LICENSE file. 31 | 32 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/go-wordwrap/README.md: -------------------------------------------------------------------------------- 1 | # go-wordwrap 2 | 3 | `go-wordwrap` (Golang package: `wordwrap`) is a package for Go that 4 | automatically wraps words into multiple lines. The primary use case for this 5 | is in formatting CLI output, but of course word wrapping is a generally useful 6 | thing to do. 7 | 8 | ## Installation and Usage 9 | 10 | Install using `go get github.com/mitchellh/go-wordwrap`. 11 | 12 | Full documentation is available at 13 | http://godoc.org/github.com/mitchellh/go-wordwrap 14 | 15 | Below is an example of its usage ignoring errors: 16 | 17 | ```go 18 | wrapped := wordwrap.WrapString("foo bar baz", 3) 19 | fmt.Println(wrapped) 20 | ``` 21 | 22 | Would output: 23 | 24 | ``` 25 | foo 26 | bar 27 | baz 28 | ``` 29 | 30 | ## Word Wrap Algorithm 31 | 32 | This library doesn't use any clever algorithm for word wrapping. The wrapping 33 | is actually very naive: whenever there is whitespace or an explicit linebreak. 34 | The goal of this library is for word wrapping CLI output, so the input is 35 | typically pretty well controlled human language. Because of this, the naive 36 | approach typically works just fine. 37 | 38 | In the future, we'd like to make the algorithm more advanced. We would do 39 | so without breaking the API. 40 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/identity_classic.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build appengine 6 | 7 | package internal 8 | 9 | import ( 10 | "appengine" 11 | 12 | netcontext "golang.org/x/net/context" 13 | ) 14 | 15 | func DefaultVersionHostname(ctx netcontext.Context) string { 16 | return appengine.DefaultVersionHostname(fromContext(ctx)) 17 | } 18 | 19 | func RequestID(ctx netcontext.Context) string { return appengine.RequestID(fromContext(ctx)) } 20 | func Datacenter(_ netcontext.Context) string { return appengine.Datacenter() } 21 | func ServerSoftware() string { return appengine.ServerSoftware() } 22 | func ModuleName(ctx netcontext.Context) string { return appengine.ModuleName(fromContext(ctx)) } 23 | func VersionID(ctx netcontext.Context) string { return appengine.VersionID(fromContext(ctx)) } 24 | func InstanceID() string { return appengine.InstanceID() } 25 | func IsDevAppServer() bool { return appengine.IsDevAppServer() } 26 | 27 | func fullyQualifiedAppID(ctx netcontext.Context) string { return fromContext(ctx).FullyQualifiedAppID() } 28 | -------------------------------------------------------------------------------- /vendor/github.com/nsf/termbox-go/termbox_common.go: -------------------------------------------------------------------------------- 1 | package termbox 2 | 3 | // private API, common OS agnostic part 4 | 5 | type cellbuf struct { 6 | width int 7 | height int 8 | cells []Cell 9 | } 10 | 11 | func (this *cellbuf) init(width, height int) { 12 | this.width = width 13 | this.height = height 14 | this.cells = make([]Cell, width*height) 15 | } 16 | 17 | func (this *cellbuf) resize(width, height int) { 18 | if this.width == width && this.height == height { 19 | return 20 | } 21 | 22 | oldw := this.width 23 | oldh := this.height 24 | oldcells := this.cells 25 | 26 | this.init(width, height) 27 | this.clear() 28 | 29 | minw, minh := oldw, oldh 30 | 31 | if width < minw { 32 | minw = width 33 | } 34 | if height < minh { 35 | minh = height 36 | } 37 | 38 | for i := 0; i < minh; i++ { 39 | srco, dsto := i*oldw, i*width 40 | src := oldcells[srco : srco+minw] 41 | dst := this.cells[dsto : dsto+minw] 42 | copy(dst, src) 43 | } 44 | } 45 | 46 | func (this *cellbuf) clear() { 47 | for i := range this.cells { 48 | c := &this.cells[i] 49 | c.Ch = ' ' 50 | c.Fg = foreground 51 | c.Bg = background 52 | } 53 | } 54 | 55 | const cursor_hidden = -1 56 | 57 | func is_cursor_hidden(x, y int) bool { 58 | return x == cursor_hidden || y == cursor_hidden 59 | } 60 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file provides error functions for common API failure modes. 6 | 7 | package appengine 8 | 9 | import ( 10 | "fmt" 11 | 12 | "google.golang.org/appengine/internal" 13 | ) 14 | 15 | // IsOverQuota reports whether err represents an API call failure 16 | // due to insufficient available quota. 17 | func IsOverQuota(err error) bool { 18 | callErr, ok := err.(*internal.CallError) 19 | return ok && callErr.Code == 4 20 | } 21 | 22 | // MultiError is returned by batch operations when there are errors with 23 | // particular elements. Errors will be in a one-to-one correspondence with 24 | // the input elements; successful elements will have a nil entry. 25 | type MultiError []error 26 | 27 | func (m MultiError) Error() string { 28 | s, n := "", 0 29 | for _, e := range m { 30 | if e != nil { 31 | if n == 0 { 32 | s = e.Error() 33 | } 34 | n++ 35 | } 36 | } 37 | switch n { 38 | case 0: 39 | return "(0 errors)" 40 | case 1: 41 | return s 42 | case 2: 43 | return s + " (and 1 other error)" 44 | } 45 | return fmt.Sprintf("%s (and %d other errors)", s, n-1) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/count_test.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | ) 7 | 8 | func setUpCount(c *int) *FlagSet { 9 | f := NewFlagSet("test", ContinueOnError) 10 | f.CountVarP(c, "verbose", "v", "a counter") 11 | return f 12 | } 13 | 14 | func TestCount(t *testing.T) { 15 | testCases := []struct { 16 | input []string 17 | success bool 18 | expected int 19 | }{ 20 | {[]string{"-vvv"}, true, 3}, 21 | {[]string{"-v", "-v", "-v"}, true, 3}, 22 | {[]string{"-v", "--verbose", "-v"}, true, 3}, 23 | {[]string{"-v=3", "-v"}, true, 4}, 24 | {[]string{"-v=a"}, false, 0}, 25 | } 26 | 27 | devnull, _ := os.Open(os.DevNull) 28 | os.Stderr = devnull 29 | for i := range testCases { 30 | var count int 31 | f := setUpCount(&count) 32 | 33 | tc := &testCases[i] 34 | 35 | err := f.Parse(tc.input) 36 | if err != nil && tc.success == true { 37 | t.Errorf("expected success, got %q", err) 38 | continue 39 | } else if err == nil && tc.success == false { 40 | t.Errorf("expected failure, got success") 41 | continue 42 | } else if tc.success { 43 | c, err := f.GetCount("verbose") 44 | if err != nil { 45 | t.Errorf("Got error trying to fetch the counter flag") 46 | } 47 | if c != tc.expected { 48 | t.Errorf("expected %q, got %q", tc.expected, c) 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/internal/oauth2_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | import ( 8 | "reflect" 9 | "strings" 10 | "testing" 11 | ) 12 | 13 | func TestParseINI(t *testing.T) { 14 | tests := []struct { 15 | ini string 16 | want map[string]map[string]string 17 | }{ 18 | { 19 | `root = toor 20 | [foo] 21 | bar = hop 22 | ini = nin 23 | `, 24 | map[string]map[string]string{ 25 | "": {"root": "toor"}, 26 | "foo": {"bar": "hop", "ini": "nin"}, 27 | }, 28 | }, 29 | { 30 | `[empty] 31 | [section] 32 | empty= 33 | `, 34 | map[string]map[string]string{ 35 | "": {}, 36 | "empty": {}, 37 | "section": {"empty": ""}, 38 | }, 39 | }, 40 | { 41 | `ignore 42 | [invalid 43 | =stuff 44 | ;comment=true 45 | `, 46 | map[string]map[string]string{ 47 | "": {}, 48 | }, 49 | }, 50 | } 51 | for _, tt := range tests { 52 | result, err := ParseINI(strings.NewReader(tt.ini)) 53 | if err != nil { 54 | t.Errorf("ParseINI(%q) error %v, want: no error", tt.ini, err) 55 | continue 56 | } 57 | if !reflect.DeepEqual(result, tt.want) { 58 | t.Errorf("ParseINI(%q) = %#v, want: %#v", tt.ini, result, tt.want) 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/regen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # This script rebuilds the generated code for the protocol buffers. 4 | # To run this you will need protoc and goprotobuf installed; 5 | # see https://github.com/golang/protobuf for instructions. 6 | 7 | PKG=google.golang.org/appengine 8 | 9 | function die() { 10 | echo 1>&2 $* 11 | exit 1 12 | } 13 | 14 | # Sanity check that the right tools are accessible. 15 | for tool in go protoc protoc-gen-go; do 16 | q=$(which $tool) || die "didn't find $tool" 17 | echo 1>&2 "$tool: $q" 18 | done 19 | 20 | echo -n 1>&2 "finding package dir... " 21 | pkgdir=$(go list -f '{{.Dir}}' $PKG) 22 | echo 1>&2 $pkgdir 23 | base=$(echo $pkgdir | sed "s,/$PKG\$,,") 24 | echo 1>&2 "base: $base" 25 | cd $base 26 | 27 | # Run protoc once per package. 28 | for dir in $(find $PKG/internal -name '*.proto' | xargs dirname | sort | uniq); do 29 | echo 1>&2 "* $dir" 30 | protoc --go_out=. $dir/*.proto 31 | done 32 | 33 | for f in $(find $PKG/internal -name '*.pb.go'); do 34 | # Remove proto.RegisterEnum calls. 35 | # These cause duplicate registration panics when these packages 36 | # are used on classic App Engine. proto.RegisterEnum only affects 37 | # parsing the text format; we don't care about that. 38 | # https://code.google.com/p/googleappengine/issues/detail?id=11670#c17 39 | sed -i '/proto.RegisterEnum/d' $f 40 | done 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import re 4 | import os 5 | import io 6 | 7 | copyright = """// Copyright 2017 Zack Guo . All rights reserved. 8 | // Use of this source code is governed by a MIT license that can 9 | // be found in the LICENSE file. 10 | 11 | """ 12 | 13 | exclude_dirs = [".git", "_docs"] 14 | exclude_files = [] 15 | include_dirs = [".", "debug", "extra", "test", "_example"] 16 | 17 | 18 | def is_target(fpath): 19 | if os.path.splitext(fpath)[-1] == ".go": 20 | return True 21 | return False 22 | 23 | 24 | def update_copyright(fpath): 25 | print("processing " + fpath) 26 | f = io.open(fpath, 'r', encoding='utf-8') 27 | fstr = f.read() 28 | f.close() 29 | 30 | # remove old 31 | m = re.search('^// Copyright .+?\r?\n\r?\n', fstr, re.MULTILINE|re.DOTALL) 32 | if m: 33 | fstr = fstr[m.end():] 34 | 35 | # add new 36 | fstr = copyright + fstr 37 | f = io.open(fpath, 'w',encoding='utf-8') 38 | f.write(fstr) 39 | f.close() 40 | 41 | 42 | def main(): 43 | for d in include_dirs: 44 | files = [ 45 | os.path.join(d, f) for f in os.listdir(d) 46 | if os.path.isfile(os.path.join(d, f)) 47 | ] 48 | for f in files: 49 | if is_target(f): 50 | update_copyright(f) 51 | 52 | 53 | if __name__ == '__main__': 54 | main() 55 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | // +build go1.4 3 | 4 | package mousetrap 5 | 6 | import ( 7 | "os" 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func getProcessEntry(pid int) (*syscall.ProcessEntry32, error) { 13 | snapshot, err := syscall.CreateToolhelp32Snapshot(syscall.TH32CS_SNAPPROCESS, 0) 14 | if err != nil { 15 | return nil, err 16 | } 17 | defer syscall.CloseHandle(snapshot) 18 | var procEntry syscall.ProcessEntry32 19 | procEntry.Size = uint32(unsafe.Sizeof(procEntry)) 20 | if err = syscall.Process32First(snapshot, &procEntry); err != nil { 21 | return nil, err 22 | } 23 | for { 24 | if procEntry.ProcessID == uint32(pid) { 25 | return &procEntry, nil 26 | } 27 | err = syscall.Process32Next(snapshot, &procEntry) 28 | if err != nil { 29 | return nil, err 30 | } 31 | } 32 | } 33 | 34 | // StartedByExplorer returns true if the program was invoked by the user double-clicking 35 | // on the executable from explorer.exe 36 | // 37 | // It is conservative and returns false if any of the internal calls fail. 38 | // It does not guarantee that the program was run from a terminal. It only can tell you 39 | // whether it was launched from explorer.exe 40 | func StartedByExplorer() bool { 41 | pe, err := getProcessEntry(os.Getppid()) 42 | if err != nil { 43 | return false 44 | } 45 | return "explorer.exe" == syscall.UTF16ToString(pe.ExeFile[:]) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/zmb3/spotify/cursor.go: -------------------------------------------------------------------------------- 1 | package spotify 2 | 3 | // This file contains the types that implement Spotify's cursor-based 4 | // paging object. Like the standard paging object, this object is a 5 | // container for a set of items. Unlike the standard paging object, a 6 | // cursor-based paging object does not provide random access to the results. 7 | 8 | // Cursor contains a key that can be used to find the next set 9 | // of items. 10 | type Cursor struct { 11 | After string `json:"after"` 12 | } 13 | 14 | // cursorPage contains all of the fields in a Spotify cursor-based 15 | // paging object, except for the actual items. This type is meant 16 | // to be embedded in other types that add the Items field. 17 | type cursorPage struct { 18 | // A link to the Web API endpoint returning the full 19 | // result of this request. 20 | Endpoint string `json:"href"` 21 | // The maximum number of items returned, as set in the query 22 | // (or default value if unset). 23 | Limit int `json:"limit"` 24 | // The URL to the next set of items. 25 | Next string `json:"next"` 26 | // The total number of items available to return. 27 | Total int `json:"total"` 28 | // The cursor used to find the next set of items. 29 | Cursor Cursor `json:"cursors"` 30 | } 31 | 32 | // FullArtistCursorPage is a cursor-based paging object containing 33 | // a set of FullArtist objects. 34 | type FullArtistCursorPage struct { 35 | cursorPage 36 | Artists []FullArtist `json:"items"` 37 | } 38 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/net.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | // This file implements a network dialer that limits the number of concurrent connections. 8 | // It is only used for API calls. 9 | 10 | import ( 11 | "log" 12 | "net" 13 | "runtime" 14 | "sync" 15 | "time" 16 | ) 17 | 18 | var limitSem = make(chan int, 100) // TODO(dsymonds): Use environment variable. 19 | 20 | func limitRelease() { 21 | // non-blocking 22 | select { 23 | case <-limitSem: 24 | default: 25 | // This should not normally happen. 26 | log.Print("appengine: unbalanced limitSem release!") 27 | } 28 | } 29 | 30 | func limitDial(network, addr string) (net.Conn, error) { 31 | limitSem <- 1 32 | 33 | // Dial with a timeout in case the API host is MIA. 34 | // The connection should normally be very fast. 35 | conn, err := net.DialTimeout(network, addr, 500*time.Millisecond) 36 | if err != nil { 37 | limitRelease() 38 | return nil, err 39 | } 40 | lc := &limitConn{Conn: conn} 41 | runtime.SetFinalizer(lc, (*limitConn).Close) // shouldn't usually be required 42 | return lc, nil 43 | } 44 | 45 | type limitConn struct { 46 | close sync.Once 47 | net.Conn 48 | } 49 | 50 | func (lc *limitConn) Close() error { 51 | defer lc.close.Do(func() { 52 | limitRelease() 53 | runtime.SetFinalizer(lc, nil) 54 | }) 55 | return lc.Conn.Close() 56 | } 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/zmb3/spotify/track_test.go: -------------------------------------------------------------------------------- 1 | package spotify 2 | 3 | import ( 4 | "net/http" 5 | "testing" 6 | ) 7 | 8 | func TestFindTrack(t *testing.T) { 9 | client, server := testClientFile(http.StatusOK, "test_data/find_track.txt") 10 | defer server.Close() 11 | 12 | track, err := client.GetTrack(ID("1zHlj4dQ8ZAtrayhuDDmkY")) 13 | if err != nil { 14 | t.Error(err) 15 | return 16 | } 17 | if track.Name != "Timber" { 18 | t.Errorf("Wanted track Timer, got %s\n", track.Name) 19 | } 20 | } 21 | 22 | func TestFindTracksSimple(t *testing.T) { 23 | client, server := testClientFile(http.StatusOK, "test_data/find_tracks_simple.txt") 24 | defer server.Close() 25 | 26 | tracks, err := client.GetTracks(ID("0eGsygTp906u18L0Oimnem"), ID("1lDWb6b6ieDQ2xT7ewTC3G")) 27 | if err != nil { 28 | t.Error(err) 29 | return 30 | } 31 | if l := len(tracks); l != 2 { 32 | t.Errorf("Wanted 2 tracks, got %d\n", l) 33 | return 34 | } 35 | 36 | } 37 | 38 | func TestFindTracksNotFound(t *testing.T) { 39 | client, server := testClientFile(http.StatusOK, "test_data/find_tracks_notfound.txt") 40 | defer server.Close() 41 | 42 | tracks, err := client.GetTracks(ID("0eGsygTp906u18L0Oimnem"), ID("1lDWb6b6iecccdsdckTC3G")) 43 | if err != nil { 44 | t.Error(err) 45 | return 46 | } 47 | if l := len(tracks); l != 2 { 48 | t.Errorf("Expected 2 results, got %d\n", l) 49 | return 50 | } 51 | if tracks[0].Name != "Mr. Brightside" { 52 | t.Errorf("Expected Mr. Brightside, got %s\n", tracks[0].Name) 53 | } 54 | if tracks[1] != nil { 55 | t.Error("Expected nil track (invalid ID) but got valid track") 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/metadata.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | // This file has code for accessing metadata. 8 | // 9 | // References: 10 | // https://cloud.google.com/compute/docs/metadata 11 | 12 | import ( 13 | "fmt" 14 | "io/ioutil" 15 | "log" 16 | "net/http" 17 | "net/url" 18 | ) 19 | 20 | const ( 21 | metadataHost = "metadata" 22 | metadataPath = "/computeMetadata/v1/" 23 | ) 24 | 25 | var ( 26 | metadataRequestHeaders = http.Header{ 27 | "Metadata-Flavor": []string{"Google"}, 28 | } 29 | ) 30 | 31 | // TODO(dsymonds): Do we need to support default values, like Python? 32 | func mustGetMetadata(key string) []byte { 33 | b, err := getMetadata(key) 34 | if err != nil { 35 | log.Fatalf("Metadata fetch failed: %v", err) 36 | } 37 | return b 38 | } 39 | 40 | func getMetadata(key string) ([]byte, error) { 41 | // TODO(dsymonds): May need to use url.Parse to support keys with query args. 42 | req := &http.Request{ 43 | Method: "GET", 44 | URL: &url.URL{ 45 | Scheme: "http", 46 | Host: metadataHost, 47 | Path: metadataPath + key, 48 | }, 49 | Header: metadataRequestHeaders, 50 | Host: metadataHost, 51 | } 52 | resp, err := http.DefaultClient.Do(req) 53 | if err != nil { 54 | return nil, err 55 | } 56 | defer resp.Body.Close() 57 | if resp.StatusCode != 200 { 58 | return nil, fmt.Errorf("metadata server returned HTTP %d", resp.StatusCode) 59 | } 60 | return ioutil.ReadAll(resp.Body) 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/zmb3/spotify/library_test.go: -------------------------------------------------------------------------------- 1 | package spotify 2 | 3 | import ( 4 | "net/http" 5 | "testing" 6 | ) 7 | 8 | func TestUserHasTracks(t *testing.T) { 9 | client, server := testClientString(http.StatusOK, `[ false, true ]`) 10 | defer server.Close() 11 | 12 | contains, err := client.UserHasTracks("0udZHhCi7p1YzMlvI4fXoK", "55nlbqqFVnSsArIeYSQlqx") 13 | if err != nil { 14 | t.Error(err) 15 | } 16 | if l := len(contains); l != 2 { 17 | t.Error("Expected 2 results, got", l) 18 | } 19 | if contains[0] || !contains[1] { 20 | t.Error("Expected [false, true], got", contains) 21 | } 22 | } 23 | 24 | func TestAddTracksToLibrary(t *testing.T) { 25 | client, server := testClientString(http.StatusOK, "") 26 | defer server.Close() 27 | 28 | err := client.AddTracksToLibrary("4iV5W9uYEdYUVa79Axb7Rh", "1301WleyT98MSxVHPZCA6M") 29 | if err != nil { 30 | t.Error(err) 31 | } 32 | } 33 | 34 | func TestAddTracksToLibraryFailure(t *testing.T) { 35 | client, server := testClientString(http.StatusUnauthorized, ` 36 | { 37 | "error": { 38 | "status": 401, 39 | "message": "Invalid access token" 40 | } 41 | }`) 42 | defer server.Close() 43 | err := client.AddTracksToLibrary("4iV5W9uYEdYUVa79Axb7Rh", "1301WleyT98MSxVHPZCA6M") 44 | if err == nil { 45 | t.Error("Expected error and didn't get one") 46 | } 47 | } 48 | 49 | func TestRemoveTracksFromLibrary(t *testing.T) { 50 | client, server := testClientString(http.StatusOK, "") 51 | defer server.Close() 52 | 53 | err := client.RemoveTracksFromLibrary("4iV5W9uYEdYUVa79Axb7Rh", "1301WleyT98MSxVHPZCA6M") 54 | if err != nil { 55 | t.Error(err) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Alex Ogier. All rights reserved. 2 | Copyright (c) 2012 The Go Authors. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/ip_test.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "os" 7 | "testing" 8 | ) 9 | 10 | func setUpIP(ip *net.IP) *FlagSet { 11 | f := NewFlagSet("test", ContinueOnError) 12 | f.IPVar(ip, "address", net.ParseIP("0.0.0.0"), "IP Address") 13 | return f 14 | } 15 | 16 | func TestIP(t *testing.T) { 17 | testCases := []struct { 18 | input string 19 | success bool 20 | expected string 21 | }{ 22 | {"0.0.0.0", true, "0.0.0.0"}, 23 | {" 0.0.0.0 ", true, "0.0.0.0"}, 24 | {"1.2.3.4", true, "1.2.3.4"}, 25 | {"127.0.0.1", true, "127.0.0.1"}, 26 | {"255.255.255.255", true, "255.255.255.255"}, 27 | {"", false, ""}, 28 | {"0", false, ""}, 29 | {"localhost", false, ""}, 30 | {"0.0.0", false, ""}, 31 | {"0.0.0.", false, ""}, 32 | {"0.0.0.0.", false, ""}, 33 | {"0.0.0.256", false, ""}, 34 | {"0 . 0 . 0 . 0", false, ""}, 35 | } 36 | 37 | devnull, _ := os.Open(os.DevNull) 38 | os.Stderr = devnull 39 | for i := range testCases { 40 | var addr net.IP 41 | f := setUpIP(&addr) 42 | 43 | tc := &testCases[i] 44 | 45 | arg := fmt.Sprintf("--address=%s", tc.input) 46 | err := f.Parse([]string{arg}) 47 | if err != nil && tc.success == true { 48 | t.Errorf("expected success, got %q", err) 49 | continue 50 | } else if err == nil && tc.success == false { 51 | t.Errorf("expected failure") 52 | continue 53 | } else if tc.success { 54 | ip, err := f.GetIP("address") 55 | if err != nil { 56 | t.Errorf("Got error trying to fetch the IP flag: %v", err) 57 | } 58 | if ip.String() != tc.expected { 59 | t.Errorf("expected %q, got %q", tc.expected, ip.String()) 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/canvas.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | /* 8 | dots: 9 | ,___, 10 | |1 4| 11 | |2 5| 12 | |3 6| 13 | |7 8| 14 | ````` 15 | */ 16 | 17 | var brailleBase = '\u2800' 18 | 19 | var brailleOftMap = [4][2]rune{ 20 | {'\u0001', '\u0008'}, 21 | {'\u0002', '\u0010'}, 22 | {'\u0004', '\u0020'}, 23 | {'\u0040', '\u0080'}} 24 | 25 | // Canvas contains drawing map: i,j -> rune 26 | type Canvas map[[2]int]rune 27 | 28 | // NewCanvas returns an empty Canvas 29 | func NewCanvas() Canvas { 30 | return make(map[[2]int]rune) 31 | } 32 | 33 | func chOft(x, y int) rune { 34 | return brailleOftMap[y%4][x%2] 35 | } 36 | 37 | func (c Canvas) rawCh(x, y int) rune { 38 | if ch, ok := c[[2]int{x, y}]; ok { 39 | return ch 40 | } 41 | return '\u0000' //brailleOffset 42 | } 43 | 44 | // return coordinate in terminal 45 | func chPos(x, y int) (int, int) { 46 | return y / 4, x / 2 47 | } 48 | 49 | // Set sets a point (x,y) in the virtual coordinate 50 | func (c Canvas) Set(x, y int) { 51 | i, j := chPos(x, y) 52 | ch := c.rawCh(i, j) 53 | ch |= chOft(x, y) 54 | c[[2]int{i, j}] = ch 55 | } 56 | 57 | // Unset removes point (x,y) 58 | func (c Canvas) Unset(x, y int) { 59 | i, j := chPos(x, y) 60 | ch := c.rawCh(i, j) 61 | ch &= ^chOft(x, y) 62 | c[[2]int{i, j}] = ch 63 | } 64 | 65 | // Buffer returns un-styled points 66 | func (c Canvas) Buffer() Buffer { 67 | buf := NewBuffer() 68 | for k, v := range c { 69 | buf.Set(k[0], k[1], Cell{Ch: v + brailleBase}) 70 | } 71 | return buf 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/block_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestBlockFloat(t *testing.T) { 12 | Init() 13 | defer Close() 14 | 15 | b := NewBlock() 16 | b.X = 10 17 | b.Y = 20 18 | 19 | b.Float = AlignCenter 20 | b.Align() 21 | } 22 | 23 | func TestBlockInnerBounds(t *testing.T) { 24 | Init() 25 | defer Close() 26 | 27 | b := NewBlock() 28 | b.X = 10 29 | b.Y = 11 30 | b.Width = 12 31 | b.Height = 13 32 | 33 | assert := func(name string, x, y, w, h int) { 34 | t.Log(name) 35 | area := b.InnerBounds() 36 | cx := area.Min.X 37 | cy := area.Min.Y 38 | cw := area.Dx() 39 | ch := area.Dy() 40 | 41 | if cx != x { 42 | t.Errorf("expected x to be %d but got %d", x, cx) 43 | } 44 | if cy != y { 45 | t.Errorf("expected y to be %d but got %d\n%+v", y, cy, area) 46 | } 47 | if cw != w { 48 | t.Errorf("expected width to be %d but got %d", w, cw) 49 | } 50 | if ch != h { 51 | t.Errorf("expected height to be %d but got %d", h, ch) 52 | } 53 | } 54 | 55 | b.Border = false 56 | assert("no border, no padding", 10, 11, 12, 13) 57 | 58 | b.Border = true 59 | assert("border, no padding", 11, 12, 10, 11) 60 | 61 | b.PaddingBottom = 2 62 | assert("border, 2b padding", 11, 12, 10, 9) 63 | 64 | b.PaddingTop = 3 65 | assert("border, 2b 3t padding", 11, 15, 10, 6) 66 | 67 | b.PaddingLeft = 4 68 | assert("border, 2b 3t 4l padding", 15, 15, 6, 6) 69 | 70 | b.PaddingRight = 5 71 | assert("border, 2b 3t 4l 5r padding", 15, 15, 1, 6) 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/maruel/panicparse/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | branch = "master" 6 | name = "github.com/kr/pretty" 7 | packages = ["."] 8 | revision = "cfb55aafdaf3ec08f0db22699ab822c50091b1c4" 9 | 10 | [[projects]] 11 | branch = "master" 12 | name = "github.com/kr/text" 13 | packages = ["."] 14 | revision = "7cafcd837844e784b526369c9bce262804aebc60" 15 | 16 | [[projects]] 17 | name = "github.com/maruel/ut" 18 | packages = ["."] 19 | revision = "a9c9f15ccfa6f8b90182a53df32f4745586fbae3" 20 | version = "v1.0.0" 21 | 22 | [[projects]] 23 | name = "github.com/mattn/go-colorable" 24 | packages = ["."] 25 | revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072" 26 | version = "v0.0.9" 27 | 28 | [[projects]] 29 | name = "github.com/mattn/go-isatty" 30 | packages = ["."] 31 | revision = "fc9e8d8ef48496124e79ae0df75490096eccf6fe" 32 | version = "v0.0.2" 33 | 34 | [[projects]] 35 | branch = "master" 36 | name = "github.com/mgutz/ansi" 37 | packages = ["."] 38 | revision = "9520e82c474b0a04dd04f8a40959027271bab992" 39 | 40 | [[projects]] 41 | name = "github.com/pmezard/go-difflib" 42 | packages = ["difflib"] 43 | revision = "792786c7400a136282c1664665ae0a8db921c6c2" 44 | version = "v1.0.0" 45 | 46 | [[projects]] 47 | branch = "master" 48 | name = "golang.org/x/sys" 49 | packages = ["unix"] 50 | revision = "e42485b6e20ae7d2304ec72e535b103ed350cc02" 51 | 52 | [solve-meta] 53 | analyzer-name = "dep" 54 | analyzer-version = 1 55 | inputs-digest = "64e1c923b988d687243b43f8168fc7a83ceb603bf1ce4126022d34625cada8d9" 56 | solver-name = "gps-cdcl" 57 | solver-version = 1 58 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Go support for Protocol Buffers - Google's data interchange format 2 | 3 | Copyright 2010 The Go Authors. All rights reserved. 4 | https://github.com/golang/protobuf 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following disclaimer 14 | in the documentation and/or other materials provided with the 15 | distribution. 16 | * Neither the name of Google Inc. nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_posix.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!js 2 | 3 | package runewidth 4 | 5 | import ( 6 | "os" 7 | "regexp" 8 | "strings" 9 | ) 10 | 11 | var reLoc = regexp.MustCompile(`^[a-z][a-z][a-z]?(?:_[A-Z][A-Z])?\.(.+)`) 12 | 13 | var mblenTable = map[string]int{ 14 | "utf-8": 6, 15 | "utf8": 6, 16 | "jis": 8, 17 | "eucjp": 3, 18 | "euckr": 2, 19 | "euccn": 2, 20 | "sjis": 2, 21 | "cp932": 2, 22 | "cp51932": 2, 23 | "cp936": 2, 24 | "cp949": 2, 25 | "cp950": 2, 26 | "big5": 2, 27 | "gbk": 2, 28 | "gb2312": 2, 29 | } 30 | 31 | func isEastAsian(locale string) bool { 32 | charset := strings.ToLower(locale) 33 | r := reLoc.FindStringSubmatch(locale) 34 | if len(r) == 2 { 35 | charset = strings.ToLower(r[1]) 36 | } 37 | 38 | if strings.HasSuffix(charset, "@cjk_narrow") { 39 | return false 40 | } 41 | 42 | for pos, b := range []byte(charset) { 43 | if b == '@' { 44 | charset = charset[:pos] 45 | break 46 | } 47 | } 48 | max := 1 49 | if m, ok := mblenTable[charset]; ok { 50 | max = m 51 | } 52 | if max > 1 && (charset[0] != 'u' || 53 | strings.HasPrefix(locale, "ja") || 54 | strings.HasPrefix(locale, "ko") || 55 | strings.HasPrefix(locale, "zh")) { 56 | return true 57 | } 58 | return false 59 | } 60 | 61 | // IsEastAsian return true if the current locale is CJK 62 | func IsEastAsian() bool { 63 | locale := os.Getenv("LC_CTYPE") 64 | if locale == "" { 65 | locale = os.Getenv("LANG") 66 | } 67 | 68 | // ignore C locale 69 | if locale == "POSIX" || locale == "C" { 70 | return false 71 | } 72 | if len(locale) > 1 && locale[0] == 'C' && (locale[1] == '.' || locale[1] == '-') { 73 | return false 74 | } 75 | 76 | return isEastAsian(locale) 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/nsf/termbox-go/syscalls_windows.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs -- -DUNICODE syscalls.go 3 | 4 | package termbox 5 | 6 | const ( 7 | foreground_blue = 0x1 8 | foreground_green = 0x2 9 | foreground_red = 0x4 10 | foreground_intensity = 0x8 11 | background_blue = 0x10 12 | background_green = 0x20 13 | background_red = 0x40 14 | background_intensity = 0x80 15 | std_input_handle = -0xa 16 | std_output_handle = -0xb 17 | key_event = 0x1 18 | mouse_event = 0x2 19 | window_buffer_size_event = 0x4 20 | enable_window_input = 0x8 21 | enable_mouse_input = 0x10 22 | enable_extended_flags = 0x80 23 | 24 | vk_f1 = 0x70 25 | vk_f2 = 0x71 26 | vk_f3 = 0x72 27 | vk_f4 = 0x73 28 | vk_f5 = 0x74 29 | vk_f6 = 0x75 30 | vk_f7 = 0x76 31 | vk_f8 = 0x77 32 | vk_f9 = 0x78 33 | vk_f10 = 0x79 34 | vk_f11 = 0x7a 35 | vk_f12 = 0x7b 36 | vk_insert = 0x2d 37 | vk_delete = 0x2e 38 | vk_home = 0x24 39 | vk_end = 0x23 40 | vk_pgup = 0x21 41 | vk_pgdn = 0x22 42 | vk_arrow_up = 0x26 43 | vk_arrow_down = 0x28 44 | vk_arrow_left = 0x25 45 | vk_arrow_right = 0x27 46 | vk_backspace = 0x8 47 | vk_tab = 0x9 48 | vk_enter = 0xd 49 | vk_esc = 0x1b 50 | vk_space = 0x20 51 | 52 | left_alt_pressed = 0x2 53 | left_ctrl_pressed = 0x8 54 | right_alt_pressed = 0x1 55 | right_ctrl_pressed = 0x4 56 | shift_pressed = 0x10 57 | 58 | generic_read = 0x80000000 59 | generic_write = 0x40000000 60 | console_textmode_buffer = 0x1 61 | ) 62 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/net_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | 7 | package internal 8 | 9 | import ( 10 | "sync" 11 | "testing" 12 | "time" 13 | 14 | netcontext "golang.org/x/net/context" 15 | 16 | basepb "google.golang.org/appengine/internal/base" 17 | ) 18 | 19 | func TestDialLimit(t *testing.T) { 20 | // Fill up semaphore with false acquisitions to permit only two TCP connections at a time. 21 | // We don't replace limitSem because that results in a data race when net/http lazily closes connections. 22 | nFake := cap(limitSem) - 2 23 | for i := 0; i < nFake; i++ { 24 | limitSem <- 1 25 | } 26 | defer func() { 27 | for i := 0; i < nFake; i++ { 28 | <-limitSem 29 | } 30 | }() 31 | 32 | f, c, cleanup := setup() // setup is in api_test.go 33 | defer cleanup() 34 | f.hang = make(chan int) 35 | 36 | // If we make two RunSlowly RPCs (which will wait for f.hang to be strobed), 37 | // then the simple Non200 RPC should hang. 38 | var wg sync.WaitGroup 39 | wg.Add(2) 40 | for i := 0; i < 2; i++ { 41 | go func() { 42 | defer wg.Done() 43 | Call(toContext(c), "errors", "RunSlowly", &basepb.VoidProto{}, &basepb.VoidProto{}) 44 | }() 45 | } 46 | time.Sleep(50 * time.Millisecond) // let those two RPCs start 47 | 48 | ctx, _ := netcontext.WithTimeout(toContext(c), 50*time.Millisecond) 49 | err := Call(ctx, "errors", "Non200", &basepb.VoidProto{}, &basepb.VoidProto{}) 50 | if err != errTimeout { 51 | t.Errorf("Non200 RPC returned with err %v, want errTimeout", err) 52 | } 53 | 54 | // Drain the two RunSlowly calls. 55 | f.hang <- 1 56 | f.hang <- 1 57 | wg.Wait() 58 | } 59 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option go_package = "urlfetch"; 3 | 4 | package appengine; 5 | 6 | message URLFetchServiceError { 7 | enum ErrorCode { 8 | OK = 0; 9 | INVALID_URL = 1; 10 | FETCH_ERROR = 2; 11 | UNSPECIFIED_ERROR = 3; 12 | RESPONSE_TOO_LARGE = 4; 13 | DEADLINE_EXCEEDED = 5; 14 | SSL_CERTIFICATE_ERROR = 6; 15 | DNS_ERROR = 7; 16 | CLOSED = 8; 17 | INTERNAL_TRANSIENT_ERROR = 9; 18 | TOO_MANY_REDIRECTS = 10; 19 | MALFORMED_REPLY = 11; 20 | CONNECTION_ERROR = 12; 21 | } 22 | } 23 | 24 | message URLFetchRequest { 25 | enum RequestMethod { 26 | GET = 1; 27 | POST = 2; 28 | HEAD = 3; 29 | PUT = 4; 30 | DELETE = 5; 31 | PATCH = 6; 32 | } 33 | required RequestMethod Method = 1; 34 | required string Url = 2; 35 | repeated group Header = 3 { 36 | required string Key = 4; 37 | required string Value = 5; 38 | } 39 | optional bytes Payload = 6 [ctype=CORD]; 40 | 41 | optional bool FollowRedirects = 7 [default=true]; 42 | 43 | optional double Deadline = 8; 44 | 45 | optional bool MustValidateServerCertificate = 9 [default=true]; 46 | } 47 | 48 | message URLFetchResponse { 49 | optional bytes Content = 1; 50 | required int32 StatusCode = 2; 51 | repeated group Header = 3 { 52 | required string Key = 4; 53 | required string Value = 5; 54 | } 55 | optional bool ContentWasTruncated = 6 [default=false]; 56 | optional int64 ExternalBytesSent = 7; 57 | optional int64 ExternalBytesReceived = 8; 58 | 59 | optional string FinalUrl = 9; 60 | 61 | optional int64 ApiCpuMilliseconds = 10 [default=0]; 62 | optional int64 ApiBytesSent = 11 [default=0]; 63 | optional int64 ApiBytesReceived = 12 [default=0]; 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/par.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | // Par displays a paragraph. 8 | /* 9 | par := termui.NewPar("Simple Text") 10 | par.Height = 3 11 | par.Width = 17 12 | par.BorderLabel = "Label" 13 | */ 14 | type Par struct { 15 | Block 16 | Text string 17 | TextFgColor Attribute 18 | TextBgColor Attribute 19 | WrapLength int // words wrap limit. Note it may not work properly with multi-width char 20 | } 21 | 22 | // NewPar returns a new *Par with given text as its content. 23 | func NewPar(s string) *Par { 24 | return &Par{ 25 | Block: *NewBlock(), 26 | Text: s, 27 | TextFgColor: ThemeAttr("par.text.fg"), 28 | TextBgColor: ThemeAttr("par.text.bg"), 29 | WrapLength: 0, 30 | } 31 | } 32 | 33 | // Buffer implements Bufferer interface. 34 | func (p *Par) Buffer() Buffer { 35 | buf := p.Block.Buffer() 36 | 37 | fg, bg := p.TextFgColor, p.TextBgColor 38 | cs := DefaultTxBuilder.Build(p.Text, fg, bg) 39 | 40 | // wrap if WrapLength set 41 | if p.WrapLength < 0 { 42 | cs = wrapTx(cs, p.Width-2) 43 | } else if p.WrapLength > 0 { 44 | cs = wrapTx(cs, p.WrapLength) 45 | } 46 | 47 | y, x, n := 0, 0, 0 48 | for y < p.innerArea.Dy() && n < len(cs) { 49 | w := cs[n].Width() 50 | if cs[n].Ch == '\n' || x+w > p.innerArea.Dx() { 51 | y++ 52 | x = 0 // set x = 0 53 | if cs[n].Ch == '\n' { 54 | n++ 55 | } 56 | 57 | if y >= p.innerArea.Dy() { 58 | buf.Set(p.innerArea.Min.X+p.innerArea.Dx()-1, 59 | p.innerArea.Min.Y+p.innerArea.Dy()-1, 60 | Cell{Ch: '…', Fg: p.TextFgColor, Bg: p.TextBgColor}) 61 | break 62 | } 63 | continue 64 | } 65 | 66 | buf.Set(p.innerArea.Min.X+x, p.innerArea.Min.Y+y, cs[n]) 67 | 68 | n++ 69 | x += w 70 | } 71 | 72 | return buf 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/grid_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/davecgh/go-spew/spew" 11 | ) 12 | 13 | var r *Row 14 | 15 | func TestRowWidth(t *testing.T) { 16 | p0 := NewBlock() 17 | p0.Height = 1 18 | p1 := NewBlock() 19 | p1.Height = 1 20 | p2 := NewBlock() 21 | p2.Height = 1 22 | p3 := NewBlock() 23 | p3.Height = 1 24 | 25 | /* test against tree: 26 | 27 | r 28 | / \ 29 | 0:w 1 30 | / \ 31 | 10:w 11 32 | / 33 | 110:w 34 | / 35 | 1100:w 36 | */ 37 | 38 | r = NewRow( 39 | NewCol(6, 0, p0), 40 | NewCol(6, 0, 41 | NewRow( 42 | NewCol(6, 0, p1), 43 | NewCol(6, 0, p2, p3)))) 44 | 45 | r.assignWidth(100) 46 | if r.Width != 100 || 47 | (r.Cols[0].Width) != 50 || 48 | (r.Cols[1].Width) != 50 || 49 | (r.Cols[1].Cols[0].Width) != 25 || 50 | (r.Cols[1].Cols[1].Width) != 25 || 51 | (r.Cols[1].Cols[1].Cols[0].Width) != 25 || 52 | (r.Cols[1].Cols[1].Cols[0].Cols[0].Width) != 25 { 53 | t.Error("assignWidth fails") 54 | } 55 | } 56 | 57 | func TestRowHeight(t *testing.T) { 58 | spew.Dump() 59 | 60 | if (r.solveHeight()) != 2 || 61 | (r.Cols[1].Cols[1].Height) != 2 || 62 | (r.Cols[1].Cols[1].Cols[0].Height) != 2 || 63 | (r.Cols[1].Cols[0].Height) != 1 { 64 | t.Error("solveHeight fails") 65 | } 66 | } 67 | 68 | func TestAssignXY(t *testing.T) { 69 | r.assignX(0) 70 | r.assignY(0) 71 | if (r.Cols[0].X) != 0 || 72 | (r.Cols[1].Cols[0].X) != 50 || 73 | (r.Cols[1].Cols[1].X) != 75 || 74 | (r.Cols[1].Cols[1].Cols[0].X) != 75 || 75 | (r.Cols[1].Cols[0].Y) != 0 || 76 | (r.Cols[1].Cols[1].Cols[0].Y) != 0 || 77 | (r.Cols[1].Cols[1].Cols[0].Cols[0].Y) != 1 { 78 | t.Error("assignXY fails") 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/internal_vm_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | 7 | package internal 8 | 9 | import ( 10 | "io" 11 | "io/ioutil" 12 | "net/http" 13 | "net/http/httptest" 14 | "testing" 15 | ) 16 | 17 | func TestInstallingHealthChecker(t *testing.T) { 18 | try := func(desc string, mux *http.ServeMux, wantCode int, wantBody string) { 19 | installHealthChecker(mux) 20 | srv := httptest.NewServer(mux) 21 | defer srv.Close() 22 | 23 | resp, err := http.Get(srv.URL + "/_ah/health") 24 | if err != nil { 25 | t.Errorf("%s: http.Get: %v", desc, err) 26 | return 27 | } 28 | defer resp.Body.Close() 29 | body, err := ioutil.ReadAll(resp.Body) 30 | if err != nil { 31 | t.Errorf("%s: reading body: %v", desc, err) 32 | return 33 | } 34 | 35 | if resp.StatusCode != wantCode { 36 | t.Errorf("%s: got HTTP %d, want %d", desc, resp.StatusCode, wantCode) 37 | return 38 | } 39 | if wantBody != "" && string(body) != wantBody { 40 | t.Errorf("%s: got HTTP body %q, want %q", desc, body, wantBody) 41 | return 42 | } 43 | } 44 | 45 | // If there's no handlers, or only a root handler, a health checker should be installed. 46 | try("empty mux", http.NewServeMux(), 200, "ok") 47 | mux := http.NewServeMux() 48 | mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 49 | io.WriteString(w, "root handler") 50 | }) 51 | try("mux with root handler", mux, 200, "ok") 52 | 53 | // If there's a custom health check handler, one should not be installed. 54 | mux = http.NewServeMux() 55 | mux.HandleFunc("/_ah/health", func(w http.ResponseWriter, r *http.Request) { 56 | w.WriteHeader(418) 57 | io.WriteString(w, "I'm short and stout!") 58 | }) 59 | try("mux with custom health checker", mux, 418, "I'm short and stout!") 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/helper_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/stretchr/testify/assert" 11 | ) 12 | 13 | func TestStr2Rune(t *testing.T) { 14 | s := "你好,世界." 15 | rs := str2runes(s) 16 | if len(rs) != 6 { 17 | t.Error(t) 18 | } 19 | } 20 | 21 | func TestWidth(t *testing.T) { 22 | s0 := "つのだ☆HIRO" 23 | s1 := "11111111111" 24 | // above not align for setting East Asian Ambiguous to wide!! 25 | 26 | if strWidth(s0) != strWidth(s1) { 27 | t.Error("str len failed") 28 | } 29 | 30 | len1 := []rune{'a', '2', '&', '「', 'オ', '。'} //will false: 'ᆵ', 'ᄚ', 'ᄒ' 31 | for _, v := range len1 { 32 | if charWidth(v) != 1 { 33 | t.Error("len1 failed") 34 | } 35 | } 36 | 37 | len2 := []rune{'漢', '字', '한', '자', '你', '好', 'だ', '。', '%', 's', 'E', 'ョ', '、', 'ヲ'} 38 | for _, v := range len2 { 39 | if charWidth(v) != 2 { 40 | t.Error("len2 failed") 41 | } 42 | } 43 | } 44 | 45 | func TestTrim(t *testing.T) { 46 | s := "つのだ☆HIRO" 47 | if string(trimStr2Runes(s, 10)) != "つのだ☆HI"+dot { 48 | t.Error("trim failed") 49 | } 50 | if string(trimStr2Runes(s, 11)) != "つのだ☆HIRO" { 51 | t.Error("avoid tail trim failed") 52 | } 53 | if string(trimStr2Runes(s, 15)) != "つのだ☆HIRO" { 54 | t.Error("avoid trim failed") 55 | } 56 | } 57 | 58 | func TestTrimStrIfAppropriate_NoTrim(t *testing.T) { 59 | assert.Equal(t, "hello", TrimStrIfAppropriate("hello", 5)) 60 | } 61 | 62 | func TestTrimStrIfAppropriate(t *testing.T) { 63 | assert.Equal(t, "hel…", TrimStrIfAppropriate("hello", 4)) 64 | assert.Equal(t, "h…", TrimStrIfAppropriate("hello", 2)) 65 | } 66 | 67 | func TestStringToAttribute(t *testing.T) { 68 | assert.Equal(t, ColorRed, StringToAttribute("ReD")) 69 | assert.Equal(t, ColorRed|AttrBold, StringToAttribute("RED, bold")) 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/ipnet_test.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "os" 7 | "testing" 8 | ) 9 | 10 | func setUpIPNet(ip *net.IPNet) *FlagSet { 11 | f := NewFlagSet("test", ContinueOnError) 12 | _, def, _ := net.ParseCIDR("0.0.0.0/0") 13 | f.IPNetVar(ip, "address", *def, "IP Address") 14 | return f 15 | } 16 | 17 | func TestIPNet(t *testing.T) { 18 | testCases := []struct { 19 | input string 20 | success bool 21 | expected string 22 | }{ 23 | {"0.0.0.0/0", true, "0.0.0.0/0"}, 24 | {" 0.0.0.0/0 ", true, "0.0.0.0/0"}, 25 | {"1.2.3.4/8", true, "1.0.0.0/8"}, 26 | {"127.0.0.1/16", true, "127.0.0.0/16"}, 27 | {"255.255.255.255/19", true, "255.255.224.0/19"}, 28 | {"255.255.255.255/32", true, "255.255.255.255/32"}, 29 | {"", false, ""}, 30 | {"/0", false, ""}, 31 | {"0", false, ""}, 32 | {"0/0", false, ""}, 33 | {"localhost/0", false, ""}, 34 | {"0.0.0/4", false, ""}, 35 | {"0.0.0./8", false, ""}, 36 | {"0.0.0.0./12", false, ""}, 37 | {"0.0.0.256/16", false, ""}, 38 | {"0.0.0.0 /20", false, ""}, 39 | {"0.0.0.0/ 24", false, ""}, 40 | {"0 . 0 . 0 . 0 / 28", false, ""}, 41 | {"0.0.0.0/33", false, ""}, 42 | } 43 | 44 | devnull, _ := os.Open(os.DevNull) 45 | os.Stderr = devnull 46 | for i := range testCases { 47 | var addr net.IPNet 48 | f := setUpIPNet(&addr) 49 | 50 | tc := &testCases[i] 51 | 52 | arg := fmt.Sprintf("--address=%s", tc.input) 53 | err := f.Parse([]string{arg}) 54 | if err != nil && tc.success == true { 55 | t.Errorf("expected success, got %q", err) 56 | continue 57 | } else if err == nil && tc.success == false { 58 | t.Errorf("expected failure") 59 | continue 60 | } else if tc.success { 61 | ip, err := f.GetIPNet("address") 62 | if err != nil { 63 | t.Errorf("Got error trying to fetch the IP flag: %v", err) 64 | } 65 | if ip.String() != tc.expected { 66 | t.Errorf("expected %q, got %q", tc.expected, ip.String()) 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/pos.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import "image" 8 | 9 | // Align is the position of the gauge's label. 10 | type Align uint 11 | 12 | // All supported positions. 13 | const ( 14 | AlignNone Align = 0 15 | AlignLeft Align = 1 << iota 16 | AlignRight 17 | AlignBottom 18 | AlignTop 19 | AlignCenterVertical 20 | AlignCenterHorizontal 21 | AlignCenter = AlignCenterVertical | AlignCenterHorizontal 22 | ) 23 | 24 | func AlignArea(parent, child image.Rectangle, a Align) image.Rectangle { 25 | w, h := child.Dx(), child.Dy() 26 | 27 | // parent center 28 | pcx, pcy := parent.Min.X+parent.Dx()/2, parent.Min.Y+parent.Dy()/2 29 | // child center 30 | ccx, ccy := child.Min.X+child.Dx()/2, child.Min.Y+child.Dy()/2 31 | 32 | if a&AlignLeft == AlignLeft { 33 | child.Min.X = parent.Min.X 34 | child.Max.X = child.Min.X + w 35 | } 36 | 37 | if a&AlignRight == AlignRight { 38 | child.Max.X = parent.Max.X 39 | child.Min.X = child.Max.X - w 40 | } 41 | 42 | if a&AlignBottom == AlignBottom { 43 | child.Max.Y = parent.Max.Y 44 | child.Min.Y = child.Max.Y - h 45 | } 46 | 47 | if a&AlignTop == AlignRight { 48 | child.Min.Y = parent.Min.Y 49 | child.Max.Y = child.Min.Y + h 50 | } 51 | 52 | if a&AlignCenterHorizontal == AlignCenterHorizontal { 53 | child.Min.X += pcx - ccx 54 | child.Max.X = child.Min.X + w 55 | } 56 | 57 | if a&AlignCenterVertical == AlignCenterVertical { 58 | child.Min.Y += pcy - ccy 59 | child.Max.Y = child.Min.Y + h 60 | } 61 | 62 | return child 63 | } 64 | 65 | func MoveArea(a image.Rectangle, dx, dy int) image.Rectangle { 66 | a.Min.X += dx 67 | a.Max.X += dx 68 | a.Min.Y += dy 69 | a.Max.Y += dy 70 | return a 71 | } 72 | 73 | var termWidth int 74 | var termHeight int 75 | 76 | func TermRect() image.Rectangle { 77 | return image.Rect(0, 0, termWidth, termHeight) 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/go-wordwrap/wordwrap.go: -------------------------------------------------------------------------------- 1 | package wordwrap 2 | 3 | import ( 4 | "bytes" 5 | "unicode" 6 | ) 7 | 8 | // WrapString wraps the given string within lim width in characters. 9 | // 10 | // Wrapping is currently naive and only happens at white-space. A future 11 | // version of the library will implement smarter wrapping. This means that 12 | // pathological cases can dramatically reach past the limit, such as a very 13 | // long word. 14 | func WrapString(s string, lim uint) string { 15 | // Initialize a buffer with a slightly larger size to account for breaks 16 | init := make([]byte, 0, len(s)) 17 | buf := bytes.NewBuffer(init) 18 | 19 | var current uint 20 | var wordBuf, spaceBuf bytes.Buffer 21 | 22 | for _, char := range s { 23 | if char == '\n' { 24 | if wordBuf.Len() == 0 { 25 | if current+uint(spaceBuf.Len()) > lim { 26 | current = 0 27 | } else { 28 | current += uint(spaceBuf.Len()) 29 | spaceBuf.WriteTo(buf) 30 | } 31 | spaceBuf.Reset() 32 | } else { 33 | current += uint(spaceBuf.Len() + wordBuf.Len()) 34 | spaceBuf.WriteTo(buf) 35 | spaceBuf.Reset() 36 | wordBuf.WriteTo(buf) 37 | wordBuf.Reset() 38 | } 39 | buf.WriteRune(char) 40 | current = 0 41 | } else if unicode.IsSpace(char) { 42 | if spaceBuf.Len() == 0 || wordBuf.Len() > 0 { 43 | current += uint(spaceBuf.Len() + wordBuf.Len()) 44 | spaceBuf.WriteTo(buf) 45 | spaceBuf.Reset() 46 | wordBuf.WriteTo(buf) 47 | wordBuf.Reset() 48 | } 49 | 50 | spaceBuf.WriteRune(char) 51 | } else { 52 | 53 | wordBuf.WriteRune(char) 54 | 55 | if current+uint(spaceBuf.Len()+wordBuf.Len()) > lim && uint(wordBuf.Len()) < lim { 56 | buf.WriteRune('\n') 57 | current = 0 58 | spaceBuf.Reset() 59 | } 60 | } 61 | } 62 | 63 | if wordBuf.Len() == 0 { 64 | if current+uint(spaceBuf.Len()) <= lim { 65 | spaceBuf.WriteTo(buf) 66 | } 67 | } else { 68 | spaceBuf.WriteTo(buf) 69 | wordBuf.WriteTo(buf) 70 | } 71 | 72 | return buf.String() 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/widget.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import ( 8 | "fmt" 9 | "sync" 10 | ) 11 | 12 | // event mixins 13 | type WgtMgr map[string]WgtInfo 14 | 15 | type WgtInfo struct { 16 | Handlers map[string]func(Event) 17 | WgtRef Widget 18 | Id string 19 | } 20 | 21 | type Widget interface { 22 | Id() string 23 | } 24 | 25 | func NewWgtInfo(wgt Widget) WgtInfo { 26 | return WgtInfo{ 27 | Handlers: make(map[string]func(Event)), 28 | WgtRef: wgt, 29 | Id: wgt.Id(), 30 | } 31 | } 32 | 33 | func NewWgtMgr() WgtMgr { 34 | wm := WgtMgr(make(map[string]WgtInfo)) 35 | return wm 36 | 37 | } 38 | 39 | func (wm WgtMgr) AddWgt(wgt Widget) { 40 | wm[wgt.Id()] = NewWgtInfo(wgt) 41 | } 42 | 43 | func (wm WgtMgr) RmWgt(wgt Widget) { 44 | wm.RmWgtById(wgt.Id()) 45 | } 46 | 47 | func (wm WgtMgr) RmWgtById(id string) { 48 | delete(wm, id) 49 | } 50 | 51 | func (wm WgtMgr) AddWgtHandler(id, path string, h func(Event)) { 52 | if w, ok := wm[id]; ok { 53 | w.Handlers[path] = h 54 | } 55 | } 56 | 57 | func (wm WgtMgr) RmWgtHandler(id, path string) { 58 | if w, ok := wm[id]; ok { 59 | delete(w.Handlers, path) 60 | } 61 | } 62 | 63 | var counter struct { 64 | sync.RWMutex 65 | count int 66 | } 67 | 68 | func GenId() string { 69 | counter.Lock() 70 | defer counter.Unlock() 71 | 72 | counter.count += 1 73 | return fmt.Sprintf("%d", counter.count) 74 | } 75 | 76 | func (wm WgtMgr) WgtHandlersHook() func(Event) { 77 | return func(e Event) { 78 | for _, v := range wm { 79 | if k := findMatch(v.Handlers, e.Path); k != "" { 80 | v.Handlers[k](e) 81 | } 82 | } 83 | } 84 | } 85 | 86 | var DefaultWgtMgr WgtMgr 87 | 88 | func (b *Block) Handle(path string, handler func(Event)) { 89 | if _, ok := DefaultWgtMgr[b.Id()]; !ok { 90 | DefaultWgtMgr.AddWgt(b) 91 | } 92 | 93 | DefaultWgtMgr.AddWgtHandler(b.Id(), path, handler) 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/zmb3/spotify/library.go: -------------------------------------------------------------------------------- 1 | package spotify 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "net/http" 7 | "strings" 8 | ) 9 | 10 | // UserHasTracks checks if one or more tracks are saved to the current user's 11 | // "Your Music" library. 12 | func (c *Client) UserHasTracks(ids ...ID) ([]bool, error) { 13 | if l := len(ids); l == 0 || l > 50 { 14 | return nil, errors.New("spotify: UserHasTracks supports 1 to 50 IDs per call") 15 | } 16 | spotifyURL := fmt.Sprintf("%sme/tracks/contains?ids=%s", c.baseURL, strings.Join(toStringSlice(ids), ",")) 17 | 18 | var result []bool 19 | 20 | err := c.get(spotifyURL, &result) 21 | if err != nil { 22 | return nil, err 23 | } 24 | 25 | return result, err 26 | } 27 | 28 | // AddTracksToLibrary saves one or more tracks to the current user's 29 | // "Your Music" library. This call requires the ScopeUserLibraryModify scope. 30 | // A track can only be saved once; duplicate IDs are ignored. 31 | func (c *Client) AddTracksToLibrary(ids ...ID) error { 32 | return c.modifyLibraryTracks(true, ids...) 33 | } 34 | 35 | // RemoveTracksFromLibrary removes one or more tracks from the current user's 36 | // "Your Music" library. This call requires the ScopeUserModifyLibrary scope. 37 | // Trying to remove a track when you do not have the user's authorization 38 | // results in a `spotify.Error` with the status code set to http.StatusUnauthorized. 39 | func (c *Client) RemoveTracksFromLibrary(ids ...ID) error { 40 | return c.modifyLibraryTracks(false, ids...) 41 | } 42 | 43 | func (c *Client) modifyLibraryTracks(add bool, ids ...ID) error { 44 | if l := len(ids); l == 0 || l > 50 { 45 | return errors.New("spotify: this call supports 1 to 50 IDs per call") 46 | } 47 | spotifyURL := fmt.Sprintf("%sme/tracks?ids=%s", c.baseURL, strings.Join(toStringSlice(ids), ",")) 48 | method := "DELETE" 49 | if add { 50 | method = "PUT" 51 | } 52 | req, err := http.NewRequest(method, spotifyURL, nil) 53 | if err != nil { 54 | return err 55 | } 56 | err = c.execute(req, nil) 57 | if err != nil { 58 | return err 59 | } 60 | return nil 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/go-wordwrap/wordwrap_test.go: -------------------------------------------------------------------------------- 1 | package wordwrap 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestWrapString(t *testing.T) { 8 | cases := []struct { 9 | Input, Output string 10 | Lim uint 11 | }{ 12 | // A simple word passes through. 13 | { 14 | "foo", 15 | "foo", 16 | 4, 17 | }, 18 | // A single word that is too long passes through. 19 | // We do not break words. 20 | { 21 | "foobarbaz", 22 | "foobarbaz", 23 | 4, 24 | }, 25 | // Lines are broken at whitespace. 26 | { 27 | "foo bar baz", 28 | "foo\nbar\nbaz", 29 | 4, 30 | }, 31 | // Lines are broken at whitespace, even if words 32 | // are too long. We do not break words. 33 | { 34 | "foo bars bazzes", 35 | "foo\nbars\nbazzes", 36 | 4, 37 | }, 38 | // A word that would run beyond the width is wrapped. 39 | { 40 | "fo sop", 41 | "fo\nsop", 42 | 4, 43 | }, 44 | // Whitespace that trails a line and fits the width 45 | // passes through, as does whitespace prefixing an 46 | // explicit line break. A tab counts as one character. 47 | { 48 | "foo\nb\t r\n baz", 49 | "foo\nb\t r\n baz", 50 | 4, 51 | }, 52 | // Trailing whitespace is removed if it doesn't fit the width. 53 | // Runs of whitespace on which a line is broken are removed. 54 | { 55 | "foo \nb ar ", 56 | "foo\nb\nar", 57 | 4, 58 | }, 59 | // An explicit line break at the end of the input is preserved. 60 | { 61 | "foo bar baz\n", 62 | "foo\nbar\nbaz\n", 63 | 4, 64 | }, 65 | // Explicit break are always preserved. 66 | { 67 | "\nfoo bar\n\n\nbaz\n", 68 | "\nfoo\nbar\n\n\nbaz\n", 69 | 4, 70 | }, 71 | // Complete example: 72 | { 73 | " This is a list: \n\n\t* foo\n\t* bar\n\n\n\t* baz \nBAM ", 74 | " This\nis a\nlist: \n\n\t* foo\n\t* bar\n\n\n\t* baz\nBAM", 75 | 6, 76 | }, 77 | } 78 | 79 | for i, tc := range cases { 80 | actual := WrapString(tc.Input, tc.Lim) 81 | if actual != tc.Output { 82 | t.Fatalf("Case %d Input:\n\n`%s`\n\nActual Output:\n\n`%s`", i, tc.Input, actual) 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | install: 33 | go install 34 | 35 | test: install generate-test-pbs 36 | go test 37 | 38 | 39 | generate-test-pbs: 40 | make install 41 | make -C testdata 42 | protoc --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 43 | make 44 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/Make.protobuf: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Includable Makefile to add a rule for generating .pb.go files from .proto files 33 | # (Google protocol buffer descriptions). 34 | # Typical use if myproto.proto is a file in package mypackage in this directory: 35 | # 36 | # include $(GOROOT)/src/pkg/github.com/golang/protobuf/Make.protobuf 37 | 38 | %.pb.go: %.proto 39 | protoc --go_out=. $< 40 | 41 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/textbuilder_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import "testing" 8 | 9 | func TestReadAttr(t *testing.T) { 10 | m := MarkdownTxBuilder{} 11 | m.baseFg = ColorCyan | AttrUnderline 12 | m.baseBg = ColorBlue | AttrBold 13 | fg, bg := m.readAttr("fg-red,bg-reverse") 14 | if fg != ColorRed|AttrUnderline || bg != ColorBlue|AttrBold|AttrReverse { 15 | t.Error("readAttr failed") 16 | } 17 | } 18 | 19 | func TestMTBParse(t *testing.T) { 20 | /* 21 | str := func(cs []Cell) string { 22 | rs := make([]rune, len(cs)) 23 | for i := range cs { 24 | rs[i] = cs[i].Ch 25 | } 26 | return string(rs) 27 | } 28 | */ 29 | 30 | tbls := [][]string{ 31 | {"hello world", "hello world"}, 32 | {"[hello](fg-red) world", "hello world"}, 33 | {"[[hello]](bg-red) world", "[hello] world"}, 34 | {"[1] hello world", "[1] hello world"}, 35 | {"[[1]](bg-white) [hello] world", "[1] [hello] world"}, 36 | {"[hello world]", "[hello world]"}, 37 | {"", ""}, 38 | {"[hello world)", "[hello world)"}, 39 | {"[0] [hello](bg-red)[ world](fg-blue)!", "[0] hello world!"}, 40 | } 41 | 42 | m := MarkdownTxBuilder{} 43 | m.baseFg = ColorWhite 44 | m.baseBg = ColorDefault 45 | for _, s := range tbls { 46 | m.reset() 47 | m.parse(s[0]) 48 | res := string(m.plainTx) 49 | if s[1] != res { 50 | t.Errorf("\ninput :%s\nshould:%s\noutput:%s", s[0], s[1], res) 51 | } 52 | } 53 | 54 | m.reset() 55 | m.parse("[0] [hello](bg-red)[ world](fg-blue)") 56 | if len(m.markers) != 2 && 57 | m.markers[0].st == 4 && 58 | m.markers[0].ed == 11 && 59 | m.markers[0].fg == ColorWhite && 60 | m.markers[0].bg == ColorRed { 61 | t.Error("markers dismatch") 62 | } 63 | 64 | m2 := NewMarkdownTxBuilder() 65 | cs := m2.Build("[0] [hellob-e) wrd]fgblue)!", ColorWhite, ColorBlack) 66 | cs = m2.Build("[0] [hello](bg-red) [world](fg-blue)!", ColorWhite, ColorBlack) 67 | if cs[4].Ch != 'h' && cs[4].Bg != ColorRed && cs[4].Fg != ColorWhite { 68 | t.Error("dismatch in Build") 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cmd/spotctl/auth.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/rand" 5 | "encoding/base64" 6 | "fmt" 7 | "log" 8 | "net/http" 9 | "os" 10 | 11 | "github.com/spf13/cobra" 12 | "github.com/zmb3/spotify" 13 | "golang.org/x/oauth2" 14 | ) 15 | 16 | var loginCmd = &cobra.Command{ 17 | Use: "login", 18 | Short: "Login with your Spotify credentials", 19 | RunE: login, 20 | } 21 | 22 | var logoutCmd = &cobra.Command{ 23 | Use: "logout", 24 | Short: "Clear your local Spotify credentials", 25 | RunE: login, 26 | } 27 | 28 | func login(cmd *cobra.Command, args []string) error { 29 | state, err := generateRandomString(32) 30 | if err != nil { 31 | return err 32 | } 33 | 34 | ch := make(chan *oauth2.Token) 35 | 36 | http.Handle("/callback", &authHandler{state: state, ch: ch, auth: auth}) 37 | go http.ListenAndServe("localhost:10028", nil) 38 | 39 | url := auth.AuthURL(state) 40 | fmt.Println("Please log in to Spotify by visiting the following page in your browser:", url) 41 | 42 | tok := <-ch 43 | 44 | if err := saveToken(tok); err != nil { 45 | return err 46 | } 47 | 48 | return nil 49 | } 50 | 51 | func logout(cmd *cobra.Command, args []string) error { 52 | os.Remove(tokenPath) 53 | return nil 54 | } 55 | 56 | type authHandler struct { 57 | state string 58 | ch chan *oauth2.Token 59 | auth spotify.Authenticator 60 | } 61 | 62 | func (a *authHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { 63 | tok, err := a.auth.Token(a.state, r) 64 | if err != nil { 65 | http.Error(w, "Couldn't get token", http.StatusForbidden) 66 | log.Fatal(err) 67 | } 68 | 69 | if st := r.FormValue("state"); st != a.state { 70 | http.NotFound(w, r) 71 | log.Fatalf("State mismatch: %s != %s\n", st, a.state) 72 | } 73 | 74 | fmt.Fprintf(w, "Login successfully. Please return to your terminal.") 75 | 76 | a.ch <- tok 77 | } 78 | 79 | func generateRandomBytes(n int) ([]byte, error) { 80 | b := make([]byte, n) 81 | _, err := rand.Read(b) 82 | if err != nil { 83 | return nil, err 84 | } 85 | 86 | return b, nil 87 | } 88 | 89 | func generateRandomString(s int) (string, error) { 90 | b, err := generateRandomBytes(s) 91 | return base64.URLEncoding.EncodeToString(b), err 92 | } 93 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !plan9,!go1.7 6 | 7 | package ctxhttp 8 | 9 | import ( 10 | "net" 11 | "net/http" 12 | "net/http/httptest" 13 | "sync" 14 | "testing" 15 | "time" 16 | 17 | "golang.org/x/net/context" 18 | ) 19 | 20 | // golang.org/issue/14065 21 | func TestClosesResponseBodyOnCancel(t *testing.T) { 22 | defer func() { testHookContextDoneBeforeHeaders = nop }() 23 | defer func() { testHookDoReturned = nop }() 24 | defer func() { testHookDidBodyClose = nop }() 25 | 26 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) 27 | defer ts.Close() 28 | 29 | ctx, cancel := context.WithCancel(context.Background()) 30 | 31 | // closed when Do enters select case <-ctx.Done() 32 | enteredDonePath := make(chan struct{}) 33 | 34 | testHookContextDoneBeforeHeaders = func() { 35 | close(enteredDonePath) 36 | } 37 | 38 | testHookDoReturned = func() { 39 | // We now have the result (the Flush'd headers) at least, 40 | // so we can cancel the request. 41 | cancel() 42 | 43 | // But block the client.Do goroutine from sending 44 | // until Do enters into the <-ctx.Done() path, since 45 | // otherwise if both channels are readable, select 46 | // picks a random one. 47 | <-enteredDonePath 48 | } 49 | 50 | sawBodyClose := make(chan struct{}) 51 | testHookDidBodyClose = func() { close(sawBodyClose) } 52 | 53 | tr := &http.Transport{} 54 | defer tr.CloseIdleConnections() 55 | c := &http.Client{Transport: tr} 56 | req, _ := http.NewRequest("GET", ts.URL, nil) 57 | _, doErr := Do(ctx, c, req) 58 | 59 | select { 60 | case <-sawBodyClose: 61 | case <-time.After(5 * time.Second): 62 | t.Fatal("timeout waiting for body to close") 63 | } 64 | 65 | if doErr != ctx.Err() { 66 | t.Errorf("Do error = %v; want %v", doErr, ctx.Err()) 67 | } 68 | } 69 | 70 | type noteCloseConn struct { 71 | net.Conn 72 | onceClose sync.Once 73 | closefn func() 74 | } 75 | 76 | func (c *noteCloseConn) Close() error { 77 | c.onceClose.Do(c.closefn) 78 | return c.Conn.Close() 79 | } 80 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/zsh_completions_test.go: -------------------------------------------------------------------------------- 1 | package cobra 2 | 3 | import ( 4 | "bytes" 5 | "strings" 6 | "testing" 7 | ) 8 | 9 | func TestZshCompletion(t *testing.T) { 10 | tcs := []struct { 11 | name string 12 | root *Command 13 | expectedExpressions []string 14 | }{ 15 | { 16 | name: "trivial", 17 | root: &Command{Use: "trivialapp"}, 18 | expectedExpressions: []string{"#compdef trivial"}, 19 | }, 20 | { 21 | name: "linear", 22 | root: func() *Command { 23 | r := &Command{Use: "linear"} 24 | 25 | sub1 := &Command{Use: "sub1"} 26 | r.AddCommand(sub1) 27 | 28 | sub2 := &Command{Use: "sub2"} 29 | sub1.AddCommand(sub2) 30 | 31 | sub3 := &Command{Use: "sub3"} 32 | sub2.AddCommand(sub3) 33 | return r 34 | }(), 35 | expectedExpressions: []string{"sub1", "sub2", "sub3"}, 36 | }, 37 | { 38 | name: "flat", 39 | root: func() *Command { 40 | r := &Command{Use: "flat"} 41 | r.AddCommand(&Command{Use: "c1"}) 42 | r.AddCommand(&Command{Use: "c2"}) 43 | return r 44 | }(), 45 | expectedExpressions: []string{"(c1 c2)"}, 46 | }, 47 | { 48 | name: "tree", 49 | root: func() *Command { 50 | r := &Command{Use: "tree"} 51 | 52 | sub1 := &Command{Use: "sub1"} 53 | r.AddCommand(sub1) 54 | 55 | sub11 := &Command{Use: "sub11"} 56 | sub12 := &Command{Use: "sub12"} 57 | 58 | sub1.AddCommand(sub11) 59 | sub1.AddCommand(sub12) 60 | 61 | sub2 := &Command{Use: "sub2"} 62 | r.AddCommand(sub2) 63 | 64 | sub21 := &Command{Use: "sub21"} 65 | sub22 := &Command{Use: "sub22"} 66 | 67 | sub2.AddCommand(sub21) 68 | sub2.AddCommand(sub22) 69 | 70 | return r 71 | }(), 72 | expectedExpressions: []string{"(sub11 sub12)", "(sub21 sub22)"}, 73 | }, 74 | } 75 | 76 | for _, tc := range tcs { 77 | t.Run(tc.name, func(t *testing.T) { 78 | buf := new(bytes.Buffer) 79 | tc.root.GenZshCompletion(buf) 80 | output := buf.String() 81 | 82 | for _, expectedExpression := range tc.expectedExpressions { 83 | if !strings.Contains(output, expectedExpression) { 84 | t.Errorf("Expected completion to contain %q somewhere; got %q", expectedExpression, output) 85 | } 86 | } 87 | }) 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/internal/transport.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | import ( 8 | "net/http" 9 | 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // HTTPClient is the context key to use with golang.org/x/net/context's 14 | // WithValue function to associate an *http.Client value with a context. 15 | var HTTPClient ContextKey 16 | 17 | // ContextKey is just an empty struct. It exists so HTTPClient can be 18 | // an immutable public variable with a unique type. It's immutable 19 | // because nobody else can create a ContextKey, being unexported. 20 | type ContextKey struct{} 21 | 22 | // ContextClientFunc is a func which tries to return an *http.Client 23 | // given a Context value. If it returns an error, the search stops 24 | // with that error. If it returns (nil, nil), the search continues 25 | // down the list of registered funcs. 26 | type ContextClientFunc func(context.Context) (*http.Client, error) 27 | 28 | var contextClientFuncs []ContextClientFunc 29 | 30 | func RegisterContextClientFunc(fn ContextClientFunc) { 31 | contextClientFuncs = append(contextClientFuncs, fn) 32 | } 33 | 34 | func ContextClient(ctx context.Context) (*http.Client, error) { 35 | if ctx != nil { 36 | if hc, ok := ctx.Value(HTTPClient).(*http.Client); ok { 37 | return hc, nil 38 | } 39 | } 40 | for _, fn := range contextClientFuncs { 41 | c, err := fn(ctx) 42 | if err != nil { 43 | return nil, err 44 | } 45 | if c != nil { 46 | return c, nil 47 | } 48 | } 49 | return http.DefaultClient, nil 50 | } 51 | 52 | func ContextTransport(ctx context.Context) http.RoundTripper { 53 | hc, err := ContextClient(ctx) 54 | // This is a rare error case (somebody using nil on App Engine). 55 | if err != nil { 56 | return ErrorTransport{err} 57 | } 58 | return hc.Transport 59 | } 60 | 61 | // ErrorTransport returns the specified error on RoundTrip. 62 | // This RoundTripper should be used in rare error cases where 63 | // error handling can be postponed to response handling time. 64 | type ErrorTransport struct{ Err error } 65 | 66 | func (t ErrorTransport) RoundTrip(*http.Request) (*http.Response, error) { 67 | return nil, t.Err 68 | } 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/internal/oauth2.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | import ( 8 | "bufio" 9 | "crypto/rsa" 10 | "crypto/x509" 11 | "encoding/pem" 12 | "errors" 13 | "fmt" 14 | "io" 15 | "strings" 16 | ) 17 | 18 | // ParseKey converts the binary contents of a private key file 19 | // to an *rsa.PrivateKey. It detects whether the private key is in a 20 | // PEM container or not. If so, it extracts the the private key 21 | // from PEM container before conversion. It only supports PEM 22 | // containers with no passphrase. 23 | func ParseKey(key []byte) (*rsa.PrivateKey, error) { 24 | block, _ := pem.Decode(key) 25 | if block != nil { 26 | key = block.Bytes 27 | } 28 | parsedKey, err := x509.ParsePKCS8PrivateKey(key) 29 | if err != nil { 30 | parsedKey, err = x509.ParsePKCS1PrivateKey(key) 31 | if err != nil { 32 | return nil, fmt.Errorf("private key should be a PEM or plain PKSC1 or PKCS8; parse error: %v", err) 33 | } 34 | } 35 | parsed, ok := parsedKey.(*rsa.PrivateKey) 36 | if !ok { 37 | return nil, errors.New("private key is invalid") 38 | } 39 | return parsed, nil 40 | } 41 | 42 | func ParseINI(ini io.Reader) (map[string]map[string]string, error) { 43 | result := map[string]map[string]string{ 44 | "": {}, // root section 45 | } 46 | scanner := bufio.NewScanner(ini) 47 | currentSection := "" 48 | for scanner.Scan() { 49 | line := strings.TrimSpace(scanner.Text()) 50 | if strings.HasPrefix(line, ";") { 51 | // comment. 52 | continue 53 | } 54 | if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") { 55 | currentSection = strings.TrimSpace(line[1 : len(line)-1]) 56 | result[currentSection] = map[string]string{} 57 | continue 58 | } 59 | parts := strings.SplitN(line, "=", 2) 60 | if len(parts) == 2 && parts[0] != "" { 61 | result[currentSection][strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1]) 62 | } 63 | } 64 | if err := scanner.Err(); err != nil { 65 | return nil, fmt.Errorf("error scanning ini: %v", err) 66 | } 67 | return result, nil 68 | } 69 | 70 | func CondVal(v string) []string { 71 | if v == "" { 72 | return nil 73 | } 74 | return []string{v} 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | 33 | all: install 34 | 35 | install: 36 | go install ./proto ./jsonpb ./ptypes 37 | go install ./protoc-gen-go 38 | 39 | test: 40 | go test ./proto ./jsonpb ./ptypes 41 | make -C protoc-gen-go/testdata test 42 | 43 | clean: 44 | go clean ./... 45 | 46 | nuke: 47 | go clean -i ./... 48 | 49 | regenerate: 50 | make -C protoc-gen-go/descriptor regenerate 51 | make -C protoc-gen-go/plugin regenerate 52 | make -C protoc-gen-go/testdata regenerate 53 | make -C proto/testdata regenerate 54 | make -C jsonpb/jsonpb_test_proto regenerate 55 | make -C _conformance regenerate 56 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/token_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package oauth2 6 | 7 | import ( 8 | "testing" 9 | "time" 10 | ) 11 | 12 | func TestTokenExtra(t *testing.T) { 13 | type testCase struct { 14 | key string 15 | val interface{} 16 | want interface{} 17 | } 18 | const key = "extra-key" 19 | cases := []testCase{ 20 | {key: key, val: "abc", want: "abc"}, 21 | {key: key, val: 123, want: 123}, 22 | {key: key, val: "", want: ""}, 23 | {key: "other-key", val: "def", want: nil}, 24 | } 25 | for _, tc := range cases { 26 | extra := make(map[string]interface{}) 27 | extra[tc.key] = tc.val 28 | tok := &Token{raw: extra} 29 | if got, want := tok.Extra(key), tc.want; got != want { 30 | t.Errorf("Extra(%q) = %q; want %q", key, got, want) 31 | } 32 | } 33 | } 34 | 35 | func TestTokenExpiry(t *testing.T) { 36 | now := time.Now() 37 | cases := []struct { 38 | name string 39 | tok *Token 40 | want bool 41 | }{ 42 | {name: "12 seconds", tok: &Token{Expiry: now.Add(12 * time.Second)}, want: false}, 43 | {name: "10 seconds", tok: &Token{Expiry: now.Add(expiryDelta)}, want: true}, 44 | {name: "-1 hour", tok: &Token{Expiry: now.Add(-1 * time.Hour)}, want: true}, 45 | } 46 | for _, tc := range cases { 47 | if got, want := tc.tok.expired(), tc.want; got != want { 48 | t.Errorf("expired (%q) = %v; want %v", tc.name, got, want) 49 | } 50 | } 51 | } 52 | 53 | func TestTokenTypeMethod(t *testing.T) { 54 | cases := []struct { 55 | name string 56 | tok *Token 57 | want string 58 | }{ 59 | {name: "bearer-mixed_case", tok: &Token{TokenType: "beAREr"}, want: "Bearer"}, 60 | {name: "default-bearer", tok: &Token{}, want: "Bearer"}, 61 | {name: "basic", tok: &Token{TokenType: "basic"}, want: "Basic"}, 62 | {name: "basic-capitalized", tok: &Token{TokenType: "Basic"}, want: "Basic"}, 63 | {name: "mac", tok: &Token{TokenType: "mac"}, want: "MAC"}, 64 | {name: "mac-caps", tok: &Token{TokenType: "MAC"}, want: "MAC"}, 65 | {name: "mac-mixed_case", tok: &Token{TokenType: "mAc"}, want: "MAC"}, 66 | } 67 | for _, tc := range cases { 68 | if got, want := tc.tok.Type(), tc.want; got != want { 69 | t.Errorf("TokenType(%q) = %v; want %v", tc.name, got, want) 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/list.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import "strings" 8 | 9 | // List displays []string as its items, 10 | // it has a Overflow option (default is "hidden"), when set to "hidden", 11 | // the item exceeding List's width is truncated, but when set to "wrap", 12 | // the overflowed text breaks into next line. 13 | /* 14 | strs := []string{ 15 | "[0] github.com/gizak/termui", 16 | "[1] editbox.go", 17 | "[2] interrupt.go", 18 | "[3] keyboard.go", 19 | "[4] output.go", 20 | "[5] random_out.go", 21 | "[6] dashboard.go", 22 | "[7] nsf/termbox-go"} 23 | 24 | ls := termui.NewList() 25 | ls.Items = strs 26 | ls.ItemFgColor = termui.ColorYellow 27 | ls.BorderLabel = "List" 28 | ls.Height = 7 29 | ls.Width = 25 30 | ls.Y = 0 31 | */ 32 | type List struct { 33 | Block 34 | Items []string 35 | Overflow string 36 | ItemFgColor Attribute 37 | ItemBgColor Attribute 38 | } 39 | 40 | // NewList returns a new *List with current theme. 41 | func NewList() *List { 42 | l := &List{Block: *NewBlock()} 43 | l.Overflow = "hidden" 44 | l.ItemFgColor = ThemeAttr("list.item.fg") 45 | l.ItemBgColor = ThemeAttr("list.item.bg") 46 | return l 47 | } 48 | 49 | // Buffer implements Bufferer interface. 50 | func (l *List) Buffer() Buffer { 51 | buf := l.Block.Buffer() 52 | 53 | switch l.Overflow { 54 | case "wrap": 55 | cs := DefaultTxBuilder.Build(strings.Join(l.Items, "\n"), l.ItemFgColor, l.ItemBgColor) 56 | i, j, k := 0, 0, 0 57 | for i < l.innerArea.Dy() && k < len(cs) { 58 | w := cs[k].Width() 59 | if cs[k].Ch == '\n' || j+w > l.innerArea.Dx() { 60 | i++ 61 | j = 0 62 | if cs[k].Ch == '\n' { 63 | k++ 64 | } 65 | continue 66 | } 67 | buf.Set(l.innerArea.Min.X+j, l.innerArea.Min.Y+i, cs[k]) 68 | 69 | k++ 70 | j++ 71 | } 72 | 73 | case "hidden": 74 | trimItems := l.Items 75 | if len(trimItems) > l.innerArea.Dy() { 76 | trimItems = trimItems[:l.innerArea.Dy()] 77 | } 78 | for i, v := range trimItems { 79 | cs := DTrimTxCls(DefaultTxBuilder.Build(v, l.ItemFgColor, l.ItemBgColor), l.innerArea.Dx()) 80 | j := 0 81 | for _, vv := range cs { 82 | w := vv.Width() 83 | buf.Set(l.innerArea.Min.X+j, l.innerArea.Min.Y+i, vv) 84 | j += w 85 | } 86 | } 87 | } 88 | return buf 89 | } 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spotctl 2 | 3 | `spotctl` is command-line interface to control Spotify from your favorite terminal. 4 | 5 | ## Demo 6 | 7 | One of the highlights is that `spotctl player` shows a real-time Spotify player that allows you to control it, right in your terminal! 8 | 9 | [![asciicast](https://asciinema.org/a/154262.png)](https://asciinema.org/a/154262) 10 | 11 | ## Installation 12 | 13 | ## Homebrew 14 | 15 | If you're on a Mac, you can install with [Homebrew](https://brew.sh/): 16 | 17 | ``` 18 | brew install https://raw.githubusercontent.com/jingweno/spotctl/master/Formula/spotctl.rb 19 | ``` 20 | 21 | ## Download 22 | 23 | You can download the latest release for your operating system [here](https://github.com/jingweno/spotctl/releases). 24 | 25 | ## Manual Installation 26 | 27 | `spotctl` needs to connect to Spotify's API in order to control it. 28 | To 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). 29 | Once you've done so, you can find its Client ID and Client Secret values and run the following command: 30 | 31 | ``` 32 | SPOTIFY_CLIENT_ID=XXX SPOTIFY_CLIENT_SECRET=YYY ./bin/build 33 | ``` 34 | 35 | ## Running 36 | 37 | **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. 38 | Here is a list of available commands: 39 | 40 | ``` 41 | $ spotctl -h 42 | A command-line interface to Spotify. 43 | 44 | Usage: 45 | spotctl [command] 46 | 47 | Available Commands: 48 | help Help about any command 49 | login Login with your Spotify credentials 50 | logout Clear your local Spotify credentials 51 | next Skip to the next track 52 | pause Pause Spotify playback 53 | play Resume playback or play a track, album, artist or playlist by name 54 | player Show the live player panel 55 | prev Return to the previous track 56 | repeat Toggle repeat playback mode 57 | shuffle Toggle shuffle playback mode 58 | status Show the current player status 59 | version Show version. 60 | vol Set or return volume percentage 61 | 62 | Flags: 63 | -h, --help help for spotctl 64 | 65 | Use "spotctl [command] --help" for more information about a command. 66 | ``` 67 | 68 | ## License 69 | 70 | [MIT](https://github.com/jingweno/spotctl/blob/master/LICENSE) 71 | -------------------------------------------------------------------------------- /vendor/github.com/zmb3/spotify/recommendation_test.go: -------------------------------------------------------------------------------- 1 | package spotify 2 | 3 | import ( 4 | "net/url" 5 | "testing" 6 | ) 7 | 8 | func TestGetRecommendations(t *testing.T) { 9 | // test data corresponding to Spotify Console web API sample 10 | client, server := testClientFile(200, "test_data/recommendations.txt") 11 | defer server.Close() 12 | 13 | seeds := Seeds{ 14 | Artists: []ID{"4NHQUGzhtTLFvgF5SZesLK"}, 15 | Tracks: []ID{"0c6xIDDpzE81m2q797ordA"}, 16 | Genres: []string{"classical", "country"}, 17 | } 18 | country := "ES" 19 | limit := 10 20 | opts := Options{ 21 | Country: &country, 22 | Limit: &limit, 23 | } 24 | recommendations, err := client.GetRecommendations(seeds, nil, &opts) 25 | if err != nil { 26 | t.Fatal(err) 27 | } 28 | if len(recommendations.Tracks) != 10 { 29 | t.Error("Expected 10 recommended tracks") 30 | } 31 | if recommendations.Tracks[0].Artists[0].Name != "Heinrich Isaac" { 32 | t.Error("Expected the artist of the first recommended track to be Heinrich Isaac") 33 | } 34 | } 35 | 36 | func TestSetSeedValues(t *testing.T) { 37 | expectedValues := "seed_artists=4NHQUGzhtTLFvgF5SZesLK%2C5PHQUGzhtTUIvgF5SZesGY&seed_genres=classical%2Ccountry" 38 | v := url.Values{} 39 | seeds := Seeds{ 40 | Artists: []ID{"4NHQUGzhtTLFvgF5SZesLK", "5PHQUGzhtTUIvgF5SZesGY"}, 41 | Genres: []string{"classical", "country"}, 42 | } 43 | setSeedValues(seeds, v) 44 | actualValues := v.Encode() 45 | if actualValues != expectedValues { 46 | t.Errorf("Expected seed values to be %s but got %s", expectedValues, actualValues) 47 | } 48 | } 49 | 50 | func TestSetTrackAttributesValues(t *testing.T) { 51 | expectedValues := "max_duration_ms=200&min_duration_ms=20&min_energy=0.45&target_acousticness=0.27&target_duration_ms=160" 52 | v := url.Values{} 53 | ta := NewTrackAttributes(). 54 | MaxDuration(200). 55 | MinDuration(20). 56 | TargetDuration(160). 57 | MinEnergy(0.45). 58 | TargetAcousticness(0.27) 59 | 60 | setTrackAttributesValues(ta, v) 61 | actualValues := v.Encode() 62 | if actualValues != expectedValues { 63 | t.Errorf("Expected track attributes values to be %s but got %s", expectedValues, actualValues) 64 | } 65 | } 66 | 67 | func TestSetEmptyTrackAttributesValues(t *testing.T) { 68 | expectedValues := "" 69 | v := url.Values{} 70 | setTrackAttributesValues(nil, v) 71 | actualValues := v.Encode() 72 | if actualValues != expectedValues { 73 | t.Errorf("Expected track attributes values to be empty but got %s", actualValues) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | // Package ctxhttp provides helper functions for performing context-aware HTTP requests. 8 | package ctxhttp // import "golang.org/x/net/context/ctxhttp" 9 | 10 | import ( 11 | "io" 12 | "net/http" 13 | "net/url" 14 | "strings" 15 | 16 | "golang.org/x/net/context" 17 | ) 18 | 19 | // Do sends an HTTP request with the provided http.Client and returns 20 | // an HTTP response. 21 | // 22 | // If the client is nil, http.DefaultClient is used. 23 | // 24 | // The provided ctx must be non-nil. If it is canceled or times out, 25 | // ctx.Err() will be returned. 26 | func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) { 27 | if client == nil { 28 | client = http.DefaultClient 29 | } 30 | resp, err := client.Do(req.WithContext(ctx)) 31 | // If we got an error, and the context has been canceled, 32 | // the context's error is probably more useful. 33 | if err != nil { 34 | select { 35 | case <-ctx.Done(): 36 | err = ctx.Err() 37 | default: 38 | } 39 | } 40 | return resp, err 41 | } 42 | 43 | // Get issues a GET request via the Do function. 44 | func Get(ctx context.Context, client *http.Client, url string) (*http.Response, error) { 45 | req, err := http.NewRequest("GET", url, nil) 46 | if err != nil { 47 | return nil, err 48 | } 49 | return Do(ctx, client, req) 50 | } 51 | 52 | // Head issues a HEAD request via the Do function. 53 | func Head(ctx context.Context, client *http.Client, url string) (*http.Response, error) { 54 | req, err := http.NewRequest("HEAD", url, nil) 55 | if err != nil { 56 | return nil, err 57 | } 58 | return Do(ctx, client, req) 59 | } 60 | 61 | // Post issues a POST request via the Do function. 62 | func Post(ctx context.Context, client *http.Client, url string, bodyType string, body io.Reader) (*http.Response, error) { 63 | req, err := http.NewRequest("POST", url, body) 64 | if err != nil { 65 | return nil, err 66 | } 67 | req.Header.Set("Content-Type", bodyType) 68 | return Do(ctx, client, req) 69 | } 70 | 71 | // PostForm issues a POST request via the Do function. 72 | func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) { 73 | return Post(ctx, client, url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode())) 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/size2_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2012 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package proto 33 | 34 | import ( 35 | "testing" 36 | ) 37 | 38 | // This is a separate file and package from size_test.go because that one uses 39 | // generated messages and thus may not be in package proto without having a circular 40 | // dependency, whereas this file tests unexported details of size.go. 41 | 42 | func TestVarintSize(t *testing.T) { 43 | // Check the edge cases carefully. 44 | testCases := []struct { 45 | n uint64 46 | size int 47 | }{ 48 | {0, 1}, 49 | {1, 1}, 50 | {127, 1}, 51 | {128, 2}, 52 | {16383, 2}, 53 | {16384, 3}, 54 | {1<<63 - 1, 9}, 55 | {1 << 63, 10}, 56 | } 57 | for _, tc := range testCases { 58 | size := sizeVarint(tc.n) 59 | if size != tc.size { 60 | t.Errorf("sizeVarint(%d) = %d, want %d", tc.n, size, tc.size) 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/nsf/termbox-go/collect_terminfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys, os, subprocess 4 | 5 | def escaped(s): 6 | return repr(s)[1:-1] 7 | 8 | def tput(term, name): 9 | try: 10 | return subprocess.check_output(['tput', '-T%s' % term, name]).decode() 11 | except subprocess.CalledProcessError as e: 12 | return e.output.decode() 13 | 14 | 15 | def w(s): 16 | if s == None: 17 | return 18 | sys.stdout.write(s) 19 | 20 | terminals = { 21 | 'xterm' : 'xterm', 22 | 'rxvt-256color' : 'rxvt_256color', 23 | 'rxvt-unicode' : 'rxvt_unicode', 24 | 'linux' : 'linux', 25 | 'Eterm' : 'eterm', 26 | 'screen' : 'screen' 27 | } 28 | 29 | keys = [ 30 | "F1", "kf1", 31 | "F2", "kf2", 32 | "F3", "kf3", 33 | "F4", "kf4", 34 | "F5", "kf5", 35 | "F6", "kf6", 36 | "F7", "kf7", 37 | "F8", "kf8", 38 | "F9", "kf9", 39 | "F10", "kf10", 40 | "F11", "kf11", 41 | "F12", "kf12", 42 | "INSERT", "kich1", 43 | "DELETE", "kdch1", 44 | "HOME", "khome", 45 | "END", "kend", 46 | "PGUP", "kpp", 47 | "PGDN", "knp", 48 | "KEY_UP", "kcuu1", 49 | "KEY_DOWN", "kcud1", 50 | "KEY_LEFT", "kcub1", 51 | "KEY_RIGHT", "kcuf1" 52 | ] 53 | 54 | funcs = [ 55 | "T_ENTER_CA", "smcup", 56 | "T_EXIT_CA", "rmcup", 57 | "T_SHOW_CURSOR", "cnorm", 58 | "T_HIDE_CURSOR", "civis", 59 | "T_CLEAR_SCREEN", "clear", 60 | "T_SGR0", "sgr0", 61 | "T_UNDERLINE", "smul", 62 | "T_BOLD", "bold", 63 | "T_BLINK", "blink", 64 | "T_REVERSE", "rev", 65 | "T_ENTER_KEYPAD", "smkx", 66 | "T_EXIT_KEYPAD", "rmkx" 67 | ] 68 | 69 | def iter_pairs(iterable): 70 | iterable = iter(iterable) 71 | while True: 72 | yield (next(iterable), next(iterable)) 73 | 74 | def do_term(term, nick): 75 | w("// %s\n" % term) 76 | w("var %s_keys = []string{\n\t" % nick) 77 | for k, v in iter_pairs(keys): 78 | w('"') 79 | w(escaped(tput(term, v))) 80 | w('",') 81 | w("\n}\n") 82 | w("var %s_funcs = []string{\n\t" % nick) 83 | for k,v in iter_pairs(funcs): 84 | w('"') 85 | if v == "sgr": 86 | w("\\033[3%d;4%dm") 87 | elif v == "cup": 88 | w("\\033[%d;%dH") 89 | else: 90 | w(escaped(tput(term, v))) 91 | w('", ') 92 | w("\n}\n\n") 93 | 94 | def do_terms(d): 95 | w("var terms = []struct {\n") 96 | w("\tname string\n") 97 | w("\tkeys []string\n") 98 | w("\tfuncs []string\n") 99 | w("}{\n") 100 | for k, v in d.items(): 101 | w('\t{"%s", %s_keys, %s_funcs},\n' % (k, v, v)) 102 | w("}\n\n") 103 | 104 | w("// +build !windows\n\npackage termbox\n\n") 105 | 106 | for k,v in terminals.items(): 107 | do_term(k, v) 108 | 109 | do_terms(terminals) 110 | 111 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/context.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package context defines the Context type, which carries deadlines, 6 | // cancelation signals, and other request-scoped values across API boundaries 7 | // and between processes. 8 | // As of Go 1.7 this package is available in the standard library under the 9 | // name context. https://golang.org/pkg/context. 10 | // 11 | // Incoming requests to a server should create a Context, and outgoing calls to 12 | // servers should accept a Context. The chain of function calls between must 13 | // propagate the Context, optionally replacing it with a modified copy created 14 | // using WithDeadline, WithTimeout, WithCancel, or WithValue. 15 | // 16 | // Programs that use Contexts should follow these rules to keep interfaces 17 | // consistent across packages and enable static analysis tools to check context 18 | // propagation: 19 | // 20 | // Do not store Contexts inside a struct type; instead, pass a Context 21 | // explicitly to each function that needs it. The Context should be the first 22 | // parameter, typically named ctx: 23 | // 24 | // func DoSomething(ctx context.Context, arg Arg) error { 25 | // // ... use ctx ... 26 | // } 27 | // 28 | // Do not pass a nil Context, even if a function permits it. Pass context.TODO 29 | // if you are unsure about which Context to use. 30 | // 31 | // Use context Values only for request-scoped data that transits processes and 32 | // APIs, not for passing optional parameters to functions. 33 | // 34 | // The same Context may be passed to functions running in different goroutines; 35 | // Contexts are safe for simultaneous use by multiple goroutines. 36 | // 37 | // See http://blog.golang.org/context for example code for a server that uses 38 | // Contexts. 39 | package context // import "golang.org/x/net/context" 40 | 41 | // Background returns a non-nil, empty Context. It is never canceled, has no 42 | // values, and has no deadline. It is typically used by the main function, 43 | // initialization, and tests, and as the top-level Context for incoming 44 | // requests. 45 | func Background() Context { 46 | return background 47 | } 48 | 49 | // TODO returns a non-nil, empty Context. Code should use context.TODO when 50 | // it's unclear which Context to use or it is not yet available (because the 51 | // surrounding function has not yet been extended to accept a Context 52 | // parameter). TODO is recognized by static analysis tools that determine 53 | // whether Contexts are propagated correctly in a program. 54 | func TODO() Context { 55 | return todo 56 | } 57 | -------------------------------------------------------------------------------- /Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | branch = "master" 6 | name = "github.com/gizak/termui" 7 | packages = ["."] 8 | revision = "72304ddb9b4e9838426a021aad64a5a860e98324" 9 | 10 | [[projects]] 11 | branch = "master" 12 | name = "github.com/golang/protobuf" 13 | packages = ["proto"] 14 | revision = "1e59b77b52bf8e4b449a57e6f79f21226d571845" 15 | 16 | [[projects]] 17 | name = "github.com/inconshreveable/mousetrap" 18 | packages = ["."] 19 | revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" 20 | version = "v1.0" 21 | 22 | [[projects]] 23 | name = "github.com/maruel/panicparse" 24 | packages = ["stack"] 25 | revision = "766956aceb8ff49664065ae50bef0ae8a0a83ec4" 26 | version = "v1.0.2" 27 | 28 | [[projects]] 29 | name = "github.com/mattn/go-runewidth" 30 | packages = ["."] 31 | revision = "9e777a8366cce605130a531d2cd6363d07ad7317" 32 | version = "v0.0.2" 33 | 34 | [[projects]] 35 | branch = "master" 36 | name = "github.com/mitchellh/go-wordwrap" 37 | packages = ["."] 38 | revision = "ad45545899c7b13c020ea92b2072220eefad42b8" 39 | 40 | [[projects]] 41 | branch = "master" 42 | name = "github.com/nsf/termbox-go" 43 | packages = ["."] 44 | revision = "aa4a75b1c20a2b03751b1a9f7e41d58bd6f71c43" 45 | 46 | [[projects]] 47 | branch = "master" 48 | name = "github.com/spf13/cobra" 49 | packages = ["."] 50 | revision = "ccaecb155a2177302cb56cae929251a256d0f646" 51 | 52 | [[projects]] 53 | name = "github.com/spf13/pflag" 54 | packages = ["."] 55 | revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66" 56 | version = "v1.0.0" 57 | 58 | [[projects]] 59 | branch = "master" 60 | name = "github.com/zmb3/spotify" 61 | packages = ["."] 62 | revision = "40a7a169da269b3ba5529949796441938d40bce3" 63 | 64 | [[projects]] 65 | branch = "master" 66 | name = "golang.org/x/net" 67 | packages = ["context","context/ctxhttp"] 68 | revision = "d866cfc389cec985d6fda2859936a575a55a3ab6" 69 | 70 | [[projects]] 71 | branch = "master" 72 | name = "golang.org/x/oauth2" 73 | packages = [".","internal"] 74 | revision = "0448841f0cbe9d174c6c1cedd177f583337b8e2c" 75 | 76 | [[projects]] 77 | name = "google.golang.org/appengine" 78 | packages = ["internal","internal/base","internal/datastore","internal/log","internal/remote_api","internal/urlfetch","urlfetch"] 79 | revision = "150dc57a1b433e64154302bdc40b6bb8aefa313a" 80 | version = "v1.0.0" 81 | 82 | [solve-meta] 83 | analyzer-name = "dep" 84 | analyzer-version = 1 85 | inputs-digest = "0720d9d92c879913d220a1442b2e7dd1ebcc7a959ee1f519c373752cb63db745" 86 | solver-name = "gps-cdcl" 87 | solver-version = 1 88 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package oauth2_test 6 | 7 | import ( 8 | "context" 9 | "fmt" 10 | "log" 11 | "net/http" 12 | "time" 13 | 14 | "golang.org/x/oauth2" 15 | ) 16 | 17 | func ExampleConfig() { 18 | ctx := context.Background() 19 | conf := &oauth2.Config{ 20 | ClientID: "YOUR_CLIENT_ID", 21 | ClientSecret: "YOUR_CLIENT_SECRET", 22 | Scopes: []string{"SCOPE1", "SCOPE2"}, 23 | Endpoint: oauth2.Endpoint{ 24 | AuthURL: "https://provider.com/o/oauth2/auth", 25 | TokenURL: "https://provider.com/o/oauth2/token", 26 | }, 27 | } 28 | 29 | // Redirect user to consent page to ask for permission 30 | // for the scopes specified above. 31 | url := conf.AuthCodeURL("state", oauth2.AccessTypeOffline) 32 | fmt.Printf("Visit the URL for the auth dialog: %v", url) 33 | 34 | // Use the authorization code that is pushed to the redirect 35 | // URL. Exchange will do the handshake to retrieve the 36 | // initial access token. The HTTP Client returned by 37 | // conf.Client will refresh the token as necessary. 38 | var code string 39 | if _, err := fmt.Scan(&code); err != nil { 40 | log.Fatal(err) 41 | } 42 | tok, err := conf.Exchange(ctx, code) 43 | if err != nil { 44 | log.Fatal(err) 45 | } 46 | 47 | client := conf.Client(ctx, tok) 48 | client.Get("...") 49 | } 50 | 51 | func ExampleConfig_customHTTP() { 52 | ctx := context.Background() 53 | 54 | conf := &oauth2.Config{ 55 | ClientID: "YOUR_CLIENT_ID", 56 | ClientSecret: "YOUR_CLIENT_SECRET", 57 | Scopes: []string{"SCOPE1", "SCOPE2"}, 58 | Endpoint: oauth2.Endpoint{ 59 | TokenURL: "https://provider.com/o/oauth2/token", 60 | AuthURL: "https://provider.com/o/oauth2/auth", 61 | }, 62 | } 63 | 64 | // Redirect user to consent page to ask for permission 65 | // for the scopes specified above. 66 | url := conf.AuthCodeURL("state", oauth2.AccessTypeOffline) 67 | fmt.Printf("Visit the URL for the auth dialog: %v", url) 68 | 69 | // Use the authorization code that is pushed to the redirect 70 | // URL. Exchange will do the handshake to retrieve the 71 | // initial access token. The HTTP Client returned by 72 | // conf.Client will refresh the token as necessary. 73 | var code string 74 | if _, err := fmt.Scan(&code); err != nil { 75 | log.Fatal(err) 76 | } 77 | 78 | // Use the custom HTTP client when requesting a token. 79 | httpClient := &http.Client{Timeout: 2 * time.Second} 80 | ctx = context.WithValue(ctx, oauth2.HTTPClient, httpClient) 81 | 82 | tok, err := conf.Exchange(ctx, code) 83 | if err != nil { 84 | log.Fatal(err) 85 | } 86 | 87 | client := conf.Client(ctx, tok) 88 | _ = client 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/trap_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | // +build !go1.4 3 | 4 | package mousetrap 5 | 6 | import ( 7 | "fmt" 8 | "os" 9 | "syscall" 10 | "unsafe" 11 | ) 12 | 13 | const ( 14 | // defined by the Win32 API 15 | th32cs_snapprocess uintptr = 0x2 16 | ) 17 | 18 | var ( 19 | kernel = syscall.MustLoadDLL("kernel32.dll") 20 | CreateToolhelp32Snapshot = kernel.MustFindProc("CreateToolhelp32Snapshot") 21 | Process32First = kernel.MustFindProc("Process32FirstW") 22 | Process32Next = kernel.MustFindProc("Process32NextW") 23 | ) 24 | 25 | // ProcessEntry32 structure defined by the Win32 API 26 | type processEntry32 struct { 27 | dwSize uint32 28 | cntUsage uint32 29 | th32ProcessID uint32 30 | th32DefaultHeapID int 31 | th32ModuleID uint32 32 | cntThreads uint32 33 | th32ParentProcessID uint32 34 | pcPriClassBase int32 35 | dwFlags uint32 36 | szExeFile [syscall.MAX_PATH]uint16 37 | } 38 | 39 | func getProcessEntry(pid int) (pe *processEntry32, err error) { 40 | snapshot, _, e1 := CreateToolhelp32Snapshot.Call(th32cs_snapprocess, uintptr(0)) 41 | if snapshot == uintptr(syscall.InvalidHandle) { 42 | err = fmt.Errorf("CreateToolhelp32Snapshot: %v", e1) 43 | return 44 | } 45 | defer syscall.CloseHandle(syscall.Handle(snapshot)) 46 | 47 | var processEntry processEntry32 48 | processEntry.dwSize = uint32(unsafe.Sizeof(processEntry)) 49 | ok, _, e1 := Process32First.Call(snapshot, uintptr(unsafe.Pointer(&processEntry))) 50 | if ok == 0 { 51 | err = fmt.Errorf("Process32First: %v", e1) 52 | return 53 | } 54 | 55 | for { 56 | if processEntry.th32ProcessID == uint32(pid) { 57 | pe = &processEntry 58 | return 59 | } 60 | 61 | ok, _, e1 = Process32Next.Call(snapshot, uintptr(unsafe.Pointer(&processEntry))) 62 | if ok == 0 { 63 | err = fmt.Errorf("Process32Next: %v", e1) 64 | return 65 | } 66 | } 67 | } 68 | 69 | func getppid() (pid int, err error) { 70 | pe, err := getProcessEntry(os.Getpid()) 71 | if err != nil { 72 | return 73 | } 74 | 75 | pid = int(pe.th32ParentProcessID) 76 | return 77 | } 78 | 79 | // StartedByExplorer returns true if the program was invoked by the user double-clicking 80 | // on the executable from explorer.exe 81 | // 82 | // It is conservative and returns false if any of the internal calls fail. 83 | // It does not guarantee that the program was run from a terminal. It only can tell you 84 | // whether it was launched from explorer.exe 85 | func StartedByExplorer() bool { 86 | ppid, err := getppid() 87 | if err != nil { 88 | return false 89 | } 90 | 91 | pe, err := getProcessEntry(ppid) 92 | if err != nil { 93 | return false 94 | } 95 | 96 | name := syscall.UTF16ToString(pe.szExeFile[:]) 97 | return name == "explorer.exe" 98 | } 99 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/README.md: -------------------------------------------------------------------------------- 1 | # OAuth2 for Go 2 | 3 | [![Build Status](https://travis-ci.org/golang/oauth2.svg?branch=master)](https://travis-ci.org/golang/oauth2) 4 | [![GoDoc](https://godoc.org/golang.org/x/oauth2?status.svg)](https://godoc.org/golang.org/x/oauth2) 5 | 6 | oauth2 package contains a client implementation for OAuth 2.0 spec. 7 | 8 | ## Installation 9 | 10 | ~~~~ 11 | go get golang.org/x/oauth2 12 | ~~~~ 13 | 14 | Or you can manually git clone the repository to 15 | `$(go env GOPATH)/src/golang.org/x/oauth2`. 16 | 17 | See godoc for further documentation and examples. 18 | 19 | * [godoc.org/golang.org/x/oauth2](http://godoc.org/golang.org/x/oauth2) 20 | * [godoc.org/golang.org/x/oauth2/google](http://godoc.org/golang.org/x/oauth2/google) 21 | 22 | 23 | ## App Engine 24 | 25 | In change 96e89be (March 2015), we removed the `oauth2.Context2` type in favor 26 | of the [`context.Context`](https://golang.org/x/net/context#Context) type from 27 | the `golang.org/x/net/context` package 28 | 29 | This means it's no longer possible to use the "Classic App Engine" 30 | `appengine.Context` type with the `oauth2` package. (You're using 31 | Classic App Engine if you import the package `"appengine"`.) 32 | 33 | To work around this, you may use the new `"google.golang.org/appengine"` 34 | package. This package has almost the same API as the `"appengine"` package, 35 | but it can be fetched with `go get` and used on "Managed VMs" and well as 36 | Classic App Engine. 37 | 38 | See the [new `appengine` package's readme](https://github.com/golang/appengine#updating-a-go-app-engine-app) 39 | for information on updating your app. 40 | 41 | If you don't want to update your entire app to use the new App Engine packages, 42 | you may use both sets of packages in parallel, using only the new packages 43 | with the `oauth2` package. 44 | 45 | ```go 46 | import ( 47 | "golang.org/x/net/context" 48 | "golang.org/x/oauth2" 49 | "golang.org/x/oauth2/google" 50 | newappengine "google.golang.org/appengine" 51 | newurlfetch "google.golang.org/appengine/urlfetch" 52 | 53 | "appengine" 54 | ) 55 | 56 | func handler(w http.ResponseWriter, r *http.Request) { 57 | var c appengine.Context = appengine.NewContext(r) 58 | c.Infof("Logging a message with the old package") 59 | 60 | var ctx context.Context = newappengine.NewContext(r) 61 | client := &http.Client{ 62 | Transport: &oauth2.Transport{ 63 | Source: google.AppEngineTokenSource(ctx, "scope"), 64 | Base: &newurlfetch.Transport{Context: ctx}, 65 | }, 66 | } 67 | client.Get("...") 68 | } 69 | ``` 70 | 71 | ## Report Issues / Send Patches 72 | 73 | This repository uses Gerrit for code changes. To learn how to submit changes to 74 | this repository, see https://golang.org/doc/contribute.html. 75 | 76 | The main issue tracker for the oauth2 repository is located at 77 | https://github.com/golang/oauth2/issues. 78 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/gauge.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import ( 8 | "strconv" 9 | "strings" 10 | ) 11 | 12 | // Gauge is a progress bar like widget. 13 | // A simple example: 14 | /* 15 | g := termui.NewGauge() 16 | g.Percent = 40 17 | g.Width = 50 18 | g.Height = 3 19 | g.BorderLabel = "Slim Gauge" 20 | g.BarColor = termui.ColorRed 21 | g.PercentColor = termui.ColorBlue 22 | */ 23 | 24 | const ColorUndef Attribute = Attribute(^uint16(0)) 25 | 26 | type Gauge struct { 27 | Block 28 | Percent int 29 | BarColor Attribute 30 | PercentColor Attribute 31 | PercentColorHighlighted Attribute 32 | Label string 33 | LabelAlign Align 34 | } 35 | 36 | // NewGauge return a new gauge with current theme. 37 | func NewGauge() *Gauge { 38 | g := &Gauge{ 39 | Block: *NewBlock(), 40 | PercentColor: ThemeAttr("gauge.percent.fg"), 41 | BarColor: ThemeAttr("gauge.bar.bg"), 42 | Label: "{{percent}}%", 43 | LabelAlign: AlignCenter, 44 | PercentColorHighlighted: ColorUndef, 45 | } 46 | 47 | g.Width = 12 48 | g.Height = 5 49 | return g 50 | } 51 | 52 | // Buffer implements Bufferer interface. 53 | func (g *Gauge) Buffer() Buffer { 54 | buf := g.Block.Buffer() 55 | 56 | // plot bar 57 | w := g.Percent * g.innerArea.Dx() / 100 58 | for i := 0; i < g.innerArea.Dy(); i++ { 59 | for j := 0; j < w; j++ { 60 | c := Cell{} 61 | c.Ch = ' ' 62 | c.Bg = g.BarColor 63 | if c.Bg == ColorDefault { 64 | c.Bg |= AttrReverse 65 | } 66 | buf.Set(g.innerArea.Min.X+j, g.innerArea.Min.Y+i, c) 67 | } 68 | } 69 | 70 | // plot percentage 71 | s := strings.Replace(g.Label, "{{percent}}", strconv.Itoa(g.Percent), -1) 72 | pry := g.innerArea.Min.Y + g.innerArea.Dy()/2 73 | rs := str2runes(s) 74 | var pos int 75 | switch g.LabelAlign { 76 | case AlignLeft: 77 | pos = 0 78 | 79 | case AlignCenter: 80 | pos = (g.innerArea.Dx() - strWidth(s)) / 2 81 | 82 | case AlignRight: 83 | pos = g.innerArea.Dx() - strWidth(s) - 1 84 | } 85 | pos += g.innerArea.Min.X 86 | 87 | for i, v := range rs { 88 | c := Cell{ 89 | Ch: v, 90 | Fg: g.PercentColor, 91 | } 92 | 93 | if w+g.innerArea.Min.X > pos+i { 94 | c.Bg = g.BarColor 95 | if c.Bg == ColorDefault { 96 | c.Bg |= AttrReverse 97 | } 98 | 99 | if g.PercentColorHighlighted != ColorUndef { 100 | c.Fg = g.PercentColorHighlighted 101 | } 102 | } else { 103 | c.Bg = g.Block.Bg 104 | } 105 | 106 | buf.Set(1+pos+i, pry, c) 107 | } 108 | return buf 109 | } 110 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/message_set_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package proto 33 | 34 | import ( 35 | "bytes" 36 | "testing" 37 | ) 38 | 39 | func TestUnmarshalMessageSetWithDuplicate(t *testing.T) { 40 | // Check that a repeated message set entry will be concatenated. 41 | in := &messageSet{ 42 | Item: []*_MessageSet_Item{ 43 | {TypeId: Int32(12345), Message: []byte("hoo")}, 44 | {TypeId: Int32(12345), Message: []byte("hah")}, 45 | }, 46 | } 47 | b, err := Marshal(in) 48 | if err != nil { 49 | t.Fatalf("Marshal: %v", err) 50 | } 51 | t.Logf("Marshaled bytes: %q", b) 52 | 53 | var extensions XXX_InternalExtensions 54 | if err := UnmarshalMessageSet(b, &extensions); err != nil { 55 | t.Fatalf("UnmarshalMessageSet: %v", err) 56 | } 57 | ext, ok := extensions.p.extensionMap[12345] 58 | if !ok { 59 | t.Fatalf("Didn't retrieve extension 12345; map is %v", extensions.p.extensionMap) 60 | } 61 | // Skip wire type/field number and length varints. 62 | got := skipVarint(skipVarint(ext.enc)) 63 | if want := []byte("hoohah"); !bytes.Equal(got, want) { 64 | t.Errorf("Combined extension is %q, want %q", got, want) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/zmb3/spotify/page.go: -------------------------------------------------------------------------------- 1 | package spotify 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // ErrNoMorePages is the error returned when you attempt to get the next 8 | // (or previous) set of data but you've reached the end of the data set. 9 | var ErrNoMorePages = errors.New("spotify: no more pages") 10 | 11 | // This file contains the types that implement Spotify's paging object. 12 | // See: https://developer.spotify.com/web-api/object-model/#paging-object 13 | 14 | // basePage contains all of the fields in a Spotify paging object, except 15 | // for the actual items. This type is meant to be embedded in other types 16 | // that add the Items field. 17 | type basePage struct { 18 | // A link to the Web API Endpoint returning the full 19 | // result of this request. 20 | Endpoint string `json:"href"` 21 | // The maximum number of items in the response, as set 22 | // in the query (or default value if unset). 23 | Limit int `json:"limit"` 24 | // The offset of the items returned, as set in the query 25 | // (or default value if unset). 26 | Offset int `json:"offset"` 27 | // The total number of items available to return. 28 | Total int `json:"total"` 29 | // The URL to the next page of items (if available). 30 | Next string `json:"next"` 31 | // The URL to the previous page of items (if available). 32 | Previous string `json:"previous"` 33 | } 34 | 35 | // FullArtistPage contains FullArtists returned by the Web API. 36 | type FullArtistPage struct { 37 | basePage 38 | Artists []FullArtist `json:"items"` 39 | } 40 | 41 | // SimpleAlbumPage contains SimpleAlbums returned by the Web API. 42 | type SimpleAlbumPage struct { 43 | basePage 44 | Albums []SimpleAlbum `json:"items"` 45 | } 46 | 47 | // SavedAlbumPage contains SavedAlbums returned by the Web API. 48 | type SavedAlbumPage struct { 49 | basePage 50 | Albums []SavedAlbum `json:"items"` 51 | } 52 | 53 | // SimplePlaylistPage contains SimplePlaylists returned by the Web API. 54 | type SimplePlaylistPage struct { 55 | basePage 56 | Playlists []SimplePlaylist `json:"items"` 57 | } 58 | 59 | // SimpleTrackPage contains SimpleTracks returned by the Web API. 60 | type SimpleTrackPage struct { 61 | basePage 62 | Tracks []SimpleTrack `json:"items"` 63 | } 64 | 65 | // FullTrackPage contains FullTracks returned by the Web API. 66 | type FullTrackPage struct { 67 | basePage 68 | Tracks []FullTrack `json:"items"` 69 | } 70 | 71 | // SavedTrackPage contains SavedTracks return by the Web API. 72 | type SavedTrackPage struct { 73 | basePage 74 | Tracks []SavedTrack `json:"items"` 75 | } 76 | 77 | // PlaylistTrackPage contains information about tracks in a playlist. 78 | type PlaylistTrackPage struct { 79 | basePage 80 | Tracks []PlaylistTrack `json:"items"` 81 | } 82 | 83 | // CategoryPage contains Category objects returned by the Web API. 84 | type CategoryPage struct { 85 | basePage 86 | Categories []Category `json:"items"` 87 | } 88 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/ctxhttp/ctxhttp_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !plan9 6 | 7 | package ctxhttp 8 | 9 | import ( 10 | "io" 11 | "io/ioutil" 12 | "net/http" 13 | "net/http/httptest" 14 | "testing" 15 | "time" 16 | 17 | "golang.org/x/net/context" 18 | ) 19 | 20 | const ( 21 | requestDuration = 100 * time.Millisecond 22 | requestBody = "ok" 23 | ) 24 | 25 | func okHandler(w http.ResponseWriter, r *http.Request) { 26 | time.Sleep(requestDuration) 27 | io.WriteString(w, requestBody) 28 | } 29 | 30 | func TestNoTimeout(t *testing.T) { 31 | ts := httptest.NewServer(http.HandlerFunc(okHandler)) 32 | defer ts.Close() 33 | 34 | ctx := context.Background() 35 | res, err := Get(ctx, nil, ts.URL) 36 | if err != nil { 37 | t.Fatal(err) 38 | } 39 | defer res.Body.Close() 40 | slurp, err := ioutil.ReadAll(res.Body) 41 | if err != nil { 42 | t.Fatal(err) 43 | } 44 | if string(slurp) != requestBody { 45 | t.Errorf("body = %q; want %q", slurp, requestBody) 46 | } 47 | } 48 | 49 | func TestCancelBeforeHeaders(t *testing.T) { 50 | ctx, cancel := context.WithCancel(context.Background()) 51 | 52 | blockServer := make(chan struct{}) 53 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 54 | cancel() 55 | <-blockServer 56 | io.WriteString(w, requestBody) 57 | })) 58 | defer ts.Close() 59 | defer close(blockServer) 60 | 61 | res, err := Get(ctx, nil, ts.URL) 62 | if err == nil { 63 | res.Body.Close() 64 | t.Fatal("Get returned unexpected nil error") 65 | } 66 | if err != context.Canceled { 67 | t.Errorf("err = %v; want %v", err, context.Canceled) 68 | } 69 | } 70 | 71 | func TestCancelAfterHangingRequest(t *testing.T) { 72 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 73 | w.WriteHeader(http.StatusOK) 74 | w.(http.Flusher).Flush() 75 | <-w.(http.CloseNotifier).CloseNotify() 76 | })) 77 | defer ts.Close() 78 | 79 | ctx, cancel := context.WithCancel(context.Background()) 80 | resp, err := Get(ctx, nil, ts.URL) 81 | if err != nil { 82 | t.Fatalf("unexpected error in Get: %v", err) 83 | } 84 | 85 | // Cancel befer reading the body. 86 | // Reading Request.Body should fail, since the request was 87 | // canceled before anything was written. 88 | cancel() 89 | 90 | done := make(chan struct{}) 91 | 92 | go func() { 93 | b, err := ioutil.ReadAll(resp.Body) 94 | if len(b) != 0 || err == nil { 95 | t.Errorf(`Read got (%q, %v); want ("", error)`, b, err) 96 | } 97 | close(done) 98 | }() 99 | 100 | select { 101 | case <-time.After(1 * time.Second): 102 | t.Errorf("Test timed out") 103 | case <-done: 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /vendor/github.com/gizak/termui/buffer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Zack Guo . All rights reserved. 2 | // Use of this source code is governed by a MIT license that can 3 | // be found in the LICENSE file. 4 | 5 | package termui 6 | 7 | import "image" 8 | 9 | // Cell is a rune with assigned Fg and Bg 10 | type Cell struct { 11 | Ch rune 12 | Fg Attribute 13 | Bg Attribute 14 | } 15 | 16 | // Buffer is a renderable rectangle cell data container. 17 | type Buffer struct { 18 | Area image.Rectangle // selected drawing area 19 | CellMap map[image.Point]Cell 20 | } 21 | 22 | // At returns the cell at (x,y). 23 | func (b Buffer) At(x, y int) Cell { 24 | return b.CellMap[image.Pt(x, y)] 25 | } 26 | 27 | // Set assigns a char to (x,y) 28 | func (b Buffer) Set(x, y int, c Cell) { 29 | b.CellMap[image.Pt(x, y)] = c 30 | } 31 | 32 | // Bounds returns the domain for which At can return non-zero color. 33 | func (b Buffer) Bounds() image.Rectangle { 34 | x0, y0, x1, y1 := 0, 0, 0, 0 35 | for p := range b.CellMap { 36 | if p.X > x1 { 37 | x1 = p.X 38 | } 39 | if p.X < x0 { 40 | x0 = p.X 41 | } 42 | if p.Y > y1 { 43 | y1 = p.Y 44 | } 45 | if p.Y < y0 { 46 | y0 = p.Y 47 | } 48 | } 49 | return image.Rect(x0, y0, x1+1, y1+1) 50 | } 51 | 52 | // SetArea assigns a new rect area to Buffer b. 53 | func (b *Buffer) SetArea(r image.Rectangle) { 54 | b.Area.Max = r.Max 55 | b.Area.Min = r.Min 56 | } 57 | 58 | // Sync sets drawing area to the buffer's bound 59 | func (b *Buffer) Sync() { 60 | b.SetArea(b.Bounds()) 61 | } 62 | 63 | // NewCell returns a new cell 64 | func NewCell(ch rune, fg, bg Attribute) Cell { 65 | return Cell{ch, fg, bg} 66 | } 67 | 68 | // Merge merges bs Buffers onto b 69 | func (b *Buffer) Merge(bs ...Buffer) { 70 | for _, buf := range bs { 71 | for p, v := range buf.CellMap { 72 | b.Set(p.X, p.Y, v) 73 | } 74 | b.SetArea(b.Area.Union(buf.Area)) 75 | } 76 | } 77 | 78 | // NewBuffer returns a new Buffer 79 | func NewBuffer() Buffer { 80 | return Buffer{ 81 | CellMap: make(map[image.Point]Cell), 82 | Area: image.Rectangle{}} 83 | } 84 | 85 | // Fill fills the Buffer b with ch,fg and bg. 86 | func (b Buffer) Fill(ch rune, fg, bg Attribute) { 87 | for x := b.Area.Min.X; x < b.Area.Max.X; x++ { 88 | for y := b.Area.Min.Y; y < b.Area.Max.Y; y++ { 89 | b.Set(x, y, Cell{ch, fg, bg}) 90 | } 91 | } 92 | } 93 | 94 | // NewFilledBuffer returns a new Buffer filled with ch, fb and bg. 95 | func NewFilledBuffer(x0, y0, x1, y1 int, ch rune, fg, bg Attribute) Buffer { 96 | buf := NewBuffer() 97 | buf.Area.Min = image.Pt(x0, y0) 98 | buf.Area.Max = image.Pt(x1, y1) 99 | 100 | for x := buf.Area.Min.X; x < buf.Area.Max.X; x++ { 101 | for y := buf.Area.Min.Y; y < buf.Area.Max.Y; y++ { 102 | buf.Set(x, y, Cell{ch, fg, bg}) 103 | } 104 | } 105 | return buf 106 | } 107 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/args.go: -------------------------------------------------------------------------------- 1 | package cobra 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type PositionalArgs func(cmd *Command, args []string) error 8 | 9 | // Legacy arg validation has the following behaviour: 10 | // - root commands with no subcommands can take arbitrary arguments 11 | // - root commands with subcommands will do subcommand validity checking 12 | // - subcommands will always accept arbitrary arguments 13 | func legacyArgs(cmd *Command, args []string) error { 14 | // no subcommand, always take args 15 | if !cmd.HasSubCommands() { 16 | return nil 17 | } 18 | 19 | // root command with subcommands, do subcommand checking. 20 | if !cmd.HasParent() && len(args) > 0 { 21 | return fmt.Errorf("unknown command %q for %q%s", args[0], cmd.CommandPath(), cmd.findSuggestions(args[0])) 22 | } 23 | return nil 24 | } 25 | 26 | // NoArgs returns an error if any args are included. 27 | func NoArgs(cmd *Command, args []string) error { 28 | if len(args) > 0 { 29 | return fmt.Errorf("unknown command %q for %q", args[0], cmd.CommandPath()) 30 | } 31 | return nil 32 | } 33 | 34 | // OnlyValidArgs returns an error if any args are not in the list of ValidArgs. 35 | func OnlyValidArgs(cmd *Command, args []string) error { 36 | if len(cmd.ValidArgs) > 0 { 37 | for _, v := range args { 38 | if !stringInSlice(v, cmd.ValidArgs) { 39 | return fmt.Errorf("invalid argument %q for %q%s", v, cmd.CommandPath(), cmd.findSuggestions(args[0])) 40 | } 41 | } 42 | } 43 | return nil 44 | } 45 | 46 | // ArbitraryArgs never returns an error. 47 | func ArbitraryArgs(cmd *Command, args []string) error { 48 | return nil 49 | } 50 | 51 | // MinimumNArgs returns an error if there is not at least N args. 52 | func MinimumNArgs(n int) PositionalArgs { 53 | return func(cmd *Command, args []string) error { 54 | if len(args) < n { 55 | return fmt.Errorf("requires at least %d arg(s), only received %d", n, len(args)) 56 | } 57 | return nil 58 | } 59 | } 60 | 61 | // MaximumNArgs returns an error if there are more than N args. 62 | func MaximumNArgs(n int) PositionalArgs { 63 | return func(cmd *Command, args []string) error { 64 | if len(args) > n { 65 | return fmt.Errorf("accepts at most %d arg(s), received %d", n, len(args)) 66 | } 67 | return nil 68 | } 69 | } 70 | 71 | // ExactArgs returns an error if there are not exactly n args. 72 | func ExactArgs(n int) PositionalArgs { 73 | return func(cmd *Command, args []string) error { 74 | if len(args) != n { 75 | return fmt.Errorf("accepts %d arg(s), received %d", n, len(args)) 76 | } 77 | return nil 78 | } 79 | } 80 | 81 | // RangeArgs returns an error if the number of args is not within the expected range. 82 | func RangeArgs(min int, max int) PositionalArgs { 83 | return func(cmd *Command, args []string) error { 84 | if len(args) < min || len(args) > max { 85 | return fmt.Errorf("accepts between %d and %d arg(s), received %d", min, max, len(args)) 86 | } 87 | return nil 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /vendor/google.golang.org/appengine/internal/identity_vm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | 7 | package internal 8 | 9 | import ( 10 | "net/http" 11 | "os" 12 | 13 | netcontext "golang.org/x/net/context" 14 | ) 15 | 16 | // These functions are implementations of the wrapper functions 17 | // in ../appengine/identity.go. See that file for commentary. 18 | 19 | const ( 20 | hDefaultVersionHostname = "X-AppEngine-Default-Version-Hostname" 21 | hRequestLogId = "X-AppEngine-Request-Log-Id" 22 | hDatacenter = "X-AppEngine-Datacenter" 23 | ) 24 | 25 | func ctxHeaders(ctx netcontext.Context) http.Header { 26 | return fromContext(ctx).Request().Header 27 | } 28 | 29 | func DefaultVersionHostname(ctx netcontext.Context) string { 30 | return ctxHeaders(ctx).Get(hDefaultVersionHostname) 31 | } 32 | 33 | func RequestID(ctx netcontext.Context) string { 34 | return ctxHeaders(ctx).Get(hRequestLogId) 35 | } 36 | 37 | func Datacenter(ctx netcontext.Context) string { 38 | return ctxHeaders(ctx).Get(hDatacenter) 39 | } 40 | 41 | func ServerSoftware() string { 42 | // TODO(dsymonds): Remove fallback when we've verified this. 43 | if s := os.Getenv("SERVER_SOFTWARE"); s != "" { 44 | return s 45 | } 46 | return "Google App Engine/1.x.x" 47 | } 48 | 49 | // TODO(dsymonds): Remove the metadata fetches. 50 | 51 | func ModuleName(_ netcontext.Context) string { 52 | if s := os.Getenv("GAE_MODULE_NAME"); s != "" { 53 | return s 54 | } 55 | return string(mustGetMetadata("instance/attributes/gae_backend_name")) 56 | } 57 | 58 | func VersionID(_ netcontext.Context) string { 59 | if s1, s2 := os.Getenv("GAE_MODULE_VERSION"), os.Getenv("GAE_MINOR_VERSION"); s1 != "" && s2 != "" { 60 | return s1 + "." + s2 61 | } 62 | return string(mustGetMetadata("instance/attributes/gae_backend_version")) + "." + string(mustGetMetadata("instance/attributes/gae_backend_minor_version")) 63 | } 64 | 65 | func InstanceID() string { 66 | if s := os.Getenv("GAE_MODULE_INSTANCE"); s != "" { 67 | return s 68 | } 69 | return string(mustGetMetadata("instance/attributes/gae_backend_instance")) 70 | } 71 | 72 | func partitionlessAppID() string { 73 | // gae_project has everything except the partition prefix. 74 | appID := os.Getenv("GAE_LONG_APP_ID") 75 | if appID == "" { 76 | appID = string(mustGetMetadata("instance/attributes/gae_project")) 77 | } 78 | return appID 79 | } 80 | 81 | func fullyQualifiedAppID(_ netcontext.Context) string { 82 | appID := partitionlessAppID() 83 | 84 | part := os.Getenv("GAE_PARTITION") 85 | if part == "" { 86 | part = string(mustGetMetadata("instance/attributes/gae_partition")) 87 | } 88 | 89 | if part != "" { 90 | appID = part + "~" + appID 91 | } 92 | return appID 93 | } 94 | 95 | func IsDevAppServer() bool { 96 | return os.Getenv("RUN_WITH_DEVAPPSERVER") != "" 97 | } 98 | -------------------------------------------------------------------------------- /vendor/golang.org/x/oauth2/transport_test.go: -------------------------------------------------------------------------------- 1 | package oauth2 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | "testing" 7 | "time" 8 | ) 9 | 10 | type tokenSource struct{ token *Token } 11 | 12 | func (t *tokenSource) Token() (*Token, error) { 13 | return t.token, nil 14 | } 15 | 16 | func TestTransportNilTokenSource(t *testing.T) { 17 | tr := &Transport{} 18 | server := newMockServer(func(w http.ResponseWriter, r *http.Request) {}) 19 | defer server.Close() 20 | client := &http.Client{Transport: tr} 21 | resp, err := client.Get(server.URL) 22 | if err == nil { 23 | t.Errorf("got no errors, want an error with nil token source") 24 | } 25 | if resp != nil { 26 | t.Errorf("Response = %v; want nil", resp) 27 | } 28 | } 29 | 30 | func TestTransportTokenSource(t *testing.T) { 31 | ts := &tokenSource{ 32 | token: &Token{ 33 | AccessToken: "abc", 34 | }, 35 | } 36 | tr := &Transport{ 37 | Source: ts, 38 | } 39 | server := newMockServer(func(w http.ResponseWriter, r *http.Request) { 40 | if got, want := r.Header.Get("Authorization"), "Bearer abc"; got != want { 41 | t.Errorf("Authorization header = %q; want %q", got, want) 42 | } 43 | }) 44 | defer server.Close() 45 | client := &http.Client{Transport: tr} 46 | res, err := client.Get(server.URL) 47 | if err != nil { 48 | t.Fatal(err) 49 | } 50 | res.Body.Close() 51 | } 52 | 53 | // Test for case-sensitive token types, per https://github.com/golang/oauth2/issues/113 54 | func TestTransportTokenSourceTypes(t *testing.T) { 55 | const val = "abc" 56 | tests := []struct { 57 | key string 58 | val string 59 | want string 60 | }{ 61 | {key: "bearer", val: val, want: "Bearer abc"}, 62 | {key: "mac", val: val, want: "MAC abc"}, 63 | {key: "basic", val: val, want: "Basic abc"}, 64 | } 65 | for _, tc := range tests { 66 | ts := &tokenSource{ 67 | token: &Token{ 68 | AccessToken: tc.val, 69 | TokenType: tc.key, 70 | }, 71 | } 72 | tr := &Transport{ 73 | Source: ts, 74 | } 75 | server := newMockServer(func(w http.ResponseWriter, r *http.Request) { 76 | if got, want := r.Header.Get("Authorization"), tc.want; got != want { 77 | t.Errorf("Authorization header (%q) = %q; want %q", val, got, want) 78 | } 79 | }) 80 | defer server.Close() 81 | client := &http.Client{Transport: tr} 82 | res, err := client.Get(server.URL) 83 | if err != nil { 84 | t.Fatal(err) 85 | } 86 | res.Body.Close() 87 | } 88 | } 89 | 90 | func TestTokenValidNoAccessToken(t *testing.T) { 91 | token := &Token{} 92 | if token.Valid() { 93 | t.Errorf("got valid with no access token; want invalid") 94 | } 95 | } 96 | 97 | func TestExpiredWithExpiry(t *testing.T) { 98 | token := &Token{ 99 | Expiry: time.Now().Add(-5 * time.Hour), 100 | } 101 | if token.Valid() { 102 | t.Errorf("got valid with expired token; want invalid") 103 | } 104 | } 105 | 106 | func newMockServer(handler func(w http.ResponseWriter, r *http.Request)) *httptest.Server { 107 | return httptest.NewServer(http.HandlerFunc(handler)) 108 | } 109 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/int.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import "strconv" 4 | 5 | // -- int Value 6 | type intValue int 7 | 8 | func newIntValue(val int, p *int) *intValue { 9 | *p = val 10 | return (*intValue)(p) 11 | } 12 | 13 | func (i *intValue) Set(s string) error { 14 | v, err := strconv.ParseInt(s, 0, 64) 15 | *i = intValue(v) 16 | return err 17 | } 18 | 19 | func (i *intValue) Type() string { 20 | return "int" 21 | } 22 | 23 | func (i *intValue) String() string { return strconv.Itoa(int(*i)) } 24 | 25 | func intConv(sval string) (interface{}, error) { 26 | return strconv.Atoi(sval) 27 | } 28 | 29 | // GetInt return the int value of a flag with the given name 30 | func (f *FlagSet) GetInt(name string) (int, error) { 31 | val, err := f.getFlagType(name, "int", intConv) 32 | if err != nil { 33 | return 0, err 34 | } 35 | return val.(int), nil 36 | } 37 | 38 | // IntVar defines an int flag with specified name, default value, and usage string. 39 | // The argument p points to an int variable in which to store the value of the flag. 40 | func (f *FlagSet) IntVar(p *int, name string, value int, usage string) { 41 | f.VarP(newIntValue(value, p), name, "", usage) 42 | } 43 | 44 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash. 45 | func (f *FlagSet) IntVarP(p *int, name, shorthand string, value int, usage string) { 46 | f.VarP(newIntValue(value, p), name, shorthand, usage) 47 | } 48 | 49 | // IntVar defines an int flag with specified name, default value, and usage string. 50 | // The argument p points to an int variable in which to store the value of the flag. 51 | func IntVar(p *int, name string, value int, usage string) { 52 | CommandLine.VarP(newIntValue(value, p), name, "", usage) 53 | } 54 | 55 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash. 56 | func IntVarP(p *int, name, shorthand string, value int, usage string) { 57 | CommandLine.VarP(newIntValue(value, p), name, shorthand, usage) 58 | } 59 | 60 | // Int defines an int flag with specified name, default value, and usage string. 61 | // The return value is the address of an int variable that stores the value of the flag. 62 | func (f *FlagSet) Int(name string, value int, usage string) *int { 63 | p := new(int) 64 | f.IntVarP(p, name, "", value, usage) 65 | return p 66 | } 67 | 68 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash. 69 | func (f *FlagSet) IntP(name, shorthand string, value int, usage string) *int { 70 | p := new(int) 71 | f.IntVarP(p, name, shorthand, value, usage) 72 | return p 73 | } 74 | 75 | // Int defines an int flag with specified name, default value, and usage string. 76 | // The return value is the address of an int variable that stores the value of the flag. 77 | func Int(name string, value int, usage string) *int { 78 | return CommandLine.IntP(name, "", value, usage) 79 | } 80 | 81 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash. 82 | func IntP(name, shorthand string, value int, usage string) *int { 83 | return CommandLine.IntP(name, shorthand, value, usage) 84 | } 85 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/go17.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package context 8 | 9 | import ( 10 | "context" // standard library's context, as of Go 1.7 11 | "time" 12 | ) 13 | 14 | var ( 15 | todo = context.TODO() 16 | background = context.Background() 17 | ) 18 | 19 | // Canceled is the error returned by Context.Err when the context is canceled. 20 | var Canceled = context.Canceled 21 | 22 | // DeadlineExceeded is the error returned by Context.Err when the context's 23 | // deadline passes. 24 | var DeadlineExceeded = context.DeadlineExceeded 25 | 26 | // WithCancel returns a copy of parent with a new Done channel. The returned 27 | // context's Done channel is closed when the returned cancel function is called 28 | // or when the parent context's Done channel is closed, whichever happens first. 29 | // 30 | // Canceling this context releases resources associated with it, so code should 31 | // call cancel as soon as the operations running in this Context complete. 32 | func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { 33 | ctx, f := context.WithCancel(parent) 34 | return ctx, CancelFunc(f) 35 | } 36 | 37 | // WithDeadline returns a copy of the parent context with the deadline adjusted 38 | // to be no later than d. If the parent's deadline is already earlier than d, 39 | // WithDeadline(parent, d) is semantically equivalent to parent. The returned 40 | // context's Done channel is closed when the deadline expires, when the returned 41 | // cancel function is called, or when the parent context's Done channel is 42 | // closed, whichever happens first. 43 | // 44 | // Canceling this context releases resources associated with it, so code should 45 | // call cancel as soon as the operations running in this Context complete. 46 | func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { 47 | ctx, f := context.WithDeadline(parent, deadline) 48 | return ctx, CancelFunc(f) 49 | } 50 | 51 | // WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). 52 | // 53 | // Canceling this context releases resources associated with it, so code should 54 | // call cancel as soon as the operations running in this Context complete: 55 | // 56 | // func slowOperationWithTimeout(ctx context.Context) (Result, error) { 57 | // ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) 58 | // defer cancel() // releases resources if slowOperation completes before timeout elapses 59 | // return slowOperation(ctx) 60 | // } 61 | func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { 62 | return WithDeadline(parent, time.Now().Add(timeout)) 63 | } 64 | 65 | // WithValue returns a copy of parent in which the value associated with key is 66 | // val. 67 | // 68 | // Use context Values only for request-scoped data that transits processes and 69 | // APIs, not for passing optional parameters to functions. 70 | func WithValue(parent Context, key interface{}, val interface{}) Context { 71 | return context.WithValue(parent, key, val) 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/golang/protobuf/proto/encode_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | // +build go1.7 33 | 34 | package proto_test 35 | 36 | import ( 37 | "strconv" 38 | "testing" 39 | 40 | "github.com/golang/protobuf/proto" 41 | tpb "github.com/golang/protobuf/proto/proto3_proto" 42 | "github.com/golang/protobuf/ptypes" 43 | ) 44 | 45 | var ( 46 | blackhole []byte 47 | ) 48 | 49 | // BenchmarkAny creates increasingly large arbitrary Any messages. The type is always the 50 | // same. 51 | func BenchmarkAny(b *testing.B) { 52 | data := make([]byte, 1<<20) 53 | quantum := 1 << 10 54 | for i := uint(0); i <= 10; i++ { 55 | b.Run(strconv.Itoa(quantum<