├── .gitignore ├── .travis.yml ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── README.md ├── _tools ├── .gitignore └── src │ ├── github.com │ ├── golang │ │ └── lint │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── golint │ │ │ ├── golint.go │ │ │ └── import.go │ │ │ └── lint.go │ ├── gordonklaus │ │ └── ineffassign │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ └── ineffassign.go │ ├── kisielk │ │ ├── errcheck │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── internal │ │ │ │ └── errcheck │ │ │ │ │ └── errcheck.go │ │ │ └── main.go │ │ └── gotool │ │ │ ├── LEGAL │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── go13.go │ │ │ ├── go14-15.go │ │ │ ├── go16-18.go │ │ │ ├── internal │ │ │ └── load │ │ │ │ ├── path.go │ │ │ │ ├── pkg.go │ │ │ │ └── search.go │ │ │ ├── match.go │ │ │ ├── match18.go │ │ │ └── tool.go │ ├── mitchellh │ │ ├── gox │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── env_override.go │ │ │ ├── go.go │ │ │ ├── main.go │ │ │ ├── main_osarch.go │ │ │ ├── platform.go │ │ │ ├── platform_flag.go │ │ │ └── toolchain.go │ │ └── iochan │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ └── iochan.go │ ├── opennota │ │ └── check │ │ │ └── cmd │ │ │ ├── aligncheck │ │ │ └── aligncheck.go │ │ │ ├── structcheck │ │ │ └── structcheck.go │ │ │ └── varcheck │ │ │ └── varcheck.go │ ├── spenczar │ │ └── go-gh-releaser │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── main.go │ │ │ └── vendor │ │ │ ├── github.com │ │ │ ├── google │ │ │ │ ├── go-github │ │ │ │ │ └── github │ │ │ │ │ │ ├── activity.go │ │ │ │ │ │ ├── activity_events.go │ │ │ │ │ │ ├── activity_notifications.go │ │ │ │ │ │ ├── activity_star.go │ │ │ │ │ │ ├── activity_watching.go │ │ │ │ │ │ ├── admin.go │ │ │ │ │ │ ├── apps.go │ │ │ │ │ │ ├── apps_installation.go │ │ │ │ │ │ ├── authorizations.go │ │ │ │ │ │ ├── doc.go │ │ │ │ │ │ ├── event_types.go │ │ │ │ │ │ ├── gen-accessors.go │ │ │ │ │ │ ├── gists.go │ │ │ │ │ │ ├── gists_comments.go │ │ │ │ │ │ ├── git.go │ │ │ │ │ │ ├── git_blobs.go │ │ │ │ │ │ ├── git_commits.go │ │ │ │ │ │ ├── git_refs.go │ │ │ │ │ │ ├── git_tags.go │ │ │ │ │ │ ├── git_trees.go │ │ │ │ │ │ ├── github-accessors.go │ │ │ │ │ │ ├── github.go │ │ │ │ │ │ ├── gitignore.go │ │ │ │ │ │ ├── issues.go │ │ │ │ │ │ ├── issues_assignees.go │ │ │ │ │ │ ├── issues_comments.go │ │ │ │ │ │ ├── issues_events.go │ │ │ │ │ │ ├── issues_labels.go │ │ │ │ │ │ ├── issues_milestones.go │ │ │ │ │ │ ├── issues_timeline.go │ │ │ │ │ │ ├── licenses.go │ │ │ │ │ │ ├── messages.go │ │ │ │ │ │ ├── migrations.go │ │ │ │ │ │ ├── migrations_source_import.go │ │ │ │ │ │ ├── misc.go │ │ │ │ │ │ ├── orgs.go │ │ │ │ │ │ ├── orgs_hooks.go │ │ │ │ │ │ ├── orgs_members.go │ │ │ │ │ │ ├── orgs_outside_collaborators.go │ │ │ │ │ │ ├── orgs_projects.go │ │ │ │ │ │ ├── orgs_teams.go │ │ │ │ │ │ ├── orgs_users_blocking.go │ │ │ │ │ │ ├── projects.go │ │ │ │ │ │ ├── pulls.go │ │ │ │ │ │ ├── pulls_comments.go │ │ │ │ │ │ ├── pulls_reviewers.go │ │ │ │ │ │ ├── pulls_reviews.go │ │ │ │ │ │ ├── reactions.go │ │ │ │ │ │ ├── repos.go │ │ │ │ │ │ ├── repos_collaborators.go │ │ │ │ │ │ ├── repos_comments.go │ │ │ │ │ │ ├── repos_commits.go │ │ │ │ │ │ ├── repos_community_health.go │ │ │ │ │ │ ├── repos_contents.go │ │ │ │ │ │ ├── repos_deployments.go │ │ │ │ │ │ ├── repos_forks.go │ │ │ │ │ │ ├── repos_hooks.go │ │ │ │ │ │ ├── repos_invitations.go │ │ │ │ │ │ ├── repos_keys.go │ │ │ │ │ │ ├── repos_merging.go │ │ │ │ │ │ ├── repos_pages.go │ │ │ │ │ │ ├── repos_projects.go │ │ │ │ │ │ ├── repos_releases.go │ │ │ │ │ │ ├── repos_stats.go │ │ │ │ │ │ ├── repos_statuses.go │ │ │ │ │ │ ├── repos_traffic.go │ │ │ │ │ │ ├── search.go │ │ │ │ │ │ ├── strings.go │ │ │ │ │ │ ├── timestamp.go │ │ │ │ │ │ ├── users.go │ │ │ │ │ │ ├── users_administration.go │ │ │ │ │ │ ├── users_blocking.go │ │ │ │ │ │ ├── users_emails.go │ │ │ │ │ │ ├── users_followers.go │ │ │ │ │ │ ├── users_gpg_keys.go │ │ │ │ │ │ ├── users_keys.go │ │ │ │ │ │ ├── with_appengine.go │ │ │ │ │ │ └── without_appengine.go │ │ │ │ └── go-querystring │ │ │ │ │ └── query │ │ │ │ │ └── encode.go │ │ │ └── pkg │ │ │ │ └── errors │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── errors.go │ │ │ │ └── stack.go │ │ │ └── golang.org │ │ │ └── x │ │ │ ├── net │ │ │ └── context │ │ │ │ ├── context.go │ │ │ │ ├── ctxhttp │ │ │ │ ├── ctxhttp.go │ │ │ │ └── ctxhttp_pre17.go │ │ │ │ ├── go17.go │ │ │ │ ├── go19.go │ │ │ │ ├── pre_go17.go │ │ │ │ └── pre_go19.go │ │ │ └── oauth2 │ │ │ ├── AUTHORS │ │ │ ├── CONTRIBUTORS │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── client_appengine.go │ │ │ ├── internal │ │ │ ├── oauth2.go │ │ │ ├── token.go │ │ │ └── transport.go │ │ │ ├── oauth2.go │ │ │ ├── token.go │ │ │ └── transport.go │ └── tsenart │ │ └── deadcode │ │ ├── LICENSE │ │ └── deadcode.go │ └── golang.org │ └── x │ └── tools │ └── go │ ├── ast │ └── astutil │ │ ├── enclosing.go │ │ ├── imports.go │ │ └── util.go │ ├── buildutil │ ├── allpackages.go │ ├── fakecontext.go │ ├── overlay.go │ ├── tags.go │ └── util.go │ ├── gcexportdata │ ├── gcexportdata.go │ ├── importer.go │ └── main.go │ ├── gcimporter15 │ ├── bexport.go │ ├── bimport.go │ ├── exportdata.go │ ├── gcimporter.go │ ├── isAlias18.go │ └── isAlias19.go │ └── loader │ ├── cgo.go │ ├── cgo_pkgconfig.go │ ├── doc.go │ ├── loader.go │ └── util.go ├── add.go ├── build.go ├── clean.go ├── clean_test.go ├── do.go ├── input.go ├── main.go ├── manifest.go ├── print.go ├── remove.go ├── retool_nonwindows_test.go ├── retool_test.go ├── retool_windows_test.go ├── spec.go ├── spec_test.go ├── sync.go ├── testdata └── specs │ ├── unversioned.json │ └── v1.2.0.json ├── tool.go ├── tooldir.go ├── tools.json ├── upgrade.go ├── vendor └── github.com │ ├── Masterminds │ └── semver │ │ ├── .travis.yml │ │ ├── CHANGELOG.md │ │ ├── LICENSE.txt │ │ ├── Makefile │ │ ├── README.md │ │ ├── appveyor.yml │ │ ├── collection.go │ │ ├── constraints.go │ │ ├── doc.go │ │ └── version.go │ └── pkg │ └── errors │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── appveyor.yml │ ├── errors.go │ └── stack.go └── version_compatibility_test.go /.gitignore: -------------------------------------------------------------------------------- 1 | *.test 2 | /retool 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go_import_path: github.com/twitchtv/retool 3 | 4 | os: 5 | - linux 6 | - osx 7 | 8 | go: 9 | - 1.9.7 10 | - 1.10.4 11 | - 1.11 12 | - tip 13 | 14 | script: 15 | - go install ./... 16 | - go test -v -race $(go list ./... | grep -v /vendor/) 17 | - go vet $(go list ./... | grep -v /vendor/) 18 | - go tool vet -shadow *.go 19 | 20 | - retool build 21 | - retool do errcheck . 22 | - retool do deadcode . 23 | - retool do varcheck . 24 | - retool do aligncheck . 25 | - retool do structcheck . 26 | - retool do ineffassign . 27 | -------------------------------------------------------------------------------- /Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | name = "github.com/Masterminds/semver" 6 | packages = ["."] 7 | revision = "0a299beba2ae1df55623af7412bd5015ba97f209" 8 | 9 | [[projects]] 10 | name = "github.com/pkg/errors" 11 | packages = ["."] 12 | revision = "839d9e913e063e28dfd0e6c7b7512793e0a48be9" 13 | 14 | [solve-meta] 15 | analyzer-name = "dep" 16 | analyzer-version = 1 17 | inputs-digest = "d149e6a118035d66eb26ac7849f09615131c7db76e41db9d8c2989f594d34595" 18 | solver-name = "gps-cdcl" 19 | solver-version = 1 20 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | # 22 | # [prune] 23 | # non-go = false 24 | # go-tests = true 25 | # unused-packages = true 26 | 27 | 28 | [prune] 29 | go-tests = true 30 | unused-packages = true 31 | -------------------------------------------------------------------------------- /_tools/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /pkg/ 3 | /manifest.json 4 | -------------------------------------------------------------------------------- /_tools/src/github.com/golang/lint/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 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 | -------------------------------------------------------------------------------- /_tools/src/github.com/golang/lint/README.md: -------------------------------------------------------------------------------- 1 | Golint is a linter for Go source code. 2 | 3 | [![Build Status](https://travis-ci.org/golang/lint.svg?branch=master)](https://travis-ci.org/golang/lint) 4 | 5 | ## Installation 6 | 7 | Golint requires Go 1.6 or later. 8 | 9 | go get -u github.com/golang/lint/golint 10 | 11 | ## Usage 12 | 13 | Invoke `golint` with one or more filenames, directories, or packages named 14 | by its import path. Golint uses the same 15 | [import path syntax](https://golang.org/cmd/go/#hdr-Import_path_syntax) as 16 | the `go` command and therefore 17 | also supports relative import paths like `./...`. Additionally the `...` 18 | wildcard can be used as suffix on relative and absolute file paths to recurse 19 | into them. 20 | 21 | The output of this tool is a list of suggestions in Vim quickfix format, 22 | which is accepted by lots of different editors. 23 | 24 | ## Purpose 25 | 26 | Golint differs from gofmt. Gofmt reformats Go source code, whereas 27 | golint prints out style mistakes. 28 | 29 | Golint differs from govet. Govet is concerned with correctness, whereas 30 | golint is concerned with coding style. Golint is in use at Google, and it 31 | seeks to match the accepted style of the open source Go project. 32 | 33 | The suggestions made by golint are exactly that: suggestions. 34 | Golint is not perfect, and has both false positives and false negatives. 35 | Do not treat its output as a gold standard. We will not be adding pragmas 36 | or other knobs to suppress specific warnings, so do not expect or require 37 | code to be completely "lint-free". 38 | In short, this tool is not, and will never be, trustworthy enough for its 39 | suggestions to be enforced automatically, for example as part of a build process. 40 | Golint makes suggestions for many of the mechanically checkable items listed in 41 | [Effective Go](https://golang.org/doc/effective_go.html) and the 42 | [CodeReviewComments wiki page](https://golang.org/wiki/CodeReviewComments). 43 | 44 | If you find an established style that is frequently violated, and which 45 | you think golint could statically check, 46 | [file an issue](https://github.com/golang/lint/issues). 47 | 48 | ## Contributions 49 | 50 | Contributions to this project are welcome, though please send mail before 51 | starting work on anything major. Contributors retain their copyright, so we 52 | need you to fill out 53 | [a short form](https://developers.google.com/open-source/cla/individual) 54 | before we can accept your contribution. 55 | 56 | ## Vim 57 | 58 | Add this to your ~/.vimrc: 59 | 60 | set rtp+=$GOPATH/src/github.com/golang/lint/misc/vim 61 | 62 | If you have multiple entries in your GOPATH, replace `$GOPATH` with the right value. 63 | 64 | Running `:Lint` will run golint on the current file and populate the quickfix list. 65 | 66 | Optionally, add this to your `~/.vimrc` to automatically run `golint` on `:w` 67 | 68 | autocmd BufWritePost,FileWritePost *.go execute 'Lint' | cwindow 69 | 70 | 71 | ## Emacs 72 | 73 | Add this to your `.emacs` file: 74 | 75 | (add-to-list 'load-path (concat (getenv "GOPATH") "/src/github.com/golang/lint/misc/emacs")) 76 | (require 'golint) 77 | 78 | If you have multiple entries in your GOPATH, replace `$GOPATH` with the right value. 79 | 80 | Running M-x golint will run golint on the current file. 81 | 82 | For more usage, see [Compilation-Mode](http://www.gnu.org/software/emacs/manual/html_node/emacs/Compilation-Mode.html). 83 | -------------------------------------------------------------------------------- /_tools/src/github.com/gordonklaus/ineffassign/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Gordon Klaus and contributors 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 | -------------------------------------------------------------------------------- /_tools/src/github.com/gordonklaus/ineffassign/README.md: -------------------------------------------------------------------------------- 1 | # ineffassign 2 | Detect ineffectual assignments in Go code. 3 | -------------------------------------------------------------------------------- /_tools/src/github.com/kisielk/errcheck/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Kamil Kisiel 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /_tools/src/github.com/kisielk/errcheck/README.md: -------------------------------------------------------------------------------- 1 | # errcheck 2 | 3 | errcheck is a program for checking for unchecked errors in go programs. 4 | 5 | [![Build Status](https://travis-ci.org/kisielk/errcheck.png?branch=master)](https://travis-ci.org/kisielk/errcheck) 6 | 7 | ## Install 8 | 9 | go get -u github.com/kisielk/errcheck 10 | 11 | errcheck requires Go 1.6 or newer and depends on the package go/loader from the golang.org/x/tools repository. 12 | 13 | ## Use 14 | 15 | For basic usage, just give the package path of interest as the first argument: 16 | 17 | errcheck github.com/kisielk/errcheck/testdata 18 | 19 | To check all packages beneath the current directory: 20 | 21 | errcheck ./... 22 | 23 | Or check all packages in your $GOPATH and $GOROOT: 24 | 25 | errcheck all 26 | 27 | errcheck also recognizes the following command-line options: 28 | 29 | The `-tags` flag takes a space-separated list of build tags, just like `go 30 | build`. If you are using any custom build tags in your code base, you may need 31 | to specify the relevant tags here. 32 | 33 | The `-asserts` flag enables checking for ignored type assertion results. It 34 | takes no arguments. 35 | 36 | The `-blank` flag enables checking for assignments of errors to the 37 | blank identifier. It takes no arguments. 38 | 39 | 40 | ## Excluding functions 41 | 42 | Use the `-exclude` flag to specify a path to a file containing a list of functions to 43 | be excluded. 44 | 45 | errcheck -exclude errcheck_excludes.txt path/to/package 46 | 47 | The file should contain one function signature per line. The format for function signatures is 48 | `package.FunctionName` while for methods it's `(package.Receiver).MethodName` for value receivers 49 | and `(*package.Receiver).MethodName` for pointer receivers. 50 | 51 | An example of an exclude file is: 52 | 53 | io/ioutil.ReadFile 54 | (*net/http.Client).Do 55 | 56 | The exclude list is combined with an internal list for functions in the Go standard library that 57 | have an error return type but are documented to never return an error. 58 | 59 | 60 | ### The deprecated method 61 | 62 | The `-ignore` flag takes a comma-separated list of pairs of the form package:regex. 63 | For each package, the regex describes which functions to ignore within that package. 64 | The package may be omitted to have the regex apply to all packages. 65 | 66 | For example, you may wish to ignore common operations like Read and Write: 67 | 68 | errcheck -ignore '[rR]ead|[wW]rite' path/to/package 69 | 70 | or you may wish to ignore common functions like the `print` variants in `fmt`: 71 | 72 | errcheck -ignore 'fmt:[FS]?[Pp]rint*' path/to/package 73 | 74 | The `-ignorepkg` flag takes a comma-separated list of package import paths 75 | to ignore: 76 | 77 | errcheck -ignorepkg 'fmt,encoding/binary' path/to/package 78 | 79 | Note that this is equivalent to: 80 | 81 | errcheck -ignore 'fmt:.*,encoding/binary:.*' path/to/package 82 | 83 | If a regex is provided for a package `pkg` via `-ignore`, and `pkg` also appears 84 | in the list of packages passed to `-ignorepkg`, the latter takes precedence; 85 | that is, all functions within `pkg` will be ignored. 86 | 87 | Note that by default the `fmt` package is ignored entirely, unless a regex is 88 | specified for it. To disable this, specify a regex that matches nothing: 89 | 90 | errcheck -ignore 'fmt:a^' path/to/package 91 | 92 | The `-ignoretests` flag disables checking of `_test.go` files. It takes 93 | no arguments. 94 | 95 | ## Cgo 96 | 97 | Currently errcheck is unable to check packages that `import "C"` due to limitations 98 | in the importer. 99 | 100 | However, you can use errcheck on packages that depend on those which use cgo. In 101 | order for this to work you need to `go install` the cgo dependencies before running 102 | errcheck on the dependant packages. 103 | 104 | See https://github.com/kisielk/errcheck/issues/16 for more details. 105 | 106 | ## Exit Codes 107 | 108 | errcheck returns 1 if any problems were found in the checked files. 109 | It returns 2 if there were any other failures. 110 | 111 | # Editor Integration 112 | 113 | ## Emacs 114 | 115 | [go-errcheck.el](https://github.com/dominikh/go-errcheck.el) 116 | integrates errcheck with Emacs by providing a `go-errcheck` command 117 | and customizable variables to automatically pass flags to errcheck. 118 | 119 | ## Vim 120 | 121 | [vim-go](https://github.com/fatih/vim-go) can run errcheck via both its `:GoErrCheck` 122 | and `:GoMetaLinter` commands. 123 | -------------------------------------------------------------------------------- /_tools/src/github.com/kisielk/gotool/LEGAL: -------------------------------------------------------------------------------- 1 | All the files in this distribution are covered under either the MIT 2 | license (see the file LICENSE) except some files mentioned below. 3 | 4 | match.go, match_test.go: 5 | 6 | Copyright (c) 2009 The Go Authors. All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above 15 | copyright notice, this list of conditions and the following disclaimer 16 | in the documentation and/or other materials provided with the 17 | distribution. 18 | * Neither the name of Google Inc. nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /_tools/src/github.com/kisielk/gotool/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Kamil Kisiel 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 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /_tools/src/github.com/kisielk/gotool/README.md: -------------------------------------------------------------------------------- 1 | gotool 2 | ====== 3 | [![GoDoc](https://godoc.org/github.com/kisielk/gotool?status.svg)](https://godoc.org/github.com/kisielk/gotool) 4 | [![Build Status](https://travis-ci.org/kisielk/gotool.svg?branch=master)](https://travis-ci.org/kisielk/gotool) 5 | 6 | Package gotool contains utility functions used to implement the standard "cmd/go" tool, provided as a convenience to developers who want to write tools with similar semantics. 7 | -------------------------------------------------------------------------------- /_tools/src/github.com/kisielk/gotool/go13.go: -------------------------------------------------------------------------------- 1 | // +build !go1.4 2 | 3 | package gotool 4 | 5 | import ( 6 | "go/build" 7 | "path/filepath" 8 | "runtime" 9 | ) 10 | 11 | var gorootSrc = filepath.Join(runtime.GOROOT(), "src", "pkg") 12 | 13 | func shouldIgnoreImport(p *build.Package) bool { 14 | return true 15 | } 16 | -------------------------------------------------------------------------------- /_tools/src/github.com/kisielk/gotool/go14-15.go: -------------------------------------------------------------------------------- 1 | // +build go1.4,!go1.6 2 | 3 | package gotool 4 | 5 | import ( 6 | "go/build" 7 | "path/filepath" 8 | "runtime" 9 | ) 10 | 11 | var gorootSrc = filepath.Join(runtime.GOROOT(), "src") 12 | 13 | func shouldIgnoreImport(p *build.Package) bool { 14 | return true 15 | } 16 | -------------------------------------------------------------------------------- /_tools/src/github.com/kisielk/gotool/go16-18.go: -------------------------------------------------------------------------------- 1 | // +build go1.6,!go1.9 2 | 3 | package gotool 4 | 5 | import ( 6 | "go/build" 7 | "path/filepath" 8 | "runtime" 9 | ) 10 | 11 | var gorootSrc = filepath.Join(runtime.GOROOT(), "src") 12 | 13 | func shouldIgnoreImport(p *build.Package) bool { 14 | return p == nil || len(p.InvalidGoFiles) == 0 15 | } 16 | -------------------------------------------------------------------------------- /_tools/src/github.com/kisielk/gotool/internal/load/path.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 load 8 | 9 | import ( 10 | "strings" 11 | ) 12 | 13 | // hasPathPrefix reports whether the path s begins with the 14 | // elements in prefix. 15 | func hasPathPrefix(s, prefix string) bool { 16 | switch { 17 | default: 18 | return false 19 | case len(s) == len(prefix): 20 | return s == prefix 21 | case len(s) > len(prefix): 22 | if prefix != "" && prefix[len(prefix)-1] == '/' { 23 | return strings.HasPrefix(s, prefix) 24 | } 25 | return s[len(prefix)] == '/' && s[:len(prefix)] == prefix 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /_tools/src/github.com/kisielk/gotool/internal/load/pkg.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.9 6 | 7 | // Package load loads packages. 8 | package load 9 | 10 | import ( 11 | "strings" 12 | ) 13 | 14 | // isStandardImportPath reports whether $GOROOT/src/path should be considered 15 | // part of the standard distribution. For historical reasons we allow people to add 16 | // their own code to $GOROOT instead of using $GOPATH, but we assume that 17 | // code will start with a domain name (dot in the first element). 18 | func isStandardImportPath(path string) bool { 19 | i := strings.Index(path, "/") 20 | if i < 0 { 21 | i = len(path) 22 | } 23 | elem := path[:i] 24 | return !strings.Contains(elem, ".") 25 | } 26 | -------------------------------------------------------------------------------- /_tools/src/github.com/kisielk/gotool/match.go: -------------------------------------------------------------------------------- 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 | 29 | // +build go1.9 30 | 31 | package gotool 32 | 33 | import ( 34 | "path/filepath" 35 | 36 | "github.com/kisielk/gotool/internal/load" 37 | ) 38 | 39 | // importPaths returns the import paths to use for the given command line. 40 | func (c *Context) importPaths(args []string) []string { 41 | lctx := load.Context{ 42 | BuildContext: c.BuildContext, 43 | GOROOTsrc: c.joinPath(c.BuildContext.GOROOT, "src"), 44 | } 45 | return lctx.ImportPaths(args) 46 | } 47 | 48 | // joinPath calls c.BuildContext.JoinPath (if not nil) or else filepath.Join. 49 | // 50 | // It's a copy of the unexported build.Context.joinPath helper. 51 | func (c *Context) joinPath(elem ...string) string { 52 | if f := c.BuildContext.JoinPath; f != nil { 53 | return f(elem...) 54 | } 55 | return filepath.Join(elem...) 56 | } 57 | -------------------------------------------------------------------------------- /_tools/src/github.com/kisielk/gotool/tool.go: -------------------------------------------------------------------------------- 1 | // Package gotool contains utility functions used to implement the standard 2 | // "cmd/go" tool, provided as a convenience to developers who want to write 3 | // tools with similar semantics. 4 | package gotool 5 | 6 | import "go/build" 7 | 8 | // Export functions here to make it easier to keep the implementations up to date with upstream. 9 | 10 | // DefaultContext is the default context that uses build.Default. 11 | var DefaultContext = Context{ 12 | BuildContext: build.Default, 13 | } 14 | 15 | // A Context specifies the supporting context. 16 | type Context struct { 17 | // BuildContext is the build.Context that is used when computing import paths. 18 | BuildContext build.Context 19 | } 20 | 21 | // ImportPaths returns the import paths to use for the given command line. 22 | // 23 | // The path "all" is expanded to all packages in $GOPATH and $GOROOT. 24 | // The path "std" is expanded to all packages in the Go standard library. 25 | // The path "cmd" is expanded to all Go standard commands. 26 | // The string "..." is treated as a wildcard within a path. 27 | // When matching recursively, directories are ignored if they are prefixed with 28 | // a dot or an underscore (such as ".foo" or "_foo"), or are named "testdata". 29 | // Relative import paths are not converted to full import paths. 30 | // If args is empty, a single element "." is returned. 31 | func (c *Context) ImportPaths(args []string) []string { 32 | return c.importPaths(args) 33 | } 34 | 35 | // ImportPaths returns the import paths to use for the given command line 36 | // using default context. 37 | // 38 | // The path "all" is expanded to all packages in $GOPATH and $GOROOT. 39 | // The path "std" is expanded to all packages in the Go standard library. 40 | // The path "cmd" is expanded to all Go standard commands. 41 | // The string "..." is treated as a wildcard within a path. 42 | // When matching recursively, directories are ignored if they are prefixed with 43 | // a dot or an underscore (such as ".foo" or "_foo"), or are named "testdata". 44 | // Relative import paths are not converted to full import paths. 45 | // If args is empty, a single element "." is returned. 46 | func ImportPaths(args []string) []string { 47 | return DefaultContext.importPaths(args) 48 | } 49 | -------------------------------------------------------------------------------- /_tools/src/github.com/mitchellh/gox/README.md: -------------------------------------------------------------------------------- 1 | # Gox - Simple Go Cross Compilation 2 | 3 | Gox is a simple, no-frills tool for Go cross compilation that behaves a 4 | lot like standard `go build`. Gox will parallelize builds for multiple 5 | platforms. Gox will also build the cross-compilation toolchain for you. 6 | 7 | ## Installation 8 | 9 | To install Gox, please use `go get`. We tag versions so feel free to 10 | checkout that tag and compile. 11 | 12 | ``` 13 | $ go get github.com/mitchellh/gox 14 | ... 15 | $ gox -h 16 | ... 17 | ``` 18 | 19 | ## Usage 20 | 21 | If you know how to use `go build`, then you know how to use Gox. For 22 | example, to build the current package, specify no parameters and just 23 | call `gox`. Gox will parallelize based on the number of CPUs you have 24 | by default and build for every platform by default: 25 | 26 | ``` 27 | $ gox 28 | Number of parallel builds: 4 29 | 30 | --> darwin/386: github.com/mitchellh/gox 31 | --> darwin/amd64: github.com/mitchellh/gox 32 | --> linux/386: github.com/mitchellh/gox 33 | --> linux/amd64: github.com/mitchellh/gox 34 | --> linux/arm: github.com/mitchellh/gox 35 | --> freebsd/386: github.com/mitchellh/gox 36 | --> freebsd/amd64: github.com/mitchellh/gox 37 | --> openbsd/386: github.com/mitchellh/gox 38 | --> openbsd/amd64: github.com/mitchellh/gox 39 | --> windows/386: github.com/mitchellh/gox 40 | --> windows/amd64: github.com/mitchellh/gox 41 | --> freebsd/arm: github.com/mitchellh/gox 42 | --> netbsd/386: github.com/mitchellh/gox 43 | --> netbsd/amd64: github.com/mitchellh/gox 44 | --> netbsd/arm: github.com/mitchellh/gox 45 | --> plan9/386: github.com/mitchellh/gox 46 | ``` 47 | 48 | Or, if you want to build a package and sub-packages: 49 | 50 | ``` 51 | $ gox ./... 52 | ... 53 | ``` 54 | 55 | Or, if you want to build multiple distinct packages: 56 | 57 | ``` 58 | $ gox github.com/mitchellh/gox github.com/hashicorp/serf 59 | ... 60 | ``` 61 | 62 | Or if you want to just build for linux: 63 | 64 | ``` 65 | $ gox -os="linux" 66 | ... 67 | ``` 68 | 69 | Or maybe you just want to build for 64-bit linux: 70 | 71 | ``` 72 | $ gox -osarch="linux/amd64" 73 | ... 74 | ``` 75 | 76 | And more! Just run `gox -h` for help and additional information. 77 | 78 | ## Versus Other Cross-Compile Tools 79 | 80 | A big thanks to these other options for existing. They each paved the 81 | way in many aspects to make Go cross-compilation approachable. 82 | 83 | * [Dave Cheney's golang-crosscompile](https://github.com/davecheney/golang-crosscompile) - 84 | Gox compiles for multiple platforms and can therefore easily run on 85 | any platform Go supports, whereas Dave's scripts require a shell. Gox 86 | will also parallelize builds. Dave's scripts build sequentially. Gox has 87 | much easier to use OS/Arch filtering built in. 88 | 89 | * [goxc](https://github.com/laher/goxc) - 90 | A very richly featured tool that can even do things such as build system 91 | packages, upload binaries, generate download webpages, etc. Gox is a 92 | super slim alternative that only cross-compiles binaries. Gox builds packages in parallel, whereas 93 | goxc doesn't. Gox doesn't enforce a specific output structure for built 94 | binaries. 95 | 96 | -------------------------------------------------------------------------------- /_tools/src/github.com/mitchellh/gox/env_override.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "strings" 7 | ) 8 | 9 | // envOverride overrides the given target based on if there is a 10 | // env var in the format of GOX_{OS}_{ARCH}_{KEY}. 11 | func envOverride(target *string, platform Platform, key string) { 12 | key = strings.ToUpper(fmt.Sprintf( 13 | "GOX_%s_%s_%s", platform.OS, platform.Arch, key)) 14 | if v := os.Getenv(key); v != "" { 15 | *target = v 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /_tools/src/github.com/mitchellh/gox/main_osarch.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func mainListOSArch(version string) int { 8 | fmt.Printf( 9 | "Supported OS/Arch combinations for %s are shown below. The \"default\"\n"+ 10 | "boolean means that if you don't specify an OS/Arch, it will be\n"+ 11 | "included by default. If it isn't a default OS/Arch, you must explicitly\n"+ 12 | "specify that OS/Arch combo for Gox to use it.\n\n", 13 | version) 14 | for _, p := range SupportedPlatforms(version) { 15 | fmt.Printf("%s\t(default: %v)\n", p.String(), p.Default) 16 | } 17 | 18 | return 0 19 | } 20 | -------------------------------------------------------------------------------- /_tools/src/github.com/mitchellh/gox/platform.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // Platform is a combination of OS/arch that can be built against. 9 | type Platform struct { 10 | OS string 11 | Arch string 12 | 13 | // Default, if true, will be included as a default build target 14 | // if no OS/arch is specified. We try to only set as a default popular 15 | // targets or targets that are generally useful. For example, Android 16 | // is not a default because it is quite rare that you're cross-compiling 17 | // something to Android AND something like Linux. 18 | Default bool 19 | } 20 | 21 | func (p *Platform) String() string { 22 | return fmt.Sprintf("%s/%s", p.OS, p.Arch) 23 | } 24 | 25 | var ( 26 | OsList = []string{ 27 | "darwin", 28 | "dragonfly", 29 | "freebsd", 30 | "linux", 31 | "netbsd", 32 | "openbsd", 33 | "plan9", 34 | "solaris", 35 | "windows", 36 | } 37 | 38 | ArchList = []string{ 39 | "386", 40 | "amd64", 41 | "arm", 42 | "arm64", 43 | "ppc64", 44 | "ppc64le", 45 | } 46 | 47 | Platforms_1_0 = []Platform{ 48 | {"darwin", "386", true}, 49 | {"darwin", "amd64", true}, 50 | {"linux", "386", true}, 51 | {"linux", "amd64", true}, 52 | {"linux", "arm", true}, 53 | {"freebsd", "386", true}, 54 | {"freebsd", "amd64", true}, 55 | {"openbsd", "386", true}, 56 | {"openbsd", "amd64", true}, 57 | {"windows", "386", true}, 58 | {"windows", "amd64", true}, 59 | } 60 | 61 | Platforms_1_1 = append(Platforms_1_0, []Platform{ 62 | {"freebsd", "arm", true}, 63 | {"netbsd", "386", true}, 64 | {"netbsd", "amd64", true}, 65 | {"netbsd", "arm", true}, 66 | {"plan9", "386", false}, 67 | }...) 68 | 69 | Platforms_1_3 = append(Platforms_1_1, []Platform{ 70 | {"dragonfly", "386", false}, 71 | {"dragonfly", "amd64", false}, 72 | {"nacl", "amd64", false}, 73 | {"nacl", "amd64p32", false}, 74 | {"nacl", "arm", false}, 75 | {"solaris", "amd64", false}, 76 | }...) 77 | 78 | Platforms_1_4 = append(Platforms_1_3, []Platform{ 79 | {"android", "arm", false}, 80 | {"plan9", "amd64", false}, 81 | }...) 82 | 83 | Platforms_1_5 = append(Platforms_1_4, []Platform{ 84 | {"darwin", "arm", false}, 85 | {"darwin", "arm64", false}, 86 | {"linux", "arm64", false}, 87 | {"linux", "ppc64", false}, 88 | {"linux", "ppc64le", false}, 89 | }...) 90 | ) 91 | 92 | // SupportedPlatforms returns the full list of supported platforms for 93 | // the version of Go that is 94 | func SupportedPlatforms(v string) []Platform { 95 | if strings.HasPrefix(v, "go1.0") { 96 | return Platforms_1_0 97 | } else if strings.HasPrefix(v, "go1.1") { 98 | return Platforms_1_1 99 | } else if strings.HasPrefix(v, "go1.3") { 100 | return Platforms_1_3 101 | } else if strings.HasPrefix(v, "go1.4") { 102 | return Platforms_1_4 103 | } else if strings.HasPrefix(v, "go1.5") { 104 | return Platforms_1_5 105 | } 106 | 107 | // Assume latest 108 | return Platforms_1_5 109 | } 110 | -------------------------------------------------------------------------------- /_tools/src/github.com/mitchellh/iochan/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 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 | -------------------------------------------------------------------------------- /_tools/src/github.com/mitchellh/iochan/README.md: -------------------------------------------------------------------------------- 1 | # iochan 2 | 3 | iochan is a Go library for treating `io` readers and writers like channels. 4 | This is useful when sometimes you wish to use `io.Reader` and such in `select` 5 | statements. 6 | 7 | ## Installation 8 | 9 | Standard `go get`: 10 | 11 | ``` 12 | $ go get github.com/mitchellh/iochan 13 | ``` 14 | -------------------------------------------------------------------------------- /_tools/src/github.com/mitchellh/iochan/iochan.go: -------------------------------------------------------------------------------- 1 | package iochan 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | ) 7 | 8 | // DelimReader takes an io.Reader and produces the contents of the reader 9 | // on the returned channel. The contents on the channel will be returned 10 | // on boundaries specified by the delim parameter, and will include this 11 | // delimiter. 12 | // 13 | // If an error occurs while reading from the reader, the reading will end. 14 | // 15 | // In the case of an EOF or error, the channel will be closed. 16 | // 17 | // This must only be called once for any individual reader. The behavior is 18 | // unknown and will be unexpected if this is called multiple times with the 19 | // same reader. 20 | func DelimReader(r io.Reader, delim byte) <-chan string { 21 | ch := make(chan string) 22 | 23 | go func() { 24 | buf := bufio.NewReader(r) 25 | 26 | for { 27 | line, err := buf.ReadString(delim) 28 | if line != "" { 29 | ch <- line 30 | } 31 | 32 | if err != nil { 33 | break 34 | } 35 | } 36 | 37 | close(ch) 38 | }() 39 | 40 | return ch 41 | } 42 | -------------------------------------------------------------------------------- /_tools/src/github.com/opennota/check/cmd/aligncheck/aligncheck.go: -------------------------------------------------------------------------------- 1 | // This program is free software: you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation, either version 3 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program. If not, see . 13 | 14 | package main 15 | 16 | import ( 17 | "flag" 18 | "fmt" 19 | "go/build" 20 | "log" 21 | "os" 22 | "sort" 23 | "unsafe" 24 | 25 | "github.com/kisielk/gotool" 26 | "golang.org/x/tools/go/loader" 27 | "go/types" 28 | ) 29 | 30 | var stdSizes = types.StdSizes{ 31 | WordSize: int64(unsafe.Sizeof(int(0))), 32 | MaxAlign: 8, 33 | } 34 | 35 | func main() { 36 | flag.Parse() 37 | exitStatus := 0 38 | 39 | importPaths := gotool.ImportPaths(flag.Args()) 40 | if len(importPaths) == 0 { 41 | importPaths = []string{"."} 42 | } 43 | 44 | ctx := build.Default 45 | loadcfg := loader.Config{ 46 | Build: &ctx, 47 | } 48 | rest, err := loadcfg.FromArgs(importPaths, false) 49 | if err != nil { 50 | log.Fatalf("could not parse arguments: %s", err) 51 | } 52 | if len(rest) > 0 { 53 | log.Fatalf("unhandled extra arguments: %v", rest) 54 | } 55 | 56 | program, err := loadcfg.Load() 57 | if err != nil { 58 | log.Fatalf("could not type check: %s", err) 59 | } 60 | 61 | var lines []string 62 | 63 | for _, pkgInfo := range program.InitialPackages() { 64 | for _, obj := range pkgInfo.Defs { 65 | if obj == nil { 66 | continue 67 | } 68 | 69 | if _, ok := obj.(*types.TypeName); !ok { 70 | continue 71 | } 72 | 73 | typ, ok := obj.Type().(*types.Named) 74 | if !ok { 75 | continue 76 | } 77 | 78 | strukt, ok := typ.Underlying().(*types.Struct) 79 | if !ok { 80 | continue 81 | } 82 | 83 | structAlign := int(stdSizes.Alignof(strukt)) 84 | structSize := int(stdSizes.Sizeof(strukt)) 85 | if structSize%structAlign != 0 { 86 | structSize += structAlign - structSize%structAlign 87 | } 88 | 89 | minSize := 0 90 | for i := 0; i < strukt.NumFields(); i++ { 91 | field := strukt.Field(i) 92 | fieldType := field.Type() 93 | typeSize := int(stdSizes.Sizeof(fieldType)) 94 | minSize += typeSize 95 | } 96 | if minSize%structAlign != 0 { 97 | minSize += structAlign - minSize%structAlign 98 | } 99 | 100 | if minSize != structSize { 101 | pos := program.Fset.Position(obj.Pos()) 102 | lines = append(lines, fmt.Sprintf( 103 | "%s: %s:%d:%d: struct %s could have size %d (currently %d)", 104 | obj.Pkg().Path(), 105 | pos.Filename, 106 | pos.Line, 107 | pos.Column, 108 | obj.Name(), 109 | minSize, 110 | structSize, 111 | )) 112 | exitStatus = 1 113 | } 114 | } 115 | } 116 | 117 | sort.Strings(lines) 118 | for _, line := range lines { 119 | fmt.Println(line) 120 | } 121 | 122 | os.Exit(exitStatus) 123 | } 124 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/README.md: -------------------------------------------------------------------------------- 1 | # go-gh-releaser # 2 | 3 | This is a little utility for cross-compiling and releasing Go projects with 4 | github releases. It cross-compiles a project using 5 | [gox](https://github.com/mitchellh/gox) and then uploads the resulting bins to 6 | the right release. Auth is handled with a personal access token. 7 | 8 | ## Installation ## 9 | 10 | ``` 11 | go get github.com/mitchellh/gox 12 | go get github.com/spenczar/go-gh-releaser 13 | ``` 14 | 15 | ## Usage ## 16 | Use it thusly, subsitituting your real github access token: 17 | 18 | ``` 19 | go-gh-releaser -release -repo -token 20 | ``` 21 | 22 | For example: 23 | ``` 24 | go-gh-releaser -release v1.3.5 -repo twitchtv/retool -token dc------------------------------------84 25 | ``` 26 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/activity.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import "context" 9 | 10 | // ActivityService handles communication with the activity related 11 | // methods of the GitHub API. 12 | // 13 | // GitHub API docs: https://developer.github.com/v3/activity/ 14 | type ActivityService service 15 | 16 | // FeedLink represents a link to a related resource. 17 | type FeedLink struct { 18 | HRef *string `json:"href,omitempty"` 19 | Type *string `json:"type,omitempty"` 20 | } 21 | 22 | // Feeds represents timeline resources in Atom format. 23 | type Feeds struct { 24 | TimelineURL *string `json:"timeline_url,omitempty"` 25 | UserURL *string `json:"user_url,omitempty"` 26 | CurrentUserPublicURL *string `json:"current_user_public_url,omitempty"` 27 | CurrentUserURL *string `json:"current_user_url,omitempty"` 28 | CurrentUserActorURL *string `json:"current_user_actor_url,omitempty"` 29 | CurrentUserOrganizationURL *string `json:"current_user_organization_url,omitempty"` 30 | CurrentUserOrganizationURLs []string `json:"current_user_organization_urls,omitempty"` 31 | Links *struct { 32 | Timeline *FeedLink `json:"timeline,omitempty"` 33 | User *FeedLink `json:"user,omitempty"` 34 | CurrentUserPublic *FeedLink `json:"current_user_public,omitempty"` 35 | CurrentUser *FeedLink `json:"current_user,omitempty"` 36 | CurrentUserActor *FeedLink `json:"current_user_actor,omitempty"` 37 | CurrentUserOrganization *FeedLink `json:"current_user_organization,omitempty"` 38 | CurrentUserOrganizations []FeedLink `json:"current_user_organizations,omitempty"` 39 | } `json:"_links,omitempty"` 40 | } 41 | 42 | // ListFeeds lists all the feeds available to the authenticated user. 43 | // 44 | // GitHub provides several timeline resources in Atom format: 45 | // Timeline: The GitHub global public timeline 46 | // User: The public timeline for any user, using URI template 47 | // Current user public: The public timeline for the authenticated user 48 | // Current user: The private timeline for the authenticated user 49 | // Current user actor: The private timeline for activity created by the 50 | // authenticated user 51 | // Current user organizations: The private timeline for the organizations 52 | // the authenticated user is a member of. 53 | // 54 | // Note: Private feeds are only returned when authenticating via Basic Auth 55 | // since current feed URIs use the older, non revocable auth tokens. 56 | func (s *ActivityService) ListFeeds(ctx context.Context) (*Feeds, *Response, error) { 57 | req, err := s.client.NewRequest("GET", "feeds", nil) 58 | if err != nil { 59 | return nil, nil, err 60 | } 61 | 62 | f := &Feeds{} 63 | resp, err := s.client.Do(ctx, req, f) 64 | if err != nil { 65 | return nil, resp, err 66 | } 67 | 68 | return f, resp, nil 69 | } 70 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/admin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // AdminService handles communication with the admin related methods of the 14 | // GitHub API. These API routes are normally only accessible for GitHub 15 | // Enterprise installations. 16 | // 17 | // GitHub API docs: https://developer.github.com/v3/enterprise/ 18 | type AdminService service 19 | 20 | // TeamLDAPMapping represents the mapping between a GitHub team and an LDAP group. 21 | type TeamLDAPMapping struct { 22 | ID *int `json:"id,omitempty"` 23 | LDAPDN *string `json:"ldap_dn,omitempty"` 24 | URL *string `json:"url,omitempty"` 25 | Name *string `json:"name,omitempty"` 26 | Slug *string `json:"slug,omitempty"` 27 | Description *string `json:"description,omitempty"` 28 | Privacy *string `json:"privacy,omitempty"` 29 | Permission *string `json:"permission,omitempty"` 30 | 31 | MembersURL *string `json:"members_url,omitempty"` 32 | RepositoriesURL *string `json:"repositories_url,omitempty"` 33 | } 34 | 35 | func (m TeamLDAPMapping) String() string { 36 | return Stringify(m) 37 | } 38 | 39 | // UserLDAPMapping represents the mapping between a GitHub user and an LDAP user. 40 | type UserLDAPMapping struct { 41 | ID *int `json:"id,omitempty"` 42 | LDAPDN *string `json:"ldap_dn,omitempty"` 43 | Login *string `json:"login,omitempty"` 44 | AvatarURL *string `json:"avatar_url,omitempty"` 45 | GravatarID *string `json:"gravatar_id,omitempty"` 46 | Type *string `json:"type,omitempty"` 47 | SiteAdmin *bool `json:"site_admin,omitempty"` 48 | 49 | URL *string `json:"url,omitempty"` 50 | EventsURL *string `json:"events_url,omitempty"` 51 | FollowingURL *string `json:"following_url,omitempty"` 52 | FollowersURL *string `json:"followers_url,omitempty"` 53 | GistsURL *string `json:"gists_url,omitempty"` 54 | OrganizationsURL *string `json:"organizations_url,omitempty"` 55 | ReceivedEventsURL *string `json:"received_events_url,omitempty"` 56 | ReposURL *string `json:"repos_url,omitempty"` 57 | StarredURL *string `json:"starred_url,omitempty"` 58 | SubscriptionsURL *string `json:"subscriptions_url,omitempty"` 59 | } 60 | 61 | func (m UserLDAPMapping) String() string { 62 | return Stringify(m) 63 | } 64 | 65 | // UpdateUserLDAPMapping updates the mapping between a GitHub user and an LDAP user. 66 | // 67 | // GitHub API docs: https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-user 68 | func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, mapping *UserLDAPMapping) (*UserLDAPMapping, *Response, error) { 69 | u := fmt.Sprintf("admin/ldap/users/%v/mapping", user) 70 | req, err := s.client.NewRequest("PATCH", u, mapping) 71 | if err != nil { 72 | return nil, nil, err 73 | } 74 | 75 | m := new(UserLDAPMapping) 76 | resp, err := s.client.Do(ctx, req, m) 77 | if err != nil { 78 | return nil, resp, err 79 | } 80 | 81 | return m, resp, nil 82 | } 83 | 84 | // UpdateTeamLDAPMapping updates the mapping between a GitHub team and an LDAP group. 85 | // 86 | // GitHub API docs: https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-team 87 | func (s *AdminService) UpdateTeamLDAPMapping(ctx context.Context, team int, mapping *TeamLDAPMapping) (*TeamLDAPMapping, *Response, error) { 88 | u := fmt.Sprintf("admin/ldap/teams/%v/mapping", team) 89 | req, err := s.client.NewRequest("PATCH", u, mapping) 90 | if err != nil { 91 | return nil, nil, err 92 | } 93 | 94 | m := new(TeamLDAPMapping) 95 | resp, err := s.client.Do(ctx, req, m) 96 | if err != nil { 97 | return nil, resp, err 98 | } 99 | 100 | return m, resp, nil 101 | } 102 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/apps.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import "context" 9 | 10 | // AppsService provides access to the installation related functions 11 | // in the GitHub API. 12 | // 13 | // GitHub API docs: https://developer.github.com/v3/apps/ 14 | type AppsService service 15 | 16 | // ListInstallations lists the installations that the current GitHub App has. 17 | // 18 | // GitHub API docs: https://developer.github.com/v3/apps/#find-installations 19 | func (s *AppsService) ListInstallations(ctx context.Context, opt *ListOptions) ([]*Installation, *Response, error) { 20 | u, err := addOptions("app/installations", opt) 21 | if err != nil { 22 | return nil, nil, err 23 | } 24 | 25 | req, err := s.client.NewRequest("GET", u, nil) 26 | if err != nil { 27 | return nil, nil, err 28 | } 29 | 30 | // TODO: remove custom Accept header when this API fully launches. 31 | req.Header.Set("Accept", mediaTypeIntegrationPreview) 32 | 33 | var i []*Installation 34 | resp, err := s.client.Do(ctx, req, &i) 35 | if err != nil { 36 | return nil, resp, err 37 | } 38 | 39 | return i, resp, nil 40 | } 41 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/apps_installation.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import "context" 9 | 10 | // Installation represents a GitHub Apps installation. 11 | type Installation struct { 12 | ID *int `json:"id,omitempty"` 13 | Account *User `json:"account,omitempty"` 14 | AccessTokensURL *string `json:"access_tokens_url,omitempty"` 15 | RepositoriesURL *string `json:"repositories_url,omitempty"` 16 | HTMLURL *string `json:"html_url,omitempty"` 17 | } 18 | 19 | func (i Installation) String() string { 20 | return Stringify(i) 21 | } 22 | 23 | // ListRepos lists the repositories that are accessible to the authenticated installation. 24 | // 25 | // GitHub API docs: https://developer.github.com/v3/apps/installations/#list-repositories 26 | func (s *AppsService) ListRepos(ctx context.Context, opt *ListOptions) ([]*Repository, *Response, error) { 27 | u, err := addOptions("installation/repositories", opt) 28 | if err != nil { 29 | return nil, nil, err 30 | } 31 | 32 | req, err := s.client.NewRequest("GET", u, nil) 33 | if err != nil { 34 | return nil, nil, err 35 | } 36 | 37 | // TODO: remove custom Accept header when this API fully launches. 38 | req.Header.Set("Accept", mediaTypeIntegrationPreview) 39 | 40 | var r struct { 41 | Repositories []*Repository `json:"repositories"` 42 | } 43 | resp, err := s.client.Do(ctx, req, &r) 44 | if err != nil { 45 | return nil, resp, err 46 | } 47 | 48 | return r.Repositories, resp, nil 49 | } 50 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/gists_comments.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | "time" 12 | ) 13 | 14 | // GistComment represents a Gist comment. 15 | type GistComment struct { 16 | ID *int `json:"id,omitempty"` 17 | URL *string `json:"url,omitempty"` 18 | Body *string `json:"body,omitempty"` 19 | User *User `json:"user,omitempty"` 20 | CreatedAt *time.Time `json:"created_at,omitempty"` 21 | } 22 | 23 | func (g GistComment) String() string { 24 | return Stringify(g) 25 | } 26 | 27 | // ListComments lists all comments for a gist. 28 | // 29 | // GitHub API docs: https://developer.github.com/v3/gists/comments/#list-comments-on-a-gist 30 | func (s *GistsService) ListComments(ctx context.Context, gistID string, opt *ListOptions) ([]*GistComment, *Response, error) { 31 | u := fmt.Sprintf("gists/%v/comments", gistID) 32 | u, err := addOptions(u, opt) 33 | if err != nil { 34 | return nil, nil, err 35 | } 36 | 37 | req, err := s.client.NewRequest("GET", u, nil) 38 | if err != nil { 39 | return nil, nil, err 40 | } 41 | 42 | var comments []*GistComment 43 | resp, err := s.client.Do(ctx, req, &comments) 44 | if err != nil { 45 | return nil, resp, err 46 | } 47 | 48 | return comments, resp, nil 49 | } 50 | 51 | // GetComment retrieves a single comment from a gist. 52 | // 53 | // GitHub API docs: https://developer.github.com/v3/gists/comments/#get-a-single-comment 54 | func (s *GistsService) GetComment(ctx context.Context, gistID string, commentID int) (*GistComment, *Response, error) { 55 | u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID) 56 | req, err := s.client.NewRequest("GET", u, nil) 57 | if err != nil { 58 | return nil, nil, err 59 | } 60 | 61 | c := new(GistComment) 62 | resp, err := s.client.Do(ctx, req, c) 63 | if err != nil { 64 | return nil, resp, err 65 | } 66 | 67 | return c, resp, nil 68 | } 69 | 70 | // CreateComment creates a comment for a gist. 71 | // 72 | // GitHub API docs: https://developer.github.com/v3/gists/comments/#create-a-comment 73 | func (s *GistsService) CreateComment(ctx context.Context, gistID string, comment *GistComment) (*GistComment, *Response, error) { 74 | u := fmt.Sprintf("gists/%v/comments", gistID) 75 | req, err := s.client.NewRequest("POST", u, comment) 76 | if err != nil { 77 | return nil, nil, err 78 | } 79 | 80 | c := new(GistComment) 81 | resp, err := s.client.Do(ctx, req, c) 82 | if err != nil { 83 | return nil, resp, err 84 | } 85 | 86 | return c, resp, nil 87 | } 88 | 89 | // EditComment edits an existing gist comment. 90 | // 91 | // GitHub API docs: https://developer.github.com/v3/gists/comments/#edit-a-comment 92 | func (s *GistsService) EditComment(ctx context.Context, gistID string, commentID int, comment *GistComment) (*GistComment, *Response, error) { 93 | u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID) 94 | req, err := s.client.NewRequest("PATCH", u, comment) 95 | if err != nil { 96 | return nil, nil, err 97 | } 98 | 99 | c := new(GistComment) 100 | resp, err := s.client.Do(ctx, req, c) 101 | if err != nil { 102 | return nil, resp, err 103 | } 104 | 105 | return c, resp, nil 106 | } 107 | 108 | // DeleteComment deletes a gist comment. 109 | // 110 | // GitHub API docs: https://developer.github.com/v3/gists/comments/#delete-a-comment 111 | func (s *GistsService) DeleteComment(ctx context.Context, gistID string, commentID int) (*Response, error) { 112 | u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID) 113 | req, err := s.client.NewRequest("DELETE", u, nil) 114 | if err != nil { 115 | return nil, err 116 | } 117 | 118 | return s.client.Do(ctx, req, nil) 119 | } 120 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/git.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | // GitService handles communication with the git data related 9 | // methods of the GitHub API. 10 | // 11 | // GitHub API docs: https://developer.github.com/v3/git/ 12 | type GitService service 13 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/git_blobs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // Blob represents a blob object. 14 | type Blob struct { 15 | Content *string `json:"content,omitempty"` 16 | Encoding *string `json:"encoding,omitempty"` 17 | SHA *string `json:"sha,omitempty"` 18 | Size *int `json:"size,omitempty"` 19 | URL *string `json:"url,omitempty"` 20 | } 21 | 22 | // GetBlob fetchs a blob from a repo given a SHA. 23 | // 24 | // GitHub API docs: https://developer.github.com/v3/git/blobs/#get-a-blob 25 | func (s *GitService) GetBlob(ctx context.Context, owner string, repo string, sha string) (*Blob, *Response, error) { 26 | u := fmt.Sprintf("repos/%v/%v/git/blobs/%v", owner, repo, sha) 27 | req, err := s.client.NewRequest("GET", u, nil) 28 | if err != nil { 29 | return nil, nil, err 30 | } 31 | 32 | blob := new(Blob) 33 | resp, err := s.client.Do(ctx, req, blob) 34 | return blob, resp, err 35 | } 36 | 37 | // CreateBlob creates a blob object. 38 | // 39 | // GitHub API docs: https://developer.github.com/v3/git/blobs/#create-a-blob 40 | func (s *GitService) CreateBlob(ctx context.Context, owner string, repo string, blob *Blob) (*Blob, *Response, error) { 41 | u := fmt.Sprintf("repos/%v/%v/git/blobs", owner, repo) 42 | req, err := s.client.NewRequest("POST", u, blob) 43 | if err != nil { 44 | return nil, nil, err 45 | } 46 | 47 | t := new(Blob) 48 | resp, err := s.client.Do(ctx, req, t) 49 | return t, resp, err 50 | } 51 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/git_tags.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // Tag represents a tag object. 14 | type Tag struct { 15 | Tag *string `json:"tag,omitempty"` 16 | SHA *string `json:"sha,omitempty"` 17 | URL *string `json:"url,omitempty"` 18 | Message *string `json:"message,omitempty"` 19 | Tagger *CommitAuthor `json:"tagger,omitempty"` 20 | Object *GitObject `json:"object,omitempty"` 21 | Verification *SignatureVerification `json:"verification,omitempty"` 22 | } 23 | 24 | // createTagRequest represents the body of a CreateTag request. This is mostly 25 | // identical to Tag with the exception that the object SHA and Type are 26 | // top-level fields, rather than being nested inside a JSON object. 27 | type createTagRequest struct { 28 | Tag *string `json:"tag,omitempty"` 29 | Message *string `json:"message,omitempty"` 30 | Object *string `json:"object,omitempty"` 31 | Type *string `json:"type,omitempty"` 32 | Tagger *CommitAuthor `json:"tagger,omitempty"` 33 | } 34 | 35 | // GetTag fetchs a tag from a repo given a SHA. 36 | // 37 | // GitHub API docs: https://developer.github.com/v3/git/tags/#get-a-tag 38 | func (s *GitService) GetTag(ctx context.Context, owner string, repo string, sha string) (*Tag, *Response, error) { 39 | u := fmt.Sprintf("repos/%v/%v/git/tags/%v", owner, repo, sha) 40 | req, err := s.client.NewRequest("GET", u, nil) 41 | if err != nil { 42 | return nil, nil, err 43 | } 44 | 45 | // TODO: remove custom Accept header when this API fully launches. 46 | req.Header.Set("Accept", mediaTypeGitSigningPreview) 47 | 48 | tag := new(Tag) 49 | resp, err := s.client.Do(ctx, req, tag) 50 | return tag, resp, err 51 | } 52 | 53 | // CreateTag creates a tag object. 54 | // 55 | // GitHub API docs: https://developer.github.com/v3/git/tags/#create-a-tag-object 56 | func (s *GitService) CreateTag(ctx context.Context, owner string, repo string, tag *Tag) (*Tag, *Response, error) { 57 | u := fmt.Sprintf("repos/%v/%v/git/tags", owner, repo) 58 | 59 | // convert Tag into a createTagRequest 60 | tagRequest := &createTagRequest{ 61 | Tag: tag.Tag, 62 | Message: tag.Message, 63 | Tagger: tag.Tagger, 64 | } 65 | if tag.Object != nil { 66 | tagRequest.Object = tag.Object.SHA 67 | tagRequest.Type = tag.Object.Type 68 | } 69 | 70 | req, err := s.client.NewRequest("POST", u, tagRequest) 71 | if err != nil { 72 | return nil, nil, err 73 | } 74 | 75 | t := new(Tag) 76 | resp, err := s.client.Do(ctx, req, t) 77 | return t, resp, err 78 | } 79 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/git_trees.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // Tree represents a GitHub tree. 14 | type Tree struct { 15 | SHA *string `json:"sha,omitempty"` 16 | Entries []TreeEntry `json:"tree,omitempty"` 17 | } 18 | 19 | func (t Tree) String() string { 20 | return Stringify(t) 21 | } 22 | 23 | // TreeEntry represents the contents of a tree structure. TreeEntry can 24 | // represent either a blob, a commit (in the case of a submodule), or another 25 | // tree. 26 | type TreeEntry struct { 27 | SHA *string `json:"sha,omitempty"` 28 | Path *string `json:"path,omitempty"` 29 | Mode *string `json:"mode,omitempty"` 30 | Type *string `json:"type,omitempty"` 31 | Size *int `json:"size,omitempty"` 32 | Content *string `json:"content,omitempty"` 33 | URL *string `json:"url,omitempty"` 34 | } 35 | 36 | func (t TreeEntry) String() string { 37 | return Stringify(t) 38 | } 39 | 40 | // GetTree fetches the Tree object for a given sha hash from a repository. 41 | // 42 | // GitHub API docs: https://developer.github.com/v3/git/trees/#get-a-tree 43 | func (s *GitService) GetTree(ctx context.Context, owner string, repo string, sha string, recursive bool) (*Tree, *Response, error) { 44 | u := fmt.Sprintf("repos/%v/%v/git/trees/%v", owner, repo, sha) 45 | if recursive { 46 | u += "?recursive=1" 47 | } 48 | 49 | req, err := s.client.NewRequest("GET", u, nil) 50 | if err != nil { 51 | return nil, nil, err 52 | } 53 | 54 | t := new(Tree) 55 | resp, err := s.client.Do(ctx, req, t) 56 | if err != nil { 57 | return nil, resp, err 58 | } 59 | 60 | return t, resp, nil 61 | } 62 | 63 | // createTree represents the body of a CreateTree request. 64 | type createTree struct { 65 | BaseTree string `json:"base_tree,omitempty"` 66 | Entries []TreeEntry `json:"tree"` 67 | } 68 | 69 | // CreateTree creates a new tree in a repository. If both a tree and a nested 70 | // path modifying that tree are specified, it will overwrite the contents of 71 | // that tree with the new path contents and write a new tree out. 72 | // 73 | // GitHub API docs: https://developer.github.com/v3/git/trees/#create-a-tree 74 | func (s *GitService) CreateTree(ctx context.Context, owner string, repo string, baseTree string, entries []TreeEntry) (*Tree, *Response, error) { 75 | u := fmt.Sprintf("repos/%v/%v/git/trees", owner, repo) 76 | 77 | body := &createTree{ 78 | BaseTree: baseTree, 79 | Entries: entries, 80 | } 81 | req, err := s.client.NewRequest("POST", u, body) 82 | if err != nil { 83 | return nil, nil, err 84 | } 85 | 86 | t := new(Tree) 87 | resp, err := s.client.Do(ctx, req, t) 88 | if err != nil { 89 | return nil, resp, err 90 | } 91 | 92 | return t, resp, nil 93 | } 94 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/gitignore.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // GitignoresService provides access to the gitignore related functions in the 14 | // GitHub API. 15 | // 16 | // GitHub API docs: https://developer.github.com/v3/gitignore/ 17 | type GitignoresService service 18 | 19 | // Gitignore represents a .gitignore file as returned by the GitHub API. 20 | type Gitignore struct { 21 | Name *string `json:"name,omitempty"` 22 | Source *string `json:"source,omitempty"` 23 | } 24 | 25 | func (g Gitignore) String() string { 26 | return Stringify(g) 27 | } 28 | 29 | // List all available Gitignore templates. 30 | // 31 | // GitHub API docs: https://developer.github.com/v3/gitignore/#listing-available-templates 32 | func (s GitignoresService) List(ctx context.Context) ([]string, *Response, error) { 33 | req, err := s.client.NewRequest("GET", "gitignore/templates", nil) 34 | if err != nil { 35 | return nil, nil, err 36 | } 37 | 38 | var availableTemplates []string 39 | resp, err := s.client.Do(ctx, req, &availableTemplates) 40 | if err != nil { 41 | return nil, resp, err 42 | } 43 | 44 | return availableTemplates, resp, nil 45 | } 46 | 47 | // Get a Gitignore by name. 48 | // 49 | // GitHub API docs: https://developer.github.com/v3/gitignore/#get-a-single-template 50 | func (s GitignoresService) Get(ctx context.Context, name string) (*Gitignore, *Response, error) { 51 | u := fmt.Sprintf("gitignore/templates/%v", name) 52 | req, err := s.client.NewRequest("GET", u, nil) 53 | if err != nil { 54 | return nil, nil, err 55 | } 56 | 57 | gitignore := new(Gitignore) 58 | resp, err := s.client.Do(ctx, req, gitignore) 59 | if err != nil { 60 | return nil, resp, err 61 | } 62 | 63 | return gitignore, resp, nil 64 | } 65 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/issues_assignees.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ListAssignees fetches all available assignees (owners and collaborators) to 14 | // which issues may be assigned. 15 | // 16 | // GitHub API docs: https://developer.github.com/v3/issues/assignees/#list-assignees 17 | func (s *IssuesService) ListAssignees(ctx context.Context, owner, repo string, opt *ListOptions) ([]*User, *Response, error) { 18 | u := fmt.Sprintf("repos/%v/%v/assignees", owner, repo) 19 | u, err := addOptions(u, opt) 20 | if err != nil { 21 | return nil, nil, err 22 | } 23 | 24 | req, err := s.client.NewRequest("GET", u, nil) 25 | if err != nil { 26 | return nil, nil, err 27 | } 28 | var assignees []*User 29 | resp, err := s.client.Do(ctx, req, &assignees) 30 | if err != nil { 31 | return nil, resp, err 32 | } 33 | 34 | return assignees, resp, nil 35 | } 36 | 37 | // IsAssignee checks if a user is an assignee for the specified repository. 38 | // 39 | // GitHub API docs: https://developer.github.com/v3/issues/assignees/#check-assignee 40 | func (s *IssuesService) IsAssignee(ctx context.Context, owner, repo, user string) (bool, *Response, error) { 41 | u := fmt.Sprintf("repos/%v/%v/assignees/%v", owner, repo, user) 42 | req, err := s.client.NewRequest("GET", u, nil) 43 | if err != nil { 44 | return false, nil, err 45 | } 46 | resp, err := s.client.Do(ctx, req, nil) 47 | assignee, err := parseBoolResponse(err) 48 | return assignee, resp, err 49 | } 50 | 51 | // AddAssignees adds the provided GitHub users as assignees to the issue. 52 | // 53 | // GitHub API docs: https://developer.github.com/v3/issues/assignees/#add-assignees-to-an-issue 54 | func (s *IssuesService) AddAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) { 55 | users := &struct { 56 | Assignees []string `json:"assignees,omitempty"` 57 | }{Assignees: assignees} 58 | u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number) 59 | req, err := s.client.NewRequest("POST", u, users) 60 | if err != nil { 61 | return nil, nil, err 62 | } 63 | 64 | issue := &Issue{} 65 | resp, err := s.client.Do(ctx, req, issue) 66 | return issue, resp, err 67 | } 68 | 69 | // RemoveAssignees removes the provided GitHub users as assignees from the issue. 70 | // 71 | // GitHub API docs: https://developer.github.com/v3/issues/assignees/#remove-assignees-from-an-issue 72 | func (s *IssuesService) RemoveAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) { 73 | users := &struct { 74 | Assignees []string `json:"assignees,omitempty"` 75 | }{Assignees: assignees} 76 | u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number) 77 | req, err := s.client.NewRequest("DELETE", u, users) 78 | if err != nil { 79 | return nil, nil, err 80 | } 81 | 82 | issue := &Issue{} 83 | resp, err := s.client.Do(ctx, req, issue) 84 | return issue, resp, err 85 | } 86 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/licenses.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // LicensesService handles communication with the license related 14 | // methods of the GitHub API. 15 | // 16 | // GitHub API docs: https://developer.github.com/v3/licenses/ 17 | type LicensesService service 18 | 19 | // RepositoryLicense represents the license for a repository. 20 | type RepositoryLicense struct { 21 | Name *string `json:"name,omitempty"` 22 | Path *string `json:"path,omitempty"` 23 | 24 | SHA *string `json:"sha,omitempty"` 25 | Size *int `json:"size,omitempty"` 26 | URL *string `json:"url,omitempty"` 27 | HTMLURL *string `json:"html_url,omitempty"` 28 | GitURL *string `json:"git_url,omitempty"` 29 | DownloadURL *string `json:"download_url,omitempty"` 30 | Type *string `json:"type,omitempty"` 31 | Content *string `json:"content,omitempty"` 32 | Encoding *string `json:"encoding,omitempty"` 33 | License *License `json:"license,omitempty"` 34 | } 35 | 36 | func (l RepositoryLicense) String() string { 37 | return Stringify(l) 38 | } 39 | 40 | // License represents an open source license. 41 | type License struct { 42 | Key *string `json:"key,omitempty"` 43 | Name *string `json:"name,omitempty"` 44 | URL *string `json:"url,omitempty"` 45 | 46 | SPDXID *string `json:"spdx_id,omitempty"` 47 | HTMLURL *string `json:"html_url,omitempty"` 48 | Featured *bool `json:"featured,omitempty"` 49 | Description *string `json:"description,omitempty"` 50 | Implementation *string `json:"implementation,omitempty"` 51 | Permissions *[]string `json:"permissions,omitempty"` 52 | Conditions *[]string `json:"conditions,omitempty"` 53 | Limitations *[]string `json:"limitations,omitempty"` 54 | Body *string `json:"body,omitempty"` 55 | } 56 | 57 | func (l License) String() string { 58 | return Stringify(l) 59 | } 60 | 61 | // List popular open source licenses. 62 | // 63 | // GitHub API docs: https://developer.github.com/v3/licenses/#list-all-licenses 64 | func (s *LicensesService) List(ctx context.Context) ([]*License, *Response, error) { 65 | req, err := s.client.NewRequest("GET", "licenses", nil) 66 | if err != nil { 67 | return nil, nil, err 68 | } 69 | 70 | // TODO: remove custom Accept header when this API fully launches 71 | req.Header.Set("Accept", mediaTypeLicensesPreview) 72 | 73 | var licenses []*License 74 | resp, err := s.client.Do(ctx, req, &licenses) 75 | if err != nil { 76 | return nil, resp, err 77 | } 78 | 79 | return licenses, resp, nil 80 | } 81 | 82 | // Get extended metadata for one license. 83 | // 84 | // GitHub API docs: https://developer.github.com/v3/licenses/#get-an-individual-license 85 | func (s *LicensesService) Get(ctx context.Context, licenseName string) (*License, *Response, error) { 86 | u := fmt.Sprintf("licenses/%s", licenseName) 87 | 88 | req, err := s.client.NewRequest("GET", u, nil) 89 | if err != nil { 90 | return nil, nil, err 91 | } 92 | 93 | // TODO: remove custom Accept header when this API fully launches 94 | req.Header.Set("Accept", mediaTypeLicensesPreview) 95 | 96 | license := new(License) 97 | resp, err := s.client.Do(ctx, req, license) 98 | if err != nil { 99 | return nil, resp, err 100 | } 101 | 102 | return license, resp, nil 103 | } 104 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/orgs_hooks.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ListHooks lists all Hooks for the specified organization. 14 | // 15 | // GitHub API docs: https://developer.github.com/v3/orgs/hooks/#list-hooks 16 | func (s *OrganizationsService) ListHooks(ctx context.Context, org string, opt *ListOptions) ([]*Hook, *Response, error) { 17 | u := fmt.Sprintf("orgs/%v/hooks", org) 18 | u, err := addOptions(u, opt) 19 | if err != nil { 20 | return nil, nil, err 21 | } 22 | 23 | req, err := s.client.NewRequest("GET", u, nil) 24 | if err != nil { 25 | return nil, nil, err 26 | } 27 | 28 | var hooks []*Hook 29 | resp, err := s.client.Do(ctx, req, &hooks) 30 | if err != nil { 31 | return nil, resp, err 32 | } 33 | 34 | return hooks, resp, nil 35 | } 36 | 37 | // GetHook returns a single specified Hook. 38 | // 39 | // GitHub API docs: https://developer.github.com/v3/orgs/hooks/#get-single-hook 40 | func (s *OrganizationsService) GetHook(ctx context.Context, org string, id int) (*Hook, *Response, error) { 41 | u := fmt.Sprintf("orgs/%v/hooks/%d", org, id) 42 | req, err := s.client.NewRequest("GET", u, nil) 43 | if err != nil { 44 | return nil, nil, err 45 | } 46 | hook := new(Hook) 47 | resp, err := s.client.Do(ctx, req, hook) 48 | return hook, resp, err 49 | } 50 | 51 | // CreateHook creates a Hook for the specified org. 52 | // Name and Config are required fields. 53 | // 54 | // GitHub API docs: https://developer.github.com/v3/orgs/hooks/#create-a-hook 55 | func (s *OrganizationsService) CreateHook(ctx context.Context, org string, hook *Hook) (*Hook, *Response, error) { 56 | u := fmt.Sprintf("orgs/%v/hooks", org) 57 | req, err := s.client.NewRequest("POST", u, hook) 58 | if err != nil { 59 | return nil, nil, err 60 | } 61 | 62 | h := new(Hook) 63 | resp, err := s.client.Do(ctx, req, h) 64 | if err != nil { 65 | return nil, resp, err 66 | } 67 | 68 | return h, resp, nil 69 | } 70 | 71 | // EditHook updates a specified Hook. 72 | // 73 | // GitHub API docs: https://developer.github.com/v3/orgs/hooks/#edit-a-hook 74 | func (s *OrganizationsService) EditHook(ctx context.Context, org string, id int, hook *Hook) (*Hook, *Response, error) { 75 | u := fmt.Sprintf("orgs/%v/hooks/%d", org, id) 76 | req, err := s.client.NewRequest("PATCH", u, hook) 77 | if err != nil { 78 | return nil, nil, err 79 | } 80 | h := new(Hook) 81 | resp, err := s.client.Do(ctx, req, h) 82 | return h, resp, err 83 | } 84 | 85 | // PingHook triggers a 'ping' event to be sent to the Hook. 86 | // 87 | // GitHub API docs: https://developer.github.com/v3/orgs/hooks/#ping-a-hook 88 | func (s *OrganizationsService) PingHook(ctx context.Context, org string, id int) (*Response, error) { 89 | u := fmt.Sprintf("orgs/%v/hooks/%d/pings", org, id) 90 | req, err := s.client.NewRequest("POST", u, nil) 91 | if err != nil { 92 | return nil, err 93 | } 94 | return s.client.Do(ctx, req, nil) 95 | } 96 | 97 | // DeleteHook deletes a specified Hook. 98 | // 99 | // GitHub API docs: https://developer.github.com/v3/orgs/hooks/#delete-a-hook 100 | func (s *OrganizationsService) DeleteHook(ctx context.Context, org string, id int) (*Response, error) { 101 | u := fmt.Sprintf("orgs/%v/hooks/%d", org, id) 102 | req, err := s.client.NewRequest("DELETE", u, nil) 103 | if err != nil { 104 | return nil, err 105 | } 106 | return s.client.Do(ctx, req, nil) 107 | } 108 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/orgs_outside_collaborators.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ListOutsideCollaboratorsOptions specifies optional parameters to the 14 | // OrganizationsService.ListOutsideCollaborators method. 15 | type ListOutsideCollaboratorsOptions struct { 16 | // Filter outside collaborators returned in the list. Possible values are: 17 | // 2fa_disabled, all. Default is "all". 18 | Filter string `url:"filter,omitempty"` 19 | 20 | ListOptions 21 | } 22 | 23 | // ListOutsideCollaborators lists outside collaborators of organization's repositories. 24 | // This will only work if the authenticated 25 | // user is an owner of the organization. 26 | // 27 | // Warning: The API may change without advance notice during the preview period. 28 | // Preview features are not supported for production use. 29 | // 30 | // GitHub API docs: https://developer.github.com/v3/orgs/outside_collaborators/#list-outside-collaborators 31 | func (s *OrganizationsService) ListOutsideCollaborators(ctx context.Context, org string, opt *ListOutsideCollaboratorsOptions) ([]*User, *Response, error) { 32 | u := fmt.Sprintf("orgs/%v/outside_collaborators", org) 33 | u, err := addOptions(u, opt) 34 | if err != nil { 35 | return nil, nil, err 36 | } 37 | 38 | req, err := s.client.NewRequest("GET", u, nil) 39 | if err != nil { 40 | return nil, nil, err 41 | } 42 | 43 | var members []*User 44 | resp, err := s.client.Do(ctx, req, &members) 45 | if err != nil { 46 | return nil, resp, err 47 | } 48 | 49 | return members, resp, nil 50 | } 51 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/orgs_projects.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ListProjects lists the projects for an organization. 14 | // 15 | // GitHub API docs: https://developer.github.com/v3/projects/#list-organization-projects 16 | func (s *OrganizationsService) ListProjects(ctx context.Context, org string, opt *ProjectListOptions) ([]*Project, *Response, error) { 17 | u := fmt.Sprintf("orgs/%v/projects", org) 18 | u, err := addOptions(u, opt) 19 | if err != nil { 20 | return nil, nil, err 21 | } 22 | 23 | req, err := s.client.NewRequest("GET", u, nil) 24 | if err != nil { 25 | return nil, nil, err 26 | } 27 | 28 | // TODO: remove custom Accept header when this API fully launches. 29 | req.Header.Set("Accept", mediaTypeProjectsPreview) 30 | 31 | var projects []*Project 32 | resp, err := s.client.Do(ctx, req, &projects) 33 | if err != nil { 34 | return nil, resp, err 35 | } 36 | 37 | return projects, resp, nil 38 | } 39 | 40 | // CreateProject creates a GitHub Project for the specified organization. 41 | // 42 | // GitHub API docs: https://developer.github.com/v3/projects/#create-an-organization-project 43 | func (s *OrganizationsService) CreateProject(ctx context.Context, org string, opt *ProjectOptions) (*Project, *Response, error) { 44 | u := fmt.Sprintf("orgs/%v/projects", org) 45 | req, err := s.client.NewRequest("POST", u, opt) 46 | if err != nil { 47 | return nil, nil, err 48 | } 49 | 50 | // TODO: remove custom Accept header when this API fully launches. 51 | req.Header.Set("Accept", mediaTypeProjectsPreview) 52 | 53 | project := &Project{} 54 | resp, err := s.client.Do(ctx, req, project) 55 | if err != nil { 56 | return nil, resp, err 57 | } 58 | 59 | return project, resp, nil 60 | } 61 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/orgs_users_blocking.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ListBlockedUsers lists all the users blocked by an organization. 14 | // 15 | // GitHub API docs: https://developer.github.com/v3/orgs/blocking/#list-blocked-users 16 | func (s *OrganizationsService) ListBlockedUsers(ctx context.Context, org string, opt *ListOptions) ([]*User, *Response, error) { 17 | u := fmt.Sprintf("orgs/%v/blocks", org) 18 | u, err := addOptions(u, opt) 19 | if err != nil { 20 | return nil, nil, err 21 | } 22 | 23 | req, err := s.client.NewRequest("GET", u, nil) 24 | if err != nil { 25 | return nil, nil, err 26 | } 27 | 28 | // TODO: remove custom Accept header when this API fully launches. 29 | req.Header.Set("Accept", mediaTypeBlockUsersPreview) 30 | 31 | var blockedUsers []*User 32 | resp, err := s.client.Do(ctx, req, &blockedUsers) 33 | if err != nil { 34 | return nil, resp, err 35 | } 36 | 37 | return blockedUsers, resp, nil 38 | } 39 | 40 | // IsBlocked reports whether specified user is blocked from an organization. 41 | // 42 | // GitHub API docs: https://developer.github.com/v3/orgs/blocking/#check-whether-a-user-is-blocked-from-an-organization 43 | func (s *OrganizationsService) IsBlocked(ctx context.Context, org string, user string) (bool, *Response, error) { 44 | u := fmt.Sprintf("orgs/%v/blocks/%v", org, user) 45 | 46 | req, err := s.client.NewRequest("GET", u, nil) 47 | if err != nil { 48 | return false, nil, err 49 | } 50 | 51 | // TODO: remove custom Accept header when this API fully launches. 52 | req.Header.Set("Accept", mediaTypeBlockUsersPreview) 53 | 54 | resp, err := s.client.Do(ctx, req, nil) 55 | isBlocked, err := parseBoolResponse(err) 56 | return isBlocked, resp, err 57 | } 58 | 59 | // BlockUser blocks specified user from an organization. 60 | // 61 | // GitHub API docs: https://developer.github.com/v3/orgs/blocking/#block-a-user 62 | func (s *OrganizationsService) BlockUser(ctx context.Context, org string, user string) (*Response, error) { 63 | u := fmt.Sprintf("orgs/%v/blocks/%v", org, user) 64 | 65 | req, err := s.client.NewRequest("PUT", u, nil) 66 | if err != nil { 67 | return nil, err 68 | } 69 | 70 | // TODO: remove custom Accept header when this API fully launches. 71 | req.Header.Set("Accept", mediaTypeBlockUsersPreview) 72 | 73 | return s.client.Do(ctx, req, nil) 74 | } 75 | 76 | // UnblockUser unblocks specified user from an organization. 77 | // 78 | // GitHub API docs: https://developer.github.com/v3/orgs/blocking/#unblock-a-user 79 | func (s *OrganizationsService) UnblockUser(ctx context.Context, org string, user string) (*Response, error) { 80 | u := fmt.Sprintf("orgs/%v/blocks/%v", org, user) 81 | 82 | req, err := s.client.NewRequest("DELETE", u, nil) 83 | if err != nil { 84 | return nil, err 85 | } 86 | 87 | // TODO: remove custom Accept header when this API fully launches. 88 | req.Header.Set("Accept", mediaTypeBlockUsersPreview) 89 | 90 | return s.client.Do(ctx, req, nil) 91 | } 92 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/pulls_reviewers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ReviewersRequest specifies users and teams for a pull request review request. 14 | type ReviewersRequest struct { 15 | Reviewers []string `json:"reviewers,omitempty"` 16 | TeamReviewers []string `json:"team_reviewers,omitempty"` 17 | } 18 | 19 | // Reviewers represents reviewers of a pull request. 20 | type Reviewers struct { 21 | Users []*User `json:"users,omitempty"` 22 | Teams []*Team `json:"teams,omitempty"` 23 | } 24 | 25 | // RequestReviewers creates a review request for the provided reviewers for the specified pull request. 26 | // 27 | // GitHub API docs: https://developer.github.com/v3/pulls/review_requests/#create-a-review-request 28 | func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo string, number int, reviewers ReviewersRequest) (*PullRequest, *Response, error) { 29 | u := fmt.Sprintf("repos/%s/%s/pulls/%d/requested_reviewers", owner, repo, number) 30 | req, err := s.client.NewRequest("POST", u, &reviewers) 31 | if err != nil { 32 | return nil, nil, err 33 | } 34 | 35 | // TODO: remove custom Accept header when this API fully launches. 36 | req.Header.Set("Accept", mediaTypeTeamReviewPreview) 37 | 38 | r := new(PullRequest) 39 | resp, err := s.client.Do(ctx, req, r) 40 | if err != nil { 41 | return nil, resp, err 42 | } 43 | 44 | return r, resp, nil 45 | } 46 | 47 | // ListReviewers lists reviewers whose reviews have been requested on the specified pull request. 48 | // 49 | // GitHub API docs: https://developer.github.com/v3/pulls/review_requests/#list-review-requests 50 | func (s *PullRequestsService) ListReviewers(ctx context.Context, owner, repo string, number int, opt *ListOptions) (*Reviewers, *Response, error) { 51 | u := fmt.Sprintf("repos/%v/%v/pulls/%d/requested_reviewers", owner, repo, number) 52 | u, err := addOptions(u, opt) 53 | if err != nil { 54 | return nil, nil, err 55 | } 56 | 57 | req, err := s.client.NewRequest("GET", u, nil) 58 | if err != nil { 59 | return nil, nil, err 60 | } 61 | 62 | // TODO: remove custom Accept header when this API fully launches. 63 | req.Header.Set("Accept", mediaTypeTeamReviewPreview) 64 | 65 | reviewers := new(Reviewers) 66 | resp, err := s.client.Do(ctx, req, reviewers) 67 | if err != nil { 68 | return nil, resp, err 69 | } 70 | 71 | return reviewers, resp, nil 72 | } 73 | 74 | // RemoveReviewers removes the review request for the provided reviewers for the specified pull request. 75 | // 76 | // GitHub API docs: https://developer.github.com/v3/pulls/review_requests/#delete-a-review-request 77 | func (s *PullRequestsService) RemoveReviewers(ctx context.Context, owner, repo string, number int, reviewers ReviewersRequest) (*Response, error) { 78 | u := fmt.Sprintf("repos/%s/%s/pulls/%d/requested_reviewers", owner, repo, number) 79 | req, err := s.client.NewRequest("DELETE", u, &reviewers) 80 | if err != nil { 81 | return nil, err 82 | } 83 | 84 | // TODO: remove custom Accept header when this API fully launches. 85 | req.Header.Set("Accept", mediaTypeTeamReviewPreview) 86 | 87 | return s.client.Do(ctx, req, reviewers) 88 | } 89 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/repos_community_health.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | "time" 12 | ) 13 | 14 | // Metric represents the different fields for one file in community health files. 15 | type Metric struct { 16 | Name *string `json:"name"` 17 | Key *string `json:"key"` 18 | URL *string `json:"url"` 19 | HTMLURL *string `json:"html_url"` 20 | } 21 | 22 | // CommunityHealthFiles represents the different files in the community health metrics response. 23 | type CommunityHealthFiles struct { 24 | CodeOfConduct *Metric `json:"code_of_conduct"` 25 | Contributing *Metric `json:"contributing"` 26 | License *Metric `json:"license"` 27 | Readme *Metric `json:"readme"` 28 | } 29 | 30 | // CommunityHealthMetrics represents a response containing the community metrics of a repository. 31 | type CommunityHealthMetrics struct { 32 | HealthPercentage *int `json:"health_percentage"` 33 | Files *CommunityHealthFiles `json:"files"` 34 | UpdatedAt *time.Time `json:"updated_at"` 35 | } 36 | 37 | // GetCommunityHealthMetrics retrieves all the community health metrics for a repository. 38 | // 39 | // GitHub API docs: https://developer.github.com/v3/repos/community/#retrieve-community-health-metrics 40 | func (s *RepositoriesService) GetCommunityHealthMetrics(ctx context.Context, owner, repo string) (*CommunityHealthMetrics, *Response, error) { 41 | u := fmt.Sprintf("repos/%v/%v/community/profile", owner, repo) 42 | req, err := s.client.NewRequest("GET", u, nil) 43 | if err != nil { 44 | return nil, nil, err 45 | } 46 | 47 | // TODO: remove custom Accept header when this API fully launches. 48 | req.Header.Set("Accept", mediaTypeRepositoryCommunityHealthMetricsPreview) 49 | 50 | metrics := &CommunityHealthMetrics{} 51 | resp, err := s.client.Do(ctx, req, metrics) 52 | if err != nil { 53 | return nil, resp, err 54 | } 55 | 56 | return metrics, resp, nil 57 | } 58 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/repos_forks.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // RepositoryListForksOptions specifies the optional parameters to the 14 | // RepositoriesService.ListForks method. 15 | type RepositoryListForksOptions struct { 16 | // How to sort the forks list. Possible values are: newest, oldest, 17 | // watchers. Default is "newest". 18 | Sort string `url:"sort,omitempty"` 19 | 20 | ListOptions 21 | } 22 | 23 | // ListForks lists the forks of the specified repository. 24 | // 25 | // GitHub API docs: https://developer.github.com/v3/repos/forks/#list-forks 26 | func (s *RepositoriesService) ListForks(ctx context.Context, owner, repo string, opt *RepositoryListForksOptions) ([]*Repository, *Response, error) { 27 | u := fmt.Sprintf("repos/%v/%v/forks", owner, repo) 28 | u, err := addOptions(u, opt) 29 | if err != nil { 30 | return nil, nil, err 31 | } 32 | 33 | req, err := s.client.NewRequest("GET", u, nil) 34 | if err != nil { 35 | return nil, nil, err 36 | } 37 | 38 | // TODO: remove custom Accept header when topics API fully launches. 39 | req.Header.Set("Accept", mediaTypeTopicsPreview) 40 | 41 | var repos []*Repository 42 | resp, err := s.client.Do(ctx, req, &repos) 43 | if err != nil { 44 | return nil, resp, err 45 | } 46 | 47 | return repos, resp, nil 48 | } 49 | 50 | // RepositoryCreateForkOptions specifies the optional parameters to the 51 | // RepositoriesService.CreateFork method. 52 | type RepositoryCreateForkOptions struct { 53 | // The organization to fork the repository into. 54 | Organization string `url:"organization,omitempty"` 55 | } 56 | 57 | // CreateFork creates a fork of the specified repository. 58 | // 59 | // This method might return an *AcceptedError and a status code of 60 | // 202. This is because this is the status that GitHub returns to signify that 61 | // it is now computing creating the fork in a background task. 62 | // A follow up request, after a delay of a second or so, should result 63 | // in a successful request. 64 | // 65 | // GitHub API docs: https://developer.github.com/v3/repos/forks/#create-a-fork 66 | func (s *RepositoriesService) CreateFork(ctx context.Context, owner, repo string, opt *RepositoryCreateForkOptions) (*Repository, *Response, error) { 67 | u := fmt.Sprintf("repos/%v/%v/forks", owner, repo) 68 | u, err := addOptions(u, opt) 69 | if err != nil { 70 | return nil, nil, err 71 | } 72 | 73 | req, err := s.client.NewRequest("POST", u, nil) 74 | if err != nil { 75 | return nil, nil, err 76 | } 77 | 78 | fork := new(Repository) 79 | resp, err := s.client.Do(ctx, req, fork) 80 | if err != nil { 81 | return nil, resp, err 82 | } 83 | 84 | return fork, resp, nil 85 | } 86 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/repos_invitations.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // RepositoryInvitation represents an invitation to collaborate on a repo. 14 | type RepositoryInvitation struct { 15 | ID *int `json:"id,omitempty"` 16 | Repo *Repository `json:"repository,omitempty"` 17 | Invitee *User `json:"invitee,omitempty"` 18 | Inviter *User `json:"inviter,omitempty"` 19 | 20 | // Permissions represents the permissions that the associated user will have 21 | // on the repository. Possible values are: "read", "write", "admin". 22 | Permissions *string `json:"permissions,omitempty"` 23 | CreatedAt *Timestamp `json:"created_at,omitempty"` 24 | URL *string `json:"url,omitempty"` 25 | HTMLURL *string `json:"html_url,omitempty"` 26 | } 27 | 28 | // ListInvitations lists all currently-open repository invitations. 29 | // 30 | // GitHub API docs: https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository 31 | func (s *RepositoriesService) ListInvitations(ctx context.Context, owner, repo string, opt *ListOptions) ([]*RepositoryInvitation, *Response, error) { 32 | u := fmt.Sprintf("repos/%v/%v/invitations", owner, repo) 33 | u, err := addOptions(u, opt) 34 | if err != nil { 35 | return nil, nil, err 36 | } 37 | 38 | req, err := s.client.NewRequest("GET", u, nil) 39 | if err != nil { 40 | return nil, nil, err 41 | } 42 | 43 | // TODO: remove custom Accept header when this API fully launches. 44 | req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview) 45 | 46 | invites := []*RepositoryInvitation{} 47 | resp, err := s.client.Do(ctx, req, &invites) 48 | if err != nil { 49 | return nil, resp, err 50 | } 51 | 52 | return invites, resp, nil 53 | } 54 | 55 | // DeleteInvitation deletes a repository invitation. 56 | // 57 | // GitHub API docs: https://developer.github.com/v3/repos/invitations/#delete-a-repository-invitation 58 | func (s *RepositoriesService) DeleteInvitation(ctx context.Context, owner, repo string, invitationID int) (*Response, error) { 59 | u := fmt.Sprintf("repos/%v/%v/invitations/%v", owner, repo, invitationID) 60 | req, err := s.client.NewRequest("DELETE", u, nil) 61 | if err != nil { 62 | return nil, err 63 | } 64 | 65 | // TODO: remove custom Accept header when this API fully launches. 66 | req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview) 67 | 68 | return s.client.Do(ctx, req, nil) 69 | } 70 | 71 | // UpdateInvitation updates the permissions associated with a repository 72 | // invitation. 73 | // 74 | // permissions represents the permissions that the associated user will have 75 | // on the repository. Possible values are: "read", "write", "admin". 76 | // 77 | // GitHub API docs: https://developer.github.com/v3/repos/invitations/#update-a-repository-invitation 78 | func (s *RepositoriesService) UpdateInvitation(ctx context.Context, owner, repo string, invitationID int, permissions string) (*RepositoryInvitation, *Response, error) { 79 | opts := &struct { 80 | Permissions string `json:"permissions"` 81 | }{Permissions: permissions} 82 | u := fmt.Sprintf("repos/%v/%v/invitations/%v", owner, repo, invitationID) 83 | req, err := s.client.NewRequest("PATCH", u, opts) 84 | if err != nil { 85 | return nil, nil, err 86 | } 87 | 88 | // TODO: remove custom Accept header when this API fully launches. 89 | req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview) 90 | 91 | invite := &RepositoryInvitation{} 92 | resp, err := s.client.Do(ctx, req, invite) 93 | if err != nil { 94 | return nil, resp, err 95 | } 96 | 97 | return invite, resp, nil 98 | } 99 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/repos_keys.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // The Key type is defined in users_keys.go 14 | 15 | // ListKeys lists the deploy keys for a repository. 16 | // 17 | // GitHub API docs: https://developer.github.com/v3/repos/keys/#list 18 | func (s *RepositoriesService) ListKeys(ctx context.Context, owner string, repo string, opt *ListOptions) ([]*Key, *Response, error) { 19 | u := fmt.Sprintf("repos/%v/%v/keys", owner, repo) 20 | u, err := addOptions(u, opt) 21 | if err != nil { 22 | return nil, nil, err 23 | } 24 | 25 | req, err := s.client.NewRequest("GET", u, nil) 26 | if err != nil { 27 | return nil, nil, err 28 | } 29 | 30 | var keys []*Key 31 | resp, err := s.client.Do(ctx, req, &keys) 32 | if err != nil { 33 | return nil, resp, err 34 | } 35 | 36 | return keys, resp, nil 37 | } 38 | 39 | // GetKey fetches a single deploy key. 40 | // 41 | // GitHub API docs: https://developer.github.com/v3/repos/keys/#get 42 | func (s *RepositoriesService) GetKey(ctx context.Context, owner string, repo string, id int) (*Key, *Response, error) { 43 | u := fmt.Sprintf("repos/%v/%v/keys/%v", owner, repo, id) 44 | 45 | req, err := s.client.NewRequest("GET", u, nil) 46 | if err != nil { 47 | return nil, nil, err 48 | } 49 | 50 | key := new(Key) 51 | resp, err := s.client.Do(ctx, req, key) 52 | if err != nil { 53 | return nil, resp, err 54 | } 55 | 56 | return key, resp, nil 57 | } 58 | 59 | // CreateKey adds a deploy key for a repository. 60 | // 61 | // GitHub API docs: https://developer.github.com/v3/repos/keys/#create 62 | func (s *RepositoriesService) CreateKey(ctx context.Context, owner string, repo string, key *Key) (*Key, *Response, error) { 63 | u := fmt.Sprintf("repos/%v/%v/keys", owner, repo) 64 | 65 | req, err := s.client.NewRequest("POST", u, key) 66 | if err != nil { 67 | return nil, nil, err 68 | } 69 | 70 | k := new(Key) 71 | resp, err := s.client.Do(ctx, req, k) 72 | if err != nil { 73 | return nil, resp, err 74 | } 75 | 76 | return k, resp, nil 77 | } 78 | 79 | // EditKey edits a deploy key. 80 | // 81 | // GitHub API docs: https://developer.github.com/v3/repos/keys/#edit 82 | func (s *RepositoriesService) EditKey(ctx context.Context, owner string, repo string, id int, key *Key) (*Key, *Response, error) { 83 | u := fmt.Sprintf("repos/%v/%v/keys/%v", owner, repo, id) 84 | 85 | req, err := s.client.NewRequest("PATCH", u, key) 86 | if err != nil { 87 | return nil, nil, err 88 | } 89 | 90 | k := new(Key) 91 | resp, err := s.client.Do(ctx, req, k) 92 | if err != nil { 93 | return nil, resp, err 94 | } 95 | 96 | return k, resp, nil 97 | } 98 | 99 | // DeleteKey deletes a deploy key. 100 | // 101 | // GitHub API docs: https://developer.github.com/v3/repos/keys/#delete 102 | func (s *RepositoriesService) DeleteKey(ctx context.Context, owner string, repo string, id int) (*Response, error) { 103 | u := fmt.Sprintf("repos/%v/%v/keys/%v", owner, repo, id) 104 | 105 | req, err := s.client.NewRequest("DELETE", u, nil) 106 | if err != nil { 107 | return nil, err 108 | } 109 | 110 | return s.client.Do(ctx, req, nil) 111 | } 112 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/repos_merging.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // RepositoryMergeRequest represents a request to merge a branch in a 14 | // repository. 15 | type RepositoryMergeRequest struct { 16 | Base *string `json:"base,omitempty"` 17 | Head *string `json:"head,omitempty"` 18 | CommitMessage *string `json:"commit_message,omitempty"` 19 | } 20 | 21 | // Merge a branch in the specified repository. 22 | // 23 | // GitHub API docs: https://developer.github.com/v3/repos/merging/#perform-a-merge 24 | func (s *RepositoriesService) Merge(ctx context.Context, owner, repo string, request *RepositoryMergeRequest) (*RepositoryCommit, *Response, error) { 25 | u := fmt.Sprintf("repos/%v/%v/merges", owner, repo) 26 | req, err := s.client.NewRequest("POST", u, request) 27 | if err != nil { 28 | return nil, nil, err 29 | } 30 | 31 | commit := new(RepositoryCommit) 32 | resp, err := s.client.Do(ctx, req, commit) 33 | if err != nil { 34 | return nil, resp, err 35 | } 36 | 37 | return commit, resp, nil 38 | } 39 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/repos_projects.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ProjectListOptions specifies the optional parameters to the 14 | // OrganizationsService.ListProjects and RepositoriesService.ListProjects methods. 15 | type ProjectListOptions struct { 16 | // Indicates the state of the projects to return. Can be either open, closed, or all. Default: open 17 | State string `url:"state,omitempty"` 18 | 19 | ListOptions 20 | } 21 | 22 | // ListProjects lists the projects for a repo. 23 | // 24 | // GitHub API docs: https://developer.github.com/v3/projects/#list-repository-projects 25 | func (s *RepositoriesService) ListProjects(ctx context.Context, owner, repo string, opt *ProjectListOptions) ([]*Project, *Response, error) { 26 | u := fmt.Sprintf("repos/%v/%v/projects", owner, repo) 27 | u, err := addOptions(u, opt) 28 | if err != nil { 29 | return nil, nil, err 30 | } 31 | 32 | req, err := s.client.NewRequest("GET", u, nil) 33 | if err != nil { 34 | return nil, nil, err 35 | } 36 | 37 | // TODO: remove custom Accept header when this API fully launches. 38 | req.Header.Set("Accept", mediaTypeProjectsPreview) 39 | 40 | var projects []*Project 41 | resp, err := s.client.Do(ctx, req, &projects) 42 | if err != nil { 43 | return nil, resp, err 44 | } 45 | 46 | return projects, resp, nil 47 | } 48 | 49 | // CreateProject creates a GitHub Project for the specified repository. 50 | // 51 | // GitHub API docs: https://developer.github.com/v3/projects/#create-a-repository-project 52 | func (s *RepositoriesService) CreateProject(ctx context.Context, owner, repo string, opt *ProjectOptions) (*Project, *Response, error) { 53 | u := fmt.Sprintf("repos/%v/%v/projects", owner, repo) 54 | req, err := s.client.NewRequest("POST", u, opt) 55 | if err != nil { 56 | return nil, nil, err 57 | } 58 | 59 | // TODO: remove custom Accept header when this API fully launches. 60 | req.Header.Set("Accept", mediaTypeProjectsPreview) 61 | 62 | project := &Project{} 63 | resp, err := s.client.Do(ctx, req, project) 64 | if err != nil { 65 | return nil, resp, err 66 | } 67 | 68 | return project, resp, nil 69 | } 70 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/strings.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "bytes" 10 | "fmt" 11 | "io" 12 | 13 | "reflect" 14 | ) 15 | 16 | var timestampType = reflect.TypeOf(Timestamp{}) 17 | 18 | // Stringify attempts to create a reasonable string representation of types in 19 | // the GitHub library. It does things like resolve pointers to their values 20 | // and omits struct fields with nil values. 21 | func Stringify(message interface{}) string { 22 | var buf bytes.Buffer 23 | v := reflect.ValueOf(message) 24 | stringifyValue(&buf, v) 25 | return buf.String() 26 | } 27 | 28 | // stringifyValue was heavily inspired by the goprotobuf library. 29 | 30 | func stringifyValue(w io.Writer, val reflect.Value) { 31 | if val.Kind() == reflect.Ptr && val.IsNil() { 32 | w.Write([]byte("")) 33 | return 34 | } 35 | 36 | v := reflect.Indirect(val) 37 | 38 | switch v.Kind() { 39 | case reflect.String: 40 | fmt.Fprintf(w, `"%s"`, v) 41 | case reflect.Slice: 42 | w.Write([]byte{'['}) 43 | for i := 0; i < v.Len(); i++ { 44 | if i > 0 { 45 | w.Write([]byte{' '}) 46 | } 47 | 48 | stringifyValue(w, v.Index(i)) 49 | } 50 | 51 | w.Write([]byte{']'}) 52 | return 53 | case reflect.Struct: 54 | if v.Type().Name() != "" { 55 | w.Write([]byte(v.Type().String())) 56 | } 57 | 58 | // special handling of Timestamp values 59 | if v.Type() == timestampType { 60 | fmt.Fprintf(w, "{%s}", v.Interface()) 61 | return 62 | } 63 | 64 | w.Write([]byte{'{'}) 65 | 66 | var sep bool 67 | for i := 0; i < v.NumField(); i++ { 68 | fv := v.Field(i) 69 | if fv.Kind() == reflect.Ptr && fv.IsNil() { 70 | continue 71 | } 72 | if fv.Kind() == reflect.Slice && fv.IsNil() { 73 | continue 74 | } 75 | 76 | if sep { 77 | w.Write([]byte(", ")) 78 | } else { 79 | sep = true 80 | } 81 | 82 | w.Write([]byte(v.Type().Field(i).Name)) 83 | w.Write([]byte{':'}) 84 | stringifyValue(w, fv) 85 | } 86 | 87 | w.Write([]byte{'}'}) 88 | default: 89 | if v.CanInterface() { 90 | fmt.Fprint(w, v.Interface()) 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/timestamp.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "strconv" 10 | "time" 11 | ) 12 | 13 | // Timestamp represents a time that can be unmarshalled from a JSON string 14 | // formatted as either an RFC3339 or Unix timestamp. This is necessary for some 15 | // fields since the GitHub API is inconsistent in how it represents times. All 16 | // exported methods of time.Time can be called on Timestamp. 17 | type Timestamp struct { 18 | time.Time 19 | } 20 | 21 | func (t Timestamp) String() string { 22 | return t.Time.String() 23 | } 24 | 25 | // UnmarshalJSON implements the json.Unmarshaler interface. 26 | // Time is expected in RFC3339 or Unix format. 27 | func (t *Timestamp) UnmarshalJSON(data []byte) (err error) { 28 | str := string(data) 29 | i, err := strconv.ParseInt(str, 10, 64) 30 | if err == nil { 31 | (*t).Time = time.Unix(i, 0) 32 | } else { 33 | (*t).Time, err = time.Parse(`"`+time.RFC3339+`"`, str) 34 | } 35 | return 36 | } 37 | 38 | // Equal reports whether t and u are equal based on time.Equal 39 | func (t Timestamp) Equal(u Timestamp) bool { 40 | return t.Time.Equal(u.Time) 41 | } 42 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/users_administration.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // PromoteSiteAdmin promotes a user to a site administrator of a GitHub Enterprise instance. 14 | // 15 | // GitHub API docs: https://developer.github.com/v3/users/administration/#promote-an-ordinary-user-to-a-site-administrator 16 | func (s *UsersService) PromoteSiteAdmin(ctx context.Context, user string) (*Response, error) { 17 | u := fmt.Sprintf("users/%v/site_admin", user) 18 | 19 | req, err := s.client.NewRequest("PUT", u, nil) 20 | if err != nil { 21 | return nil, err 22 | } 23 | 24 | return s.client.Do(ctx, req, nil) 25 | } 26 | 27 | // DemoteSiteAdmin demotes a user from site administrator of a GitHub Enterprise instance. 28 | // 29 | // GitHub API docs: https://developer.github.com/v3/users/administration/#demote-a-site-administrator-to-an-ordinary-user 30 | func (s *UsersService) DemoteSiteAdmin(ctx context.Context, user string) (*Response, error) { 31 | u := fmt.Sprintf("users/%v/site_admin", user) 32 | 33 | req, err := s.client.NewRequest("DELETE", u, nil) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | return s.client.Do(ctx, req, nil) 39 | } 40 | 41 | // Suspend a user on a GitHub Enterprise instance. 42 | // 43 | // GitHub API docs: https://developer.github.com/v3/users/administration/#suspend-a-user 44 | func (s *UsersService) Suspend(ctx context.Context, user string) (*Response, error) { 45 | u := fmt.Sprintf("users/%v/suspended", user) 46 | 47 | req, err := s.client.NewRequest("PUT", u, nil) 48 | if err != nil { 49 | return nil, err 50 | } 51 | 52 | return s.client.Do(ctx, req, nil) 53 | } 54 | 55 | // Unsuspend a user on a GitHub Enterprise instance. 56 | // 57 | // GitHub API docs: https://developer.github.com/v3/users/administration/#unsuspend-a-user 58 | func (s *UsersService) Unsuspend(ctx context.Context, user string) (*Response, error) { 59 | u := fmt.Sprintf("users/%v/suspended", user) 60 | 61 | req, err := s.client.NewRequest("DELETE", u, nil) 62 | if err != nil { 63 | return nil, err 64 | } 65 | 66 | return s.client.Do(ctx, req, nil) 67 | } 68 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/users_blocking.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ListBlockedUsers lists all the blocked users by the authenticated user. 14 | // 15 | // GitHub API docs: https://developer.github.com/v3/users/blocking/#list-blocked-users 16 | func (s *UsersService) ListBlockedUsers(ctx context.Context, opt *ListOptions) ([]*User, *Response, error) { 17 | u := "user/blocks" 18 | u, err := addOptions(u, opt) 19 | if err != nil { 20 | return nil, nil, err 21 | } 22 | 23 | req, err := s.client.NewRequest("GET", u, nil) 24 | if err != nil { 25 | return nil, nil, err 26 | } 27 | 28 | // TODO: remove custom Accept header when this API fully launches. 29 | req.Header.Set("Accept", mediaTypeBlockUsersPreview) 30 | 31 | var blockedUsers []*User 32 | resp, err := s.client.Do(ctx, req, &blockedUsers) 33 | if err != nil { 34 | return nil, resp, err 35 | } 36 | 37 | return blockedUsers, resp, nil 38 | } 39 | 40 | // IsBlocked reports whether specified user is blocked by the authenticated user. 41 | // 42 | // GitHub API docs: https://developer.github.com/v3/users/blocking/#check-whether-youve-blocked-a-user 43 | func (s *UsersService) IsBlocked(ctx context.Context, user string) (bool, *Response, error) { 44 | u := fmt.Sprintf("user/blocks/%v", user) 45 | 46 | req, err := s.client.NewRequest("GET", u, nil) 47 | if err != nil { 48 | return false, nil, err 49 | } 50 | 51 | // TODO: remove custom Accept header when this API fully launches. 52 | req.Header.Set("Accept", mediaTypeBlockUsersPreview) 53 | 54 | resp, err := s.client.Do(ctx, req, nil) 55 | isBlocked, err := parseBoolResponse(err) 56 | return isBlocked, resp, err 57 | } 58 | 59 | // BlockUser blocks specified user for the authenticated user. 60 | // 61 | // GitHub API docs: https://developer.github.com/v3/users/blocking/#block-a-user 62 | func (s *UsersService) BlockUser(ctx context.Context, user string) (*Response, error) { 63 | u := fmt.Sprintf("user/blocks/%v", user) 64 | 65 | req, err := s.client.NewRequest("PUT", u, nil) 66 | if err != nil { 67 | return nil, err 68 | } 69 | 70 | // TODO: remove custom Accept header when this API fully launches. 71 | req.Header.Set("Accept", mediaTypeBlockUsersPreview) 72 | 73 | return s.client.Do(ctx, req, nil) 74 | } 75 | 76 | // UnblockUser unblocks specified user for the authenticated user. 77 | // 78 | // GitHub API docs: https://developer.github.com/v3/users/blocking/#unblock-a-user 79 | func (s *UsersService) UnblockUser(ctx context.Context, user string) (*Response, error) { 80 | u := fmt.Sprintf("user/blocks/%v", user) 81 | 82 | req, err := s.client.NewRequest("DELETE", u, nil) 83 | if err != nil { 84 | return nil, err 85 | } 86 | 87 | // TODO: remove custom Accept header when this API fully launches. 88 | req.Header.Set("Accept", mediaTypeBlockUsersPreview) 89 | 90 | return s.client.Do(ctx, req, nil) 91 | } 92 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/users_emails.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import "context" 9 | 10 | // UserEmail represents user's email address 11 | type UserEmail struct { 12 | Email *string `json:"email,omitempty"` 13 | Primary *bool `json:"primary,omitempty"` 14 | Verified *bool `json:"verified,omitempty"` 15 | } 16 | 17 | // ListEmails lists all email addresses for the authenticated user. 18 | // 19 | // GitHub API docs: https://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user 20 | func (s *UsersService) ListEmails(ctx context.Context, opt *ListOptions) ([]*UserEmail, *Response, error) { 21 | u := "user/emails" 22 | u, err := addOptions(u, opt) 23 | if err != nil { 24 | return nil, nil, err 25 | } 26 | 27 | req, err := s.client.NewRequest("GET", u, nil) 28 | if err != nil { 29 | return nil, nil, err 30 | } 31 | 32 | var emails []*UserEmail 33 | resp, err := s.client.Do(ctx, req, &emails) 34 | if err != nil { 35 | return nil, resp, err 36 | } 37 | 38 | return emails, resp, nil 39 | } 40 | 41 | // AddEmails adds email addresses of the authenticated user. 42 | // 43 | // GitHub API docs: https://developer.github.com/v3/users/emails/#add-email-addresses 44 | func (s *UsersService) AddEmails(ctx context.Context, emails []string) ([]*UserEmail, *Response, error) { 45 | u := "user/emails" 46 | req, err := s.client.NewRequest("POST", u, emails) 47 | if err != nil { 48 | return nil, nil, err 49 | } 50 | 51 | var e []*UserEmail 52 | resp, err := s.client.Do(ctx, req, &e) 53 | if err != nil { 54 | return nil, resp, err 55 | } 56 | 57 | return e, resp, nil 58 | } 59 | 60 | // DeleteEmails deletes email addresses from authenticated user. 61 | // 62 | // GitHub API docs: https://developer.github.com/v3/users/emails/#delete-email-addresses 63 | func (s *UsersService) DeleteEmails(ctx context.Context, emails []string) (*Response, error) { 64 | u := "user/emails" 65 | req, err := s.client.NewRequest("DELETE", u, emails) 66 | if err != nil { 67 | return nil, err 68 | } 69 | 70 | return s.client.Do(ctx, req, nil) 71 | } 72 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/users_followers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ListFollowers lists the followers for a user. Passing the empty string will 14 | // fetch followers for the authenticated user. 15 | // 16 | // GitHub API docs: https://developer.github.com/v3/users/followers/#list-followers-of-a-user 17 | func (s *UsersService) ListFollowers(ctx context.Context, user string, opt *ListOptions) ([]*User, *Response, error) { 18 | var u string 19 | if user != "" { 20 | u = fmt.Sprintf("users/%v/followers", user) 21 | } else { 22 | u = "user/followers" 23 | } 24 | u, err := addOptions(u, opt) 25 | if err != nil { 26 | return nil, nil, err 27 | } 28 | 29 | req, err := s.client.NewRequest("GET", u, nil) 30 | if err != nil { 31 | return nil, nil, err 32 | } 33 | 34 | var users []*User 35 | resp, err := s.client.Do(ctx, req, &users) 36 | if err != nil { 37 | return nil, resp, err 38 | } 39 | 40 | return users, resp, nil 41 | } 42 | 43 | // ListFollowing lists the people that a user is following. Passing the empty 44 | // string will list people the authenticated user is following. 45 | // 46 | // GitHub API docs: https://developer.github.com/v3/users/followers/#list-users-followed-by-another-user 47 | func (s *UsersService) ListFollowing(ctx context.Context, user string, opt *ListOptions) ([]*User, *Response, error) { 48 | var u string 49 | if user != "" { 50 | u = fmt.Sprintf("users/%v/following", user) 51 | } else { 52 | u = "user/following" 53 | } 54 | u, err := addOptions(u, opt) 55 | if err != nil { 56 | return nil, nil, err 57 | } 58 | 59 | req, err := s.client.NewRequest("GET", u, nil) 60 | if err != nil { 61 | return nil, nil, err 62 | } 63 | 64 | var users []*User 65 | resp, err := s.client.Do(ctx, req, &users) 66 | if err != nil { 67 | return nil, resp, err 68 | } 69 | 70 | return users, resp, nil 71 | } 72 | 73 | // IsFollowing checks if "user" is following "target". Passing the empty 74 | // string for "user" will check if the authenticated user is following "target". 75 | // 76 | // GitHub API docs: https://developer.github.com/v3/users/followers/#check-if-you-are-following-a-user 77 | func (s *UsersService) IsFollowing(ctx context.Context, user, target string) (bool, *Response, error) { 78 | var u string 79 | if user != "" { 80 | u = fmt.Sprintf("users/%v/following/%v", user, target) 81 | } else { 82 | u = fmt.Sprintf("user/following/%v", target) 83 | } 84 | 85 | req, err := s.client.NewRequest("GET", u, nil) 86 | if err != nil { 87 | return false, nil, err 88 | } 89 | 90 | resp, err := s.client.Do(ctx, req, nil) 91 | following, err := parseBoolResponse(err) 92 | return following, resp, err 93 | } 94 | 95 | // Follow will cause the authenticated user to follow the specified user. 96 | // 97 | // GitHub API docs: https://developer.github.com/v3/users/followers/#follow-a-user 98 | func (s *UsersService) Follow(ctx context.Context, user string) (*Response, error) { 99 | u := fmt.Sprintf("user/following/%v", user) 100 | req, err := s.client.NewRequest("PUT", u, nil) 101 | if err != nil { 102 | return nil, err 103 | } 104 | 105 | return s.client.Do(ctx, req, nil) 106 | } 107 | 108 | // Unfollow will cause the authenticated user to unfollow the specified user. 109 | // 110 | // GitHub API docs: https://developer.github.com/v3/users/followers/#unfollow-a-user 111 | func (s *UsersService) Unfollow(ctx context.Context, user string) (*Response, error) { 112 | u := fmt.Sprintf("user/following/%v", user) 113 | req, err := s.client.NewRequest("DELETE", u, nil) 114 | if err != nil { 115 | return nil, err 116 | } 117 | 118 | return s.client.Do(ctx, req, nil) 119 | } 120 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/users_keys.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // Key represents a public SSH key used to authenticate a user or deploy script. 14 | type Key struct { 15 | ID *int `json:"id,omitempty"` 16 | Key *string `json:"key,omitempty"` 17 | URL *string `json:"url,omitempty"` 18 | Title *string `json:"title,omitempty"` 19 | ReadOnly *bool `json:"read_only,omitempty"` 20 | } 21 | 22 | func (k Key) String() string { 23 | return Stringify(k) 24 | } 25 | 26 | // ListKeys lists the verified public keys for a user. Passing the empty 27 | // string will fetch keys for the authenticated user. 28 | // 29 | // GitHub API docs: https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user 30 | func (s *UsersService) ListKeys(ctx context.Context, user string, opt *ListOptions) ([]*Key, *Response, error) { 31 | var u string 32 | if user != "" { 33 | u = fmt.Sprintf("users/%v/keys", user) 34 | } else { 35 | u = "user/keys" 36 | } 37 | u, err := addOptions(u, opt) 38 | if err != nil { 39 | return nil, nil, err 40 | } 41 | 42 | req, err := s.client.NewRequest("GET", u, nil) 43 | if err != nil { 44 | return nil, nil, err 45 | } 46 | 47 | var keys []*Key 48 | resp, err := s.client.Do(ctx, req, &keys) 49 | if err != nil { 50 | return nil, resp, err 51 | } 52 | 53 | return keys, resp, nil 54 | } 55 | 56 | // GetKey fetches a single public key. 57 | // 58 | // GitHub API docs: https://developer.github.com/v3/users/keys/#get-a-single-public-key 59 | func (s *UsersService) GetKey(ctx context.Context, id int) (*Key, *Response, error) { 60 | u := fmt.Sprintf("user/keys/%v", id) 61 | 62 | req, err := s.client.NewRequest("GET", u, nil) 63 | if err != nil { 64 | return nil, nil, err 65 | } 66 | 67 | key := new(Key) 68 | resp, err := s.client.Do(ctx, req, key) 69 | if err != nil { 70 | return nil, resp, err 71 | } 72 | 73 | return key, resp, nil 74 | } 75 | 76 | // CreateKey adds a public key for the authenticated user. 77 | // 78 | // GitHub API docs: https://developer.github.com/v3/users/keys/#create-a-public-key 79 | func (s *UsersService) CreateKey(ctx context.Context, key *Key) (*Key, *Response, error) { 80 | u := "user/keys" 81 | 82 | req, err := s.client.NewRequest("POST", u, key) 83 | if err != nil { 84 | return nil, nil, err 85 | } 86 | 87 | k := new(Key) 88 | resp, err := s.client.Do(ctx, req, k) 89 | if err != nil { 90 | return nil, resp, err 91 | } 92 | 93 | return k, resp, nil 94 | } 95 | 96 | // DeleteKey deletes a public key. 97 | // 98 | // GitHub API docs: https://developer.github.com/v3/users/keys/#delete-a-public-key 99 | func (s *UsersService) DeleteKey(ctx context.Context, id int) (*Response, error) { 100 | u := fmt.Sprintf("user/keys/%v", id) 101 | 102 | req, err := s.client.NewRequest("DELETE", u, nil) 103 | if err != nil { 104 | return nil, err 105 | } 106 | 107 | return s.client.Do(ctx, req, nil) 108 | } 109 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/with_appengine.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build appengine 7 | 8 | // This file provides glue for making github work on App Engine. 9 | // In order to get the entire github package to compile with 10 | // Go 1.6, you will need to rewrite all the import "context" lines. 11 | // Fortunately, this is easy with "gofmt": 12 | // 13 | // gofmt -w -r '"context" -> "golang.org/x/net/context"' *.go 14 | 15 | package github 16 | 17 | import ( 18 | "context" 19 | "net/http" 20 | ) 21 | 22 | func withContext(ctx context.Context, req *http.Request) *http.Request { 23 | // No-op because App Engine adds context to a request differently. 24 | return req 25 | } 26 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/google/go-github/github/without_appengine.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build !appengine 7 | 8 | // This file provides glue for making github work without App Engine. 9 | 10 | package github 11 | 12 | import ( 13 | "context" 14 | "net/http" 15 | ) 16 | 17 | func withContext(ctx context.Context, req *http.Request) *http.Request { 18 | return req.WithContext(ctx) 19 | } 20 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/pkg/errors/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Dave Cheney 2 | 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 met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/github.com/pkg/errors/README.md: -------------------------------------------------------------------------------- 1 | # errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) 2 | 3 | Package errors provides simple error handling primitives. 4 | 5 | `go get github.com/pkg/errors` 6 | 7 | The traditional error handling idiom in Go is roughly akin to 8 | ```go 9 | if err != nil { 10 | return err 11 | } 12 | ``` 13 | which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error. 14 | 15 | ## Adding context to an error 16 | 17 | The errors.Wrap function returns a new error that adds context to the original error. For example 18 | ```go 19 | _, err := ioutil.ReadAll(r) 20 | if err != nil { 21 | return errors.Wrap(err, "read failed") 22 | } 23 | ``` 24 | ## Retrieving the cause of an error 25 | 26 | Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`. 27 | ```go 28 | type causer interface { 29 | Cause() error 30 | } 31 | ``` 32 | `errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example: 33 | ```go 34 | switch err := errors.Cause(err).(type) { 35 | case *MyError: 36 | // handle specifically 37 | default: 38 | // unknown error 39 | } 40 | ``` 41 | 42 | [Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). 43 | 44 | ## Contributing 45 | 46 | We welcome pull requests, bug fixes and issue reports. With that said, the bar for adding new symbols to this package is intentionally set high. 47 | 48 | Before proposing a change, please discuss your change by raising an issue. 49 | 50 | ## Licence 51 | 52 | BSD-2-Clause 53 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/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 | // 9 | // Incoming requests to a server should create a Context, and outgoing calls to 10 | // servers should accept a Context. The chain of function calls between must 11 | // propagate the Context, optionally replacing it with a modified copy created 12 | // using WithDeadline, WithTimeout, WithCancel, or WithValue. 13 | // 14 | // Programs that use Contexts should follow these rules to keep interfaces 15 | // consistent across packages and enable static analysis tools to check context 16 | // propagation: 17 | // 18 | // Do not store Contexts inside a struct type; instead, pass a Context 19 | // explicitly to each function that needs it. The Context should be the first 20 | // parameter, typically named ctx: 21 | // 22 | // func DoSomething(ctx context.Context, arg Arg) error { 23 | // // ... use ctx ... 24 | // } 25 | // 26 | // Do not pass a nil Context, even if a function permits it. Pass context.TODO 27 | // if you are unsure about which Context to use. 28 | // 29 | // Use context Values only for request-scoped data that transits processes and 30 | // APIs, not for passing optional parameters to functions. 31 | // 32 | // The same Context may be passed to functions running in different goroutines; 33 | // Contexts are safe for simultaneous use by multiple goroutines. 34 | // 35 | // See http://blog.golang.org/context for example code for a server that uses 36 | // Contexts. 37 | package context // import "golang.org/x/net/context" 38 | 39 | // Background returns a non-nil, empty Context. It is never canceled, has no 40 | // values, and has no deadline. It is typically used by the main function, 41 | // initialization, and tests, and as the top-level Context for incoming 42 | // requests. 43 | func Background() Context { 44 | return background 45 | } 46 | 47 | // TODO returns a non-nil, empty Context. Code should use context.TODO when 48 | // it's unclear which Context to use or it is not yet available (because the 49 | // surrounding function has not yet been extended to accept a Context 50 | // parameter). TODO is recognized by static analysis tools that determine 51 | // whether Contexts are propagated correctly in a program. 52 | func TODO() Context { 53 | return todo 54 | } 55 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/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 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.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 !go1.7 6 | 7 | package ctxhttp // import "golang.org/x/net/context/ctxhttp" 8 | 9 | import ( 10 | "io" 11 | "net/http" 12 | "net/url" 13 | "strings" 14 | 15 | "golang.org/x/net/context" 16 | ) 17 | 18 | func nop() {} 19 | 20 | var ( 21 | testHookContextDoneBeforeHeaders = nop 22 | testHookDoReturned = nop 23 | testHookDidBodyClose = nop 24 | ) 25 | 26 | // Do sends an HTTP request with the provided http.Client and returns an HTTP response. 27 | // If the client is nil, http.DefaultClient is used. 28 | // If the context is canceled or times out, ctx.Err() will be returned. 29 | func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) { 30 | if client == nil { 31 | client = http.DefaultClient 32 | } 33 | 34 | // TODO(djd): Respect any existing value of req.Cancel. 35 | cancel := make(chan struct{}) 36 | req.Cancel = cancel 37 | 38 | type responseAndError struct { 39 | resp *http.Response 40 | err error 41 | } 42 | result := make(chan responseAndError, 1) 43 | 44 | // Make local copies of test hooks closed over by goroutines below. 45 | // Prevents data races in tests. 46 | testHookDoReturned := testHookDoReturned 47 | testHookDidBodyClose := testHookDidBodyClose 48 | 49 | go func() { 50 | resp, err := client.Do(req) 51 | testHookDoReturned() 52 | result <- responseAndError{resp, err} 53 | }() 54 | 55 | var resp *http.Response 56 | 57 | select { 58 | case <-ctx.Done(): 59 | testHookContextDoneBeforeHeaders() 60 | close(cancel) 61 | // Clean up after the goroutine calling client.Do: 62 | go func() { 63 | if r := <-result; r.resp != nil { 64 | testHookDidBodyClose() 65 | r.resp.Body.Close() 66 | } 67 | }() 68 | return nil, ctx.Err() 69 | case r := <-result: 70 | var err error 71 | resp, err = r.resp, r.err 72 | if err != nil { 73 | return resp, err 74 | } 75 | } 76 | 77 | c := make(chan struct{}) 78 | go func() { 79 | select { 80 | case <-ctx.Done(): 81 | close(cancel) 82 | case <-c: 83 | // The response's Body is closed. 84 | } 85 | }() 86 | resp.Body = ¬ifyingReader{resp.Body, c} 87 | 88 | return resp, nil 89 | } 90 | 91 | // Get issues a GET request via the Do function. 92 | func Get(ctx context.Context, client *http.Client, url string) (*http.Response, error) { 93 | req, err := http.NewRequest("GET", url, nil) 94 | if err != nil { 95 | return nil, err 96 | } 97 | return Do(ctx, client, req) 98 | } 99 | 100 | // Head issues a HEAD request via the Do function. 101 | func Head(ctx context.Context, client *http.Client, url string) (*http.Response, error) { 102 | req, err := http.NewRequest("HEAD", url, nil) 103 | if err != nil { 104 | return nil, err 105 | } 106 | return Do(ctx, client, req) 107 | } 108 | 109 | // Post issues a POST request via the Do function. 110 | func Post(ctx context.Context, client *http.Client, url string, bodyType string, body io.Reader) (*http.Response, error) { 111 | req, err := http.NewRequest("POST", url, body) 112 | if err != nil { 113 | return nil, err 114 | } 115 | req.Header.Set("Content-Type", bodyType) 116 | return Do(ctx, client, req) 117 | } 118 | 119 | // PostForm issues a POST request via the Do function. 120 | func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) { 121 | return Post(ctx, client, url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode())) 122 | } 123 | 124 | // notifyingReader is an io.ReadCloser that closes the notify channel after 125 | // Close is called or a Read fails on the underlying ReadCloser. 126 | type notifyingReader struct { 127 | io.ReadCloser 128 | notify chan<- struct{} 129 | } 130 | 131 | func (r *notifyingReader) Read(p []byte) (int, error) { 132 | n, err := r.ReadCloser.Read(p) 133 | if err != nil && r.notify != nil { 134 | close(r.notify) 135 | r.notify = nil 136 | } 137 | return n, err 138 | } 139 | 140 | func (r *notifyingReader) Close() error { 141 | err := r.ReadCloser.Close() 142 | if r.notify != nil { 143 | close(r.notify) 144 | r.notify = nil 145 | } 146 | return err 147 | } 148 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/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 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/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 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/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 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/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 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/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 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/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 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/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 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/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 contains support packages for oauth2 package. 6 | package internal 7 | 8 | import ( 9 | "bufio" 10 | "crypto/rsa" 11 | "crypto/x509" 12 | "encoding/pem" 13 | "errors" 14 | "fmt" 15 | "io" 16 | "strings" 17 | ) 18 | 19 | // ParseKey converts the binary contents of a private key file 20 | // to an *rsa.PrivateKey. It detects whether the private key is in a 21 | // PEM container or not. If so, it extracts the the private key 22 | // from PEM container before conversion. It only supports PEM 23 | // containers with no passphrase. 24 | func ParseKey(key []byte) (*rsa.PrivateKey, error) { 25 | block, _ := pem.Decode(key) 26 | if block != nil { 27 | key = block.Bytes 28 | } 29 | parsedKey, err := x509.ParsePKCS8PrivateKey(key) 30 | if err != nil { 31 | parsedKey, err = x509.ParsePKCS1PrivateKey(key) 32 | if err != nil { 33 | return nil, fmt.Errorf("private key should be a PEM or plain PKSC1 or PKCS8; parse error: %v", err) 34 | } 35 | } 36 | parsed, ok := parsedKey.(*rsa.PrivateKey) 37 | if !ok { 38 | return nil, errors.New("private key is invalid") 39 | } 40 | return parsed, nil 41 | } 42 | 43 | func ParseINI(ini io.Reader) (map[string]map[string]string, error) { 44 | result := map[string]map[string]string{ 45 | "": {}, // root section 46 | } 47 | scanner := bufio.NewScanner(ini) 48 | currentSection := "" 49 | for scanner.Scan() { 50 | line := strings.TrimSpace(scanner.Text()) 51 | if strings.HasPrefix(line, ";") { 52 | // comment. 53 | continue 54 | } 55 | if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") { 56 | currentSection = strings.TrimSpace(line[1 : len(line)-1]) 57 | result[currentSection] = map[string]string{} 58 | continue 59 | } 60 | parts := strings.SplitN(line, "=", 2) 61 | if len(parts) == 2 && parts[0] != "" { 62 | result[currentSection][strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1]) 63 | } 64 | } 65 | if err := scanner.Err(); err != nil { 66 | return nil, fmt.Errorf("error scanning ini: %v", err) 67 | } 68 | return result, nil 69 | } 70 | 71 | func CondVal(v string) []string { 72 | if v == "" { 73 | return nil 74 | } 75 | return []string{v} 76 | } 77 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/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 contains support packages for oauth2 package. 6 | package internal 7 | 8 | import ( 9 | "net/http" 10 | 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | // HTTPClient is the context key to use with golang.org/x/net/context's 15 | // WithValue function to associate an *http.Client value with a context. 16 | var HTTPClient ContextKey 17 | 18 | // ContextKey is just an empty struct. It exists so HTTPClient can be 19 | // an immutable public variable with a unique type. It's immutable 20 | // because nobody else can create a ContextKey, being unexported. 21 | type ContextKey struct{} 22 | 23 | // ContextClientFunc is a func which tries to return an *http.Client 24 | // given a Context value. If it returns an error, the search stops 25 | // with that error. If it returns (nil, nil), the search continues 26 | // down the list of registered funcs. 27 | type ContextClientFunc func(context.Context) (*http.Client, error) 28 | 29 | var contextClientFuncs []ContextClientFunc 30 | 31 | func RegisterContextClientFunc(fn ContextClientFunc) { 32 | contextClientFuncs = append(contextClientFuncs, fn) 33 | } 34 | 35 | func ContextClient(ctx context.Context) (*http.Client, error) { 36 | if ctx != nil { 37 | if hc, ok := ctx.Value(HTTPClient).(*http.Client); ok { 38 | return hc, nil 39 | } 40 | } 41 | for _, fn := range contextClientFuncs { 42 | c, err := fn(ctx) 43 | if err != nil { 44 | return nil, err 45 | } 46 | if c != nil { 47 | return c, nil 48 | } 49 | } 50 | return http.DefaultClient, nil 51 | } 52 | 53 | func ContextTransport(ctx context.Context) http.RoundTripper { 54 | hc, err := ContextClient(ctx) 55 | // This is a rare error case (somebody using nil on App Engine). 56 | if err != nil { 57 | return ErrorTransport{err} 58 | } 59 | return hc.Transport 60 | } 61 | 62 | // ErrorTransport returns the specified error on RoundTrip. 63 | // This RoundTripper should be used in rare error cases where 64 | // error handling can be postponed to response handling time. 65 | type ErrorTransport struct{ Err error } 66 | 67 | func (t ErrorTransport) RoundTrip(*http.Request) (*http.Response, error) { 68 | return nil, t.Err 69 | } 70 | -------------------------------------------------------------------------------- /_tools/src/github.com/spenczar/go-gh-releaser/vendor/golang.org/x/oauth2/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 oauth2 6 | 7 | import ( 8 | "errors" 9 | "io" 10 | "net/http" 11 | "sync" 12 | ) 13 | 14 | // Transport is an http.RoundTripper that makes OAuth 2.0 HTTP requests, 15 | // wrapping a base RoundTripper and adding an Authorization header 16 | // with a token from the supplied Sources. 17 | // 18 | // Transport is a low-level mechanism. Most code will use the 19 | // higher-level Config.Client method instead. 20 | type Transport struct { 21 | // Source supplies the token to add to outgoing requests' 22 | // Authorization headers. 23 | Source TokenSource 24 | 25 | // Base is the base RoundTripper used to make HTTP requests. 26 | // If nil, http.DefaultTransport is used. 27 | Base http.RoundTripper 28 | 29 | mu sync.Mutex // guards modReq 30 | modReq map[*http.Request]*http.Request // original -> modified 31 | } 32 | 33 | // RoundTrip authorizes and authenticates the request with an 34 | // access token. If no token exists or token is expired, 35 | // tries to refresh/fetch a new token. 36 | func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { 37 | if t.Source == nil { 38 | return nil, errors.New("oauth2: Transport's Source is nil") 39 | } 40 | token, err := t.Source.Token() 41 | if err != nil { 42 | return nil, err 43 | } 44 | 45 | req2 := cloneRequest(req) // per RoundTripper contract 46 | token.SetAuthHeader(req2) 47 | t.setModReq(req, req2) 48 | res, err := t.base().RoundTrip(req2) 49 | if err != nil { 50 | t.setModReq(req, nil) 51 | return nil, err 52 | } 53 | res.Body = &onEOFReader{ 54 | rc: res.Body, 55 | fn: func() { t.setModReq(req, nil) }, 56 | } 57 | return res, nil 58 | } 59 | 60 | // CancelRequest cancels an in-flight request by closing its connection. 61 | func (t *Transport) CancelRequest(req *http.Request) { 62 | type canceler interface { 63 | CancelRequest(*http.Request) 64 | } 65 | if cr, ok := t.base().(canceler); ok { 66 | t.mu.Lock() 67 | modReq := t.modReq[req] 68 | delete(t.modReq, req) 69 | t.mu.Unlock() 70 | cr.CancelRequest(modReq) 71 | } 72 | } 73 | 74 | func (t *Transport) base() http.RoundTripper { 75 | if t.Base != nil { 76 | return t.Base 77 | } 78 | return http.DefaultTransport 79 | } 80 | 81 | func (t *Transport) setModReq(orig, mod *http.Request) { 82 | t.mu.Lock() 83 | defer t.mu.Unlock() 84 | if t.modReq == nil { 85 | t.modReq = make(map[*http.Request]*http.Request) 86 | } 87 | if mod == nil { 88 | delete(t.modReq, orig) 89 | } else { 90 | t.modReq[orig] = mod 91 | } 92 | } 93 | 94 | // cloneRequest returns a clone of the provided *http.Request. 95 | // The clone is a shallow copy of the struct and its Header map. 96 | func cloneRequest(r *http.Request) *http.Request { 97 | // shallow copy of the struct 98 | r2 := new(http.Request) 99 | *r2 = *r 100 | // deep copy of the Header 101 | r2.Header = make(http.Header, len(r.Header)) 102 | for k, s := range r.Header { 103 | r2.Header[k] = append([]string(nil), s...) 104 | } 105 | return r2 106 | } 107 | 108 | type onEOFReader struct { 109 | rc io.ReadCloser 110 | fn func() 111 | } 112 | 113 | func (r *onEOFReader) Read(p []byte) (n int, err error) { 114 | n, err = r.rc.Read(p) 115 | if err == io.EOF { 116 | r.runFunc() 117 | } 118 | return 119 | } 120 | 121 | func (r *onEOFReader) Close() error { 122 | err := r.rc.Close() 123 | r.runFunc() 124 | return err 125 | } 126 | 127 | func (r *onEOFReader) runFunc() { 128 | if fn := r.fn; fn != nil { 129 | fn() 130 | r.fn = nil 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /_tools/src/github.com/tsenart/deadcode/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rémy Oudompheng. 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 | * The name of Rémy Oudompheng may not be used to endorse or promote products derived from 14 | this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | -------------------------------------------------------------------------------- /_tools/src/golang.org/x/tools/go/ast/astutil/util.go: -------------------------------------------------------------------------------- 1 | package astutil 2 | 3 | import "go/ast" 4 | 5 | // Unparen returns e with any enclosing parentheses stripped. 6 | func Unparen(e ast.Expr) ast.Expr { 7 | for { 8 | p, ok := e.(*ast.ParenExpr) 9 | if !ok { 10 | return e 11 | } 12 | e = p.X 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /_tools/src/golang.org/x/tools/go/buildutil/fakecontext.go: -------------------------------------------------------------------------------- 1 | package buildutil 2 | 3 | import ( 4 | "fmt" 5 | "go/build" 6 | "io" 7 | "io/ioutil" 8 | "os" 9 | "path" 10 | "path/filepath" 11 | "sort" 12 | "strings" 13 | "time" 14 | ) 15 | 16 | // FakeContext returns a build.Context for the fake file tree specified 17 | // by pkgs, which maps package import paths to a mapping from file base 18 | // names to contents. 19 | // 20 | // The fake Context has a GOROOT of "/go" and no GOPATH, and overrides 21 | // the necessary file access methods to read from memory instead of the 22 | // real file system. 23 | // 24 | // Unlike a real file tree, the fake one has only two levels---packages 25 | // and files---so ReadDir("/go/src/") returns all packages under 26 | // /go/src/ including, for instance, "math" and "math/big". 27 | // ReadDir("/go/src/math/big") would return all the files in the 28 | // "math/big" package. 29 | // 30 | func FakeContext(pkgs map[string]map[string]string) *build.Context { 31 | clean := func(filename string) string { 32 | f := path.Clean(filepath.ToSlash(filename)) 33 | // Removing "/go/src" while respecting segment 34 | // boundaries has this unfortunate corner case: 35 | if f == "/go/src" { 36 | return "" 37 | } 38 | return strings.TrimPrefix(f, "/go/src/") 39 | } 40 | 41 | ctxt := build.Default // copy 42 | ctxt.GOROOT = "/go" 43 | ctxt.GOPATH = "" 44 | ctxt.IsDir = func(dir string) bool { 45 | dir = clean(dir) 46 | if dir == "" { 47 | return true // needed by (*build.Context).SrcDirs 48 | } 49 | return pkgs[dir] != nil 50 | } 51 | ctxt.ReadDir = func(dir string) ([]os.FileInfo, error) { 52 | dir = clean(dir) 53 | var fis []os.FileInfo 54 | if dir == "" { 55 | // enumerate packages 56 | for importPath := range pkgs { 57 | fis = append(fis, fakeDirInfo(importPath)) 58 | } 59 | } else { 60 | // enumerate files of package 61 | for basename := range pkgs[dir] { 62 | fis = append(fis, fakeFileInfo(basename)) 63 | } 64 | } 65 | sort.Sort(byName(fis)) 66 | return fis, nil 67 | } 68 | ctxt.OpenFile = func(filename string) (io.ReadCloser, error) { 69 | filename = clean(filename) 70 | dir, base := path.Split(filename) 71 | content, ok := pkgs[path.Clean(dir)][base] 72 | if !ok { 73 | return nil, fmt.Errorf("file not found: %s", filename) 74 | } 75 | return ioutil.NopCloser(strings.NewReader(content)), nil 76 | } 77 | ctxt.IsAbsPath = func(path string) bool { 78 | path = filepath.ToSlash(path) 79 | // Don't rely on the default (filepath.Path) since on 80 | // Windows, it reports virtual paths as non-absolute. 81 | return strings.HasPrefix(path, "/") 82 | } 83 | return &ctxt 84 | } 85 | 86 | type byName []os.FileInfo 87 | 88 | func (s byName) Len() int { return len(s) } 89 | func (s byName) Swap(i, j int) { s[i], s[j] = s[j], s[i] } 90 | func (s byName) Less(i, j int) bool { return s[i].Name() < s[j].Name() } 91 | 92 | type fakeFileInfo string 93 | 94 | func (fi fakeFileInfo) Name() string { return string(fi) } 95 | func (fakeFileInfo) Sys() interface{} { return nil } 96 | func (fakeFileInfo) ModTime() time.Time { return time.Time{} } 97 | func (fakeFileInfo) IsDir() bool { return false } 98 | func (fakeFileInfo) Size() int64 { return 0 } 99 | func (fakeFileInfo) Mode() os.FileMode { return 0644 } 100 | 101 | type fakeDirInfo string 102 | 103 | func (fd fakeDirInfo) Name() string { return string(fd) } 104 | func (fakeDirInfo) Sys() interface{} { return nil } 105 | func (fakeDirInfo) ModTime() time.Time { return time.Time{} } 106 | func (fakeDirInfo) IsDir() bool { return true } 107 | func (fakeDirInfo) Size() int64 { return 0 } 108 | func (fakeDirInfo) Mode() os.FileMode { return 0755 } 109 | -------------------------------------------------------------------------------- /_tools/src/golang.org/x/tools/go/buildutil/overlay.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 | package buildutil 6 | 7 | import ( 8 | "bufio" 9 | "bytes" 10 | "fmt" 11 | "go/build" 12 | "io" 13 | "io/ioutil" 14 | "path/filepath" 15 | "strconv" 16 | "strings" 17 | ) 18 | 19 | // OverlayContext overlays a build.Context with additional files from 20 | // a map. Files in the map take precedence over other files. 21 | // 22 | // In addition to plain string comparison, two file names are 23 | // considered equal if their base names match and their directory 24 | // components point at the same directory on the file system. That is, 25 | // symbolic links are followed for directories, but not files. 26 | // 27 | // A common use case for OverlayContext is to allow editors to pass in 28 | // a set of unsaved, modified files. 29 | // 30 | // Currently, only the Context.OpenFile function will respect the 31 | // overlay. This may change in the future. 32 | func OverlayContext(orig *build.Context, overlay map[string][]byte) *build.Context { 33 | // TODO(dominikh): Implement IsDir, HasSubdir and ReadDir 34 | 35 | rc := func(data []byte) (io.ReadCloser, error) { 36 | return ioutil.NopCloser(bytes.NewBuffer(data)), nil 37 | } 38 | 39 | copy := *orig // make a copy 40 | ctxt := © 41 | ctxt.OpenFile = func(path string) (io.ReadCloser, error) { 42 | // Fast path: names match exactly. 43 | if content, ok := overlay[path]; ok { 44 | return rc(content) 45 | } 46 | 47 | // Slow path: check for same file under a different 48 | // alias, perhaps due to a symbolic link. 49 | for filename, content := range overlay { 50 | if sameFile(path, filename) { 51 | return rc(content) 52 | } 53 | } 54 | 55 | return OpenFile(orig, path) 56 | } 57 | return ctxt 58 | } 59 | 60 | // ParseOverlayArchive parses an archive containing Go files and their 61 | // contents. The result is intended to be used with OverlayContext. 62 | // 63 | // 64 | // Archive format 65 | // 66 | // The archive consists of a series of files. Each file consists of a 67 | // name, a decimal file size and the file contents, separated by 68 | // newlinews. No newline follows after the file contents. 69 | func ParseOverlayArchive(archive io.Reader) (map[string][]byte, error) { 70 | overlay := make(map[string][]byte) 71 | r := bufio.NewReader(archive) 72 | for { 73 | // Read file name. 74 | filename, err := r.ReadString('\n') 75 | if err != nil { 76 | if err == io.EOF { 77 | break // OK 78 | } 79 | return nil, fmt.Errorf("reading archive file name: %v", err) 80 | } 81 | filename = filepath.Clean(strings.TrimSpace(filename)) 82 | 83 | // Read file size. 84 | sz, err := r.ReadString('\n') 85 | if err != nil { 86 | return nil, fmt.Errorf("reading size of archive file %s: %v", filename, err) 87 | } 88 | sz = strings.TrimSpace(sz) 89 | size, err := strconv.ParseUint(sz, 10, 32) 90 | if err != nil { 91 | return nil, fmt.Errorf("parsing size of archive file %s: %v", filename, err) 92 | } 93 | 94 | // Read file content. 95 | content := make([]byte, size) 96 | if _, err := io.ReadFull(r, content); err != nil { 97 | return nil, fmt.Errorf("reading archive file %s: %v", filename, err) 98 | } 99 | overlay[filename] = content 100 | } 101 | 102 | return overlay, nil 103 | } 104 | -------------------------------------------------------------------------------- /_tools/src/golang.org/x/tools/go/buildutil/tags.go: -------------------------------------------------------------------------------- 1 | package buildutil 2 | 3 | // This logic was copied from stringsFlag from $GOROOT/src/cmd/go/build.go. 4 | 5 | import "fmt" 6 | 7 | const TagsFlagDoc = "a list of `build tags` to consider satisfied during the build. " + 8 | "For more information about build tags, see the description of " + 9 | "build constraints in the documentation for the go/build package" 10 | 11 | // TagsFlag is an implementation of the flag.Value and flag.Getter interfaces that parses 12 | // a flag value in the same manner as go build's -tags flag and 13 | // populates a []string slice. 14 | // 15 | // See $GOROOT/src/go/build/doc.go for description of build tags. 16 | // See $GOROOT/src/cmd/go/doc.go for description of 'go build -tags' flag. 17 | // 18 | // Example: 19 | // flag.Var((*buildutil.TagsFlag)(&build.Default.BuildTags), "tags", buildutil.TagsFlagDoc) 20 | type TagsFlag []string 21 | 22 | func (v *TagsFlag) Set(s string) error { 23 | var err error 24 | *v, err = splitQuotedFields(s) 25 | if *v == nil { 26 | *v = []string{} 27 | } 28 | return err 29 | } 30 | 31 | func (v *TagsFlag) Get() interface{} { return *v } 32 | 33 | func splitQuotedFields(s string) ([]string, error) { 34 | // Split fields allowing '' or "" around elements. 35 | // Quotes further inside the string do not count. 36 | var f []string 37 | for len(s) > 0 { 38 | for len(s) > 0 && isSpaceByte(s[0]) { 39 | s = s[1:] 40 | } 41 | if len(s) == 0 { 42 | break 43 | } 44 | // Accepted quoted string. No unescaping inside. 45 | if s[0] == '"' || s[0] == '\'' { 46 | quote := s[0] 47 | s = s[1:] 48 | i := 0 49 | for i < len(s) && s[i] != quote { 50 | i++ 51 | } 52 | if i >= len(s) { 53 | return nil, fmt.Errorf("unterminated %c string", quote) 54 | } 55 | f = append(f, s[:i]) 56 | s = s[i+1:] 57 | continue 58 | } 59 | i := 0 60 | for i < len(s) && !isSpaceByte(s[i]) { 61 | i++ 62 | } 63 | f = append(f, s[:i]) 64 | s = s[i:] 65 | } 66 | return f, nil 67 | } 68 | 69 | func (v *TagsFlag) String() string { 70 | return "" 71 | } 72 | 73 | func isSpaceByte(c byte) bool { 74 | return c == ' ' || c == '\t' || c == '\n' || c == '\r' 75 | } 76 | -------------------------------------------------------------------------------- /_tools/src/golang.org/x/tools/go/gcexportdata/importer.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 | package gcexportdata 6 | 7 | import ( 8 | "fmt" 9 | "go/token" 10 | "go/types" 11 | "os" 12 | ) 13 | 14 | // NewImporter returns a new instance of the types.Importer interface 15 | // that reads type information from export data files written by gc. 16 | // The Importer also satisfies types.ImporterFrom. 17 | // 18 | // Export data files are located using "go build" workspace conventions 19 | // and the build.Default context. 20 | // 21 | // Use this importer instead of go/importer.For("gc", ...) to avoid the 22 | // version-skew problems described in the documentation of this package, 23 | // or to control the FileSet or access the imports map populated during 24 | // package loading. 25 | // 26 | func NewImporter(fset *token.FileSet, imports map[string]*types.Package) types.ImporterFrom { 27 | return importer{fset, imports} 28 | } 29 | 30 | type importer struct { 31 | fset *token.FileSet 32 | imports map[string]*types.Package 33 | } 34 | 35 | func (imp importer) Import(importPath string) (*types.Package, error) { 36 | return imp.ImportFrom(importPath, "", 0) 37 | } 38 | 39 | func (imp importer) ImportFrom(importPath, srcDir string, mode types.ImportMode) (_ *types.Package, err error) { 40 | filename, path := Find(importPath, srcDir) 41 | if filename == "" { 42 | if importPath == "unsafe" { 43 | // Even for unsafe, call Find first in case 44 | // the package was vendored. 45 | return types.Unsafe, nil 46 | } 47 | return nil, fmt.Errorf("can't find import: %s", importPath) 48 | } 49 | 50 | if pkg, ok := imp.imports[path]; ok && pkg.Complete() { 51 | return pkg, nil // cache hit 52 | } 53 | 54 | // open file 55 | f, err := os.Open(filename) 56 | if err != nil { 57 | return nil, err 58 | } 59 | defer func() { 60 | f.Close() 61 | if err != nil { 62 | // add file name to error 63 | err = fmt.Errorf("reading export data: %s: %v", filename, err) 64 | } 65 | }() 66 | 67 | r, err := NewReader(f) 68 | if err != nil { 69 | return nil, err 70 | } 71 | 72 | return Read(r, imp.fset, imp.imports, path) 73 | } 74 | -------------------------------------------------------------------------------- /_tools/src/golang.org/x/tools/go/gcexportdata/main.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 ignore 6 | 7 | // The gcexportdata command is a diagnostic tool that displays the 8 | // contents of gc export data files. 9 | package main 10 | 11 | import ( 12 | "flag" 13 | "fmt" 14 | "go/token" 15 | "go/types" 16 | "log" 17 | "os" 18 | 19 | "golang.org/x/tools/go/gcexportdata" 20 | "golang.org/x/tools/go/types/typeutil" 21 | ) 22 | 23 | func main() { 24 | log.SetPrefix("gcexportdata: ") 25 | log.SetFlags(0) 26 | flag.Usage = func() { 27 | fmt.Fprintln(os.Stderr, "usage: gcexportdata file.a") 28 | } 29 | flag.Parse() 30 | if flag.NArg() != 1 { 31 | flag.Usage() 32 | os.Exit(2) 33 | } 34 | filename := flag.Args()[0] 35 | 36 | f, err := os.Open(filename) 37 | if err != nil { 38 | log.Fatal(err) 39 | } 40 | 41 | r, err := gcexportdata.NewReader(f) 42 | if err != nil { 43 | log.Fatalf("%s: %s", filename, err) 44 | } 45 | 46 | // Decode the package. 47 | imports := make(map[string]*types.Package) 48 | fset := token.NewFileSet() 49 | pkg, err := gcexportdata.Read(r, fset, imports, "dummy") 50 | if err != nil { 51 | log.Fatal("%s: %s", filename, err) 52 | } 53 | 54 | // Print all package-level declarations, including non-exported ones. 55 | fmt.Printf("package %s\n", pkg.Name()) 56 | for _, imp := range pkg.Imports() { 57 | fmt.Printf("import %q\n", imp.Path()) 58 | } 59 | qual := func(p *types.Package) string { 60 | if pkg == p { 61 | return "" 62 | } 63 | return p.Name() 64 | } 65 | scope := pkg.Scope() 66 | for _, name := range scope.Names() { 67 | obj := scope.Lookup(name) 68 | fmt.Printf("%s: %s\n", 69 | fset.Position(obj.Pos()), 70 | types.ObjectString(obj, qual)) 71 | 72 | // For types, print each method. 73 | if _, ok := obj.(*types.TypeName); ok { 74 | for _, method := range typeutil.IntuitiveMethodSet(obj.Type(), nil) { 75 | fmt.Printf("%s: %s\n", 76 | fset.Position(method.Obj().Pos()), 77 | types.SelectionString(method, qual)) 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /_tools/src/golang.org/x/tools/go/gcimporter15/exportdata.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file is a copy of $GOROOT/src/go/internal/gcimporter/exportdata.go. 6 | 7 | // This file implements FindExportData. 8 | 9 | package gcimporter 10 | 11 | import ( 12 | "bufio" 13 | "fmt" 14 | "io" 15 | "strconv" 16 | "strings" 17 | ) 18 | 19 | func readGopackHeader(r *bufio.Reader) (name string, size int, err error) { 20 | // See $GOROOT/include/ar.h. 21 | hdr := make([]byte, 16+12+6+6+8+10+2) 22 | _, err = io.ReadFull(r, hdr) 23 | if err != nil { 24 | return 25 | } 26 | // leave for debugging 27 | if false { 28 | fmt.Printf("header: %s", hdr) 29 | } 30 | s := strings.TrimSpace(string(hdr[16+12+6+6+8:][:10])) 31 | size, err = strconv.Atoi(s) 32 | if err != nil || hdr[len(hdr)-2] != '`' || hdr[len(hdr)-1] != '\n' { 33 | err = fmt.Errorf("invalid archive header") 34 | return 35 | } 36 | name = strings.TrimSpace(string(hdr[:16])) 37 | return 38 | } 39 | 40 | // FindExportData positions the reader r at the beginning of the 41 | // export data section of an underlying GC-created object/archive 42 | // file by reading from it. The reader must be positioned at the 43 | // start of the file before calling this function. The hdr result 44 | // is the string before the export data, either "$$" or "$$B". 45 | // 46 | func FindExportData(r *bufio.Reader) (hdr string, err error) { 47 | // Read first line to make sure this is an object file. 48 | line, err := r.ReadSlice('\n') 49 | if err != nil { 50 | err = fmt.Errorf("can't find export data (%v)", err) 51 | return 52 | } 53 | 54 | if string(line) == "!\n" { 55 | // Archive file. Scan to __.PKGDEF. 56 | var name string 57 | if name, _, err = readGopackHeader(r); err != nil { 58 | return 59 | } 60 | 61 | // First entry should be __.PKGDEF. 62 | if name != "__.PKGDEF" { 63 | err = fmt.Errorf("go archive is missing __.PKGDEF") 64 | return 65 | } 66 | 67 | // Read first line of __.PKGDEF data, so that line 68 | // is once again the first line of the input. 69 | if line, err = r.ReadSlice('\n'); err != nil { 70 | err = fmt.Errorf("can't find export data (%v)", err) 71 | return 72 | } 73 | } 74 | 75 | // Now at __.PKGDEF in archive or still at beginning of file. 76 | // Either way, line should begin with "go object ". 77 | if !strings.HasPrefix(string(line), "go object ") { 78 | err = fmt.Errorf("not a Go object file") 79 | return 80 | } 81 | 82 | // Skip over object header to export data. 83 | // Begins after first line starting with $$. 84 | for line[0] != '$' { 85 | if line, err = r.ReadSlice('\n'); err != nil { 86 | err = fmt.Errorf("can't find export data (%v)", err) 87 | return 88 | } 89 | } 90 | hdr = string(line) 91 | 92 | return 93 | } 94 | -------------------------------------------------------------------------------- /_tools/src/golang.org/x/tools/go/gcimporter15/isAlias18.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 gcimporter 8 | 9 | import "go/types" 10 | 11 | func isAlias(obj *types.TypeName) bool { 12 | return false // there are no type aliases before Go 1.9 13 | } 14 | -------------------------------------------------------------------------------- /_tools/src/golang.org/x/tools/go/gcimporter15/isAlias19.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 gcimporter 8 | 9 | import "go/types" 10 | 11 | func isAlias(obj *types.TypeName) bool { 12 | return obj.IsAlias() 13 | } 14 | -------------------------------------------------------------------------------- /_tools/src/golang.org/x/tools/go/loader/cgo_pkgconfig.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 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 loader 6 | 7 | import ( 8 | "errors" 9 | "fmt" 10 | "go/build" 11 | "os/exec" 12 | "strings" 13 | ) 14 | 15 | // pkgConfig runs pkg-config with the specified arguments and returns the flags it prints. 16 | func pkgConfig(mode string, pkgs []string) (flags []string, err error) { 17 | cmd := exec.Command("pkg-config", append([]string{mode}, pkgs...)...) 18 | out, err := cmd.CombinedOutput() 19 | if err != nil { 20 | s := fmt.Sprintf("%s failed: %v", strings.Join(cmd.Args, " "), err) 21 | if len(out) > 0 { 22 | s = fmt.Sprintf("%s: %s", s, out) 23 | } 24 | return nil, errors.New(s) 25 | } 26 | if len(out) > 0 { 27 | flags = strings.Fields(string(out)) 28 | } 29 | return 30 | } 31 | 32 | // pkgConfigFlags calls pkg-config if needed and returns the cflags 33 | // needed to build the package. 34 | func pkgConfigFlags(p *build.Package) (cflags []string, err error) { 35 | if len(p.CgoPkgConfig) == 0 { 36 | return nil, nil 37 | } 38 | return pkgConfig("--cflags", p.CgoPkgConfig) 39 | } 40 | -------------------------------------------------------------------------------- /_tools/src/golang.org/x/tools/go/loader/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 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 loader 6 | 7 | import ( 8 | "go/ast" 9 | "go/build" 10 | "go/parser" 11 | "go/token" 12 | "io" 13 | "os" 14 | "strconv" 15 | "sync" 16 | 17 | "golang.org/x/tools/go/buildutil" 18 | ) 19 | 20 | // We use a counting semaphore to limit 21 | // the number of parallel I/O calls per process. 22 | var ioLimit = make(chan bool, 10) 23 | 24 | // parseFiles parses the Go source files within directory dir and 25 | // returns the ASTs of the ones that could be at least partially parsed, 26 | // along with a list of I/O and parse errors encountered. 27 | // 28 | // I/O is done via ctxt, which may specify a virtual file system. 29 | // displayPath is used to transform the filenames attached to the ASTs. 30 | // 31 | func parseFiles(fset *token.FileSet, ctxt *build.Context, displayPath func(string) string, dir string, files []string, mode parser.Mode) ([]*ast.File, []error) { 32 | if displayPath == nil { 33 | displayPath = func(path string) string { return path } 34 | } 35 | var wg sync.WaitGroup 36 | n := len(files) 37 | parsed := make([]*ast.File, n) 38 | errors := make([]error, n) 39 | for i, file := range files { 40 | if !buildutil.IsAbsPath(ctxt, file) { 41 | file = buildutil.JoinPath(ctxt, dir, file) 42 | } 43 | wg.Add(1) 44 | go func(i int, file string) { 45 | ioLimit <- true // wait 46 | defer func() { 47 | wg.Done() 48 | <-ioLimit // signal 49 | }() 50 | var rd io.ReadCloser 51 | var err error 52 | if ctxt.OpenFile != nil { 53 | rd, err = ctxt.OpenFile(file) 54 | } else { 55 | rd, err = os.Open(file) 56 | } 57 | if err != nil { 58 | errors[i] = err // open failed 59 | return 60 | } 61 | 62 | // ParseFile may return both an AST and an error. 63 | parsed[i], errors[i] = parser.ParseFile(fset, displayPath(file), rd, mode) 64 | rd.Close() 65 | }(i, file) 66 | } 67 | wg.Wait() 68 | 69 | // Eliminate nils, preserving order. 70 | var o int 71 | for _, f := range parsed { 72 | if f != nil { 73 | parsed[o] = f 74 | o++ 75 | } 76 | } 77 | parsed = parsed[:o] 78 | 79 | o = 0 80 | for _, err := range errors { 81 | if err != nil { 82 | errors[o] = err 83 | o++ 84 | } 85 | } 86 | errors = errors[:o] 87 | 88 | return parsed, errors 89 | } 90 | 91 | // scanImports returns the set of all import paths from all 92 | // import specs in the specified files. 93 | func scanImports(files []*ast.File) map[string]bool { 94 | imports := make(map[string]bool) 95 | for _, f := range files { 96 | for _, decl := range f.Decls { 97 | if decl, ok := decl.(*ast.GenDecl); ok && decl.Tok == token.IMPORT { 98 | for _, spec := range decl.Specs { 99 | spec := spec.(*ast.ImportSpec) 100 | 101 | // NB: do not assume the program is well-formed! 102 | path, err := strconv.Unquote(spec.Path.Value) 103 | if err != nil { 104 | continue // quietly ignore the error 105 | } 106 | if path == "C" { 107 | continue // skip pseudopackage 108 | } 109 | imports[path] = true 110 | } 111 | } 112 | } 113 | } 114 | return imports 115 | } 116 | 117 | // ---------- Internal helpers ---------- 118 | 119 | // TODO(adonovan): make this a method: func (*token.File) Contains(token.Pos) 120 | func tokenFileContainsPos(f *token.File, pos token.Pos) bool { 121 | p := int(pos) 122 | base := f.Base() 123 | return base <= p && p < base+f.Size() 124 | } 125 | -------------------------------------------------------------------------------- /add.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func (s spec) add(t *tool) { 4 | if s.find(t) != -1 { 5 | log(t.Repository + " already installed (did you mean retool upgrade?)") 6 | return 7 | } 8 | 9 | s.Tools = append(s.Tools, t) 10 | 11 | s.sync() 12 | 13 | err := s.write() 14 | if err != nil { 15 | fatal("unable to add "+t.Repository, err) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /build.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // builds all tools in the spec file using whatever is installed in the tool directory (_tools, 4 | // typically). Shouldn't do any network if _tools is set up correctly. 5 | func (s spec) build() { 6 | err := setGoEnv() 7 | if err != nil { 8 | fatal("unable to set GOPATH and GOBIN env variables", err) 9 | } 10 | 11 | m := getManifest() 12 | for _, t := range s.Tools { 13 | err := install(t) 14 | if err != nil { 15 | fatalExec("go install "+t.Repository, err) 16 | } 17 | } 18 | m.replace(s.Tools) 19 | m.write() 20 | } 21 | -------------------------------------------------------------------------------- /clean_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "path/filepath" 5 | "testing" 6 | ) 7 | 8 | func TestIsLegalFile(t *testing.T) { 9 | testcase := func(filename string, want bool) { 10 | t.Run(filename, func(t *testing.T) { 11 | have := isLegalFile(filename) 12 | if have != want { 13 | t.Fail() 14 | } 15 | }) 16 | } 17 | 18 | testcase("license.md", true) 19 | testcase("license.txt", true) 20 | testcase("LICENSE", true) 21 | testcase("LICENCE", true) 22 | testcase("LICENSE.md", true) 23 | testcase(filepath.Join("pkg", "LICENSE.md"), true) 24 | testcase("LEGAL", true) 25 | testcase("README", true) 26 | testcase("COPYING", true) 27 | testcase("COPYRIGHT", true) 28 | testcase("UNLICENSE", true) 29 | testcase("PATENTS", true) 30 | 31 | testcase(filepath.Join("pat", "ents"), false) 32 | testcase("picture.jpeg", false) 33 | } 34 | 35 | func TestKeep(t *testing.T) { 36 | testcase := func(filename string, want bool) { 37 | t.Run(filename, func(t *testing.T) { 38 | have := keepFile(filename) 39 | if have != want { 40 | t.Fail() 41 | } 42 | }) 43 | } 44 | 45 | testcase("program.go", true) 46 | testcase("program_test.go", false) 47 | testcase(filepath.Join("pkg", "program.go"), true) 48 | testcase(filepath.Join("pkg", "program_test.go"), false) 49 | 50 | testcase("assembly.s", true) 51 | testcase("notassembly.as", false) 52 | testcase("sqlite.c", true) 53 | testcase("spec", false) 54 | testcase("sqlite.h", true) 55 | testcase("picture.gif", false) 56 | testcase("LICENSE.md", true) 57 | } 58 | -------------------------------------------------------------------------------- /do.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "os/exec" 6 | "path/filepath" 7 | "strings" 8 | ) 9 | 10 | func setPath() error { 11 | prevpath := os.Getenv("PATH") 12 | newPath := filepath.Join(toolDirPath, "bin") + string(os.PathListSeparator) + prevpath 13 | return os.Setenv("PATH", newPath) 14 | } 15 | 16 | // setGoEnv sets GOBIN and GOPATH to point to _tools/bin and $GOPATH:_tools, 17 | // respectively. This is done for github.com/alecthomas/gometalinter 18 | // compatibility: gometalinter vendors its own linters, and checks for their 19 | // existence by checking in each GOPATH entry for 20 | // src/github.com/alecthomas/gometalinter/_linters. 21 | // 22 | // GOBIN is set so gometalinter will use it to decide where to put its vendored 23 | // linters with the gometalinter --install command, and so that it prefers the 24 | // binaries built in _tools/bin when executing linters. 25 | func setGoEnv() error { 26 | newGoBin := filepath.Join(toolDirPath, "bin") 27 | if err := os.Setenv("GOBIN", newGoBin); err != nil { 28 | return err 29 | } 30 | 31 | prevGoPath := os.Getenv("GOPATH") 32 | if prevGoPath == "" { 33 | prevGoPath = filepath.Join(os.Getenv("HOME"), "go") 34 | } 35 | newGoPath := prevGoPath + string(os.PathListSeparator) + toolDirPath 36 | return os.Setenv("GOPATH", newGoPath) 37 | } 38 | 39 | func do() { 40 | args := positionalArgs 41 | if len(args) == 0 { 42 | fatal("no command passed to retool do", nil) 43 | } 44 | 45 | if err := setPath(); err != nil { 46 | fatal("unable to set PATH", err) 47 | } 48 | if err := setGoEnv(); err != nil { 49 | fatal("unable to set up go environment variables", err) 50 | } 51 | 52 | cmd := exec.Command(args[0], args[1:]...) 53 | cmd.Stdin = os.Stdin 54 | cmd.Stderr = os.Stderr 55 | cmd.Stdout = os.Stdout 56 | 57 | err := cmd.Run() 58 | if err != nil { 59 | msg := "failed on '" + strings.Join(args, " ") + "'" 60 | fatal(msg, err) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/Masterminds/semver" 9 | ) 10 | 11 | var version = semver.MustParse("v1.3.7") 12 | 13 | func main() { 14 | flag.Parse() 15 | if err := ensureTooldir(); err != nil { 16 | fatal("failed to locate or create tool directory", err) 17 | } 18 | cmd, tool := parseArgs() 19 | 20 | if cmd == "version" { 21 | fmt.Fprintf(os.Stdout, "retool %s", version) 22 | os.Exit(0) 23 | } 24 | 25 | if !specExists() { 26 | if cmd == "add" { 27 | err := writeBlankSpec() 28 | if err != nil { 29 | fatal("failed to write blank spec", err) 30 | } 31 | } else { 32 | fatal("tools.json does not yet exist. You need to add a tool first with 'retool add'", nil) 33 | } 34 | } 35 | 36 | s, err := read() 37 | if err != nil { 38 | fatal("failed to load tools.json", err) 39 | } 40 | 41 | switch cmd { 42 | case "add": 43 | s.add(tool) 44 | case "upgrade": 45 | s.upgrade(tool) 46 | case "remove": 47 | s.remove(tool) 48 | case "build": 49 | s.build() 50 | case "sync": 51 | s.sync() 52 | case "do": 53 | s.sync() 54 | do() 55 | case "clean": 56 | log("the clean subcommand is deprecated and has no effect") 57 | default: 58 | fatal(fmt.Sprintf("unknown cmd %q", cmd), nil) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /manifest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "os" 6 | "path/filepath" 7 | ) 8 | 9 | const manifestFile = "manifest.json" 10 | 11 | type manifest map[string]string 12 | 13 | func getManifest() manifest { 14 | m := manifest{} 15 | 16 | file, err := os.Open(filepath.Join(toolDirPath, manifestFile)) 17 | if err != nil { 18 | return m 19 | } 20 | defer func() { 21 | _ = file.Close() 22 | }() 23 | 24 | err = json.NewDecoder(file).Decode(&m) 25 | if err != nil { 26 | fatal("Failed to decode manifest", err) 27 | } 28 | return m 29 | } 30 | 31 | func (m manifest) write() { 32 | f, err := os.Create(filepath.Join(toolDirPath, manifestFile)) 33 | if err != nil { 34 | return 35 | } 36 | defer func() { 37 | _ = f.Close() 38 | }() 39 | 40 | bytes, err := json.MarshalIndent(m, "", " ") 41 | if err != nil { 42 | return 43 | } 44 | 45 | _, _ = f.Write(bytes) 46 | } 47 | 48 | func (m manifest) outOfDate(ts []*tool) bool { 49 | // Make a copy to check for elements in ts but not m 50 | m2 := make(map[string]string) 51 | for k, v := range m { 52 | m2[k] = v 53 | } 54 | 55 | for _, t := range ts { 56 | if v, ok := m[t.Repository]; !ok || v != t.Commit { 57 | return true 58 | } 59 | delete(m2, t.Repository) 60 | } 61 | 62 | return len(m2) != 0 63 | } 64 | 65 | func (m manifest) replace(ts []*tool) { 66 | for k := range m { 67 | delete(m, k) 68 | } 69 | for _, t := range ts { 70 | m[t.Repository] = t.Commit 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /print.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "os/exec" 7 | 8 | "github.com/pkg/errors" 9 | ) 10 | 11 | func log(msg string) { 12 | fmt.Fprintf(os.Stderr, "retool: %s\n", msg) 13 | } 14 | 15 | func fatal(msg string, err error) { 16 | if err == nil { 17 | fmt.Fprintf(os.Stderr, "retool: fatal err: %s\n", msg) 18 | } else { 19 | fmt.Fprintf(os.Stderr, "retool: fatal err: %s: %s\n", msg, err) 20 | } 21 | os.Exit(1) 22 | } 23 | 24 | func fatalExec(cmd string, err error) { 25 | if exErr, ok := errors.Cause(err).(*exec.ExitError); ok { 26 | fatal(fmt.Sprintf("execution error on %q: %s", cmd, exErr.Stderr), err) 27 | } else { 28 | fatal(fmt.Sprintf("execution error on %q", cmd), err) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /remove.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func (s spec) remove(t *tool) { 4 | idx := s.find(t) 5 | if idx == -1 { 6 | fatal(t.Repository+" is not in tools.json", nil) 7 | } 8 | s.Tools = append(s.Tools[:idx], s.Tools[idx+1:]...) 9 | err := s.write() 10 | if err != nil { 11 | fatal("unable to remove "+t.Repository, err) 12 | } 13 | 14 | s.sync() 15 | } 16 | -------------------------------------------------------------------------------- /retool_nonwindows_test.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package main 4 | 5 | import ( 6 | "io/ioutil" 7 | "os" 8 | "path/filepath" 9 | "testing" 10 | ) 11 | 12 | // Go builds files on windows with an '.exe' suffix. Everywhere else, there's no 13 | // suffix. 14 | const osBinSuffix = "" 15 | 16 | // Test that we correctly preserve .c and .h files by running a test against a 17 | // command that uses go-sqlite3. 18 | // 19 | // This test can only be run on non-windows platforms because go-sqlite3 cannot 20 | // be built on windows. 21 | func TestCSourceFilePreservation(t *testing.T) { 22 | t.Parallel() 23 | 24 | retool, err := buildRetool() 25 | if err != nil { 26 | t.Fatal(err) 27 | } 28 | defer func() { 29 | _ = os.RemoveAll(filepath.Dir(retool)) 30 | }() 31 | 32 | dir, err := ioutil.TempDir("", "") 33 | if err != nil { 34 | t.Fatalf("unable to make temp dir: %s", err) 35 | } 36 | defer func() { 37 | _ = os.RemoveAll(dir) 38 | }() 39 | runRetoolCmd(t, dir, retool, "add", "github.com/spenczar/sqlite_retool_testcmd", "origin/master") 40 | runRetoolCmd(t, dir, retool, "build") 41 | } 42 | -------------------------------------------------------------------------------- /retool_windows_test.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package main 4 | 5 | // Go builds files on windows with an '.exe' suffix, so we need a few pieces of 6 | // special logic to make sure things work there. 7 | const osBinSuffix = ".exe" 8 | -------------------------------------------------------------------------------- /spec.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "os" 7 | "path/filepath" 8 | 9 | "github.com/Masterminds/semver" 10 | ) 11 | 12 | // Filename to read/write the spec data. 13 | const specfile = "tools.json" 14 | 15 | type spec struct { 16 | Tools []*tool 17 | RetoolVersion *semver.Version 18 | } 19 | 20 | // jsonSpec is a helper type to describe the JSON encoding of a spec 21 | type jsonSpec struct { 22 | Tools []*tool 23 | RetoolVersion string 24 | } 25 | 26 | func (s *spec) UnmarshalJSON(data []byte) error { 27 | js := new(jsonSpec) 28 | if err := json.Unmarshal(data, js); err != nil { 29 | return err 30 | } 31 | if js.RetoolVersion != "" { 32 | v, err := semver.NewVersion(js.RetoolVersion) 33 | if err != nil { 34 | return err 35 | } 36 | s.RetoolVersion = v 37 | } 38 | s.Tools = js.Tools 39 | return nil 40 | } 41 | 42 | func (s spec) MarshalJSON() ([]byte, error) { 43 | return json.Marshal(&jsonSpec{ 44 | Tools: s.Tools, 45 | RetoolVersion: s.RetoolVersion.String(), 46 | }) 47 | } 48 | 49 | func (s spec) write() error { 50 | specfilePath := filepath.Join(baseDirPath, specfile) 51 | 52 | f, err := os.Create(specfilePath) 53 | if err != nil { 54 | return fmt.Errorf("unable to open %s: %s", specfile, err) 55 | } 56 | defer func() { 57 | _ = f.Close() 58 | }() 59 | 60 | // s.write() is called when we have successfully added, removed, or upgraded a 61 | // tool. The success of that operation indicates that we should be comfortable 62 | // bumping up this version. 63 | s.RetoolVersion = version 64 | 65 | bytes, err := json.MarshalIndent(s, "", " ") 66 | if err != nil { 67 | return fmt.Errorf("unable to marshal json spec: %s", err) 68 | } 69 | 70 | _, err = f.Write(bytes) 71 | if err != nil { 72 | return fmt.Errorf("unable to write %s: %s", specfile, err) 73 | } 74 | 75 | return nil 76 | } 77 | 78 | func (s spec) find(t *tool) int { 79 | for i, tt := range s.Tools { 80 | if t.Repository == tt.Repository { 81 | return i 82 | } 83 | } 84 | return -1 85 | } 86 | 87 | func (s spec) cleanup() { 88 | var pkgs []string 89 | for _, t := range s.Tools { 90 | pkgs = append(pkgs, t.Repository) 91 | } 92 | clean(pkgs) 93 | } 94 | 95 | func readPath(path string) (spec, error) { 96 | file, err := os.Open(path) 97 | if err != nil { 98 | return spec{}, fmt.Errorf("unable to open spec file at %s: %s", path, err) 99 | } 100 | defer func() { 101 | _ = file.Close() 102 | }() 103 | 104 | s := new(spec) 105 | err = json.NewDecoder(file).Decode(s) 106 | if err != nil { 107 | return spec{}, err 108 | } 109 | return *s, nil 110 | } 111 | 112 | func read() (spec, error) { 113 | specfilePath := filepath.Join(baseDirPath, specfile) 114 | return readPath(specfilePath) 115 | } 116 | 117 | func specExists() bool { 118 | specfilePath := filepath.Join(baseDirPath, specfile) 119 | 120 | _, err := os.Stat(specfilePath) 121 | if os.IsNotExist(err) { 122 | return false 123 | } 124 | if err != nil { 125 | fatal("unable to stat tools.json: %s", err) 126 | } 127 | return true 128 | } 129 | 130 | func writeBlankSpec() error { 131 | return spec{ 132 | Tools: []*tool{}, 133 | RetoolVersion: version, 134 | }.write() 135 | } 136 | -------------------------------------------------------------------------------- /spec_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "path/filepath" 5 | "testing" 6 | 7 | "github.com/Masterminds/semver" 8 | ) 9 | 10 | func TestSpecVersioning(t *testing.T) { 11 | readTest := func(file string, wantVersion *semver.Version) func(*testing.T) { 12 | return func(t *testing.T) { 13 | t.Parallel() 14 | path := filepath.Join("testdata", "specs", file) 15 | s, err := readPath(path) 16 | if err != nil { 17 | t.Fatalf("unable to read spec file: %s", err) 18 | } 19 | 20 | if wantVersion == nil { 21 | if s.RetoolVersion != nil { 22 | t.Errorf("unexpected spec retool version, have=%q want=nil", s.RetoolVersion) 23 | } 24 | } else if !s.RetoolVersion.Equal(wantVersion) { 25 | t.Errorf("unexpected spec retool version, have=%q want=%q", s.RetoolVersion, wantVersion) 26 | } 27 | } 28 | } 29 | 30 | t.Run("read", func(t *testing.T) { 31 | t.Parallel() 32 | t.Run("unversioned", readTest("unversioned.json", nil)) 33 | t.Run("v1.2.0", readTest("v1.2.0.json", semver.MustParse("v1.2.0"))) 34 | }) 35 | } 36 | -------------------------------------------------------------------------------- /sync.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "os" 4 | 5 | func (s spec) sync() { 6 | m := getManifest() 7 | if m.outOfDate(s.Tools) { 8 | // Delete existing tools directory 9 | err := os.RemoveAll(toolDirPath) 10 | if err != nil { 11 | fatalExec("failed to remove _tools ", err) 12 | } 13 | 14 | // Recreate the tools directory 15 | err = ensureTooldir() 16 | if err != nil { 17 | fatal("failed to ensure tool dir", err) 18 | } 19 | 20 | // Download everything to tool directory 21 | for _, t := range s.Tools { 22 | err = download(t) 23 | if err != nil { 24 | fatalExec("failed to sync "+t.Repository, err) 25 | } 26 | } 27 | 28 | // Install the packages 29 | s.build() 30 | 31 | // Delete unneccessary source files 32 | s.cleanup() 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /testdata/specs/unversioned.json: -------------------------------------------------------------------------------- 1 | { 2 | "Tools": [ 3 | { 4 | "Repository": "github.com/golang/lint/golint", 5 | "Commit": "cb00e5669539f047b2f4c53a421a01b0c8e172c6" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /testdata/specs/v1.2.0.json: -------------------------------------------------------------------------------- 1 | { 2 | "Tools": [ 3 | { 4 | "Repository": "github.com/golang/lint/golint", 5 | "Commit": "cb00e5669539f047b2f4c53a421a01b0c8e172c6" 6 | } 7 | ], 8 | "RetoolVersion": "v1.2.0" 9 | } 10 | -------------------------------------------------------------------------------- /tool.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "os/exec" 7 | "path/filepath" 8 | "strings" 9 | 10 | "github.com/pkg/errors" 11 | ) 12 | 13 | type tool struct { 14 | Repository string // eg "github.com/tools/godep" 15 | Commit string // eg "3020345802e4bff23902cfc1d19e90a79fae714e" 16 | ref string // eg "origin/master" 17 | Fork string `json:"Fork,omitempty"` // eg "code.jusin.tv/twitch/godep" 18 | } 19 | 20 | func (t *tool) path() string { 21 | return filepath.Join(toolDirPath, "src", t.Repository) 22 | } 23 | 24 | func (t *tool) executable() string { 25 | return filepath.Base(t.Repository) 26 | } 27 | 28 | func setEnvVar(cmd *exec.Cmd, key, val string) { 29 | var env []string 30 | if cmd.Env != nil { 31 | env = cmd.Env 32 | } else { 33 | env = os.Environ() 34 | } 35 | 36 | envSet := false 37 | for i, envVar := range env { 38 | if strings.HasPrefix(envVar, key+"=") { 39 | env[i] = key + "=" + val 40 | envSet = true 41 | } 42 | } 43 | if !envSet { 44 | env = append(env, key+"="+val) 45 | } 46 | 47 | cmd.Env = env 48 | } 49 | 50 | func get(t *tool) error { 51 | log("downloading " + t.Repository) 52 | cmd := exec.Command("go", "get", "-d", t.Repository) 53 | setEnvVar(cmd, "GOPATH", toolDirPath) 54 | _, err := cmd.Output() 55 | if err != nil { 56 | return errors.Wrap(err, "failed to 'go get' tool") 57 | } 58 | return err 59 | } 60 | 61 | func setVersion(t *tool) error { 62 | // If we're using a fork, add it 63 | if t.Fork != "" { 64 | cmd := exec.Command("git", "remote") 65 | cmd.Dir = t.path() 66 | b, err := cmd.Output() 67 | if err != nil { 68 | return err 69 | } 70 | 71 | rs := strings.Split(string(b), "\n") 72 | containsFork := false 73 | for _, r := range rs { 74 | if r == "fork" { 75 | containsFork = true 76 | break 77 | } 78 | } 79 | 80 | if containsFork { 81 | cmd = exec.Command("git", "remote", "rm", "fork") 82 | cmd.Dir = t.path() 83 | _, err = cmd.Output() 84 | if err != nil { 85 | return err 86 | } 87 | } 88 | 89 | cmd = exec.Command("git", "remote", "add", "-f", "fork", t.Fork) 90 | cmd.Dir = t.path() 91 | _, err = cmd.Output() 92 | if err != nil { 93 | return err 94 | } 95 | } 96 | 97 | log("setting version for " + t.Repository) 98 | cmd := exec.Command("git", "fetch") 99 | cmd.Dir = t.path() 100 | _, err := cmd.Output() 101 | if err != nil { 102 | return err 103 | } 104 | 105 | // If we have a symbolic reference, parse it 106 | if t.ref != "" { 107 | log(fmt.Sprintf("parsing revision %q", t.ref)) 108 | cmd = exec.Command("git", "rev-parse", t.ref) 109 | cmd.Dir = t.path() 110 | 111 | var out []byte 112 | out, err = cmd.Output() 113 | if err != nil { 114 | return err 115 | } 116 | t.Commit = strings.TrimSpace(string(out)) 117 | log(fmt.Sprintf("parsed as %q", t.Commit)) 118 | } 119 | 120 | cmd = exec.Command("git", "checkout", t.Commit) 121 | cmd.Dir = t.path() 122 | _, err = cmd.Output() 123 | if err != nil { 124 | return errors.Wrap(err, "failed to 'git checkout' tool") 125 | } 126 | 127 | // Re-run 'go get' in case the new version has a different set of dependencies. 128 | cmd = exec.Command("go", "get", "-d", t.Repository) 129 | setEnvVar(cmd, "GOPATH", toolDirPath) 130 | _, err = cmd.Output() 131 | if err != nil { 132 | return errors.Wrap(err, "failed to 'go get' tool") 133 | } 134 | return err 135 | } 136 | 137 | func download(t *tool) error { 138 | err := get(t) 139 | if err != nil { 140 | fatalExec("go get -d "+t.Repository, err) 141 | } 142 | 143 | err = setVersion(t) 144 | if err != nil { 145 | fatalExec("git checkout "+t.Commit, err) 146 | } 147 | 148 | return nil 149 | } 150 | 151 | func install(t *tool) error { 152 | log("installing " + t.Repository) 153 | cmd := exec.Command("go", "install", t.Repository) 154 | setEnvVar(cmd, "GOPATH", toolDirPath) 155 | _, err := cmd.Output() 156 | if err != nil { 157 | return errors.Wrap(err, "failed to 'go install' tool") 158 | } 159 | return err 160 | } 161 | -------------------------------------------------------------------------------- /tooldir.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "io/ioutil" 6 | "os" 7 | "os/exec" 8 | "path" 9 | "path/filepath" 10 | "strings" 11 | "syscall" 12 | 13 | "github.com/pkg/errors" 14 | ) 15 | 16 | const ( 17 | toolDirName = "_tools" 18 | ) 19 | 20 | var ( 21 | baseDir = flag.String("base-dir", "", 22 | "Path of project root. If not specified and the working directory is within a git repository, the root of "+ 23 | "the repository is used. If the working directory is not within a git repository, the working directory "+ 24 | "is used.") 25 | toolDir = flag.String("tool-dir", "", 26 | "Path where tools are stored. The default value is the subdirectory of -base-dir named '_tools'.") 27 | 28 | // These globals are set by ensureTooldir() after factoring in the flags above. 29 | baseDirPath string 30 | toolDirPath string 31 | ) 32 | 33 | // If the working directory is within a git repository, return the path of the repository's root; otherwise, return the 34 | // empty string. An error is returned iff invoking 'git' fails for some other reason. 35 | func getRepoRoot() (string, error) { 36 | cmd := exec.Command("git", "rev-parse", "--show-toplevel") 37 | stdout, err := cmd.Output() 38 | if err != nil { 39 | if exitErr, ok := err.(*exec.ExitError); ok { 40 | exitStatus := exitErr.Sys().(syscall.WaitStatus).ExitStatus() 41 | if exitStatus == 128 { // not in a repository 42 | return "", nil 43 | } 44 | } 45 | return "", errors.Wrap(err, "failed to invoke git") 46 | } 47 | repoRoot := strings.TrimSpace(string(stdout)) 48 | return repoRoot, nil 49 | } 50 | 51 | func ensureTooldir() error { 52 | var err error 53 | 54 | baseDirPath = *baseDir 55 | if baseDirPath == "" { 56 | var repoRootPath string 57 | repoRootPath, err = getRepoRoot() 58 | if err != nil { 59 | return errors.Wrap(err, "failed to check for enclosing git repository") 60 | } 61 | if repoRootPath == "" { 62 | baseDirPath, err = os.Getwd() 63 | if err != nil { 64 | return errors.Wrap(err, "failed to get working directory") 65 | } 66 | } else { 67 | baseDirPath = repoRootPath 68 | } 69 | } 70 | 71 | toolDirPath = *toolDir 72 | if toolDirPath == "" { 73 | toolDirPath = filepath.Join(baseDirPath, toolDirName) 74 | } 75 | 76 | verbosef("base dir: %v\n", baseDirPath) 77 | verbosef("tool dir: %v\n", toolDirPath) 78 | 79 | stat, err := os.Stat(toolDirPath) 80 | switch { 81 | case os.IsNotExist(err): 82 | err = os.Mkdir(toolDirPath, 0777) 83 | if err != nil { 84 | return errors.Wrap(err, "unable to create tooldir") 85 | } 86 | case err != nil: 87 | return errors.Wrap(err, "unable to stat tool directory") 88 | case !stat.IsDir(): 89 | return errors.New("tool directory already exists, but it is not a directory; you can use -tool-dir to change where tools are saved") 90 | } 91 | 92 | err = ioutil.WriteFile(path.Join(toolDirPath, ".gitignore"), gitignore, 0664) 93 | if err != nil { 94 | return errors.Wrap(err, "unable to update .gitignore") 95 | } 96 | 97 | return nil 98 | } 99 | 100 | var gitignore = []byte(strings.TrimLeft(` 101 | /bin/ 102 | /pkg/ 103 | /manifest.json 104 | `, "\n")) 105 | -------------------------------------------------------------------------------- /tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "Tools": [ 3 | { 4 | "Repository": "github.com/golang/lint/golint", 5 | "Commit": "cb00e5669539f047b2f4c53a421a01b0c8e172c6" 6 | }, 7 | { 8 | "Repository": "github.com/tsenart/deadcode", 9 | "Commit": "210d2dc333e90c7e3eedf4f2242507a8e83ed4ab" 10 | }, 11 | { 12 | "Repository": "github.com/opennota/check/cmd/varcheck", 13 | "Commit": "5b00aacd5639507d2b039245a278ec9f5505509f" 14 | }, 15 | { 16 | "Repository": "github.com/opennota/check/cmd/aligncheck", 17 | "Commit": "5b00aacd5639507d2b039245a278ec9f5505509f" 18 | }, 19 | { 20 | "Repository": "github.com/opennota/check/cmd/structcheck", 21 | "Commit": "5b00aacd5639507d2b039245a278ec9f5505509f" 22 | }, 23 | { 24 | "Repository": "github.com/kisielk/errcheck", 25 | "Commit": "db0ca22445717d1b2c51ac1034440e0a2a2de645" 26 | }, 27 | { 28 | "Repository": "github.com/gordonklaus/ineffassign", 29 | "Commit": "99762ed65232b1477364c8c53778f8b6503e868c" 30 | }, 31 | { 32 | "Repository": "github.com/spenczar/go-gh-releaser", 33 | "Commit": "c538a068ce390df2b2a102ad916a986901019e89" 34 | }, 35 | { 36 | "Repository": "github.com/mitchellh/gox", 37 | "Commit": "c9740af9c6574448fd48eb30a71f964014c7a837" 38 | } 39 | ], 40 | "RetoolVersion": "1.3.5" 41 | } -------------------------------------------------------------------------------- /upgrade.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func (s spec) upgrade(t *tool) { 4 | idx := s.find(t) 5 | if idx == -1 { 6 | log(t.Repository + " is not yet installed (did you mean retool add?)") 7 | return 8 | } 9 | 10 | s.Tools[idx] = t 11 | 12 | s.sync() 13 | 14 | err := s.write() 15 | if err != nil { 16 | fatal("unable to remove "+t.Repository, err) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/Masterminds/semver/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.6 5 | - 1.7 6 | - 1.8 7 | - tip 8 | 9 | # Setting sudo access to false will let Travis CI use containers rather than 10 | # VMs to run the tests. For more details see: 11 | # - http://docs.travis-ci.com/user/workers/container-based-infrastructure/ 12 | # - http://docs.travis-ci.com/user/workers/standard-infrastructure/ 13 | sudo: false 14 | 15 | script: 16 | - GO15VENDOREXPERIMENT=1 make setup 17 | - GO15VENDOREXPERIMENT=1 make test 18 | 19 | notifications: 20 | webhooks: 21 | urls: 22 | - https://webhooks.gitter.im/e/06e3328629952dabe3e0 23 | on_success: change # options: [always|never|change] default: always 24 | on_failure: always # options: [always|never|change] default: always 25 | on_start: never # options: [always|never|change] default: always 26 | -------------------------------------------------------------------------------- /vendor/github.com/Masterminds/semver/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Unreleased 2 | 3 | ## Fixed 4 | - #46: Fixed 0.x.x and 0.0.x in constraints being treated as * 5 | 6 | # Release 1.2.2 (2016-12-13) 7 | 8 | ## Fixed 9 | - #34: Fixed issue where hyphen range was not working with pre-release parsing. 10 | 11 | # Release 1.2.1 (2016-11-28) 12 | 13 | ## Fixed 14 | - #24: Fixed edge case issue where constraint "> 0" does not handle "0.0.1-alpha" 15 | properly. 16 | 17 | # Release 1.2.0 (2016-11-04) 18 | 19 | ## Added 20 | - #20: Added MustParse function for versions (thanks @adamreese) 21 | - #15: Added increment methods on versions (thanks @mh-cbon) 22 | 23 | ## Fixed 24 | - Issue #21: Per the SemVer spec (section 9) a pre-release is unstable and 25 | might not satisfy the intended compatibility. The change here ignores pre-releases 26 | on constraint checks (e.g., ~ or ^) when a pre-release is not part of the 27 | constraint. For example, `^1.2.3` will ignore pre-releases while 28 | `^1.2.3-alpha` will include them. 29 | 30 | # Release 1.1.1 (2016-06-30) 31 | 32 | ## Changed 33 | - Issue #9: Speed up version comparison performance (thanks @sdboyer) 34 | - Issue #8: Added benchmarks (thanks @sdboyer) 35 | - Updated Go Report Card URL to new location 36 | - Updated Readme to add code snippet formatting (thanks @mh-cbon) 37 | - Updating tagging to v[SemVer] structure for compatibility with other tools. 38 | 39 | # Release 1.1.0 (2016-03-11) 40 | 41 | - Issue #2: Implemented validation to provide reasons a versions failed a 42 | constraint. 43 | 44 | # Release 1.0.1 (2015-12-31) 45 | 46 | - Fixed #1: * constraint failing on valid versions. 47 | 48 | # Release 1.0.0 (2015-10-20) 49 | 50 | - Initial release 51 | -------------------------------------------------------------------------------- /vendor/github.com/Masterminds/semver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The Masterminds 2 | Copyright (C) 2014-2015, Matt Butcher and Matt Farina 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/Masterminds/semver/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: setup 2 | setup: 3 | go get -u gopkg.in/alecthomas/gometalinter.v1 4 | gometalinter.v1 --install 5 | 6 | .PHONY: test 7 | test: validate lint 8 | @echo "==> Running tests" 9 | go test -v 10 | 11 | .PHONY: validate 12 | validate: 13 | @echo "==> Running static validations" 14 | @gometalinter.v1 \ 15 | --disable-all \ 16 | --enable deadcode \ 17 | --severity deadcode:error \ 18 | --enable gofmt \ 19 | --enable gosimple \ 20 | --enable ineffassign \ 21 | --enable misspell \ 22 | --enable vet \ 23 | --tests \ 24 | --vendor \ 25 | --deadline 60s \ 26 | ./... || exit_code=1 27 | 28 | .PHONY: lint 29 | lint: 30 | @echo "==> Running linters" 31 | @gometalinter.v1 \ 32 | --disable-all \ 33 | --enable golint \ 34 | --vendor \ 35 | --deadline 60s \ 36 | ./... || : 37 | -------------------------------------------------------------------------------- /vendor/github.com/Masterminds/semver/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: build-{build}.{branch} 2 | 3 | clone_folder: C:\gopath\src\github.com\Masterminds\semver 4 | shallow_clone: true 5 | 6 | environment: 7 | GOPATH: C:\gopath 8 | 9 | platform: 10 | - x64 11 | 12 | install: 13 | - go version 14 | - go env 15 | - go get -u gopkg.in/alecthomas/gometalinter.v1 16 | - set PATH=%PATH%;%GOPATH%\bin 17 | - gometalinter.v1.exe --install 18 | 19 | build_script: 20 | - go install -v ./... 21 | 22 | test_script: 23 | - "gometalinter.v1 \ 24 | --disable-all \ 25 | --enable deadcode \ 26 | --severity deadcode:error \ 27 | --enable gofmt \ 28 | --enable gosimple \ 29 | --enable ineffassign \ 30 | --enable misspell \ 31 | --enable vet \ 32 | --tests \ 33 | --vendor \ 34 | --deadline 60s \ 35 | ./... || exit_code=1" 36 | - "gometalinter.v1 \ 37 | --disable-all \ 38 | --enable golint \ 39 | --vendor \ 40 | --deadline 60s \ 41 | ./... || :" 42 | - go test -v 43 | 44 | deploy: off 45 | -------------------------------------------------------------------------------- /vendor/github.com/Masterminds/semver/collection.go: -------------------------------------------------------------------------------- 1 | package semver 2 | 3 | // Collection is a collection of Version instances and implements the sort 4 | // interface. See the sort package for more details. 5 | // https://golang.org/pkg/sort/ 6 | type Collection []*Version 7 | 8 | // Len returns the length of a collection. The number of Version instances 9 | // on the slice. 10 | func (c Collection) Len() int { 11 | return len(c) 12 | } 13 | 14 | // Less is needed for the sort interface to compare two Version objects on the 15 | // slice. If checks if one is less than the other. 16 | func (c Collection) Less(i, j int) bool { 17 | return c[i].LessThan(c[j]) 18 | } 19 | 20 | // Swap is needed for the sort interface to replace the Version objects 21 | // at two different positions in the slice. 22 | func (c Collection) Swap(i, j int) { 23 | c[i], c[j] = c[j], c[i] 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/Masterminds/semver/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package semver provides the ability to work with Semantic Versions (http://semver.org) in Go. 3 | 4 | Specifically it provides the ability to: 5 | 6 | * Parse semantic versions 7 | * Sort semantic versions 8 | * Check if a semantic version fits within a set of constraints 9 | * Optionally work with a `v` prefix 10 | 11 | Parsing Semantic Versions 12 | 13 | To parse a semantic version use the `NewVersion` function. For example, 14 | 15 | v, err := semver.NewVersion("1.2.3-beta.1+build345") 16 | 17 | If there is an error the version wasn't parseable. The version object has methods 18 | to get the parts of the version, compare it to other versions, convert the 19 | version back into a string, and get the original string. For more details 20 | please see the documentation at https://godoc.org/github.com/Masterminds/semver. 21 | 22 | Sorting Semantic Versions 23 | 24 | A set of versions can be sorted using the `sort` package from the standard library. 25 | For example, 26 | 27 | raw := []string{"1.2.3", "1.0", "1.3", "2", "0.4.2",} 28 | vs := make([]*semver.Version, len(raw)) 29 | for i, r := range raw { 30 | v, err := semver.NewVersion(r) 31 | if err != nil { 32 | t.Errorf("Error parsing version: %s", err) 33 | } 34 | 35 | vs[i] = v 36 | } 37 | 38 | sort.Sort(semver.Collection(vs)) 39 | 40 | Checking Version Constraints 41 | 42 | Checking a version against version constraints is one of the most featureful 43 | parts of the package. 44 | 45 | c, err := semver.NewConstraint(">= 1.2.3") 46 | if err != nil { 47 | // Handle constraint not being parseable. 48 | } 49 | 50 | v, _ := semver.NewVersion("1.3") 51 | if err != nil { 52 | // Handle version not being parseable. 53 | } 54 | // Check if the version meets the constraints. The a variable will be true. 55 | a := c.Check(v) 56 | 57 | Basic Comparisons 58 | 59 | There are two elements to the comparisons. First, a comparison string is a list 60 | of comma separated and comparisons. These are then separated by || separated or 61 | comparisons. For example, `">= 1.2, < 3.0.0 || >= 4.2.3"` is looking for a 62 | comparison that's greater than or equal to 1.2 and less than 3.0.0 or is 63 | greater than or equal to 4.2.3. 64 | 65 | The basic comparisons are: 66 | 67 | * `=`: equal (aliased to no operator) 68 | * `!=`: not equal 69 | * `>`: greater than 70 | * `<`: less than 71 | * `>=`: greater than or equal to 72 | * `<=`: less than or equal to 73 | 74 | Hyphen Range Comparisons 75 | 76 | There are multiple methods to handle ranges and the first is hyphens ranges. 77 | These look like: 78 | 79 | * `1.2 - 1.4.5` which is equivalent to `>= 1.2, <= 1.4.5` 80 | * `2.3.4 - 4.5` which is equivalent to `>= 2.3.4, <= 4.5` 81 | 82 | Wildcards In Comparisons 83 | 84 | The `x`, `X`, and `*` characters can be used as a wildcard character. This works 85 | for all comparison operators. When used on the `=` operator it falls 86 | back to the pack level comparison (see tilde below). For example, 87 | 88 | * `1.2.x` is equivalent to `>= 1.2.0, < 1.3.0` 89 | * `>= 1.2.x` is equivalent to `>= 1.2.0` 90 | * `<= 2.x` is equivalent to `<= 3` 91 | * `*` is equivalent to `>= 0.0.0` 92 | 93 | Tilde Range Comparisons (Patch) 94 | 95 | The tilde (`~`) comparison operator is for patch level ranges when a minor 96 | version is specified and major level changes when the minor number is missing. 97 | For example, 98 | 99 | * `~1.2.3` is equivalent to `>= 1.2.3, < 1.3.0` 100 | * `~1` is equivalent to `>= 1, < 2` 101 | * `~2.3` is equivalent to `>= 2.3, < 2.4` 102 | * `~1.2.x` is equivalent to `>= 1.2.0, < 1.3.0` 103 | * `~1.x` is equivalent to `>= 1, < 2` 104 | 105 | Caret Range Comparisons (Major) 106 | 107 | The caret (`^`) comparison operator is for major level changes. This is useful 108 | when comparisons of API versions as a major change is API breaking. For example, 109 | 110 | * `^1.2.3` is equivalent to `>= 1.2.3, < 2.0.0` 111 | * `^1.2.x` is equivalent to `>= 1.2.0, < 2.0.0` 112 | * `^2.3` is equivalent to `>= 2.3, < 3` 113 | * `^2.x` is equivalent to `>= 2.0.0, < 3` 114 | */ 115 | package semver 116 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/.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 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go_import_path: github.com/pkg/errors 3 | go: 4 | - 1.4.3 5 | - 1.5.4 6 | - 1.6.2 7 | - 1.7.1 8 | - tip 9 | 10 | script: 11 | - go test -v ./... 12 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Dave Cheney 2 | 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 met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/README.md: -------------------------------------------------------------------------------- 1 | # errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) 2 | 3 | Package errors provides simple error handling primitives. 4 | 5 | `go get github.com/pkg/errors` 6 | 7 | The traditional error handling idiom in Go is roughly akin to 8 | ```go 9 | if err != nil { 10 | return err 11 | } 12 | ``` 13 | which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error. 14 | 15 | ## Adding context to an error 16 | 17 | The errors.Wrap function returns a new error that adds context to the original error. For example 18 | ```go 19 | _, err := ioutil.ReadAll(r) 20 | if err != nil { 21 | return errors.Wrap(err, "read failed") 22 | } 23 | ``` 24 | ## Retrieving the cause of an error 25 | 26 | Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`. 27 | ```go 28 | type causer interface { 29 | Cause() error 30 | } 31 | ``` 32 | `errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example: 33 | ```go 34 | switch err := errors.Cause(err).(type) { 35 | case *MyError: 36 | // handle specifically 37 | default: 38 | // unknown error 39 | } 40 | ``` 41 | 42 | [Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). 43 | 44 | ## Contributing 45 | 46 | We welcome pull requests, bug fixes and issue reports. With that said, the bar for adding new symbols to this package is intentionally set high. 47 | 48 | Before proposing a change, please discuss your change by raising an issue. 49 | 50 | ## Licence 51 | 52 | BSD-2-Clause 53 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: build-{build}.{branch} 2 | 3 | clone_folder: C:\gopath\src\github.com\pkg\errors 4 | shallow_clone: true # for startup speed 5 | 6 | environment: 7 | GOPATH: C:\gopath 8 | 9 | platform: 10 | - x64 11 | 12 | # http://www.appveyor.com/docs/installed-software 13 | install: 14 | # some helpful output for debugging builds 15 | - go version 16 | - go env 17 | # pre-installed MinGW at C:\MinGW is 32bit only 18 | # but MSYS2 at C:\msys64 has mingw64 19 | - set PATH=C:\msys64\mingw64\bin;%PATH% 20 | - gcc --version 21 | - g++ --version 22 | 23 | build_script: 24 | - go install -v ./... 25 | 26 | test_script: 27 | - set PATH=C:\gopath\bin;%PATH% 28 | - go test -v ./... 29 | 30 | #artifacts: 31 | # - path: '%GOPATH%\bin\*.exe' 32 | deploy: off 33 | -------------------------------------------------------------------------------- /version_compatibility_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "path/filepath" 5 | "strings" 6 | "testing" 7 | ) 8 | 9 | func assertRetoolDoWorks(t *testing.T, wd string, retoolBin string) { 10 | output := runRetoolCmd(t, wd, retoolBin, "do", "retool_test_app") 11 | want := "v1" 12 | if strings.TrimSpace(output) != want { 13 | t.Errorf("'retool do' gave unexpected output, have=%q want=%q", output, want) 14 | } 15 | } 16 | 17 | // TestCompatibility tests that the current version of retool is compatible with 18 | // old versions. It should set up projects that are readable by old versions, 19 | // and it should be able to read projects set up by old versions. 20 | func TestCompatibility(t *testing.T) { 21 | newRetool, err := buildRetool() 22 | if err != nil { 23 | t.Fatalf("unable to build current retool version: %s", err) 24 | } 25 | 26 | compatibilityTest := func(oldVersion string) { 27 | t.Run(oldVersion, func(t *testing.T) { 28 | t.Parallel() 29 | // Install old version 30 | installDir, installCleanup := setupTempDir(t) 31 | defer installCleanup() 32 | 33 | runRetoolCmd(t, installDir, newRetool, "add", "github.com/twitchtv/retool", oldVersion) 34 | oldRetool := filepath.Join(installDir, "_tools", "bin", "retool"+osBinSuffix) 35 | 36 | t.Run("parallel tests", func(t *testing.T) { 37 | // The extra t.Run("parallel tests" grouping here is necessary to make 38 | 39 | // sure that 'defer installCleanup()' gets run *after* these two 40 | // subtests run. 41 | t.Run("project set up with "+oldVersion, func(t *testing.T) { 42 | t.Parallel() 43 | project, cleanup := setupTempDir(t) 44 | defer cleanup() 45 | runRetoolCmd(t, project, oldRetool, "add", "github.com/spenczar/retool_test_app", "v1") 46 | runRetoolCmd(t, project, oldRetool, "sync") 47 | 48 | assertRetoolDoWorks(t, project, newRetool) 49 | }) 50 | 51 | t.Run("project set up with new version", func(t *testing.T) { 52 | t.Parallel() 53 | project, cleanup := setupTempDir(t) 54 | defer cleanup() 55 | runRetoolCmd(t, project, newRetool, "add", "github.com/spenczar/retool_test_app", "v1") 56 | runRetoolCmd(t, project, newRetool, "sync") 57 | 58 | assertRetoolDoWorks(t, project, oldRetool) 59 | }) 60 | }) 61 | }) 62 | } 63 | 64 | compatibilityTest("v1.2.0") 65 | compatibilityTest("v1.1.0") 66 | compatibilityTest("v1.0.3") 67 | } 68 | --------------------------------------------------------------------------------