From fe59c43cfc1d9d4b713efc099c4319d8aed42246 Mon Sep 17 00:00:00 2001 From: John Roche Date: Thu, 22 Nov 2018 09:42:19 +0000 Subject: [PATCH] vendor files --- Gopkg.lock | 251 +- vendor/github.com/davecgh/go-spew/.gitignore | 22 + vendor/github.com/davecgh/go-spew/.travis.yml | 28 + vendor/github.com/davecgh/go-spew/LICENSE | 15 + vendor/github.com/davecgh/go-spew/README.md | 201 + .../github.com/davecgh/go-spew/cov_report.sh | 22 + .../github.com/davecgh/go-spew/spew/bypass.go | 145 + .../davecgh/go-spew/spew/bypasssafe.go | 38 + .../github.com/davecgh/go-spew/spew/common.go | 341 + .../davecgh/go-spew/spew/common_test.go | 298 + .../github.com/davecgh/go-spew/spew/config.go | 306 + vendor/github.com/davecgh/go-spew/spew/doc.go | 211 + .../github.com/davecgh/go-spew/spew/dump.go | 509 + .../davecgh/go-spew/spew/dump_test.go | 1042 + .../davecgh/go-spew/spew/dumpcgo_test.go | 101 + .../davecgh/go-spew/spew/dumpnocgo_test.go | 26 + .../davecgh/go-spew/spew/example_test.go | 226 + .../github.com/davecgh/go-spew/spew/format.go | 419 + .../davecgh/go-spew/spew/format_test.go | 1558 + .../davecgh/go-spew/spew/internal_test.go | 84 + .../go-spew/spew/internalunsafe_test.go | 101 + .../github.com/davecgh/go-spew/spew/spew.go | 148 + .../davecgh/go-spew/spew/spew_test.go | 320 + .../davecgh/go-spew/spew/testdata/dumpcgo.go | 82 + .../davecgh/go-spew/test_coverage.txt | 61 + .../hashicorp/golang-lru/.gitignore | 23 + vendor/github.com/hashicorp/golang-lru/2q.go | 223 + .../hashicorp/golang-lru/2q_test.go | 306 + .../github.com/hashicorp/golang-lru/LICENSE | 362 + .../github.com/hashicorp/golang-lru/README.md | 25 + vendor/github.com/hashicorp/golang-lru/arc.go | 257 + .../hashicorp/golang-lru/arc_test.go | 377 + vendor/github.com/hashicorp/golang-lru/doc.go | 21 + vendor/github.com/hashicorp/golang-lru/go.mod | 1 + vendor/github.com/hashicorp/golang-lru/lru.go | 110 + .../hashicorp/golang-lru/lru_test.go | 221 + .../hashicorp/golang-lru/simplelru/lru.go | 161 + .../golang-lru/simplelru/lru_interface.go | 36 + .../golang-lru/simplelru/lru_test.go | 167 + vendor/golang.org/x/tools/.gitattributes | 10 + vendor/golang.org/x/tools/.gitignore | 2 + vendor/golang.org/x/tools/AUTHORS | 3 + vendor/golang.org/x/tools/CONTRIBUTING.md | 26 + vendor/golang.org/x/tools/CONTRIBUTORS | 3 + vendor/golang.org/x/tools/LICENSE | 27 + vendor/golang.org/x/tools/PATENTS | 22 + vendor/golang.org/x/tools/README.md | 27 + .../x/tools/benchmark/parse/parse.go | 131 + .../x/tools/benchmark/parse/parse_test.go | 154 + vendor/golang.org/x/tools/blog/atom/atom.go | 61 + vendor/golang.org/x/tools/blog/blog.go | 456 + vendor/golang.org/x/tools/blog/blog_test.go | 44 + .../x/tools/cmd/benchcmp/benchcmp.go | 184 + .../x/tools/cmd/benchcmp/benchcmp_test.go | 59 + .../x/tools/cmd/benchcmp/compare.go | 156 + .../x/tools/cmd/benchcmp/compare_test.go | 133 + vendor/golang.org/x/tools/cmd/benchcmp/doc.go | 37 + .../golang.org/x/tools/cmd/bundle/.gitignore | 1 + vendor/golang.org/x/tools/cmd/bundle/main.go | 467 + .../x/tools/cmd/bundle/main_test.go | 74 + .../x/tools/cmd/bundle/testdata/out.golden | 62 + .../testdata/src/domain.name/importdecl/p.go | 3 + .../cmd/bundle/testdata/src/initial/a.go | 27 + .../cmd/bundle/testdata/src/initial/b.go | 23 + .../cmd/bundle/testdata/src/initial/c.go | 12 + .../golang.org/x/tools/cmd/callgraph/main.go | 349 + .../x/tools/cmd/callgraph/main_test.go | 99 + .../cmd/callgraph/testdata/src/pkg/pkg.go | 25 + .../callgraph/testdata/src/pkg/pkg_test.go | 10 + .../x/tools/cmd/compilebench/main.go | 378 + vendor/golang.org/x/tools/cmd/cover/README | 2 + vendor/golang.org/x/tools/cmd/cover/cover.go | 722 + .../x/tools/cmd/cover/cover_test.go | 94 + vendor/golang.org/x/tools/cmd/cover/doc.go | 27 + vendor/golang.org/x/tools/cmd/cover/func.go | 166 + vendor/golang.org/x/tools/cmd/cover/html.go | 284 + .../x/tools/cmd/cover/testdata/main.go | 112 + .../x/tools/cmd/cover/testdata/test.go | 218 + .../golang.org/x/tools/cmd/digraph/digraph.go | 541 + .../x/tools/cmd/digraph/digraph_test.go | 121 + vendor/golang.org/x/tools/cmd/eg/eg.go | 150 + .../golang.org/x/tools/cmd/fiximports/main.go | 514 + .../x/tools/cmd/fiximports/main_test.go | 253 + .../testdata/src/fruit.io/banana/banana.go | 7 + .../testdata/src/fruit.io/orange/orange.go | 3 + .../testdata/src/fruit.io/pear/pear.go | 3 + .../testdata/src/new.com/one/one.go | 1 + .../testdata/src/old.com/bad/bad.go | 2 + .../testdata/src/old.com/one/one.go | 1 + .../testdata/src/titanic.biz/bar/bar.go | 2 + .../testdata/src/titanic.biz/foo/foo.go | 2 + .../x/tools/cmd/getgo/.dockerignore | 5 + .../golang.org/x/tools/cmd/getgo/.gitignore | 3 + .../golang.org/x/tools/cmd/getgo/Dockerfile | 20 + vendor/golang.org/x/tools/cmd/getgo/LICENSE | 27 + vendor/golang.org/x/tools/cmd/getgo/README.md | 71 + .../golang.org/x/tools/cmd/getgo/download.go | 184 + .../x/tools/cmd/getgo/download_test.go | 36 + vendor/golang.org/x/tools/cmd/getgo/main.go | 117 + .../golang.org/x/tools/cmd/getgo/main_test.go | 173 + vendor/golang.org/x/tools/cmd/getgo/make.bash | 13 + vendor/golang.org/x/tools/cmd/getgo/path.go | 155 + .../golang.org/x/tools/cmd/getgo/path_test.go | 58 + .../x/tools/cmd/getgo/server/README.md | 7 + .../x/tools/cmd/getgo/server/app.yaml | 7 + .../x/tools/cmd/getgo/server/main.go | 61 + vendor/golang.org/x/tools/cmd/getgo/steps.go | 133 + vendor/golang.org/x/tools/cmd/getgo/system.go | 38 + .../x/tools/cmd/getgo/system_unix.go | 55 + .../x/tools/cmd/getgo/system_windows.go | 86 + .../golang.org/x/tools/cmd/getgo/upload.bash | 19 + .../x/tools/cmd/go-contrib-init/contrib.go | 289 + .../tools/cmd/go-contrib-init/contrib_test.go | 35 + vendor/golang.org/x/tools/cmd/godex/doc.go | 69 + vendor/golang.org/x/tools/cmd/godex/gc.go | 13 + vendor/golang.org/x/tools/cmd/godex/gccgo.go | 34 + vendor/golang.org/x/tools/cmd/godex/godex.go | 211 + .../golang.org/x/tools/cmd/godex/isAlias18.go | 13 + .../golang.org/x/tools/cmd/godex/isAlias19.go | 13 + vendor/golang.org/x/tools/cmd/godex/print.go | 373 + vendor/golang.org/x/tools/cmd/godex/source.go | 19 + .../golang.org/x/tools/cmd/godex/writetype.go | 242 + .../golang.org/x/tools/cmd/godoc/.gitignore | 3 + .../x/tools/cmd/godoc/Dockerfile.prod | 67 + vendor/golang.org/x/tools/cmd/godoc/Makefile | 80 + .../x/tools/cmd/godoc/README.godoc-app | 94 + .../golang.org/x/tools/cmd/godoc/app.dev.yaml | 13 + .../x/tools/cmd/godoc/app.prod.yaml | 16 + .../golang.org/x/tools/cmd/godoc/appinit.go | 155 + .../golang.org/x/tools/cmd/godoc/autocert.go | 88 + vendor/golang.org/x/tools/cmd/godoc/blog.go | 85 + .../x/tools/cmd/godoc/cloudbuild.yaml | 25 + .../golang.org/x/tools/cmd/godoc/codewalk.go | 523 + vendor/golang.org/x/tools/cmd/godoc/dl.go | 16 + vendor/golang.org/x/tools/cmd/godoc/doc.go | 118 + .../x/tools/cmd/godoc/generate-index.bash | 72 + .../x/tools/cmd/godoc/godoc_test.go | 464 + vendor/golang.org/x/tools/cmd/godoc/goroot.go | 74 + .../golang.org/x/tools/cmd/godoc/handlers.go | 151 + .../x/tools/cmd/godoc/hg-git-mapping.bin | Bin 0 -> 189416 bytes vendor/golang.org/x/tools/cmd/godoc/index.go | 11 + vendor/golang.org/x/tools/cmd/godoc/main.go | 342 + vendor/golang.org/x/tools/cmd/godoc/play.go | 11 + .../x/tools/cmd/godoc/regtest_test.go | 155 + vendor/golang.org/x/tools/cmd/godoc/x.go | 92 + .../golang.org/x/tools/cmd/goimports/doc.go | 45 + .../x/tools/cmd/goimports/goimports.go | 369 + .../x/tools/cmd/goimports/goimports_gc.go | 26 + .../x/tools/cmd/goimports/goimports_not_gc.go | 11 + vendor/golang.org/x/tools/cmd/golsp/main.go | 147 + vendor/golang.org/x/tools/cmd/gomvpkg/main.go | 94 + .../x/tools/cmd/gorename/cgo_test.go | 11 + .../x/tools/cmd/gorename/gorename_test.go | 382 + .../golang.org/x/tools/cmd/gorename/main.go | 55 + .../golang.org/x/tools/cmd/gotype/gotype.go | 341 + .../x/tools/cmd/gotype/sizesFor18.go | 40 + .../x/tools/cmd/gotype/sizesFor19.go | 15 + vendor/golang.org/x/tools/cmd/goyacc/doc.go | 70 + .../x/tools/cmd/goyacc/testdata/expr/README | 20 + .../x/tools/cmd/goyacc/testdata/expr/expr.y | 202 + .../x/tools/cmd/goyacc/testdata/expr/main.go | 14 + vendor/golang.org/x/tools/cmd/goyacc/yacc.go | 3592 + vendor/golang.org/x/tools/cmd/guru/callees.go | 257 + vendor/golang.org/x/tools/cmd/guru/callers.go | 195 + .../golang.org/x/tools/cmd/guru/callstack.go | 141 + .../golang.org/x/tools/cmd/guru/definition.go | 205 + .../golang.org/x/tools/cmd/guru/describe.go | 947 + .../golang.org/x/tools/cmd/guru/freevars.go | 223 + vendor/golang.org/x/tools/cmd/guru/guru.go | 401 + .../golang.org/x/tools/cmd/guru/guru_test.go | 351 + .../golang.org/x/tools/cmd/guru/implements.go | 364 + .../golang.org/x/tools/cmd/guru/isAlias18.go | 15 + .../golang.org/x/tools/cmd/guru/isAlias19.go | 15 + vendor/golang.org/x/tools/cmd/guru/main.go | 225 + vendor/golang.org/x/tools/cmd/guru/peers.go | 252 + .../golang.org/x/tools/cmd/guru/pointsto.go | 290 + vendor/golang.org/x/tools/cmd/guru/pos.go | 142 + .../golang.org/x/tools/cmd/guru/referrers.go | 802 + .../x/tools/cmd/guru/serial/serial.go | 260 + .../x/tools/cmd/guru/testdata/src/README.txt | 2 + .../cmd/guru/testdata/src/alias/alias.go | 23 + .../cmd/guru/testdata/src/alias/alias.golden | 47 + .../cmd/guru/testdata/src/calls-json/main.go | 16 + .../guru/testdata/src/calls-json/main.golden | 28 + .../tools/cmd/guru/testdata/src/calls/main.go | 129 + .../cmd/guru/testdata/src/calls/main.golden | 125 + .../guru/testdata/src/definition-json/main.go | 66 + .../testdata/src/definition-json/main.golden | 90 + .../testdata/src/definition-json/main19.go | 5 + .../src/definition-json/main19.golden | 5 + .../guru/testdata/src/definition-json/type.go | 3 + .../guru/testdata/src/describe-json/main.go | 29 + .../testdata/src/describe-json/main.golden | 134 + .../cmd/guru/testdata/src/describe/main.go | 111 + .../guru/testdata/src/describe/main.golden | 249 + .../cmd/guru/testdata/src/describe/main19.go | 13 + .../guru/testdata/src/describe/main19.golden | 6 + .../cmd/guru/testdata/src/freevars/main.go | 40 + .../guru/testdata/src/freevars/main.golden | 25 + .../guru/testdata/src/implements-json/main.go | 27 + .../testdata/src/implements-json/main.golden | 135 + .../src/implements-methods-json/main.go | 37 + .../src/implements-methods-json/main.golden | 266 + .../testdata/src/implements-methods/main.go | 37 + .../src/implements-methods/main.golden | 37 + .../cmd/guru/testdata/src/implements/main.go | 44 + .../guru/testdata/src/implements/main.golden | 50 + .../cmd/guru/testdata/src/imports/main.go | 29 + .../cmd/guru/testdata/src/imports/main.golden | 56 + .../x/tools/cmd/guru/testdata/src/lib/lib.go | 37 + .../guru/testdata/src/lib/sublib/sublib.go | 3 + .../tools/cmd/guru/testdata/src/main/multi.go | 13 + .../cmd/guru/testdata/src/peers-json/main.go | 13 + .../guru/testdata/src/peers-json/main.golden | 12 + .../tools/cmd/guru/testdata/src/peers/main.go | 52 + .../cmd/guru/testdata/src/peers/main.golden | 100 + .../guru/testdata/src/pointsto-json/main.go | 27 + .../testdata/src/pointsto-json/main.golden | 29 + .../cmd/guru/testdata/src/pointsto/main.go | 75 + .../guru/testdata/src/pointsto/main.golden | 96 + .../guru/testdata/src/referrers-json/main.go | 24 + .../testdata/src/referrers-json/main.golden | 234 + .../guru/testdata/src/referrers/ext_test.go | 12 + .../guru/testdata/src/referrers/int_test.go | 10 + .../cmd/guru/testdata/src/referrers/main.go | 36 + .../guru/testdata/src/referrers/main.golden | 64 + .../cmd/guru/testdata/src/reflection/main.go | 30 + .../guru/testdata/src/reflection/main.golden | 34 + .../cmd/guru/testdata/src/softerrs/main.go | 15 + .../guru/testdata/src/softerrs/main.golden | 8 + .../cmd/guru/testdata/src/what-json/main.go | 14 + .../guru/testdata/src/what-json/main.golden | 95 + .../tools/cmd/guru/testdata/src/what/main.go | 11 + .../cmd/guru/testdata/src/what/main.golden | 41 + .../cmd/guru/testdata/src/whicherrs/main.go | 32 + .../guru/testdata/src/whicherrs/main.golden | 11 + .../golang.org/x/tools/cmd/guru/unit_test.go | 105 + vendor/golang.org/x/tools/cmd/guru/what.go | 282 + .../golang.org/x/tools/cmd/guru/whicherrs.go | 327 + .../x/tools/cmd/heapview/client/.clang-format | 1 + .../x/tools/cmd/heapview/client/.gitignore | 1 + .../x/tools/cmd/heapview/client/README.md | 45 + .../x/tools/cmd/heapview/client/main.ts | 195 + .../x/tools/cmd/heapview/client/main_test.ts | 29 + .../x/tools/cmd/heapview/client/package.json | 35 + .../cmd/heapview/client/testing/karma.conf.js | 22 + .../cmd/heapview/client/testing/test_main.js | 32 + .../x/tools/cmd/heapview/client/tsconfig.json | 16 + .../x/tools/cmd/heapview/client/tslint.json | 40 + .../cmd/heapview/internal/core/mmapfile.go | 145 + .../heapview/internal/core/mmapfile_other.go | 14 + .../x/tools/cmd/heapview/internal/core/raw.go | 308 + .../golang.org/x/tools/cmd/heapview/main.go | 83 + .../x/tools/cmd/html2article/conv.go | 331 + vendor/golang.org/x/tools/cmd/present/dir.go | 217 + vendor/golang.org/x/tools/cmd/present/doc.go | 52 + vendor/golang.org/x/tools/cmd/present/main.go | 150 + vendor/golang.org/x/tools/cmd/present/play.go | 89 + .../x/tools/cmd/present/static/article.css | 161 + .../x/tools/cmd/present/static/dir.css | 186 + .../x/tools/cmd/present/static/dir.js | 41 + .../x/tools/cmd/present/static/favicon.ico | Bin 0 -> 785 bytes .../x/tools/cmd/present/static/jquery-ui.js | 6 + .../x/tools/cmd/present/static/notes.css | 32 + .../x/tools/cmd/present/static/notes.js | 161 + .../x/tools/cmd/present/static/slides.js | 612 + .../x/tools/cmd/present/static/styles.css | 542 + .../x/tools/cmd/present/templates/action.tmpl | 62 + .../tools/cmd/present/templates/article.tmpl | 98 + .../x/tools/cmd/present/templates/dir.tmpl | 108 + .../x/tools/cmd/present/templates/slides.tmpl | 107 + vendor/golang.org/x/tools/cmd/ssadump/main.go | 190 + .../golang.org/x/tools/cmd/stress/stress.go | 133 + .../x/tools/cmd/stringer/endtoend_test.go | 167 + .../x/tools/cmd/stringer/golden_test.go | 319 + .../x/tools/cmd/stringer/importer18.go | 16 + .../x/tools/cmd/stringer/importer19.go | 16 + .../x/tools/cmd/stringer/stringer.go | 686 + .../x/tools/cmd/stringer/testdata/cgo.go | 32 + .../x/tools/cmd/stringer/testdata/conv.go | 41 + .../x/tools/cmd/stringer/testdata/day.go | 39 + .../x/tools/cmd/stringer/testdata/gap.go | 44 + .../x/tools/cmd/stringer/testdata/num.go | 35 + .../x/tools/cmd/stringer/testdata/number.go | 34 + .../x/tools/cmd/stringer/testdata/prime.go | 56 + .../x/tools/cmd/stringer/testdata/tag_main.go | 11 + .../x/tools/cmd/stringer/testdata/tag_tag.go | 7 + .../x/tools/cmd/stringer/testdata/unum.go | 38 + .../x/tools/cmd/stringer/testdata/unum2.go | 31 + .../x/tools/cmd/stringer/util_test.go | 77 + vendor/golang.org/x/tools/cmd/tip/Dockerfile | 144 + vendor/golang.org/x/tools/cmd/tip/Makefile | 40 + vendor/golang.org/x/tools/cmd/tip/README | 32 + vendor/golang.org/x/tools/cmd/tip/cert.go | 64 + vendor/golang.org/x/tools/cmd/tip/godoc.go | 73 + vendor/golang.org/x/tools/cmd/tip/godoc.yaml | 17 + vendor/golang.org/x/tools/cmd/tip/talks.go | 73 + vendor/golang.org/x/tools/cmd/tip/talks.yaml | 12 + .../golang.org/x/tools/cmd/tip/tip-prod.yaml | 38 + .../x/tools/cmd/tip/tip-service.yaml | 16 + vendor/golang.org/x/tools/cmd/tip/tip.go | 426 + vendor/golang.org/x/tools/cmd/tip/tip_test.go | 25 + .../golang.org/x/tools/cmd/toolstash/buildall | 68 + .../golang.org/x/tools/cmd/toolstash/cmp.go | 157 + .../golang.org/x/tools/cmd/toolstash/main.go | 637 + vendor/golang.org/x/tools/codereview.cfg | 1 + .../x/tools/container/intsets/popcnt_amd64.go | 20 + .../x/tools/container/intsets/popcnt_amd64.s | 30 + .../x/tools/container/intsets/popcnt_gccgo.go | 9 + .../tools/container/intsets/popcnt_gccgo_c.c | 19 + .../tools/container/intsets/popcnt_generic.go | 33 + .../x/tools/container/intsets/sparse.go | 1091 + .../x/tools/container/intsets/sparse_test.go | 710 + .../x/tools/container/intsets/util.go | 84 + .../x/tools/container/intsets/util_test.go | 58 + vendor/golang.org/x/tools/cover/profile.go | 213 + .../x/tools/go/analysis/analysis.go | 192 + .../go/analysis/analysistest/analysistest.go | 387 + .../analysistest/analysistest_test.go | 93 + .../x/tools/go/analysis/cmd/vet/README | 33 + .../x/tools/go/analysis/cmd/vet/vet.go | 80 + vendor/golang.org/x/tools/go/analysis/doc.go | 340 + .../analysis/internal/analysisflags/flags.go | 343 + .../internal/analysisflags/flags_test.go | 67 + .../analysis/internal/analysisflags/help.go | 89 + .../go/analysis/internal/checker/checker.go | 701 + .../tools/go/analysis/internal/facts/facts.go | 299 + .../go/analysis/internal/facts/facts_test.go | 174 + .../go/analysis/internal/facts/imports.go | 88 + .../go/analysis/multichecker/multichecker.go | 60 + .../multichecker/multichecker_test.go | 82 + .../x/tools/go/analysis/passes/README | 8 + .../go/analysis/passes/asmdecl/asmdecl.go | 760 + .../analysis/passes/asmdecl/asmdecl_test.go | 17 + .../passes/asmdecl/testdata/src/a/asm.go | 48 + .../passes/asmdecl/testdata/src/a/asm1.s | 314 + .../passes/asmdecl/testdata/src/a/asm2.s | 256 + .../passes/asmdecl/testdata/src/a/asm3.s | 191 + .../passes/asmdecl/testdata/src/a/asm4.s | 25 + .../passes/asmdecl/testdata/src/a/asm5.s | 192 + .../passes/asmdecl/testdata/src/a/asm6.s | 192 + .../passes/asmdecl/testdata/src/a/asm7.s | 192 + .../passes/asmdecl/testdata/src/a/asm8.s | 164 + .../tools/go/analysis/passes/assign/assign.go | 68 + .../go/analysis/passes/assign/assign_test.go | 17 + .../passes/assign/testdata/src/a/a.go | 31 + .../tools/go/analysis/passes/atomic/atomic.go | 96 + .../go/analysis/passes/atomic/atomic_test.go | 17 + .../passes/atomic/testdata/src/a/a.go | 62 + .../x/tools/go/analysis/passes/bools/bools.go | 214 + .../go/analysis/passes/bools/bools_test.go | 17 + .../analysis/passes/bools/testdata/src/a/a.go | 137 + .../go/analysis/passes/buildssa/buildssa.go | 117 + .../analysis/passes/buildssa/buildssa_test.go | 29 + .../passes/buildssa/testdata/src/a/a.go | 16 + .../go/analysis/passes/buildtag/buildtag.go | 159 + .../analysis/passes/buildtag/buildtag_test.go | 17 + .../buildtag/testdata/src/a/buildtag.go | 21 + .../go/analysis/passes/cgocall/cgocall.go | 390 + .../analysis/passes/cgocall/cgocall_test.go | 17 + .../passes/cgocall/testdata/src/a/cgo.go | 71 + .../passes/cgocall/testdata/src/a/cgo3.go | 21 + .../passes/cgocall/testdata/src/b/b.go | 20 + .../passes/cgocall/testdata/src/c/c.go | 14 + .../go/analysis/passes/composite/composite.go | 108 + .../passes/composite/composite_test.go | 17 + .../passes/composite/testdata/src/a/a.go | 121 + .../go/analysis/passes/composite/whitelist.go | 33 + .../go/analysis/passes/copylock/copylock.go | 300 + .../analysis/passes/copylock/copylock_test.go | 17 + .../copylock/testdata/src/a/copylock.go | 188 + .../copylock/testdata/src/a/copylock_func.go | 136 + .../copylock/testdata/src/a/copylock_range.go | 67 + .../go/analysis/passes/ctrlflow/ctrlflow.go | 225 + .../analysis/passes/ctrlflow/ctrlflow_test.go | 35 + .../passes/ctrlflow/testdata/src/a/a.go | 109 + .../passes/ctrlflow/testdata/src/lib/lib.go | 8 + .../passes/findcall/cmd/findcall/main.go | 9 + .../go/analysis/passes/findcall/findcall.go | 80 + .../analysis/passes/findcall/findcall_test.go | 64 + .../passes/findcall/testdata/src/a/a.go | 6 + .../passes/httpresponse/httpresponse.go | 177 + .../passes/httpresponse/httpresponse_test.go | 17 + .../passes/httpresponse/testdata/src/a/a.go | 85 + .../go/analysis/passes/inspect/inspect.go | 45 + .../passes/internal/analysisutil/util.go | 106 + .../passes/loopclosure/loopclosure.go | 130 + .../passes/loopclosure/loopclosure_test.go | 17 + .../passes/loopclosure/testdata/src/a/a.go | 90 + .../passes/lostcancel/cmd/lostcancel/main.go | 10 + .../analysis/passes/lostcancel/lostcancel.go | 315 + .../passes/lostcancel/lostcancel_test.go | 17 + .../passes/lostcancel/testdata/src/a/a.go | 173 + .../passes/lostcancel/testdata/src/b/b.go | 26 + .../go/analysis/passes/nilfunc/nilfunc.go | 74 + .../analysis/passes/nilfunc/nilfunc_test.go | 17 + .../passes/nilfunc/testdata/src/a/a.go | 35 + .../passes/nilness/cmd/nilness/main.go | 10 + .../go/analysis/passes/nilness/nilness.go | 271 + .../analysis/passes/nilness/nilness_test.go | 17 + .../passes/nilness/testdata/src/a/a.go | 91 + .../go/analysis/passes/pkgfact/pkgfact.go | 127 + .../analysis/passes/pkgfact/pkgfact_test.go | 17 + .../passes/pkgfact/testdata/src/a/a.go | 4 + .../passes/pkgfact/testdata/src/b/b.go | 5 + .../passes/pkgfact/testdata/src/c/c.go | 5 + .../tools/go/analysis/passes/printf/printf.go | 1017 + .../go/analysis/passes/printf/printf_test.go | 14 + .../passes/printf/testdata/src/a/a.go | 710 + .../passes/printf/testdata/src/b/b.go | 33 + .../tools/go/analysis/passes/printf/types.go | 236 + .../analysis/passes/shadow/cmd/shadow/main.go | 9 + .../tools/go/analysis/passes/shadow/shadow.go | 288 + .../go/analysis/passes/shadow/shadow_test.go | 13 + .../passes/shadow/testdata/src/a/a.go | 91 + .../x/tools/go/analysis/passes/shift/dead.go | 101 + .../x/tools/go/analysis/passes/shift/shift.go | 128 + .../go/analysis/passes/shift/shift_test.go | 17 + .../analysis/passes/shift/testdata/src/a/a.go | 155 + .../analysis/passes/stdmethods/stdmethods.go | 186 + .../passes/stdmethods/stdmethods_test.go | 17 + .../passes/stdmethods/testdata/src/a/a.go | 33 + .../go/analysis/passes/structtag/structtag.go | 260 + .../passes/structtag/structtag_test.go | 17 + .../passes/structtag/testdata/src/a/a.go | 113 + .../analysis/passes/tests/testdata/src/a/a.go | 3 + .../passes/tests/testdata/src/a/a_test.go | 78 + .../passes/tests/testdata/src/a/ax_test.go | 7 + .../tests/testdata/src/divergent/buf.go | 17 + .../tests/testdata/src/divergent/buf_test.go | 35 + .../x/tools/go/analysis/passes/tests/tests.go | 175 + .../go/analysis/passes/tests/tests_test.go | 21 + .../passes/unmarshal/cmd/unmarshal/main.go | 9 + .../passes/unmarshal/testdata/src/a/a.go | 58 + .../go/analysis/passes/unmarshal/unmarshal.go | 92 + .../passes/unmarshal/unmarshal_test.go | 17 + .../passes/unreachable/testdata/src/a/a.go | 2133 + .../passes/unreachable/unreachable.go | 314 + .../passes/unreachable/unreachable_test.go | 17 + .../passes/unsafeptr/testdata/src/a/a.go | 63 + .../go/analysis/passes/unsafeptr/unsafeptr.go | 130 + .../passes/unsafeptr/unsafeptr_test.go | 17 + .../passes/unusedresult/testdata/src/a/a.go | 27 + .../passes/unusedresult/unusedresult.go | 131 + .../passes/unusedresult/unusedresult_test.go | 17 + .../analysis/singlechecker/singlechecker.go | 77 + .../x/tools/go/analysis/unitchecker/main.go | 64 + .../analysis/unitchecker/testdata/src/a/a.go | 7 + .../analysis/unitchecker/testdata/src/b/b.go | 10 + .../go/analysis/unitchecker/unitchecker.go | 382 + .../analysis/unitchecker/unitchecker_test.go | 108 + .../x/tools/go/analysis/validate.go | 104 + .../x/tools/go/ast/astutil/enclosing.go | 627 + .../x/tools/go/ast/astutil/enclosing_test.go | 195 + .../x/tools/go/ast/astutil/imports.go | 481 + .../x/tools/go/ast/astutil/imports_test.go | 2087 + .../x/tools/go/ast/astutil/rewrite.go | 477 + .../x/tools/go/ast/astutil/rewrite_test.go | 248 + .../golang.org/x/tools/go/ast/astutil/util.go | 14 + .../x/tools/go/ast/inspector/inspector.go | 182 + .../tools/go/ast/inspector/inspector_test.go | 220 + .../x/tools/go/ast/inspector/typeof.go | 216 + .../x/tools/go/buildutil/allpackages.go | 198 + .../x/tools/go/buildutil/allpackages_test.go | 83 + .../x/tools/go/buildutil/fakecontext.go | 109 + .../x/tools/go/buildutil/overlay.go | 103 + .../x/tools/go/buildutil/overlay_test.go | 70 + .../golang.org/x/tools/go/buildutil/tags.go | 75 + .../x/tools/go/buildutil/tags_test.go | 28 + .../golang.org/x/tools/go/buildutil/util.go | 212 + .../x/tools/go/buildutil/util_test.go | 85 + .../x/tools/go/buildutil/util_windows_test.go | 48 + .../x/tools/go/callgraph/callgraph.go | 129 + .../x/tools/go/callgraph/cha/cha.go | 139 + .../x/tools/go/callgraph/cha/cha_test.go | 111 + .../x/tools/go/callgraph/cha/testdata/func.go | 23 + .../tools/go/callgraph/cha/testdata/iface.go | 65 + .../go/callgraph/cha/testdata/issue23925.go | 38 + .../x/tools/go/callgraph/cha/testdata/recv.go | 37 + .../x/tools/go/callgraph/rta/rta.go | 459 + .../x/tools/go/callgraph/rta/rta_test.go | 139 + .../x/tools/go/callgraph/rta/testdata/func.go | 37 + .../tools/go/callgraph/rta/testdata/iface.go | 79 + .../tools/go/callgraph/rta/testdata/rtype.go | 35 + .../x/tools/go/callgraph/static/static.go | 35 + .../tools/go/callgraph/static/static_test.go | 88 + .../golang.org/x/tools/go/callgraph/util.go | 181 + vendor/golang.org/x/tools/go/cfg/builder.go | 510 + vendor/golang.org/x/tools/go/cfg/cfg.go | 150 + vendor/golang.org/x/tools/go/cfg/cfg_test.go | 177 + vendor/golang.org/x/tools/go/expect/expect.go | 149 + .../x/tools/go/expect/expect_test.go | 135 + .../golang.org/x/tools/go/expect/extract.go | 221 + .../x/tools/go/expect/testdata/test.go | 30 + .../go/gccgoexportdata/gccgoexportdata.go | 129 + .../gccgoexportdata/gccgoexportdata_test.go | 67 + .../go/gccgoexportdata/testdata/errors.gox | Bin 0 -> 24632 bytes .../tools/go/gccgoexportdata/testdata/long.a | Bin 0 -> 802 bytes .../tools/go/gccgoexportdata/testdata/short.a | Bin 0 -> 710 bytes .../x/tools/go/gcexportdata/example_test.go | 122 + .../x/tools/go/gcexportdata/gcexportdata.go | 109 + .../go/gcexportdata/gcexportdata_test.go | 41 + .../x/tools/go/gcexportdata/importer.go | 73 + .../x/tools/go/gcexportdata/main.go | 99 + .../go/gcexportdata/testdata/errors-ae16.a | Bin 0 -> 5494 bytes .../golang.org/x/tools/go/internal/cgo/cgo.go | 220 + .../x/tools/go/internal/cgo/cgo_pkgconfig.go | 39 + .../x/tools/go/internal/gccgoimporter/ar.go | 151 + .../go/internal/gccgoimporter/backdoor.go | 32 + .../gccgoimporter/gccgoinstallation.go | 100 + .../gccgoimporter/gccgoinstallation_test.go | 191 + .../go/internal/gccgoimporter/importer.go | 249 + .../internal/gccgoimporter/importer_test.go | 182 + .../internal/gccgoimporter/newInterface10.go | 21 + .../internal/gccgoimporter/newInterface11.go | 13 + .../tools/go/internal/gccgoimporter/parser.go | 997 + .../go/internal/gccgoimporter/parser_test.go | 80 + .../gccgoimporter/testdata/aliases.go | 65 + .../gccgoimporter/testdata/aliases.gox | 33 + .../gccgoimporter/testdata/complexnums.go | 6 + .../gccgoimporter/testdata/complexnums.gox | 8 + .../gccgoimporter/testdata/conversions.go | 5 + .../gccgoimporter/testdata/conversions.gox | 6 + .../gccgoimporter/testdata/escapeinfo.go | 13 + .../gccgoimporter/testdata/escapeinfo.gox | Bin 0 -> 824 bytes .../gccgoimporter/testdata/imports.go | 5 + .../gccgoimporter/testdata/imports.gox | 7 + .../gccgoimporter/testdata/issue27856.go | 9 + .../gccgoimporter/testdata/issue27856.gox | 9 + .../gccgoimporter/testdata/libimportsar.a | Bin 0 -> 9302 bytes .../gccgoimporter/testdata/pointer.go | 3 + .../gccgoimporter/testdata/pointer.gox | 4 + .../internal/gccgoimporter/testdata/time.gox | Bin 0 -> 7977 bytes .../gccgoimporter/testdata/unicode.gox | Bin 0 -> 7945 bytes .../go/internal/gccgoimporter/testenv_test.go | 44 + .../x/tools/go/internal/gcimporter/bexport.go | 852 + .../go/internal/gcimporter/bexport_test.go | 414 + .../x/tools/go/internal/gcimporter/bimport.go | 1028 + .../go/internal/gcimporter/exportdata.go | 93 + .../go/internal/gcimporter/gcimporter.go | 1078 + .../internal/gcimporter/gcimporter11_test.go | 129 + .../go/internal/gcimporter/gcimporter_test.go | 517 + .../x/tools/go/internal/gcimporter/iimport.go | 598 + .../go/internal/gcimporter/newInterface10.go | 21 + .../go/internal/gcimporter/newInterface11.go | 13 + .../go/internal/gcimporter/testdata/a.go | 14 + .../go/internal/gcimporter/testdata/b.go | 11 + .../internal/gcimporter/testdata/exports.go | 89 + .../gcimporter/testdata/issue15920.go | 11 + .../gcimporter/testdata/issue20046.go | 9 + .../gcimporter/testdata/issue25301.go | 17 + .../go/internal/gcimporter/testdata/p.go | 13 + .../gcimporter/testdata/versions/test.go | 30 + .../testdata/versions/test_go1.11_0i.a | Bin 0 -> 2420 bytes .../testdata/versions/test_go1.11_6b.a | Bin 0 -> 2426 bytes .../testdata/versions/test_go1.11_999b.a | Bin 0 -> 2600 bytes .../testdata/versions/test_go1.11_999i.a | Bin 0 -> 2420 bytes .../testdata/versions/test_go1.7_0.a | Bin 0 -> 1862 bytes .../testdata/versions/test_go1.7_1.a | Bin 0 -> 2316 bytes .../testdata/versions/test_go1.8_4.a | Bin 0 -> 1658 bytes .../testdata/versions/test_go1.8_5.a | Bin 0 -> 1658 bytes vendor/golang.org/x/tools/go/loader/doc.go | 205 + .../x/tools/go/loader/example_test.go | 179 + vendor/golang.org/x/tools/go/loader/loader.go | 1078 + .../x/tools/go/loader/loader_test.go | 825 + .../x/tools/go/loader/stdlib_test.go | 201 + .../x/tools/go/loader/testdata/a.go | 1 + .../x/tools/go/loader/testdata/b.go | 1 + .../x/tools/go/loader/testdata/badpkgdecl.go | 1 + vendor/golang.org/x/tools/go/loader/util.go | 124 + vendor/golang.org/x/tools/go/packages/doc.go | 241 + .../x/tools/go/packages/example_test.go | 34 + .../x/tools/go/packages/external.go | 80 + .../golang.org/x/tools/go/packages/golist.go | 734 + .../x/tools/go/packages/golist_fallback.go | 450 + .../go/packages/golist_fallback_testmain.go | 318 + .../x/tools/go/packages/gopackages/main.go | 272 + .../x/tools/go/packages/packages.go | 936 + .../x/tools/go/packages/packages110_test.go | 11 + .../x/tools/go/packages/packages_test.go | 1635 + .../x/tools/go/packages/packagescgo_test.go | 60 + .../tools/go/packages/packagestest/expect.go | 341 + .../go/packages/packagestest/expect_test.go | 66 + .../tools/go/packages/packagestest/export.go | 294 + .../go/packages/packagestest/export_test.go | 73 + .../tools/go/packages/packagestest/gopath.go | 74 + .../go/packages/packagestest/gopath_test.go | 28 + .../tools/go/packages/packagestest/modules.go | 210 + .../go/packages/packagestest/modules_111.go | 7 + .../go/packages/packagestest/modules_test.go | 32 + .../go/packages/packagestest/testdata/test.go | 24 + .../x/tools/go/packages/stdlib_test.go | 136 + .../x/tools/go/packages/testdata/README | 3 + .../github.com/heschik/tools-testrepo/@v/list | 1 + .../heschik/tools-testrepo/@v/v1.0.0.info | 1 + .../heschik/tools-testrepo/@v/v1.0.0.mod | 1 + .../heschik/tools-testrepo/@v/v1.0.0.zip | Bin 0 -> 467 bytes .../heschik/tools-testrepo/@v/v1.0.0.ziphash | 1 + .../heschik/tools-testrepo/v2/@v/list | 1 + .../heschik/tools-testrepo/v2/@v/v2.0.0.info | 1 + .../heschik/tools-testrepo/v2/@v/v2.0.0.mod | 1 + .../heschik/tools-testrepo/v2/@v/v2.0.0.zip | Bin 0 -> 482 bytes .../tools-testrepo/v2/@v/v2.0.0.ziphash | 1 + .../heschik/tools-testrepo/v2@v2.0.0/go.mod | 1 + .../tools-testrepo/v2@v2.0.0/pkg/pkg.go | 1 + .../heschik/tools-testrepo@v1.0.0/go.mod | 1 + .../heschik/tools-testrepo@v1.0.0/pkg/pkg.go | 1 + .../TestName_Modules/src/b/pkg/pkg.go | 1 + .../github.com/heschik/tools-testrepo/@v/list | 1 + .../heschik/tools-testrepo/@v/v1.0.0.info | 1 + .../heschik/tools-testrepo/@v/v1.0.0.mod | 1 + .../heschik/tools-testrepo/@v/v1.0.0.zip | Bin 0 -> 467 bytes .../heschik/tools-testrepo/@v/v1.0.0.ziphash | 1 + .../heschik/tools-testrepo/v2/@v/list | 2 + .../heschik/tools-testrepo/v2/@v/v2.0.1.info | 1 + .../heschik/tools-testrepo/v2/@v/v2.0.1.mod | 1 + .../heschik/tools-testrepo/v2/@v/v2.0.1.zip | Bin 0 -> 482 bytes .../tools-testrepo/v2/@v/v2.0.1.ziphash | 1 + .../heschik/tools-testrepo/v2/@v/v2.0.2.info | 1 + .../heschik/tools-testrepo/v2/@v/v2.0.2.mod | 1 + .../heschik/tools-testrepo/v2/@v/v2.0.2.zip | Bin 0 -> 482 bytes .../tools-testrepo/v2/@v/v2.0.2.ziphash | 1 + .../heschik/tools-testrepo/v2@v2.0.1/go.mod | 1 + .../tools-testrepo/v2@v2.0.1/pkg/pkg.go | 1 + .../heschik/tools-testrepo/v2@v2.0.2/go.mod | 1 + .../tools-testrepo/v2@v2.0.2/pkg/pkg.go | 1 + .../heschik/tools-testrepo@v1.0.0/go.mod | 1 + .../heschik/tools-testrepo@v1.0.0/pkg/pkg.go | 1 + .../golang.org/x/tools/go/packages/visit.go | 55 + vendor/golang.org/x/tools/go/pointer/TODO | 33 + .../golang.org/x/tools/go/pointer/analysis.go | 452 + vendor/golang.org/x/tools/go/pointer/api.go | 285 + .../x/tools/go/pointer/callgraph.go | 61 + .../x/tools/go/pointer/constraint.go | 149 + vendor/golang.org/x/tools/go/pointer/doc.go | 610 + .../x/tools/go/pointer/example_test.go | 126 + vendor/golang.org/x/tools/go/pointer/gen.go | 1325 + vendor/golang.org/x/tools/go/pointer/hvn.go | 973 + .../x/tools/go/pointer/intrinsics.go | 361 + .../golang.org/x/tools/go/pointer/labels.go | 152 + vendor/golang.org/x/tools/go/pointer/opt.go | 132 + .../x/tools/go/pointer/pointer_test.go | 601 + vendor/golang.org/x/tools/go/pointer/print.go | 43 + vendor/golang.org/x/tools/go/pointer/query.go | 221 + .../x/tools/go/pointer/query_test.go | 76 + .../golang.org/x/tools/go/pointer/reflect.go | 1975 + vendor/golang.org/x/tools/go/pointer/solve.go | 370 + .../x/tools/go/pointer/stdlib_test.go | 111 + .../x/tools/go/pointer/testdata/a_test.go | 42 + .../x/tools/go/pointer/testdata/another.go | 36 + .../tools/go/pointer/testdata/arrayreflect.go | 191 + .../x/tools/go/pointer/testdata/arrays.go | 97 + .../x/tools/go/pointer/testdata/channels.go | 118 + .../tools/go/pointer/testdata/chanreflect.go | 85 + .../tools/go/pointer/testdata/chanreflect1.go | 35 + .../x/tools/go/pointer/testdata/context.go | 48 + .../x/tools/go/pointer/testdata/conv.go | 63 + .../x/tools/go/pointer/testdata/extended.go | 21 + .../x/tools/go/pointer/testdata/finalizer.go | 89 + .../x/tools/go/pointer/testdata/flow.go | 63 + .../x/tools/go/pointer/testdata/fmtexcerpt.go | 42 + .../x/tools/go/pointer/testdata/func.go | 205 + .../tools/go/pointer/testdata/funcreflect.go | 130 + .../x/tools/go/pointer/testdata/hello.go | 27 + .../x/tools/go/pointer/testdata/interfaces.go | 152 + .../x/tools/go/pointer/testdata/issue9002.go | 17 + .../x/tools/go/pointer/testdata/mapreflect.go | 117 + .../x/tools/go/pointer/testdata/maps.go | 74 + .../x/tools/go/pointer/testdata/panic.go | 36 + .../x/tools/go/pointer/testdata/recur.go | 11 + .../x/tools/go/pointer/testdata/reflect.go | 115 + .../x/tools/go/pointer/testdata/rtti.go | 29 + .../go/pointer/testdata/structreflect.go | 45 + .../x/tools/go/pointer/testdata/structs.go | 100 + .../x/tools/go/pointer/testdata/timer.go | 24 + vendor/golang.org/x/tools/go/pointer/util.go | 313 + vendor/golang.org/x/tools/go/ssa/blockopt.go | 187 + vendor/golang.org/x/tools/go/ssa/builder.go | 2379 + .../golang.org/x/tools/go/ssa/builder_test.go | 500 + vendor/golang.org/x/tools/go/ssa/const.go | 169 + vendor/golang.org/x/tools/go/ssa/create.go | 270 + vendor/golang.org/x/tools/go/ssa/doc.go | 125 + vendor/golang.org/x/tools/go/ssa/dom.go | 341 + vendor/golang.org/x/tools/go/ssa/emit.go | 468 + .../golang.org/x/tools/go/ssa/example_test.go | 164 + vendor/golang.org/x/tools/go/ssa/func.go | 689 + vendor/golang.org/x/tools/go/ssa/identical.go | 7 + .../golang.org/x/tools/go/ssa/identical_17.go | 7 + .../x/tools/go/ssa/identical_test.go | 9 + .../x/tools/go/ssa/interp/external.go | 562 + .../x/tools/go/ssa/interp/external_darwin.go | 35 + .../x/tools/go/ssa/interp/external_unix.go | 256 + .../x/tools/go/ssa/interp/interp.go | 764 + .../x/tools/go/ssa/interp/interp_test.go | 318 + .../golang.org/x/tools/go/ssa/interp/map.go | 121 + .../golang.org/x/tools/go/ssa/interp/ops.go | 1396 + .../x/tools/go/ssa/interp/reflect.go | 574 + .../x/tools/go/ssa/interp/testdata/a_test.go | 17 + .../x/tools/go/ssa/interp/testdata/b_test.go | 11 + .../tools/go/ssa/interp/testdata/boundmeth.go | 144 + .../x/tools/go/ssa/interp/testdata/c_test.go | 17 + .../tools/go/ssa/interp/testdata/callstack.go | 52 + .../x/tools/go/ssa/interp/testdata/complit.go | 186 + .../tools/go/ssa/interp/testdata/coverage.go | 534 + .../x/tools/go/ssa/interp/testdata/defer.go | 53 + .../tools/go/ssa/interp/testdata/fieldprom.go | 114 + .../tools/go/ssa/interp/testdata/ifaceconv.go | 83 + .../tools/go/ssa/interp/testdata/ifaceprom.go | 58 + .../tools/go/ssa/interp/testdata/initorder.go | 67 + .../tools/go/ssa/interp/testdata/methprom.go | 93 + .../tools/go/ssa/interp/testdata/mrvchain.go | 75 + .../x/tools/go/ssa/interp/testdata/range.go | 55 + .../x/tools/go/ssa/interp/testdata/recover.go | 34 + .../x/tools/go/ssa/interp/testdata/reflect.go | 11 + .../x/tools/go/ssa/interp/testdata/static.go | 58 + .../golang.org/x/tools/go/ssa/interp/value.go | 497 + vendor/golang.org/x/tools/go/ssa/lift.go | 653 + vendor/golang.org/x/tools/go/ssa/lvalue.go | 120 + vendor/golang.org/x/tools/go/ssa/methods.go | 239 + vendor/golang.org/x/tools/go/ssa/mode.go | 100 + vendor/golang.org/x/tools/go/ssa/print.go | 431 + vendor/golang.org/x/tools/go/ssa/sanity.go | 532 + vendor/golang.org/x/tools/go/ssa/source.go | 293 + .../golang.org/x/tools/go/ssa/source_test.go | 402 + vendor/golang.org/x/tools/go/ssa/ssa.go | 1695 + .../golang.org/x/tools/go/ssa/ssautil/load.go | 175 + .../x/tools/go/ssa/ssautil/load_test.go | 120 + .../x/tools/go/ssa/ssautil/switch.go | 234 + .../x/tools/go/ssa/ssautil/switch_test.go | 74 + .../tools/go/ssa/ssautil/testdata/switches.go | 357 + .../x/tools/go/ssa/ssautil/visit.go | 79 + .../golang.org/x/tools/go/ssa/stdlib_test.go | 151 + .../x/tools/go/ssa/testdata/objlookup.go | 160 + .../x/tools/go/ssa/testdata/structconv.go | 24 + .../x/tools/go/ssa/testdata/valueforexpr.go | 153 + vendor/golang.org/x/tools/go/ssa/testmain.go | 271 + .../x/tools/go/ssa/testmain_test.go | 124 + vendor/golang.org/x/tools/go/ssa/util.go | 119 + vendor/golang.org/x/tools/go/ssa/wrappers.go | 290 + .../x/tools/go/types/objectpath/objectpath.go | 523 + .../go/types/objectpath/objectpath_test.go | 301 + .../x/tools/go/types/typeutil/callee.go | 46 + .../x/tools/go/types/typeutil/callee_test.go | 89 + .../x/tools/go/types/typeutil/example_test.go | 67 + .../x/tools/go/types/typeutil/imports.go | 31 + .../x/tools/go/types/typeutil/imports_test.go | 80 + .../x/tools/go/types/typeutil/map.go | 313 + .../x/tools/go/types/typeutil/map_test.go | 174 + .../tools/go/types/typeutil/methodsetcache.go | 72 + .../x/tools/go/types/typeutil/ui.go | 52 + .../x/tools/go/types/typeutil/ui_test.go | 61 + vendor/golang.org/x/tools/go/vcs/discovery.go | 76 + vendor/golang.org/x/tools/go/vcs/env.go | 39 + vendor/golang.org/x/tools/go/vcs/http.go | 80 + vendor/golang.org/x/tools/go/vcs/vcs.go | 768 + vendor/golang.org/x/tools/go/vcs/vcs_test.go | 280 + vendor/golang.org/x/tools/godoc/README.md | 31 + .../golang.org/x/tools/godoc/analysis/README | 111 + .../x/tools/godoc/analysis/analysis.go | 613 + .../x/tools/godoc/analysis/callgraph.go | 351 + .../x/tools/godoc/analysis/implements.go | 195 + .../golang.org/x/tools/godoc/analysis/json.go | 69 + .../x/tools/godoc/analysis/peers.go | 154 + .../x/tools/godoc/analysis/typeinfo.go | 234 + vendor/golang.org/x/tools/godoc/corpus.go | 168 + vendor/golang.org/x/tools/godoc/dirtrees.go | 383 + .../golang.org/x/tools/godoc/dirtrees_test.go | 64 + vendor/golang.org/x/tools/godoc/dl/dl.go | 352 + vendor/golang.org/x/tools/godoc/dl/dl_test.go | 135 + vendor/golang.org/x/tools/godoc/dl/server.go | 267 + vendor/golang.org/x/tools/godoc/dl/tmpl.go | 277 + vendor/golang.org/x/tools/godoc/env/env.go | 41 + vendor/golang.org/x/tools/godoc/format.go | 371 + vendor/golang.org/x/tools/godoc/godoc.go | 959 + .../golang.org/x/tools/godoc/godoc17_test.go | 35 + vendor/golang.org/x/tools/godoc/godoc_test.go | 370 + vendor/golang.org/x/tools/godoc/index.go | 1580 + vendor/golang.org/x/tools/godoc/index_test.go | 323 + vendor/golang.org/x/tools/godoc/linkify.go | 195 + vendor/golang.org/x/tools/godoc/meta.go | 144 + vendor/golang.org/x/tools/godoc/page.go | 80 + vendor/golang.org/x/tools/godoc/parser.go | 74 + vendor/golang.org/x/tools/godoc/pres.go | 169 + .../golang.org/x/tools/godoc/proxy/proxy.go | 157 + .../golang.org/x/tools/godoc/redirect/hash.go | 138 + .../x/tools/godoc/redirect/redirect.go | 254 + .../x/tools/godoc/redirect/redirect_test.go | 113 + .../x/tools/godoc/redirect/rietveld.go | 1093 + vendor/golang.org/x/tools/godoc/search.go | 186 + vendor/golang.org/x/tools/godoc/server.go | 836 + .../golang.org/x/tools/godoc/server_test.go | 48 + .../golang.org/x/tools/godoc/short/short.go | 186 + vendor/golang.org/x/tools/godoc/short/tmpl.go | 119 + vendor/golang.org/x/tools/godoc/snippet.go | 123 + vendor/golang.org/x/tools/godoc/spec.go | 179 + vendor/golang.org/x/tools/godoc/spec_test.go | 22 + vendor/golang.org/x/tools/godoc/spot.go | 83 + .../x/tools/godoc/static/analysis/call-eg.png | Bin 0 -> 11383 bytes .../x/tools/godoc/static/analysis/call3.png | Bin 0 -> 16960 bytes .../tools/godoc/static/analysis/callers1.png | Bin 0 -> 13068 bytes .../tools/godoc/static/analysis/callers2.png | Bin 0 -> 20822 bytes .../x/tools/godoc/static/analysis/chan1.png | Bin 0 -> 44287 bytes .../x/tools/godoc/static/analysis/chan2a.png | Bin 0 -> 19600 bytes .../x/tools/godoc/static/analysis/chan2b.png | Bin 0 -> 18204 bytes .../x/tools/godoc/static/analysis/error1.png | Bin 0 -> 13633 bytes .../x/tools/godoc/static/analysis/help.html | 254 + .../tools/godoc/static/analysis/ident-def.png | Bin 0 -> 13141 bytes .../godoc/static/analysis/ident-field.png | Bin 0 -> 12131 bytes .../godoc/static/analysis/ident-func.png | Bin 0 -> 12554 bytes .../tools/godoc/static/analysis/ipcg-func.png | Bin 0 -> 10919 bytes .../tools/godoc/static/analysis/ipcg-pkg.png | Bin 0 -> 21092 bytes .../godoc/static/analysis/typeinfo-pkg.png | Bin 0 -> 30004 bytes .../godoc/static/analysis/typeinfo-src.png | Bin 0 -> 16891 bytes .../x/tools/godoc/static/callgraph.html | 15 + .../x/tools/godoc/static/codewalk.html | 56 + .../x/tools/godoc/static/codewalkdir.html | 16 + .../x/tools/godoc/static/dirlist.html | 31 + vendor/golang.org/x/tools/godoc/static/doc.go | 8 + .../x/tools/godoc/static/error.html | 9 + .../x/tools/godoc/static/example.html | 30 + vendor/golang.org/x/tools/godoc/static/gen.go | 109 + .../x/tools/godoc/static/gen_test.go | 49 + .../x/tools/godoc/static/godoc.html | 143 + .../golang.org/x/tools/godoc/static/godocs.js | 640 + .../x/tools/godoc/static/images/minus.gif | Bin 0 -> 837 bytes .../x/tools/godoc/static/images/plus.gif | Bin 0 -> 841 bytes .../static/images/treeview-black-line.gif | Bin 0 -> 1877 bytes .../godoc/static/images/treeview-black.gif | Bin 0 -> 402 bytes .../static/images/treeview-default-line.gif | Bin 0 -> 1993 bytes .../godoc/static/images/treeview-default.gif | Bin 0 -> 400 bytes .../static/images/treeview-gray-line.gif | Bin 0 -> 1877 bytes .../godoc/static/images/treeview-gray.gif | Bin 0 -> 411 bytes .../x/tools/godoc/static/implements.html | 9 + .../golang.org/x/tools/godoc/static/jquery.js | 2 + .../x/tools/godoc/static/jquery.treeview.css | 76 + .../godoc/static/jquery.treeview.edit.js | 39 + .../x/tools/godoc/static/jquery.treeview.js | 256 + .../x/tools/godoc/static/makestatic.go | 36 + .../x/tools/godoc/static/methodset.html | 9 + .../x/tools/godoc/static/opensearch.xml | 11 + .../x/tools/godoc/static/package.html | 292 + .../x/tools/godoc/static/packageroot.html | 150 + .../golang.org/x/tools/godoc/static/play.js | 114 + .../x/tools/godoc/static/playground.js | 534 + .../x/tools/godoc/static/search.html | 66 + .../x/tools/godoc/static/searchcode.html | 64 + .../x/tools/godoc/static/searchdoc.html | 24 + .../x/tools/godoc/static/searchtxt.html | 42 + .../golang.org/x/tools/godoc/static/static.go | 105 + .../golang.org/x/tools/godoc/static/style.css | 867 + vendor/golang.org/x/tools/godoc/tab.go | 82 + vendor/golang.org/x/tools/godoc/template.go | 179 + .../golang.org/x/tools/godoc/util/throttle.go | 88 + vendor/golang.org/x/tools/godoc/util/util.go | 89 + vendor/golang.org/x/tools/godoc/versions.go | 224 + .../golang.org/x/tools/godoc/versions_test.go | 132 + .../golang.org/x/tools/godoc/vfs/emptyvfs.go | 89 + .../x/tools/godoc/vfs/emptyvfs_test.go | 58 + .../x/tools/godoc/vfs/gatefs/gatefs.go | 93 + .../x/tools/godoc/vfs/gatefs/gatefs_test.go | 39 + .../x/tools/godoc/vfs/httpfs/httpfs.go | 94 + .../x/tools/godoc/vfs/mapfs/mapfs.go | 156 + .../x/tools/godoc/vfs/mapfs/mapfs_test.go | 111 + .../golang.org/x/tools/godoc/vfs/namespace.go | 403 + vendor/golang.org/x/tools/godoc/vfs/os.go | 105 + .../golang.org/x/tools/godoc/vfs/os_test.go | 38 + vendor/golang.org/x/tools/godoc/vfs/vfs.go | 58 + .../x/tools/godoc/vfs/zipfs/zipfs.go | 291 + .../x/tools/godoc/vfs/zipfs/zipfs_test.go | 206 + vendor/golang.org/x/tools/imports/fix.go | 934 + vendor/golang.org/x/tools/imports/fix_test.go | 2187 + vendor/golang.org/x/tools/imports/imports.go | 310 + vendor/golang.org/x/tools/imports/mkindex.go | 173 + vendor/golang.org/x/tools/imports/mkstdlib.go | 108 + .../golang.org/x/tools/imports/sortimports.go | 230 + vendor/golang.org/x/tools/imports/zstdlib.go | 9970 +++ .../x/tools/internal/fastwalk/fastwalk.go | 196 + .../fastwalk/fastwalk_dirent_fileno.go | 13 + .../internal/fastwalk/fastwalk_dirent_ino.go | 14 + .../fastwalk/fastwalk_dirent_namlen_bsd.go | 13 + .../fastwalk/fastwalk_dirent_namlen_linux.go | 29 + .../internal/fastwalk/fastwalk_portable.go | 37 + .../tools/internal/fastwalk/fastwalk_test.go | 239 + .../tools/internal/fastwalk/fastwalk_unix.go | 127 + .../x/tools/internal/gopathwalk/walk.go | 249 + .../x/tools/internal/gopathwalk/walk_test.go | 135 + .../x/tools/internal/jsonrpc2/jsonrpc2.go | 358 + .../tools/internal/jsonrpc2/jsonrpc2_test.go | 163 + .../x/tools/internal/jsonrpc2/log.go | 59 + .../x/tools/internal/jsonrpc2/stream.go | 146 + .../x/tools/internal/jsonrpc2/wire.go | 139 + .../x/tools/internal/lsp/completion.go | 111 + .../x/tools/internal/lsp/diagnostics.go | 52 + .../x/tools/internal/lsp/lsp110_test.go | 7 + .../x/tools/internal/lsp/lsp_test.go | 346 + .../x/tools/internal/lsp/position.go | 114 + .../x/tools/internal/lsp/protocol/basic.go | 362 + .../x/tools/internal/lsp/protocol/client.go | 187 + .../internal/lsp/protocol/diagnostics.go | 20 + .../x/tools/internal/lsp/protocol/doc.go | 16 + .../x/tools/internal/lsp/protocol/general.go | 849 + .../x/tools/internal/lsp/protocol/language.go | 1020 + .../x/tools/internal/lsp/protocol/printers.go | 83 + .../x/tools/internal/lsp/protocol/protocol.go | 49 + .../internal/lsp/protocol/registration.go | 61 + .../x/tools/internal/lsp/protocol/server.go | 646 + .../x/tools/internal/lsp/protocol/text.go | 130 + .../x/tools/internal/lsp/protocol/window.go | 77 + .../tools/internal/lsp/protocol/workspace.go | 203 + .../golang.org/x/tools/internal/lsp/server.go | 338 + .../x/tools/internal/lsp/signature_help.go | 33 + .../x/tools/internal/lsp/source/completion.go | 737 + .../x/tools/internal/lsp/source/definition.go | 121 + .../tools/internal/lsp/source/diagnostics.go | 148 + .../x/tools/internal/lsp/source/file.go | 131 + .../x/tools/internal/lsp/source/format.go | 59 + .../internal/lsp/source/signature_help.go | 118 + .../x/tools/internal/lsp/source/uri.go | 47 + .../x/tools/internal/lsp/source/view.go | 82 + .../testdata/assign_rank/assign_rank.go.in | 19 + .../x/tools/internal/lsp/testdata/bad/bad.go | 21 + .../internal/lsp/testdata/bad/bad_util.go | 27 + .../tools/internal/lsp/testdata/bar/bar.go.in | 46 + .../tools/internal/lsp/testdata/baz/baz.go.in | 31 + .../internal/lsp/testdata/cast/cast.go.in | 11 + .../x/tools/internal/lsp/testdata/foo/foo.go | 23 + .../lsp/testdata/format/bad_format.go | 21 + .../lsp/testdata/format/good_format.go | 9 + .../tools/internal/lsp/testdata/godef/a/a.go | 11 + .../internal/lsp/testdata/godef/a/random.go | 23 + .../tools/internal/lsp/testdata/godef/b/b.go | 23 + .../tools/internal/lsp/testdata/godef/b/c.go | 8 + .../internal/lsp/testdata/godef/b/c.go.saved | 7 + .../testdata/godef/broken/unclosedIf.go.in | 11 + .../tools/internal/lsp/testdata/good/good.go | 6 + .../internal/lsp/testdata/good/good_util.go | 19 + .../lsp/testdata/noparse/noparse.go.in | 11 + .../noparse_format/noparse_format.go.in | 9 + .../lsp/testdata/selector/selector.go.in | 66 + .../internal/lsp/testdata/types/types.go | 16 + .../x/tools/internal/memcache/memcache.go | 159 + .../tools/internal/memcache/memcache_test.go | 85 + .../x/tools/internal/semver/semver.go | 388 + .../x/tools/internal/semver/semver_test.go | 182 + .../x/tools/playground/appengine.go | 34 + .../golang.org/x/tools/playground/common.go | 67 + vendor/golang.org/x/tools/playground/local.go | 32 + .../x/tools/playground/socket/socket.go | 524 + .../x/tools/playground/socket/socket_test.go | 77 + vendor/golang.org/x/tools/present/args.go | 229 + vendor/golang.org/x/tools/present/caption.go | 22 + vendor/golang.org/x/tools/present/code.go | 267 + .../golang.org/x/tools/present/code_test.go | 225 + vendor/golang.org/x/tools/present/doc.go | 261 + vendor/golang.org/x/tools/present/html.go | 31 + vendor/golang.org/x/tools/present/iframe.go | 45 + vendor/golang.org/x/tools/present/image.go | 50 + vendor/golang.org/x/tools/present/link.go | 100 + .../golang.org/x/tools/present/link_test.go | 40 + vendor/golang.org/x/tools/present/parse.go | 568 + vendor/golang.org/x/tools/present/style.go | 167 + .../golang.org/x/tools/present/style_test.go | 124 + vendor/golang.org/x/tools/present/video.go | 51 + vendor/golang.org/x/tools/refactor/README | 1 + vendor/golang.org/x/tools/refactor/eg/eg.go | 373 + .../golang.org/x/tools/refactor/eg/eg_test.go | 166 + .../golang.org/x/tools/refactor/eg/match.go | 249 + .../golang.org/x/tools/refactor/eg/rewrite.go | 401 + .../x/tools/refactor/eg/testdata/A.template | 13 + .../x/tools/refactor/eg/testdata/A1.go | 51 + .../x/tools/refactor/eg/testdata/A1.golden | 52 + .../x/tools/refactor/eg/testdata/A2.go | 12 + .../x/tools/refactor/eg/testdata/A2.golden | 15 + .../x/tools/refactor/eg/testdata/B.template | 9 + .../x/tools/refactor/eg/testdata/B1.go | 17 + .../x/tools/refactor/eg/testdata/B1.golden | 17 + .../x/tools/refactor/eg/testdata/C.template | 10 + .../x/tools/refactor/eg/testdata/C1.go | 22 + .../x/tools/refactor/eg/testdata/C1.golden | 22 + .../x/tools/refactor/eg/testdata/D.template | 8 + .../x/tools/refactor/eg/testdata/D1.go | 12 + .../x/tools/refactor/eg/testdata/D1.golden | 12 + .../x/tools/refactor/eg/testdata/E.template | 12 + .../x/tools/refactor/eg/testdata/E1.go | 9 + .../x/tools/refactor/eg/testdata/E1.golden | 13 + .../x/tools/refactor/eg/testdata/F.template | 8 + .../x/tools/refactor/eg/testdata/F1.go | 48 + .../x/tools/refactor/eg/testdata/F1.golden | 48 + .../x/tools/refactor/eg/testdata/G.template | 10 + .../x/tools/refactor/eg/testdata/G1.go | 12 + .../x/tools/refactor/eg/testdata/G1.golden | 12 + .../x/tools/refactor/eg/testdata/H.template | 9 + .../x/tools/refactor/eg/testdata/H1.go | 12 + .../x/tools/refactor/eg/testdata/H1.golden | 12 + .../x/tools/refactor/eg/testdata/I.template | 14 + .../x/tools/refactor/eg/testdata/I1.go | 9 + .../x/tools/refactor/eg/testdata/I1.golden | 14 + .../x/tools/refactor/eg/testdata/J.template | 11 + .../x/tools/refactor/eg/testdata/J1.go | 10 + .../x/tools/refactor/eg/testdata/J1.golden | 11 + .../refactor/eg/testdata/bad_type.template | 8 + .../eg/testdata/expr_type_mismatch.template | 15 + .../eg/testdata/no_after_return.template | 4 + .../refactor/eg/testdata/no_before.template | 5 + .../eg/testdata/type_mismatch.template | 6 + .../x/tools/refactor/importgraph/graph.go | 167 + .../tools/refactor/importgraph/graph_test.go | 99 + .../x/tools/refactor/rename/check.go | 858 + .../x/tools/refactor/rename/mvpkg.go | 375 + .../x/tools/refactor/rename/mvpkg_test.go | 463 + .../x/tools/refactor/rename/rename.go | 603 + .../x/tools/refactor/rename/rename_test.go | 1334 + .../x/tools/refactor/rename/spec.go | 593 + .../x/tools/refactor/rename/util.go | 105 + .../x/tools/refactor/satisfy/find.go | 705 + .../x/tools/third_party/moduleloader/LICENSE | 22 + .../third_party/moduleloader/moduleloader.js | 7 + .../x/tools/third_party/typescript/LICENSE | 55 + .../third_party/typescript/typescript.js | 60312 ++++++++++++++++ .../x/tools/third_party/webcomponents/LICENSE | 27 + .../webcomponents/customelements.js | 1029 + .../.github/PULL_REQUEST_TEMPLATE.md | 2 + vendor/k8s.io/code-generator/CONTRIBUTING.md | 7 + .../k8s.io/code-generator/Godeps/Godeps.json | 270 + vendor/k8s.io/code-generator/Godeps/OWNERS | 2 + vendor/k8s.io/code-generator/Godeps/Readme | 5 + vendor/k8s.io/code-generator/LICENSE | 202 + vendor/k8s.io/code-generator/OWNERS | 8 + vendor/k8s.io/code-generator/README.md | 24 + .../_examples/apiserver/apis/example/doc.go | 19 + .../apiserver/apis/example/install/install.go | 43 + .../apiserver/apis/example/register.go | 45 + .../_examples/apiserver/apis/example/types.go | 44 + .../apiserver/apis/example/v1/doc.go | 20 + .../apiserver/apis/example/v1/register.go | 59 + .../apiserver/apis/example/v1/types.go | 47 + .../example/v1/zz_generated.conversion.go | 114 + .../apis/example/v1/zz_generated.deepcopy.go | 101 + .../apis/example/v1/zz_generated.defaults.go | 32 + .../apis/example/zz_generated.deepcopy.go | 101 + .../_examples/apiserver/apis/example2/doc.go | 20 + .../apis/example2/install/install.go | 43 + .../apiserver/apis/example2/register.go | 45 + .../apiserver/apis/example2/types.go | 44 + .../apiserver/apis/example2/v1/doc.go | 21 + .../apiserver/apis/example2/v1/register.go | 59 + .../apiserver/apis/example2/v1/types.go | 47 + .../example2/v1/zz_generated.conversion.go | 114 + .../apis/example2/v1/zz_generated.deepcopy.go | 101 + .../apis/example2/v1/zz_generated.defaults.go | 32 + .../apis/example2/zz_generated.deepcopy.go | 101 + .../clientset/internalversion/clientset.go | 106 + .../clientset/internalversion/doc.go | 20 + .../fake/clientset_generated.go | 83 + .../clientset/internalversion/fake/doc.go | 20 + .../internalversion/fake/register.go | 56 + .../clientset/internalversion/scheme/doc.go | 20 + .../internalversion/scheme/register.go | 50 + .../typed/example/internalversion/doc.go | 20 + .../example/internalversion/example_client.go | 101 + .../typed/example/internalversion/fake/doc.go | 20 + .../fake/fake_example_client.go | 40 + .../internalversion/fake/fake_testtype.go | 140 + .../internalversion/generated_expansion.go | 21 + .../typed/example/internalversion/testtype.go | 174 + .../typed/example2/internalversion/doc.go | 20 + .../internalversion/example2_client.go | 101 + .../example2/internalversion/fake/doc.go | 20 + .../fake/fake_example2_client.go | 40 + .../internalversion/fake/fake_testtype.go | 140 + .../internalversion/generated_expansion.go | 21 + .../example2/internalversion/testtype.go | 174 + .../clientset/versioned/clientset.go | 122 + .../apiserver/clientset/versioned/doc.go | 20 + .../versioned/fake/clientset_generated.go | 93 + .../apiserver/clientset/versioned/fake/doc.go | 20 + .../clientset/versioned/fake/register.go | 56 + .../clientset/versioned/scheme/doc.go | 20 + .../clientset/versioned/scheme/register.go | 56 + .../versioned/typed/example/v1/doc.go | 20 + .../typed/example/v1/example_client.go | 90 + .../versioned/typed/example/v1/fake/doc.go | 20 + .../example/v1/fake/fake_example_client.go | 40 + .../typed/example/v1/fake/fake_testtype.go | 140 + .../typed/example/v1/generated_expansion.go | 21 + .../versioned/typed/example/v1/testtype.go | 174 + .../versioned/typed/example2/v1/doc.go | 20 + .../typed/example2/v1/example2_client.go | 90 + .../versioned/typed/example2/v1/fake/doc.go | 20 + .../example2/v1/fake/fake_example2_client.go | 40 + .../typed/example2/v1/fake/fake_testtype.go | 140 + .../typed/example2/v1/generated_expansion.go | 21 + .../versioned/typed/example2/v1/testtype.go | 174 + .../externalversions/example/interface.go | 46 + .../externalversions/example/v1/interface.go | 45 + .../externalversions/example/v1/testtype.go | 89 + .../externalversions/example2/interface.go | 46 + .../externalversions/example2/v1/interface.go | 45 + .../externalversions/example2/v1/testtype.go | 89 + .../informers/externalversions/factory.go | 137 + .../informers/externalversions/generic.go | 67 + .../internalinterfaces/factory_interfaces.go | 38 + .../internalversion/example/interface.go | 46 + .../example/internalversion/interface.go | 45 + .../example/internalversion/testtype.go | 89 + .../internalversion/example2/interface.go | 46 + .../example2/internalversion/interface.go | 45 + .../example2/internalversion/testtype.go | 89 + .../informers/internalversion/factory.go | 137 + .../informers/internalversion/generic.go | 67 + .../internalinterfaces/factory_interfaces.go | 38 + .../internalversion/expansion_generated.go | 27 + .../example/internalversion/testtype.go | 94 + .../listers/example/v1/expansion_generated.go | 27 + .../apiserver/listers/example/v1/testtype.go | 94 + .../internalversion/expansion_generated.go | 27 + .../example2/internalversion/testtype.go | 94 + .../example2/v1/expansion_generated.go | 27 + .../apiserver/listers/example2/v1/testtype.go | 94 + .../_examples/crd/apis/example/v1/doc.go | 19 + .../_examples/crd/apis/example/v1/register.go | 59 + .../_examples/crd/apis/example/v1/types.go | 47 + .../apis/example/v1/zz_generated.deepcopy.go | 101 + .../_examples/crd/apis/example2/v1/doc.go | 20 + .../crd/apis/example2/v1/register.go | 59 + .../_examples/crd/apis/example2/v1/types.go | 47 + .../apis/example2/v1/zz_generated.deepcopy.go | 101 + .../crd/clientset/versioned/clientset.go | 122 + .../_examples/crd/clientset/versioned/doc.go | 20 + .../versioned/fake/clientset_generated.go | 93 + .../crd/clientset/versioned/fake/doc.go | 20 + .../crd/clientset/versioned/fake/register.go | 56 + .../crd/clientset/versioned/scheme/doc.go | 20 + .../clientset/versioned/scheme/register.go | 56 + .../versioned/typed/example/v1/doc.go | 20 + .../typed/example/v1/example_client.go | 90 + .../versioned/typed/example/v1/fake/doc.go | 20 + .../example/v1/fake/fake_example_client.go | 40 + .../typed/example/v1/fake/fake_testtype.go | 140 + .../typed/example/v1/generated_expansion.go | 21 + .../versioned/typed/example/v1/testtype.go | 174 + .../versioned/typed/example2/v1/doc.go | 20 + .../typed/example2/v1/example2_client.go | 90 + .../versioned/typed/example2/v1/fake/doc.go | 20 + .../example2/v1/fake/fake_example2_client.go | 40 + .../typed/example2/v1/fake/fake_testtype.go | 140 + .../typed/example2/v1/generated_expansion.go | 21 + .../versioned/typed/example2/v1/testtype.go | 174 + .../externalversions/example/interface.go | 46 + .../externalversions/example/v1/interface.go | 45 + .../externalversions/example/v1/testtype.go | 89 + .../externalversions/example2/interface.go | 46 + .../externalversions/example2/v1/interface.go | 45 + .../externalversions/example2/v1/testtype.go | 89 + .../crd/informers/externalversions/factory.go | 137 + .../crd/informers/externalversions/generic.go | 67 + .../internalinterfaces/factory_interfaces.go | 38 + .../listers/example/v1/expansion_generated.go | 27 + .../crd/listers/example/v1/testtype.go | 94 + .../example2/v1/expansion_generated.go | 27 + .../crd/listers/example2/v1/testtype.go | 94 + .../code-generator/cmd/client-gen/OWNERS | 8 + .../code-generator/cmd/client-gen/README.md | 4 + .../cmd/client-gen/args/args.go | 120 + .../cmd/client-gen/args/gvpackages.go | 183 + .../cmd/client-gen/args/gvpackages_test.go | 116 + .../cmd/client-gen/args/gvtype.go | 110 + .../client-gen/generators/client_generator.go | 426 + .../generators/fake/fake_client_generator.go | 130 + .../fake/generator_fake_for_clientset.go | 172 + .../fake/generator_fake_for_group.go | 130 + .../fake/generator_fake_for_type.go | 494 + .../generators/generator_for_clientset.go | 194 + .../generators/generator_for_expansion.go | 54 + .../generators/generator_for_group.go | 252 + .../generators/generator_for_type.go | 579 + .../generators/scheme/generator_for_scheme.go | 191 + .../cmd/client-gen/generators/tags.go | 32 + .../cmd/client-gen/generators/util/tags.go | 341 + .../client-gen/generators/util/tags_test.go | 148 + .../code-generator/cmd/client-gen/main.go | 65 + .../cmd/client-gen/path/path.go | 31 + .../cmd/client-gen/types/helpers.go | 123 + .../cmd/client-gen/types/helpers_test.go | 32 + .../cmd/client-gen/types/types.go | 78 + .../cmd/conversion-gen/args/args.go | 83 + .../conversion-gen/generators/conversion.go | 960 + .../code-generator/cmd/conversion-gen/main.go | 76 + .../cmd/deepcopy-gen/args/args.go | 54 + .../code-generator/cmd/deepcopy-gen/main.go | 84 + .../cmd/defaulter-gen/args/args.go | 54 + .../code-generator/cmd/defaulter-gen/main.go | 83 + .../cmd/go-to-protobuf/.gitignore | 1 + .../code-generator/cmd/go-to-protobuf/OWNERS | 4 + .../code-generator/cmd/go-to-protobuf/main.go | 39 + .../cmd/go-to-protobuf/protobuf/cmd.go | 349 + .../cmd/go-to-protobuf/protobuf/generator.go | 769 + .../go-to-protobuf/protobuf/import_tracker.go | 50 + .../cmd/go-to-protobuf/protobuf/namer.go | 205 + .../cmd/go-to-protobuf/protobuf/namer_test.go | 50 + .../cmd/go-to-protobuf/protobuf/package.go | 215 + .../cmd/go-to-protobuf/protobuf/parser.go | 452 + .../cmd/go-to-protobuf/protobuf/tags.go | 33 + .../go-to-protobuf/protoc-gen-gogo/main.go | 32 + .../code-generator/cmd/import-boss/.gitignore | 1 + .../code-generator/cmd/import-boss/main.go | 89 + .../cmd/informer-gen/args/args.go | 77 + .../cmd/informer-gen/generators/factory.go | 208 + .../generators/factoryinterface.go | 88 + .../cmd/informer-gen/generators/generic.go | 180 + .../informer-gen/generators/groupinterface.go | 118 + .../cmd/informer-gen/generators/informer.go | 186 + .../cmd/informer-gen/generators/packages.go | 352 + .../cmd/informer-gen/generators/tags.go | 33 + .../cmd/informer-gen/generators/types.go | 41 + .../generators/versioninterface.go | 109 + .../code-generator/cmd/informer-gen/main.go | 62 + .../cmd/lister-gen/.import-restrictions | 1 + .../cmd/lister-gen/args/args.go | 56 + .../cmd/lister-gen/generators/expansion.go | 67 + .../cmd/lister-gen/generators/lister.go | 371 + .../cmd/lister-gen/generators/tags.go | 33 + .../code-generator/cmd/lister-gen/main.go | 59 + .../code-generator/cmd/openapi-gen/README | 13 + .../cmd/openapi-gen/args/args.go | 53 + .../code-generator/cmd/openapi-gen/main.go | 61 + .../code-generator/cmd/set-gen/.gitignore | 1 + .../k8s.io/code-generator/cmd/set-gen/main.go | 55 + .../k8s.io/code-generator/code-of-conduct.md | 3 + .../k8s.io/code-generator/generate-groups.sh | 86 + .../generate-internal-groups.sh | 109 + .../code-generator/hack/boilerplate.go.txt | 16 + .../code-generator/hack/update-codegen.sh | 32 + .../code-generator/hack/verify-codegen.sh | 53 + .../k8s.io/code-generator/pkg/util/build.go | 61 + .../third_party/forked/golang/reflect/type.go | 91 + vendor/k8s.io/gengo/.import-restrictions | 11 + vendor/k8s.io/gengo/.travis.yml | 16 + vendor/k8s.io/gengo/CONTRIBUTING.md | 9 + vendor/k8s.io/gengo/LICENSE | 202 + vendor/k8s.io/gengo/OWNERS | 4 + vendor/k8s.io/gengo/README.md | 56 + vendor/k8s.io/gengo/SECURITY_CONTACTS | 15 + vendor/k8s.io/gengo/args/args.go | 199 + vendor/k8s.io/gengo/args/args_test.go | 35 + .../gengo/boilerplate/boilerplate.go.txt | 16 + .../gengo/boilerplate/no-boilerplate.go.txt | 0 vendor/k8s.io/gengo/code-of-conduct.md | 3 + .../gengo/examples/deepcopy-gen/.gitignore | 1 + .../gengo/examples/deepcopy-gen/Makefile | 16 + .../deepcopy-gen/generators/deepcopy.go | 912 + .../deepcopy-gen/generators/deepcopy_test.go | 749 + .../gengo/examples/deepcopy-gen/main.go | 88 + .../deepcopy-gen/output_tests/aliases/doc.go | 89 + .../output_tests/aliases/zz_generated.go | 412 + .../deepcopy-gen/output_tests/builtins/doc.go | 35 + .../output_tests/builtins/zz_generated.go | 37 + .../output_tests/interface_fuzzer.go | 131 + .../output_tests/interfaces/doc.go | 29 + .../output_tests/interfaces/zz_generated.go | 46 + .../deepcopy-gen/output_tests/maps/doc.go | 43 + .../output_tests/maps/zz_generated.go | 242 + .../output_tests/otherpkg/interfaces.go | 25 + .../deepcopy-gen/output_tests/output_test.go | 157 + .../deepcopy-gen/output_tests/pointer/doc.go | 31 + .../output_tests/pointer/zz_generated.go | 113 + .../output_tests/reflect_deepcopy.go | 81 + .../deepcopy-gen/output_tests/slices/doc.go | 43 + .../output_tests/slices/zz_generated.go | 192 + .../deepcopy-gen/output_tests/structs/doc.go | 40 + .../output_tests/structs/zz_generated.go | 55 + .../deepcopy-gen/output_tests/value_fuzzer.go | 86 + .../deepcopy-gen/output_tests/wholepkg/a.go | 171 + .../deepcopy-gen/output_tests/wholepkg/b.go | 20 + .../output_tests/wholepkg/deepcopy_test.go | 145 + .../deepcopy-gen/output_tests/wholepkg/doc.go | 20 + .../output_tests/wholepkg/interfaces.go | 21 + .../output_tests/wholepkg/zz_generated.go | 760 + .../gengo/examples/defaulter-gen/.gitignore | 1 + .../defaulter-gen/.import-restrictions | 13 + .../gengo/examples/defaulter-gen/Makefile | 15 + .../gengo/examples/defaulter-gen/OWNERS | 2 + .../defaulter-gen/_output_tests/empty/doc.go | 20 + .../defaulter-gen/_output_tests/empty/type.go | 29 + .../_output_tests/empty/zz_generated.go | 32 + .../_output_tests/pointer/defaults.go | 32 + .../_output_tests/pointer/doc.go | 20 + .../_output_tests/pointer/type.go | 33 + .../_output_tests/pointer/zz_generated.go | 45 + .../_output_tests/slices/defaults.go | 32 + .../defaulter-gen/_output_tests/slices/doc.go | 20 + .../_output_tests/slices/type.go | 37 + .../_output_tests/slices/zz_generated.go | 55 + .../_output_tests/wholepkg/defaults.go | 32 + .../_output_tests/wholepkg/doc.go | 20 + .../_output_tests/wholepkg/type.go | 74 + .../_output_tests/wholepkg/zz_generated.go | 84 + .../defaulter-gen/generators/defaulter.go | 828 + .../gengo/examples/defaulter-gen/main.go | 75 + .../gengo/examples/import-boss/.gitignore | 1 + .../import-boss/generators/import_restrict.go | 272 + .../generators/import_restrict_test.go | 39 + .../k8s.io/gengo/examples/import-boss/main.go | 78 + .../k8s.io/gengo/examples/set-gen/.gitignore | 1 + vendor/k8s.io/gengo/examples/set-gen/Makefile | 15 + .../gengo/examples/set-gen/generators/sets.go | 360 + .../gengo/examples/set-gen/generators/tags.go | 33 + vendor/k8s.io/gengo/examples/set-gen/main.go | 47 + .../gengo/examples/set-gen/sets/byte.go | 203 + .../k8s.io/gengo/examples/set-gen/sets/doc.go | 20 + .../gengo/examples/set-gen/sets/empty.go | 23 + .../k8s.io/gengo/examples/set-gen/sets/int.go | 203 + .../gengo/examples/set-gen/sets/int64.go | 203 + .../gengo/examples/set-gen/sets/set_test.go | 270 + .../gengo/examples/set-gen/sets/string.go | 203 + .../examples/set-gen/sets/types/types.go | 30 + .../gengo/generator/default_generator.go | 62 + .../k8s.io/gengo/generator/default_package.go | 72 + vendor/k8s.io/gengo/generator/doc.go | 31 + .../k8s.io/gengo/generator/error_tracker.go | 50 + vendor/k8s.io/gengo/generator/execute.go | 312 + vendor/k8s.io/gengo/generator/generator.go | 219 + .../k8s.io/gengo/generator/import_tracker.go | 64 + .../k8s.io/gengo/generator/snippet_writer.go | 154 + .../gengo/generator/snippet_writer_test.go | 88 + vendor/k8s.io/gengo/namer/doc.go | 31 + vendor/k8s.io/gengo/namer/import_tracker.go | 112 + vendor/k8s.io/gengo/namer/namer.go | 383 + vendor/k8s.io/gengo/namer/namer_test.go | 100 + vendor/k8s.io/gengo/namer/order.go | 69 + vendor/k8s.io/gengo/namer/plural_namer.go | 120 + .../k8s.io/gengo/namer/plural_namer_test.go | 123 + vendor/k8s.io/gengo/parser/doc.go | 19 + .../k8s.io/gengo/parser/local_parse_test.go | 68 + vendor/k8s.io/gengo/parser/parse.go | 813 + vendor/k8s.io/gengo/parser/parse_test.go | 459 + vendor/k8s.io/gengo/testdata/a/a.go | 20 + vendor/k8s.io/gengo/testdata/a/b/b.go | 20 + vendor/k8s.io/gengo/types/comments.go | 82 + vendor/k8s.io/gengo/types/comments_test.go | 86 + vendor/k8s.io/gengo/types/doc.go | 19 + vendor/k8s.io/gengo/types/flatten.go | 57 + vendor/k8s.io/gengo/types/flatten_test.go | 68 + vendor/k8s.io/gengo/types/types.go | 499 + vendor/k8s.io/gengo/types/types_test.go | 210 + vendor/k8s.io/klog/.travis.yml | 14 + vendor/k8s.io/klog/CONTRIBUTING.md | 31 + vendor/k8s.io/klog/LICENSE | 191 + vendor/k8s.io/klog/OWNERS | 11 + vendor/k8s.io/klog/README.md | 51 + vendor/k8s.io/klog/RELEASE.md | 9 + vendor/k8s.io/klog/SECURITY_CONTACTS | 20 + .../examples/coexist_glog/coexist_glog.go | 28 + .../klog/examples/log_file/usage_log_file.go | 14 + .../examples/set_output/usage_set_output.go | 22 + vendor/k8s.io/klog/glog/README.md | 9 + vendor/k8s.io/klog/glog/glog.go | 160 + vendor/k8s.io/klog/glog/glog_test.go | 46 + vendor/k8s.io/klog/klog.go | 1239 + vendor/k8s.io/klog/klog_file.go | 126 + vendor/k8s.io/klog/klog_test.go | 415 + 1361 files changed, 267039 insertions(+), 198 deletions(-) create mode 100644 vendor/github.com/davecgh/go-spew/.gitignore create mode 100644 vendor/github.com/davecgh/go-spew/.travis.yml create mode 100644 vendor/github.com/davecgh/go-spew/LICENSE create mode 100644 vendor/github.com/davecgh/go-spew/README.md create mode 100644 vendor/github.com/davecgh/go-spew/cov_report.sh create mode 100644 vendor/github.com/davecgh/go-spew/spew/bypass.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/bypasssafe.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/common.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/common_test.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/config.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/doc.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/dump.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/dump_test.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/example_test.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/format.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/format_test.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/internal_test.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/internalunsafe_test.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/spew.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/spew_test.go create mode 100644 vendor/github.com/davecgh/go-spew/spew/testdata/dumpcgo.go create mode 100644 vendor/github.com/davecgh/go-spew/test_coverage.txt create mode 100644 vendor/github.com/hashicorp/golang-lru/.gitignore create mode 100644 vendor/github.com/hashicorp/golang-lru/2q.go create mode 100644 vendor/github.com/hashicorp/golang-lru/2q_test.go create mode 100644 vendor/github.com/hashicorp/golang-lru/LICENSE create mode 100644 vendor/github.com/hashicorp/golang-lru/README.md create mode 100644 vendor/github.com/hashicorp/golang-lru/arc.go create mode 100644 vendor/github.com/hashicorp/golang-lru/arc_test.go create mode 100644 vendor/github.com/hashicorp/golang-lru/doc.go create mode 100644 vendor/github.com/hashicorp/golang-lru/go.mod create mode 100644 vendor/github.com/hashicorp/golang-lru/lru.go create mode 100644 vendor/github.com/hashicorp/golang-lru/lru_test.go create mode 100644 vendor/github.com/hashicorp/golang-lru/simplelru/lru.go create mode 100644 vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go create mode 100644 vendor/github.com/hashicorp/golang-lru/simplelru/lru_test.go create mode 100644 vendor/golang.org/x/tools/.gitattributes create mode 100644 vendor/golang.org/x/tools/.gitignore create mode 100644 vendor/golang.org/x/tools/AUTHORS create mode 100644 vendor/golang.org/x/tools/CONTRIBUTING.md create mode 100644 vendor/golang.org/x/tools/CONTRIBUTORS create mode 100644 vendor/golang.org/x/tools/LICENSE create mode 100644 vendor/golang.org/x/tools/PATENTS create mode 100644 vendor/golang.org/x/tools/README.md create mode 100644 vendor/golang.org/x/tools/benchmark/parse/parse.go create mode 100644 vendor/golang.org/x/tools/benchmark/parse/parse_test.go create mode 100644 vendor/golang.org/x/tools/blog/atom/atom.go create mode 100644 vendor/golang.org/x/tools/blog/blog.go create mode 100644 vendor/golang.org/x/tools/blog/blog_test.go create mode 100644 vendor/golang.org/x/tools/cmd/benchcmp/benchcmp.go create mode 100644 vendor/golang.org/x/tools/cmd/benchcmp/benchcmp_test.go create mode 100644 vendor/golang.org/x/tools/cmd/benchcmp/compare.go create mode 100644 vendor/golang.org/x/tools/cmd/benchcmp/compare_test.go create mode 100644 vendor/golang.org/x/tools/cmd/benchcmp/doc.go create mode 100644 vendor/golang.org/x/tools/cmd/bundle/.gitignore create mode 100644 vendor/golang.org/x/tools/cmd/bundle/main.go create mode 100644 vendor/golang.org/x/tools/cmd/bundle/main_test.go create mode 100644 vendor/golang.org/x/tools/cmd/bundle/testdata/out.golden create mode 100644 vendor/golang.org/x/tools/cmd/bundle/testdata/src/domain.name/importdecl/p.go create mode 100644 vendor/golang.org/x/tools/cmd/bundle/testdata/src/initial/a.go create mode 100644 vendor/golang.org/x/tools/cmd/bundle/testdata/src/initial/b.go create mode 100644 vendor/golang.org/x/tools/cmd/bundle/testdata/src/initial/c.go create mode 100644 vendor/golang.org/x/tools/cmd/callgraph/main.go create mode 100644 vendor/golang.org/x/tools/cmd/callgraph/main_test.go create mode 100644 vendor/golang.org/x/tools/cmd/callgraph/testdata/src/pkg/pkg.go create mode 100644 vendor/golang.org/x/tools/cmd/callgraph/testdata/src/pkg/pkg_test.go create mode 100644 vendor/golang.org/x/tools/cmd/compilebench/main.go create mode 100644 vendor/golang.org/x/tools/cmd/cover/README create mode 100644 vendor/golang.org/x/tools/cmd/cover/cover.go create mode 100644 vendor/golang.org/x/tools/cmd/cover/cover_test.go create mode 100644 vendor/golang.org/x/tools/cmd/cover/doc.go create mode 100644 vendor/golang.org/x/tools/cmd/cover/func.go create mode 100644 vendor/golang.org/x/tools/cmd/cover/html.go create mode 100644 vendor/golang.org/x/tools/cmd/cover/testdata/main.go create mode 100644 vendor/golang.org/x/tools/cmd/cover/testdata/test.go create mode 100644 vendor/golang.org/x/tools/cmd/digraph/digraph.go create mode 100644 vendor/golang.org/x/tools/cmd/digraph/digraph_test.go create mode 100644 vendor/golang.org/x/tools/cmd/eg/eg.go create mode 100644 vendor/golang.org/x/tools/cmd/fiximports/main.go create mode 100644 vendor/golang.org/x/tools/cmd/fiximports/main_test.go create mode 100644 vendor/golang.org/x/tools/cmd/fiximports/testdata/src/fruit.io/banana/banana.go create mode 100644 vendor/golang.org/x/tools/cmd/fiximports/testdata/src/fruit.io/orange/orange.go create mode 100644 vendor/golang.org/x/tools/cmd/fiximports/testdata/src/fruit.io/pear/pear.go create mode 100644 vendor/golang.org/x/tools/cmd/fiximports/testdata/src/new.com/one/one.go create mode 100644 vendor/golang.org/x/tools/cmd/fiximports/testdata/src/old.com/bad/bad.go create mode 100644 vendor/golang.org/x/tools/cmd/fiximports/testdata/src/old.com/one/one.go create mode 100644 vendor/golang.org/x/tools/cmd/fiximports/testdata/src/titanic.biz/bar/bar.go create mode 100644 vendor/golang.org/x/tools/cmd/fiximports/testdata/src/titanic.biz/foo/foo.go create mode 100644 vendor/golang.org/x/tools/cmd/getgo/.dockerignore create mode 100644 vendor/golang.org/x/tools/cmd/getgo/.gitignore create mode 100644 vendor/golang.org/x/tools/cmd/getgo/Dockerfile create mode 100644 vendor/golang.org/x/tools/cmd/getgo/LICENSE create mode 100644 vendor/golang.org/x/tools/cmd/getgo/README.md create mode 100644 vendor/golang.org/x/tools/cmd/getgo/download.go create mode 100644 vendor/golang.org/x/tools/cmd/getgo/download_test.go create mode 100644 vendor/golang.org/x/tools/cmd/getgo/main.go create mode 100644 vendor/golang.org/x/tools/cmd/getgo/main_test.go create mode 100755 vendor/golang.org/x/tools/cmd/getgo/make.bash create mode 100644 vendor/golang.org/x/tools/cmd/getgo/path.go create mode 100644 vendor/golang.org/x/tools/cmd/getgo/path_test.go create mode 100644 vendor/golang.org/x/tools/cmd/getgo/server/README.md create mode 100644 vendor/golang.org/x/tools/cmd/getgo/server/app.yaml create mode 100644 vendor/golang.org/x/tools/cmd/getgo/server/main.go create mode 100644 vendor/golang.org/x/tools/cmd/getgo/steps.go create mode 100644 vendor/golang.org/x/tools/cmd/getgo/system.go create mode 100644 vendor/golang.org/x/tools/cmd/getgo/system_unix.go create mode 100644 vendor/golang.org/x/tools/cmd/getgo/system_windows.go create mode 100755 vendor/golang.org/x/tools/cmd/getgo/upload.bash create mode 100644 vendor/golang.org/x/tools/cmd/go-contrib-init/contrib.go create mode 100644 vendor/golang.org/x/tools/cmd/go-contrib-init/contrib_test.go create mode 100644 vendor/golang.org/x/tools/cmd/godex/doc.go create mode 100644 vendor/golang.org/x/tools/cmd/godex/gc.go create mode 100644 vendor/golang.org/x/tools/cmd/godex/gccgo.go create mode 100644 vendor/golang.org/x/tools/cmd/godex/godex.go create mode 100644 vendor/golang.org/x/tools/cmd/godex/isAlias18.go create mode 100644 vendor/golang.org/x/tools/cmd/godex/isAlias19.go create mode 100644 vendor/golang.org/x/tools/cmd/godex/print.go create mode 100644 vendor/golang.org/x/tools/cmd/godex/source.go create mode 100644 vendor/golang.org/x/tools/cmd/godex/writetype.go create mode 100644 vendor/golang.org/x/tools/cmd/godoc/.gitignore create mode 100644 vendor/golang.org/x/tools/cmd/godoc/Dockerfile.prod create mode 100644 vendor/golang.org/x/tools/cmd/godoc/Makefile create mode 100644 vendor/golang.org/x/tools/cmd/godoc/README.godoc-app create mode 100644 vendor/golang.org/x/tools/cmd/godoc/app.dev.yaml create mode 100644 vendor/golang.org/x/tools/cmd/godoc/app.prod.yaml create mode 100644 vendor/golang.org/x/tools/cmd/godoc/appinit.go create mode 100644 vendor/golang.org/x/tools/cmd/godoc/autocert.go create mode 100644 vendor/golang.org/x/tools/cmd/godoc/blog.go create mode 100644 vendor/golang.org/x/tools/cmd/godoc/cloudbuild.yaml create mode 100644 vendor/golang.org/x/tools/cmd/godoc/codewalk.go create mode 100644 vendor/golang.org/x/tools/cmd/godoc/dl.go create mode 100644 vendor/golang.org/x/tools/cmd/godoc/doc.go create mode 100755 vendor/golang.org/x/tools/cmd/godoc/generate-index.bash create mode 100644 vendor/golang.org/x/tools/cmd/godoc/godoc_test.go create mode 100644 vendor/golang.org/x/tools/cmd/godoc/goroot.go create mode 100644 vendor/golang.org/x/tools/cmd/godoc/handlers.go create mode 100644 vendor/golang.org/x/tools/cmd/godoc/hg-git-mapping.bin create mode 100644 vendor/golang.org/x/tools/cmd/godoc/index.go create mode 100644 vendor/golang.org/x/tools/cmd/godoc/main.go create mode 100644 vendor/golang.org/x/tools/cmd/godoc/play.go create mode 100644 vendor/golang.org/x/tools/cmd/godoc/regtest_test.go create mode 100644 vendor/golang.org/x/tools/cmd/godoc/x.go create mode 100644 vendor/golang.org/x/tools/cmd/goimports/doc.go create mode 100644 vendor/golang.org/x/tools/cmd/goimports/goimports.go create mode 100644 vendor/golang.org/x/tools/cmd/goimports/goimports_gc.go create mode 100644 vendor/golang.org/x/tools/cmd/goimports/goimports_not_gc.go create mode 100644 vendor/golang.org/x/tools/cmd/golsp/main.go create mode 100644 vendor/golang.org/x/tools/cmd/gomvpkg/main.go create mode 100644 vendor/golang.org/x/tools/cmd/gorename/cgo_test.go create mode 100644 vendor/golang.org/x/tools/cmd/gorename/gorename_test.go create mode 100644 vendor/golang.org/x/tools/cmd/gorename/main.go create mode 100644 vendor/golang.org/x/tools/cmd/gotype/gotype.go create mode 100644 vendor/golang.org/x/tools/cmd/gotype/sizesFor18.go create mode 100644 vendor/golang.org/x/tools/cmd/gotype/sizesFor19.go create mode 100644 vendor/golang.org/x/tools/cmd/goyacc/doc.go create mode 100644 vendor/golang.org/x/tools/cmd/goyacc/testdata/expr/README create mode 100644 vendor/golang.org/x/tools/cmd/goyacc/testdata/expr/expr.y create mode 100644 vendor/golang.org/x/tools/cmd/goyacc/testdata/expr/main.go create mode 100644 vendor/golang.org/x/tools/cmd/goyacc/yacc.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/callees.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/callers.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/callstack.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/definition.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/describe.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/freevars.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/guru.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/guru_test.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/implements.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/isAlias18.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/isAlias19.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/peers.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/pointsto.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/pos.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/referrers.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/serial/serial.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/README.txt create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/alias/alias.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/alias/alias.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/calls-json/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/calls-json/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/calls/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/calls/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/definition-json/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/definition-json/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/definition-json/main19.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/definition-json/main19.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/definition-json/type.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/describe-json/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/describe-json/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/describe/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/describe/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/describe/main19.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/describe/main19.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/freevars/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/freevars/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/implements-json/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/implements-json/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/implements-methods-json/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/implements-methods-json/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/implements-methods/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/implements-methods/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/implements/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/implements/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/imports/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/imports/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/lib/lib.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/lib/sublib/sublib.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/main/multi.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/peers-json/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/peers-json/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/peers/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/peers/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/pointsto-json/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/pointsto-json/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/pointsto/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/pointsto/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/referrers-json/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/referrers-json/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/referrers/ext_test.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/referrers/int_test.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/referrers/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/referrers/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/reflection/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/reflection/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/softerrs/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/softerrs/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/what-json/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/what-json/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/what/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/what/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/whicherrs/main.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/testdata/src/whicherrs/main.golden create mode 100644 vendor/golang.org/x/tools/cmd/guru/unit_test.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/what.go create mode 100644 vendor/golang.org/x/tools/cmd/guru/whicherrs.go create mode 100644 vendor/golang.org/x/tools/cmd/heapview/client/.clang-format create mode 100644 vendor/golang.org/x/tools/cmd/heapview/client/.gitignore create mode 100644 vendor/golang.org/x/tools/cmd/heapview/client/README.md create mode 100644 vendor/golang.org/x/tools/cmd/heapview/client/main.ts create mode 100644 vendor/golang.org/x/tools/cmd/heapview/client/main_test.ts create mode 100644 vendor/golang.org/x/tools/cmd/heapview/client/package.json create mode 100644 vendor/golang.org/x/tools/cmd/heapview/client/testing/karma.conf.js create mode 100644 vendor/golang.org/x/tools/cmd/heapview/client/testing/test_main.js create mode 100644 vendor/golang.org/x/tools/cmd/heapview/client/tsconfig.json create mode 100644 vendor/golang.org/x/tools/cmd/heapview/client/tslint.json create mode 100644 vendor/golang.org/x/tools/cmd/heapview/internal/core/mmapfile.go create mode 100644 vendor/golang.org/x/tools/cmd/heapview/internal/core/mmapfile_other.go create mode 100644 vendor/golang.org/x/tools/cmd/heapview/internal/core/raw.go create mode 100644 vendor/golang.org/x/tools/cmd/heapview/main.go create mode 100644 vendor/golang.org/x/tools/cmd/html2article/conv.go create mode 100644 vendor/golang.org/x/tools/cmd/present/dir.go create mode 100644 vendor/golang.org/x/tools/cmd/present/doc.go create mode 100644 vendor/golang.org/x/tools/cmd/present/main.go create mode 100644 vendor/golang.org/x/tools/cmd/present/play.go create mode 100644 vendor/golang.org/x/tools/cmd/present/static/article.css create mode 100644 vendor/golang.org/x/tools/cmd/present/static/dir.css create mode 100644 vendor/golang.org/x/tools/cmd/present/static/dir.js create mode 100644 vendor/golang.org/x/tools/cmd/present/static/favicon.ico create mode 100644 vendor/golang.org/x/tools/cmd/present/static/jquery-ui.js create mode 100644 vendor/golang.org/x/tools/cmd/present/static/notes.css create mode 100644 vendor/golang.org/x/tools/cmd/present/static/notes.js create mode 100644 vendor/golang.org/x/tools/cmd/present/static/slides.js create mode 100644 vendor/golang.org/x/tools/cmd/present/static/styles.css create mode 100644 vendor/golang.org/x/tools/cmd/present/templates/action.tmpl create mode 100644 vendor/golang.org/x/tools/cmd/present/templates/article.tmpl create mode 100644 vendor/golang.org/x/tools/cmd/present/templates/dir.tmpl create mode 100644 vendor/golang.org/x/tools/cmd/present/templates/slides.tmpl create mode 100644 vendor/golang.org/x/tools/cmd/ssadump/main.go create mode 100644 vendor/golang.org/x/tools/cmd/stress/stress.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/endtoend_test.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/golden_test.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/importer18.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/importer19.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/stringer.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/testdata/cgo.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/testdata/conv.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/testdata/day.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/testdata/gap.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/testdata/num.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/testdata/number.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/testdata/prime.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/testdata/tag_main.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/testdata/tag_tag.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/testdata/unum.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/testdata/unum2.go create mode 100644 vendor/golang.org/x/tools/cmd/stringer/util_test.go create mode 100644 vendor/golang.org/x/tools/cmd/tip/Dockerfile create mode 100644 vendor/golang.org/x/tools/cmd/tip/Makefile create mode 100644 vendor/golang.org/x/tools/cmd/tip/README create mode 100644 vendor/golang.org/x/tools/cmd/tip/cert.go create mode 100644 vendor/golang.org/x/tools/cmd/tip/godoc.go create mode 100644 vendor/golang.org/x/tools/cmd/tip/godoc.yaml create mode 100644 vendor/golang.org/x/tools/cmd/tip/talks.go create mode 100644 vendor/golang.org/x/tools/cmd/tip/talks.yaml create mode 100644 vendor/golang.org/x/tools/cmd/tip/tip-prod.yaml create mode 100644 vendor/golang.org/x/tools/cmd/tip/tip-service.yaml create mode 100644 vendor/golang.org/x/tools/cmd/tip/tip.go create mode 100644 vendor/golang.org/x/tools/cmd/tip/tip_test.go create mode 100755 vendor/golang.org/x/tools/cmd/toolstash/buildall create mode 100644 vendor/golang.org/x/tools/cmd/toolstash/cmp.go create mode 100644 vendor/golang.org/x/tools/cmd/toolstash/main.go create mode 100644 vendor/golang.org/x/tools/codereview.cfg create mode 100644 vendor/golang.org/x/tools/container/intsets/popcnt_amd64.go create mode 100644 vendor/golang.org/x/tools/container/intsets/popcnt_amd64.s create mode 100644 vendor/golang.org/x/tools/container/intsets/popcnt_gccgo.go create mode 100644 vendor/golang.org/x/tools/container/intsets/popcnt_gccgo_c.c create mode 100644 vendor/golang.org/x/tools/container/intsets/popcnt_generic.go create mode 100644 vendor/golang.org/x/tools/container/intsets/sparse.go create mode 100644 vendor/golang.org/x/tools/container/intsets/sparse_test.go create mode 100644 vendor/golang.org/x/tools/container/intsets/util.go create mode 100644 vendor/golang.org/x/tools/container/intsets/util_test.go create mode 100644 vendor/golang.org/x/tools/cover/profile.go create mode 100644 vendor/golang.org/x/tools/go/analysis/analysis.go create mode 100644 vendor/golang.org/x/tools/go/analysis/analysistest/analysistest.go create mode 100644 vendor/golang.org/x/tools/go/analysis/analysistest/analysistest_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/cmd/vet/README create mode 100644 vendor/golang.org/x/tools/go/analysis/cmd/vet/vet.go create mode 100644 vendor/golang.org/x/tools/go/analysis/doc.go create mode 100644 vendor/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go create mode 100644 vendor/golang.org/x/tools/go/analysis/internal/analysisflags/flags_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/internal/analysisflags/help.go create mode 100644 vendor/golang.org/x/tools/go/analysis/internal/checker/checker.go create mode 100644 vendor/golang.org/x/tools/go/analysis/internal/facts/facts.go create mode 100644 vendor/golang.org/x/tools/go/analysis/internal/facts/facts_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/internal/facts/imports.go create mode 100644 vendor/golang.org/x/tools/go/analysis/multichecker/multichecker.go create mode 100644 vendor/golang.org/x/tools/go/analysis/multichecker/multichecker_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/README create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/asmdecl/asmdecl.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/asmdecl/asmdecl_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/asmdecl/testdata/src/a/asm.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/asmdecl/testdata/src/a/asm1.s create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/asmdecl/testdata/src/a/asm2.s create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/asmdecl/testdata/src/a/asm3.s create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/asmdecl/testdata/src/a/asm4.s create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/asmdecl/testdata/src/a/asm5.s create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/asmdecl/testdata/src/a/asm6.s create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/asmdecl/testdata/src/a/asm7.s create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/asmdecl/testdata/src/a/asm8.s create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/assign/assign.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/assign/assign_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/assign/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/atomic/atomic.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/atomic/atomic_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/atomic/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/bools/bools.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/bools/bools_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/bools/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/buildssa/buildssa.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/buildssa/buildssa_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/buildssa/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/buildtag/testdata/src/a/buildtag.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/cgocall/cgocall.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/cgocall/cgocall_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/cgocall/testdata/src/a/cgo.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/cgocall/testdata/src/a/cgo3.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/cgocall/testdata/src/b/b.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/cgocall/testdata/src/c/c.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/composite/composite_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/composite/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/composite/whitelist.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/copylock/copylock.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/copylock/copylock_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/copylock/testdata/src/a/copylock.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/copylock/testdata/src/a/copylock_func.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/copylock/testdata/src/a/copylock_range.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/ctrlflow/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/ctrlflow/testdata/src/lib/lib.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/findcall/cmd/findcall/main.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/findcall/findcall.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/findcall/findcall_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/findcall/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/httpresponse/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/inspect/inspect.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/loopclosure/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/lostcancel/cmd/lostcancel/main.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/lostcancel/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/lostcancel/testdata/src/b/b.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/nilfunc/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/nilness/cmd/nilness/main.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/nilness/nilness.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/nilness/nilness_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/nilness/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/pkgfact/pkgfact.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/pkgfact/pkgfact_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/pkgfact/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/pkgfact/testdata/src/b/b.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/pkgfact/testdata/src/c/c.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/printf/printf_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/printf/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/printf/testdata/src/b/b.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/printf/types.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow/main.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/shadow/shadow.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/shadow/shadow_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/shadow/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/shift/dead.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/shift/shift.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/shift/shift_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/shift/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/stdmethods/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/structtag/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/tests/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/tests/testdata/src/a/a_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/tests/testdata/src/a/ax_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/tests/testdata/src/divergent/buf.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/tests/testdata/src/divergent/buf_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/tests/tests.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/tests/tests_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/unmarshal/cmd/unmarshal/main.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/unmarshal/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/unmarshal/unmarshal.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/unmarshal/unmarshal_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/unreachable/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/unreachable/unreachable.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/unreachable/unreachable_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/unsafeptr/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/unusedresult/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/singlechecker/singlechecker.go create mode 100644 vendor/golang.org/x/tools/go/analysis/unitchecker/main.go create mode 100644 vendor/golang.org/x/tools/go/analysis/unitchecker/testdata/src/a/a.go create mode 100644 vendor/golang.org/x/tools/go/analysis/unitchecker/testdata/src/b/b.go create mode 100644 vendor/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go create mode 100644 vendor/golang.org/x/tools/go/analysis/unitchecker/unitchecker_test.go create mode 100644 vendor/golang.org/x/tools/go/analysis/validate.go create mode 100644 vendor/golang.org/x/tools/go/ast/astutil/enclosing.go create mode 100644 vendor/golang.org/x/tools/go/ast/astutil/enclosing_test.go create mode 100644 vendor/golang.org/x/tools/go/ast/astutil/imports.go create mode 100644 vendor/golang.org/x/tools/go/ast/astutil/imports_test.go create mode 100644 vendor/golang.org/x/tools/go/ast/astutil/rewrite.go create mode 100644 vendor/golang.org/x/tools/go/ast/astutil/rewrite_test.go create mode 100644 vendor/golang.org/x/tools/go/ast/astutil/util.go create mode 100644 vendor/golang.org/x/tools/go/ast/inspector/inspector.go create mode 100644 vendor/golang.org/x/tools/go/ast/inspector/inspector_test.go create mode 100644 vendor/golang.org/x/tools/go/ast/inspector/typeof.go create mode 100644 vendor/golang.org/x/tools/go/buildutil/allpackages.go create mode 100644 vendor/golang.org/x/tools/go/buildutil/allpackages_test.go create mode 100644 vendor/golang.org/x/tools/go/buildutil/fakecontext.go create mode 100644 vendor/golang.org/x/tools/go/buildutil/overlay.go create mode 100644 vendor/golang.org/x/tools/go/buildutil/overlay_test.go create mode 100644 vendor/golang.org/x/tools/go/buildutil/tags.go create mode 100644 vendor/golang.org/x/tools/go/buildutil/tags_test.go create mode 100644 vendor/golang.org/x/tools/go/buildutil/util.go create mode 100644 vendor/golang.org/x/tools/go/buildutil/util_test.go create mode 100644 vendor/golang.org/x/tools/go/buildutil/util_windows_test.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/callgraph.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/cha/cha.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/cha/cha_test.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/cha/testdata/func.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/cha/testdata/iface.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/cha/testdata/issue23925.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/cha/testdata/recv.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/rta/rta.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/rta/rta_test.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/rta/testdata/func.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/rta/testdata/iface.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/rta/testdata/rtype.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/static/static.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/static/static_test.go create mode 100644 vendor/golang.org/x/tools/go/callgraph/util.go create mode 100644 vendor/golang.org/x/tools/go/cfg/builder.go create mode 100644 vendor/golang.org/x/tools/go/cfg/cfg.go create mode 100644 vendor/golang.org/x/tools/go/cfg/cfg_test.go create mode 100644 vendor/golang.org/x/tools/go/expect/expect.go create mode 100644 vendor/golang.org/x/tools/go/expect/expect_test.go create mode 100644 vendor/golang.org/x/tools/go/expect/extract.go create mode 100644 vendor/golang.org/x/tools/go/expect/testdata/test.go create mode 100644 vendor/golang.org/x/tools/go/gccgoexportdata/gccgoexportdata.go create mode 100644 vendor/golang.org/x/tools/go/gccgoexportdata/gccgoexportdata_test.go create mode 100644 vendor/golang.org/x/tools/go/gccgoexportdata/testdata/errors.gox create mode 100644 vendor/golang.org/x/tools/go/gccgoexportdata/testdata/long.a create mode 100644 vendor/golang.org/x/tools/go/gccgoexportdata/testdata/short.a create mode 100644 vendor/golang.org/x/tools/go/gcexportdata/example_test.go create mode 100644 vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go create mode 100644 vendor/golang.org/x/tools/go/gcexportdata/gcexportdata_test.go create mode 100644 vendor/golang.org/x/tools/go/gcexportdata/importer.go create mode 100644 vendor/golang.org/x/tools/go/gcexportdata/main.go create mode 100644 vendor/golang.org/x/tools/go/gcexportdata/testdata/errors-ae16.a create mode 100644 vendor/golang.org/x/tools/go/internal/cgo/cgo.go create mode 100644 vendor/golang.org/x/tools/go/internal/cgo/cgo_pkgconfig.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/ar.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/backdoor.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/gccgoinstallation.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/gccgoinstallation_test.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/importer.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/importer_test.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/newInterface10.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/newInterface11.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/parser.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/parser_test.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/aliases.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/aliases.gox create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/complexnums.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/complexnums.gox create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/conversions.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/conversions.gox create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/escapeinfo.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/escapeinfo.gox create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/imports.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/imports.gox create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/issue27856.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/issue27856.gox create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/libimportsar.a create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/pointer.go create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/pointer.gox create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/time.gox create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testdata/unicode.gox create mode 100644 vendor/golang.org/x/tools/go/internal/gccgoimporter/testenv_test.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/bexport.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/bexport_test.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/bimport.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/exportdata.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/gcimporter.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/gcimporter11_test.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/gcimporter_test.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/iimport.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/newInterface10.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/newInterface11.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/a.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/b.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/exports.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/issue15920.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/issue20046.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/issue25301.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/p.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/versions/test.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/versions/test_go1.11_0i.a create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/versions/test_go1.11_6b.a create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/versions/test_go1.11_999b.a create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/versions/test_go1.11_999i.a create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/versions/test_go1.7_0.a create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/versions/test_go1.7_1.a create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/versions/test_go1.8_4.a create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/testdata/versions/test_go1.8_5.a create mode 100644 vendor/golang.org/x/tools/go/loader/doc.go create mode 100644 vendor/golang.org/x/tools/go/loader/example_test.go create mode 100644 vendor/golang.org/x/tools/go/loader/loader.go create mode 100644 vendor/golang.org/x/tools/go/loader/loader_test.go create mode 100644 vendor/golang.org/x/tools/go/loader/stdlib_test.go create mode 100644 vendor/golang.org/x/tools/go/loader/testdata/a.go create mode 100644 vendor/golang.org/x/tools/go/loader/testdata/b.go create mode 100644 vendor/golang.org/x/tools/go/loader/testdata/badpkgdecl.go create mode 100644 vendor/golang.org/x/tools/go/loader/util.go create mode 100644 vendor/golang.org/x/tools/go/packages/doc.go create mode 100644 vendor/golang.org/x/tools/go/packages/example_test.go create mode 100644 vendor/golang.org/x/tools/go/packages/external.go create mode 100644 vendor/golang.org/x/tools/go/packages/golist.go create mode 100644 vendor/golang.org/x/tools/go/packages/golist_fallback.go create mode 100644 vendor/golang.org/x/tools/go/packages/golist_fallback_testmain.go create mode 100644 vendor/golang.org/x/tools/go/packages/gopackages/main.go create mode 100644 vendor/golang.org/x/tools/go/packages/packages.go create mode 100644 vendor/golang.org/x/tools/go/packages/packages110_test.go create mode 100644 vendor/golang.org/x/tools/go/packages/packages_test.go create mode 100644 vendor/golang.org/x/tools/go/packages/packagescgo_test.go create mode 100644 vendor/golang.org/x/tools/go/packages/packagestest/expect.go create mode 100644 vendor/golang.org/x/tools/go/packages/packagestest/expect_test.go create mode 100644 vendor/golang.org/x/tools/go/packages/packagestest/export.go create mode 100644 vendor/golang.org/x/tools/go/packages/packagestest/export_test.go create mode 100644 vendor/golang.org/x/tools/go/packages/packagestest/gopath.go create mode 100644 vendor/golang.org/x/tools/go/packages/packagestest/gopath_test.go create mode 100644 vendor/golang.org/x/tools/go/packages/packagestest/modules.go create mode 100644 vendor/golang.org/x/tools/go/packages/packagestest/modules_111.go create mode 100644 vendor/golang.org/x/tools/go/packages/packagestest/modules_test.go create mode 100644 vendor/golang.org/x/tools/go/packages/packagestest/testdata/test.go create mode 100644 vendor/golang.org/x/tools/go/packages/stdlib_test.go create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/README create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/cache/download/github.com/heschik/tools-testrepo/@v/list create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/cache/download/github.com/heschik/tools-testrepo/@v/v1.0.0.info create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/cache/download/github.com/heschik/tools-testrepo/@v/v1.0.0.mod create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/cache/download/github.com/heschik/tools-testrepo/@v/v1.0.0.zip create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/cache/download/github.com/heschik/tools-testrepo/@v/v1.0.0.ziphash create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/list create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/v2.0.0.info create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/v2.0.0.mod create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/v2.0.0.zip create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/v2.0.0.ziphash create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/github.com/heschik/tools-testrepo/v2@v2.0.0/go.mod create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/github.com/heschik/tools-testrepo/v2@v2.0.0/pkg/pkg.go create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/github.com/heschik/tools-testrepo@v1.0.0/go.mod create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/pkg/mod/github.com/heschik/tools-testrepo@v1.0.0/pkg/pkg.go create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_Modules/src/b/pkg/pkg.go create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/@v/list create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/@v/v1.0.0.info create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/@v/v1.0.0.mod create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/@v/v1.0.0.zip create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/@v/v1.0.0.ziphash create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/list create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/v2.0.1.info create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/v2.0.1.mod create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/v2.0.1.zip create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/v2.0.1.ziphash create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/v2.0.2.info create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/v2.0.2.mod create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/v2.0.2.zip create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/cache/download/github.com/heschik/tools-testrepo/v2/@v/v2.0.2.ziphash create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/github.com/heschik/tools-testrepo/v2@v2.0.1/go.mod create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/github.com/heschik/tools-testrepo/v2@v2.0.1/pkg/pkg.go create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/github.com/heschik/tools-testrepo/v2@v2.0.2/go.mod create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/github.com/heschik/tools-testrepo/v2@v2.0.2/pkg/pkg.go create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/github.com/heschik/tools-testrepo@v1.0.0/go.mod create mode 100644 vendor/golang.org/x/tools/go/packages/testdata/TestName_ModulesDedup/pkg/mod/github.com/heschik/tools-testrepo@v1.0.0/pkg/pkg.go create mode 100644 vendor/golang.org/x/tools/go/packages/visit.go create mode 100644 vendor/golang.org/x/tools/go/pointer/TODO create mode 100644 vendor/golang.org/x/tools/go/pointer/analysis.go create mode 100644 vendor/golang.org/x/tools/go/pointer/api.go create mode 100644 vendor/golang.org/x/tools/go/pointer/callgraph.go create mode 100644 vendor/golang.org/x/tools/go/pointer/constraint.go create mode 100644 vendor/golang.org/x/tools/go/pointer/doc.go create mode 100644 vendor/golang.org/x/tools/go/pointer/example_test.go create mode 100644 vendor/golang.org/x/tools/go/pointer/gen.go create mode 100644 vendor/golang.org/x/tools/go/pointer/hvn.go create mode 100644 vendor/golang.org/x/tools/go/pointer/intrinsics.go create mode 100644 vendor/golang.org/x/tools/go/pointer/labels.go create mode 100644 vendor/golang.org/x/tools/go/pointer/opt.go create mode 100644 vendor/golang.org/x/tools/go/pointer/pointer_test.go create mode 100644 vendor/golang.org/x/tools/go/pointer/print.go create mode 100644 vendor/golang.org/x/tools/go/pointer/query.go create mode 100644 vendor/golang.org/x/tools/go/pointer/query_test.go create mode 100644 vendor/golang.org/x/tools/go/pointer/reflect.go create mode 100644 vendor/golang.org/x/tools/go/pointer/solve.go create mode 100644 vendor/golang.org/x/tools/go/pointer/stdlib_test.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/a_test.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/another.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/arrayreflect.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/arrays.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/channels.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/chanreflect.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/chanreflect1.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/context.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/conv.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/extended.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/finalizer.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/flow.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/fmtexcerpt.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/func.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/funcreflect.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/hello.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/interfaces.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/issue9002.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/mapreflect.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/maps.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/panic.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/recur.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/reflect.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/rtti.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/structreflect.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/structs.go create mode 100644 vendor/golang.org/x/tools/go/pointer/testdata/timer.go create mode 100644 vendor/golang.org/x/tools/go/pointer/util.go create mode 100644 vendor/golang.org/x/tools/go/ssa/blockopt.go create mode 100644 vendor/golang.org/x/tools/go/ssa/builder.go create mode 100644 vendor/golang.org/x/tools/go/ssa/builder_test.go create mode 100644 vendor/golang.org/x/tools/go/ssa/const.go create mode 100644 vendor/golang.org/x/tools/go/ssa/create.go create mode 100644 vendor/golang.org/x/tools/go/ssa/doc.go create mode 100644 vendor/golang.org/x/tools/go/ssa/dom.go create mode 100644 vendor/golang.org/x/tools/go/ssa/emit.go create mode 100644 vendor/golang.org/x/tools/go/ssa/example_test.go create mode 100644 vendor/golang.org/x/tools/go/ssa/func.go create mode 100644 vendor/golang.org/x/tools/go/ssa/identical.go create mode 100644 vendor/golang.org/x/tools/go/ssa/identical_17.go create mode 100644 vendor/golang.org/x/tools/go/ssa/identical_test.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/external.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/external_darwin.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/external_unix.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/interp.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/interp_test.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/map.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/ops.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/reflect.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/a_test.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/b_test.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/boundmeth.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/c_test.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/callstack.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/complit.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/coverage.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/defer.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/fieldprom.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/ifaceconv.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/ifaceprom.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/initorder.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/methprom.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/mrvchain.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/range.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/recover.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/reflect.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/testdata/static.go create mode 100644 vendor/golang.org/x/tools/go/ssa/interp/value.go create mode 100644 vendor/golang.org/x/tools/go/ssa/lift.go create mode 100644 vendor/golang.org/x/tools/go/ssa/lvalue.go create mode 100644 vendor/golang.org/x/tools/go/ssa/methods.go create mode 100644 vendor/golang.org/x/tools/go/ssa/mode.go create mode 100644 vendor/golang.org/x/tools/go/ssa/print.go create mode 100644 vendor/golang.org/x/tools/go/ssa/sanity.go create mode 100644 vendor/golang.org/x/tools/go/ssa/source.go create mode 100644 vendor/golang.org/x/tools/go/ssa/source_test.go create mode 100644 vendor/golang.org/x/tools/go/ssa/ssa.go create mode 100644 vendor/golang.org/x/tools/go/ssa/ssautil/load.go create mode 100644 vendor/golang.org/x/tools/go/ssa/ssautil/load_test.go create mode 100644 vendor/golang.org/x/tools/go/ssa/ssautil/switch.go create mode 100644 vendor/golang.org/x/tools/go/ssa/ssautil/switch_test.go create mode 100644 vendor/golang.org/x/tools/go/ssa/ssautil/testdata/switches.go create mode 100644 vendor/golang.org/x/tools/go/ssa/ssautil/visit.go create mode 100644 vendor/golang.org/x/tools/go/ssa/stdlib_test.go create mode 100644 vendor/golang.org/x/tools/go/ssa/testdata/objlookup.go create mode 100644 vendor/golang.org/x/tools/go/ssa/testdata/structconv.go create mode 100644 vendor/golang.org/x/tools/go/ssa/testdata/valueforexpr.go create mode 100644 vendor/golang.org/x/tools/go/ssa/testmain.go create mode 100644 vendor/golang.org/x/tools/go/ssa/testmain_test.go create mode 100644 vendor/golang.org/x/tools/go/ssa/util.go create mode 100644 vendor/golang.org/x/tools/go/ssa/wrappers.go create mode 100644 vendor/golang.org/x/tools/go/types/objectpath/objectpath.go create mode 100644 vendor/golang.org/x/tools/go/types/objectpath/objectpath_test.go create mode 100644 vendor/golang.org/x/tools/go/types/typeutil/callee.go create mode 100644 vendor/golang.org/x/tools/go/types/typeutil/callee_test.go create mode 100644 vendor/golang.org/x/tools/go/types/typeutil/example_test.go create mode 100644 vendor/golang.org/x/tools/go/types/typeutil/imports.go create mode 100644 vendor/golang.org/x/tools/go/types/typeutil/imports_test.go create mode 100644 vendor/golang.org/x/tools/go/types/typeutil/map.go create mode 100644 vendor/golang.org/x/tools/go/types/typeutil/map_test.go create mode 100644 vendor/golang.org/x/tools/go/types/typeutil/methodsetcache.go create mode 100644 vendor/golang.org/x/tools/go/types/typeutil/ui.go create mode 100644 vendor/golang.org/x/tools/go/types/typeutil/ui_test.go create mode 100644 vendor/golang.org/x/tools/go/vcs/discovery.go create mode 100644 vendor/golang.org/x/tools/go/vcs/env.go create mode 100644 vendor/golang.org/x/tools/go/vcs/http.go create mode 100644 vendor/golang.org/x/tools/go/vcs/vcs.go create mode 100644 vendor/golang.org/x/tools/go/vcs/vcs_test.go create mode 100644 vendor/golang.org/x/tools/godoc/README.md create mode 100644 vendor/golang.org/x/tools/godoc/analysis/README create mode 100644 vendor/golang.org/x/tools/godoc/analysis/analysis.go create mode 100644 vendor/golang.org/x/tools/godoc/analysis/callgraph.go create mode 100644 vendor/golang.org/x/tools/godoc/analysis/implements.go create mode 100644 vendor/golang.org/x/tools/godoc/analysis/json.go create mode 100644 vendor/golang.org/x/tools/godoc/analysis/peers.go create mode 100644 vendor/golang.org/x/tools/godoc/analysis/typeinfo.go create mode 100644 vendor/golang.org/x/tools/godoc/corpus.go create mode 100644 vendor/golang.org/x/tools/godoc/dirtrees.go create mode 100644 vendor/golang.org/x/tools/godoc/dirtrees_test.go create mode 100644 vendor/golang.org/x/tools/godoc/dl/dl.go create mode 100644 vendor/golang.org/x/tools/godoc/dl/dl_test.go create mode 100644 vendor/golang.org/x/tools/godoc/dl/server.go create mode 100644 vendor/golang.org/x/tools/godoc/dl/tmpl.go create mode 100644 vendor/golang.org/x/tools/godoc/env/env.go create mode 100644 vendor/golang.org/x/tools/godoc/format.go create mode 100644 vendor/golang.org/x/tools/godoc/godoc.go create mode 100644 vendor/golang.org/x/tools/godoc/godoc17_test.go create mode 100644 vendor/golang.org/x/tools/godoc/godoc_test.go create mode 100644 vendor/golang.org/x/tools/godoc/index.go create mode 100644 vendor/golang.org/x/tools/godoc/index_test.go create mode 100644 vendor/golang.org/x/tools/godoc/linkify.go create mode 100644 vendor/golang.org/x/tools/godoc/meta.go create mode 100644 vendor/golang.org/x/tools/godoc/page.go create mode 100644 vendor/golang.org/x/tools/godoc/parser.go create mode 100644 vendor/golang.org/x/tools/godoc/pres.go create mode 100644 vendor/golang.org/x/tools/godoc/proxy/proxy.go create mode 100644 vendor/golang.org/x/tools/godoc/redirect/hash.go create mode 100644 vendor/golang.org/x/tools/godoc/redirect/redirect.go create mode 100644 vendor/golang.org/x/tools/godoc/redirect/redirect_test.go create mode 100644 vendor/golang.org/x/tools/godoc/redirect/rietveld.go create mode 100644 vendor/golang.org/x/tools/godoc/search.go create mode 100644 vendor/golang.org/x/tools/godoc/server.go create mode 100644 vendor/golang.org/x/tools/godoc/server_test.go create mode 100644 vendor/golang.org/x/tools/godoc/short/short.go create mode 100644 vendor/golang.org/x/tools/godoc/short/tmpl.go create mode 100644 vendor/golang.org/x/tools/godoc/snippet.go create mode 100644 vendor/golang.org/x/tools/godoc/spec.go create mode 100644 vendor/golang.org/x/tools/godoc/spec_test.go create mode 100644 vendor/golang.org/x/tools/godoc/spot.go create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/call-eg.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/call3.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/callers1.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/callers2.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/chan1.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/chan2a.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/chan2b.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/error1.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/help.html create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/ident-def.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/ident-field.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/ident-func.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/ipcg-func.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/ipcg-pkg.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/typeinfo-pkg.png create mode 100644 vendor/golang.org/x/tools/godoc/static/analysis/typeinfo-src.png create mode 100644 vendor/golang.org/x/tools/godoc/static/callgraph.html create mode 100644 vendor/golang.org/x/tools/godoc/static/codewalk.html create mode 100644 vendor/golang.org/x/tools/godoc/static/codewalkdir.html create mode 100644 vendor/golang.org/x/tools/godoc/static/dirlist.html create mode 100644 vendor/golang.org/x/tools/godoc/static/doc.go create mode 100644 vendor/golang.org/x/tools/godoc/static/error.html create mode 100644 vendor/golang.org/x/tools/godoc/static/example.html create mode 100644 vendor/golang.org/x/tools/godoc/static/gen.go create mode 100644 vendor/golang.org/x/tools/godoc/static/gen_test.go create mode 100644 vendor/golang.org/x/tools/godoc/static/godoc.html create mode 100644 vendor/golang.org/x/tools/godoc/static/godocs.js create mode 100644 vendor/golang.org/x/tools/godoc/static/images/minus.gif create mode 100644 vendor/golang.org/x/tools/godoc/static/images/plus.gif create mode 100644 vendor/golang.org/x/tools/godoc/static/images/treeview-black-line.gif create mode 100644 vendor/golang.org/x/tools/godoc/static/images/treeview-black.gif create mode 100644 vendor/golang.org/x/tools/godoc/static/images/treeview-default-line.gif create mode 100644 vendor/golang.org/x/tools/godoc/static/images/treeview-default.gif create mode 100644 vendor/golang.org/x/tools/godoc/static/images/treeview-gray-line.gif create mode 100644 vendor/golang.org/x/tools/godoc/static/images/treeview-gray.gif create mode 100644 vendor/golang.org/x/tools/godoc/static/implements.html create mode 100644 vendor/golang.org/x/tools/godoc/static/jquery.js create mode 100644 vendor/golang.org/x/tools/godoc/static/jquery.treeview.css create mode 100644 vendor/golang.org/x/tools/godoc/static/jquery.treeview.edit.js create mode 100644 vendor/golang.org/x/tools/godoc/static/jquery.treeview.js create mode 100644 vendor/golang.org/x/tools/godoc/static/makestatic.go create mode 100644 vendor/golang.org/x/tools/godoc/static/methodset.html create mode 100644 vendor/golang.org/x/tools/godoc/static/opensearch.xml create mode 100644 vendor/golang.org/x/tools/godoc/static/package.html create mode 100644 vendor/golang.org/x/tools/godoc/static/packageroot.html create mode 100644 vendor/golang.org/x/tools/godoc/static/play.js create mode 100644 vendor/golang.org/x/tools/godoc/static/playground.js create mode 100644 vendor/golang.org/x/tools/godoc/static/search.html create mode 100644 vendor/golang.org/x/tools/godoc/static/searchcode.html create mode 100644 vendor/golang.org/x/tools/godoc/static/searchdoc.html create mode 100644 vendor/golang.org/x/tools/godoc/static/searchtxt.html create mode 100644 vendor/golang.org/x/tools/godoc/static/static.go create mode 100644 vendor/golang.org/x/tools/godoc/static/style.css create mode 100644 vendor/golang.org/x/tools/godoc/tab.go create mode 100644 vendor/golang.org/x/tools/godoc/template.go create mode 100644 vendor/golang.org/x/tools/godoc/util/throttle.go create mode 100644 vendor/golang.org/x/tools/godoc/util/util.go create mode 100644 vendor/golang.org/x/tools/godoc/versions.go create mode 100644 vendor/golang.org/x/tools/godoc/versions_test.go create mode 100644 vendor/golang.org/x/tools/godoc/vfs/emptyvfs.go create mode 100644 vendor/golang.org/x/tools/godoc/vfs/emptyvfs_test.go create mode 100644 vendor/golang.org/x/tools/godoc/vfs/gatefs/gatefs.go create mode 100644 vendor/golang.org/x/tools/godoc/vfs/gatefs/gatefs_test.go create mode 100644 vendor/golang.org/x/tools/godoc/vfs/httpfs/httpfs.go create mode 100644 vendor/golang.org/x/tools/godoc/vfs/mapfs/mapfs.go create mode 100644 vendor/golang.org/x/tools/godoc/vfs/mapfs/mapfs_test.go create mode 100644 vendor/golang.org/x/tools/godoc/vfs/namespace.go create mode 100644 vendor/golang.org/x/tools/godoc/vfs/os.go create mode 100644 vendor/golang.org/x/tools/godoc/vfs/os_test.go create mode 100644 vendor/golang.org/x/tools/godoc/vfs/vfs.go create mode 100644 vendor/golang.org/x/tools/godoc/vfs/zipfs/zipfs.go create mode 100644 vendor/golang.org/x/tools/godoc/vfs/zipfs/zipfs_test.go create mode 100644 vendor/golang.org/x/tools/imports/fix.go create mode 100644 vendor/golang.org/x/tools/imports/fix_test.go create mode 100644 vendor/golang.org/x/tools/imports/imports.go create mode 100644 vendor/golang.org/x/tools/imports/mkindex.go create mode 100644 vendor/golang.org/x/tools/imports/mkstdlib.go create mode 100644 vendor/golang.org/x/tools/imports/sortimports.go create mode 100644 vendor/golang.org/x/tools/imports/zstdlib.go create mode 100644 vendor/golang.org/x/tools/internal/fastwalk/fastwalk.go create mode 100644 vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_fileno.go create mode 100644 vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_ino.go create mode 100644 vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_namlen_bsd.go create mode 100644 vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_namlen_linux.go create mode 100644 vendor/golang.org/x/tools/internal/fastwalk/fastwalk_portable.go create mode 100644 vendor/golang.org/x/tools/internal/fastwalk/fastwalk_test.go create mode 100644 vendor/golang.org/x/tools/internal/fastwalk/fastwalk_unix.go create mode 100644 vendor/golang.org/x/tools/internal/gopathwalk/walk.go create mode 100644 vendor/golang.org/x/tools/internal/gopathwalk/walk_test.go create mode 100644 vendor/golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go create mode 100644 vendor/golang.org/x/tools/internal/jsonrpc2/jsonrpc2_test.go create mode 100644 vendor/golang.org/x/tools/internal/jsonrpc2/log.go create mode 100644 vendor/golang.org/x/tools/internal/jsonrpc2/stream.go create mode 100644 vendor/golang.org/x/tools/internal/jsonrpc2/wire.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/completion.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/diagnostics.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/lsp110_test.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/lsp_test.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/position.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/protocol/basic.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/protocol/client.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/protocol/diagnostics.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/protocol/doc.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/protocol/general.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/protocol/language.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/protocol/printers.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/protocol/protocol.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/protocol/registration.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/protocol/server.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/protocol/text.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/protocol/window.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/protocol/workspace.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/server.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/signature_help.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/source/completion.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/source/definition.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/source/diagnostics.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/source/file.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/source/format.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/source/signature_help.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/source/uri.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/source/view.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/assign_rank/assign_rank.go.in create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/bad/bad.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/bad/bad_util.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/bar/bar.go.in create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/baz/baz.go.in create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/cast/cast.go.in create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/foo/foo.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/format/bad_format.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/format/good_format.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/godef/a/a.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/godef/a/random.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/godef/b/b.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/godef/b/c.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/godef/b/c.go.saved create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/godef/broken/unclosedIf.go.in create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/good/good.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/good/good_util.go create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/noparse/noparse.go.in create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/noparse_format/noparse_format.go.in create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/selector/selector.go.in create mode 100644 vendor/golang.org/x/tools/internal/lsp/testdata/types/types.go create mode 100644 vendor/golang.org/x/tools/internal/memcache/memcache.go create mode 100644 vendor/golang.org/x/tools/internal/memcache/memcache_test.go create mode 100644 vendor/golang.org/x/tools/internal/semver/semver.go create mode 100644 vendor/golang.org/x/tools/internal/semver/semver_test.go create mode 100644 vendor/golang.org/x/tools/playground/appengine.go create mode 100644 vendor/golang.org/x/tools/playground/common.go create mode 100644 vendor/golang.org/x/tools/playground/local.go create mode 100644 vendor/golang.org/x/tools/playground/socket/socket.go create mode 100644 vendor/golang.org/x/tools/playground/socket/socket_test.go create mode 100644 vendor/golang.org/x/tools/present/args.go create mode 100644 vendor/golang.org/x/tools/present/caption.go create mode 100644 vendor/golang.org/x/tools/present/code.go create mode 100644 vendor/golang.org/x/tools/present/code_test.go create mode 100644 vendor/golang.org/x/tools/present/doc.go create mode 100644 vendor/golang.org/x/tools/present/html.go create mode 100644 vendor/golang.org/x/tools/present/iframe.go create mode 100644 vendor/golang.org/x/tools/present/image.go create mode 100644 vendor/golang.org/x/tools/present/link.go create mode 100644 vendor/golang.org/x/tools/present/link_test.go create mode 100644 vendor/golang.org/x/tools/present/parse.go create mode 100644 vendor/golang.org/x/tools/present/style.go create mode 100644 vendor/golang.org/x/tools/present/style_test.go create mode 100644 vendor/golang.org/x/tools/present/video.go create mode 100644 vendor/golang.org/x/tools/refactor/README create mode 100644 vendor/golang.org/x/tools/refactor/eg/eg.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/eg_test.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/match.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/rewrite.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/A.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/A1.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/A1.golden create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/A2.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/A2.golden create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/B.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/B1.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/B1.golden create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/C.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/C1.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/C1.golden create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/D.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/D1.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/D1.golden create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/E.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/E1.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/E1.golden create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/F.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/F1.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/F1.golden create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/G.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/G1.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/G1.golden create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/H.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/H1.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/H1.golden create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/I.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/I1.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/I1.golden create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/J.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/J1.go create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/J1.golden create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/bad_type.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/expr_type_mismatch.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/no_after_return.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/no_before.template create mode 100644 vendor/golang.org/x/tools/refactor/eg/testdata/type_mismatch.template create mode 100644 vendor/golang.org/x/tools/refactor/importgraph/graph.go create mode 100644 vendor/golang.org/x/tools/refactor/importgraph/graph_test.go create mode 100644 vendor/golang.org/x/tools/refactor/rename/check.go create mode 100644 vendor/golang.org/x/tools/refactor/rename/mvpkg.go create mode 100644 vendor/golang.org/x/tools/refactor/rename/mvpkg_test.go create mode 100644 vendor/golang.org/x/tools/refactor/rename/rename.go create mode 100644 vendor/golang.org/x/tools/refactor/rename/rename_test.go create mode 100644 vendor/golang.org/x/tools/refactor/rename/spec.go create mode 100644 vendor/golang.org/x/tools/refactor/rename/util.go create mode 100644 vendor/golang.org/x/tools/refactor/satisfy/find.go create mode 100644 vendor/golang.org/x/tools/third_party/moduleloader/LICENSE create mode 100644 vendor/golang.org/x/tools/third_party/moduleloader/moduleloader.js create mode 100644 vendor/golang.org/x/tools/third_party/typescript/LICENSE create mode 100644 vendor/golang.org/x/tools/third_party/typescript/typescript.js create mode 100644 vendor/golang.org/x/tools/third_party/webcomponents/LICENSE create mode 100644 vendor/golang.org/x/tools/third_party/webcomponents/customelements.js create mode 100644 vendor/k8s.io/code-generator/.github/PULL_REQUEST_TEMPLATE.md create mode 100644 vendor/k8s.io/code-generator/CONTRIBUTING.md create mode 100644 vendor/k8s.io/code-generator/Godeps/Godeps.json create mode 100644 vendor/k8s.io/code-generator/Godeps/OWNERS create mode 100644 vendor/k8s.io/code-generator/Godeps/Readme create mode 100644 vendor/k8s.io/code-generator/LICENSE create mode 100644 vendor/k8s.io/code-generator/OWNERS create mode 100644 vendor/k8s.io/code-generator/README.md create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/install/install.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/types.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/types.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.conversion.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/v1/zz_generated.defaults.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/install/install.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/types.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/types.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.conversion.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/v1/zz_generated.defaults.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/apis/example2/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/clientset.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/clientset_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/fake/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/scheme/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/example_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_example_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/fake/fake_testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/generated_expansion.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/example2_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_example2_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/fake/fake_testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/generated_expansion.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/clientset.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/clientset_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/fake/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/scheme/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/example_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_example_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake/fake_testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/generated_expansion.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/example2_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_example2_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake/fake_testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/generated_expansion.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/v1/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/v1/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/example2/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/factory.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/generic.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/internalversion/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example/internalversion/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/internalversion/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/example2/internalversion/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/factory.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/generic.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/informers/internalversion/internalinterfaces/factory_interfaces.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example/internalversion/expansion_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example/internalversion/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example/v1/expansion_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/internalversion/expansion_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/internalversion/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/v1/expansion_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/apiserver/listers/example2/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/types.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example/v1/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/types.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/apis/example2/v1/zz_generated.deepcopy.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/clientset.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/clientset_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/fake/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/scheme/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/scheme/register.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/example_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/fake_example_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake/fake_testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/generated_expansion.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/example2_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/doc.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/fake_example2_client.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake/fake_testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/generated_expansion.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/clientset/versioned/typed/example2/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/v1/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/v1/interface.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/example2/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/factory.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/generic.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/listers/example/v1/expansion_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/listers/example/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/listers/example2/v1/expansion_generated.go create mode 100644 vendor/k8s.io/code-generator/_examples/crd/listers/example2/v1/testtype.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/OWNERS create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/README.md create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/args/args.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/args/gvpackages.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/args/gvpackages_test.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/args/gvtype.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/client_generator.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/fake/fake_client_generator.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/fake/generator_fake_for_clientset.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/fake/generator_fake_for_group.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/fake/generator_fake_for_type.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/generator_for_clientset.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/generator_for_expansion.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/generator_for_group.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/generator_for_type.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/scheme/generator_for_scheme.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/tags.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/util/tags.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/generators/util/tags_test.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/path/path.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/types/helpers.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/types/helpers_test.go create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/types/types.go create mode 100644 vendor/k8s.io/code-generator/cmd/conversion-gen/args/args.go create mode 100644 vendor/k8s.io/code-generator/cmd/conversion-gen/generators/conversion.go create mode 100644 vendor/k8s.io/code-generator/cmd/conversion-gen/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/deepcopy-gen/args/args.go create mode 100644 vendor/k8s.io/code-generator/cmd/deepcopy-gen/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/defaulter-gen/args/args.go create mode 100644 vendor/k8s.io/code-generator/cmd/defaulter-gen/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/.gitignore create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/OWNERS create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/cmd.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/generator.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/import_tracker.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/namer.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/namer_test.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/package.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/parser.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/tags.go create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/import-boss/.gitignore create mode 100644 vendor/k8s.io/code-generator/cmd/import-boss/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/informer-gen/args/args.go create mode 100644 vendor/k8s.io/code-generator/cmd/informer-gen/generators/factory.go create mode 100644 vendor/k8s.io/code-generator/cmd/informer-gen/generators/factoryinterface.go create mode 100644 vendor/k8s.io/code-generator/cmd/informer-gen/generators/generic.go create mode 100644 vendor/k8s.io/code-generator/cmd/informer-gen/generators/groupinterface.go create mode 100644 vendor/k8s.io/code-generator/cmd/informer-gen/generators/informer.go create mode 100644 vendor/k8s.io/code-generator/cmd/informer-gen/generators/packages.go create mode 100644 vendor/k8s.io/code-generator/cmd/informer-gen/generators/tags.go create mode 100644 vendor/k8s.io/code-generator/cmd/informer-gen/generators/types.go create mode 100644 vendor/k8s.io/code-generator/cmd/informer-gen/generators/versioninterface.go create mode 100644 vendor/k8s.io/code-generator/cmd/informer-gen/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/lister-gen/.import-restrictions create mode 100644 vendor/k8s.io/code-generator/cmd/lister-gen/args/args.go create mode 100644 vendor/k8s.io/code-generator/cmd/lister-gen/generators/expansion.go create mode 100644 vendor/k8s.io/code-generator/cmd/lister-gen/generators/lister.go create mode 100644 vendor/k8s.io/code-generator/cmd/lister-gen/generators/tags.go create mode 100644 vendor/k8s.io/code-generator/cmd/lister-gen/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/openapi-gen/README create mode 100644 vendor/k8s.io/code-generator/cmd/openapi-gen/args/args.go create mode 100644 vendor/k8s.io/code-generator/cmd/openapi-gen/main.go create mode 100644 vendor/k8s.io/code-generator/cmd/set-gen/.gitignore create mode 100644 vendor/k8s.io/code-generator/cmd/set-gen/main.go create mode 100644 vendor/k8s.io/code-generator/code-of-conduct.md create mode 100755 vendor/k8s.io/code-generator/generate-groups.sh create mode 100755 vendor/k8s.io/code-generator/generate-internal-groups.sh create mode 100644 vendor/k8s.io/code-generator/hack/boilerplate.go.txt create mode 100755 vendor/k8s.io/code-generator/hack/update-codegen.sh create mode 100755 vendor/k8s.io/code-generator/hack/verify-codegen.sh create mode 100644 vendor/k8s.io/code-generator/pkg/util/build.go create mode 100644 vendor/k8s.io/code-generator/third_party/forked/golang/reflect/type.go create mode 100644 vendor/k8s.io/gengo/.import-restrictions create mode 100644 vendor/k8s.io/gengo/.travis.yml create mode 100644 vendor/k8s.io/gengo/CONTRIBUTING.md create mode 100644 vendor/k8s.io/gengo/LICENSE create mode 100644 vendor/k8s.io/gengo/OWNERS create mode 100644 vendor/k8s.io/gengo/README.md create mode 100644 vendor/k8s.io/gengo/SECURITY_CONTACTS create mode 100644 vendor/k8s.io/gengo/args/args.go create mode 100644 vendor/k8s.io/gengo/args/args_test.go create mode 100644 vendor/k8s.io/gengo/boilerplate/boilerplate.go.txt create mode 100644 vendor/k8s.io/gengo/boilerplate/no-boilerplate.go.txt create mode 100644 vendor/k8s.io/gengo/code-of-conduct.md create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/.gitignore create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/Makefile create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/generators/deepcopy.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/generators/deepcopy_test.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/main.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/aliases/doc.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/aliases/zz_generated.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/builtins/doc.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/builtins/zz_generated.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/interface_fuzzer.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/interfaces/doc.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/interfaces/zz_generated.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/maps/doc.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/maps/zz_generated.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/otherpkg/interfaces.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/output_test.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/pointer/doc.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/pointer/zz_generated.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/reflect_deepcopy.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/slices/doc.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/slices/zz_generated.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/structs/doc.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/structs/zz_generated.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/value_fuzzer.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/wholepkg/a.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/wholepkg/b.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/wholepkg/deepcopy_test.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/wholepkg/doc.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/wholepkg/interfaces.go create mode 100644 vendor/k8s.io/gengo/examples/deepcopy-gen/output_tests/wholepkg/zz_generated.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/.gitignore create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/.import-restrictions create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/Makefile create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/OWNERS create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/empty/doc.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/empty/type.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/empty/zz_generated.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/pointer/defaults.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/pointer/doc.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/pointer/type.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/pointer/zz_generated.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/slices/defaults.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/slices/doc.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/slices/type.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/slices/zz_generated.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/wholepkg/defaults.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/wholepkg/doc.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/wholepkg/type.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/_output_tests/wholepkg/zz_generated.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/generators/defaulter.go create mode 100644 vendor/k8s.io/gengo/examples/defaulter-gen/main.go create mode 100644 vendor/k8s.io/gengo/examples/import-boss/.gitignore create mode 100644 vendor/k8s.io/gengo/examples/import-boss/generators/import_restrict.go create mode 100644 vendor/k8s.io/gengo/examples/import-boss/generators/import_restrict_test.go create mode 100644 vendor/k8s.io/gengo/examples/import-boss/main.go create mode 100644 vendor/k8s.io/gengo/examples/set-gen/.gitignore create mode 100644 vendor/k8s.io/gengo/examples/set-gen/Makefile create mode 100644 vendor/k8s.io/gengo/examples/set-gen/generators/sets.go create mode 100644 vendor/k8s.io/gengo/examples/set-gen/generators/tags.go create mode 100644 vendor/k8s.io/gengo/examples/set-gen/main.go create mode 100644 vendor/k8s.io/gengo/examples/set-gen/sets/byte.go create mode 100644 vendor/k8s.io/gengo/examples/set-gen/sets/doc.go create mode 100644 vendor/k8s.io/gengo/examples/set-gen/sets/empty.go create mode 100644 vendor/k8s.io/gengo/examples/set-gen/sets/int.go create mode 100644 vendor/k8s.io/gengo/examples/set-gen/sets/int64.go create mode 100644 vendor/k8s.io/gengo/examples/set-gen/sets/set_test.go create mode 100644 vendor/k8s.io/gengo/examples/set-gen/sets/string.go create mode 100644 vendor/k8s.io/gengo/examples/set-gen/sets/types/types.go create mode 100644 vendor/k8s.io/gengo/generator/default_generator.go create mode 100644 vendor/k8s.io/gengo/generator/default_package.go create mode 100644 vendor/k8s.io/gengo/generator/doc.go create mode 100644 vendor/k8s.io/gengo/generator/error_tracker.go create mode 100644 vendor/k8s.io/gengo/generator/execute.go create mode 100644 vendor/k8s.io/gengo/generator/generator.go create mode 100644 vendor/k8s.io/gengo/generator/import_tracker.go create mode 100644 vendor/k8s.io/gengo/generator/snippet_writer.go create mode 100644 vendor/k8s.io/gengo/generator/snippet_writer_test.go create mode 100644 vendor/k8s.io/gengo/namer/doc.go create mode 100644 vendor/k8s.io/gengo/namer/import_tracker.go create mode 100644 vendor/k8s.io/gengo/namer/namer.go create mode 100644 vendor/k8s.io/gengo/namer/namer_test.go create mode 100644 vendor/k8s.io/gengo/namer/order.go create mode 100644 vendor/k8s.io/gengo/namer/plural_namer.go create mode 100644 vendor/k8s.io/gengo/namer/plural_namer_test.go create mode 100644 vendor/k8s.io/gengo/parser/doc.go create mode 100644 vendor/k8s.io/gengo/parser/local_parse_test.go create mode 100644 vendor/k8s.io/gengo/parser/parse.go create mode 100644 vendor/k8s.io/gengo/parser/parse_test.go create mode 100644 vendor/k8s.io/gengo/testdata/a/a.go create mode 100644 vendor/k8s.io/gengo/testdata/a/b/b.go create mode 100644 vendor/k8s.io/gengo/types/comments.go create mode 100644 vendor/k8s.io/gengo/types/comments_test.go create mode 100644 vendor/k8s.io/gengo/types/doc.go create mode 100644 vendor/k8s.io/gengo/types/flatten.go create mode 100644 vendor/k8s.io/gengo/types/flatten_test.go create mode 100644 vendor/k8s.io/gengo/types/types.go create mode 100644 vendor/k8s.io/gengo/types/types_test.go create mode 100644 vendor/k8s.io/klog/.travis.yml create mode 100644 vendor/k8s.io/klog/CONTRIBUTING.md create mode 100644 vendor/k8s.io/klog/LICENSE create mode 100644 vendor/k8s.io/klog/OWNERS create mode 100644 vendor/k8s.io/klog/README.md create mode 100644 vendor/k8s.io/klog/RELEASE.md create mode 100644 vendor/k8s.io/klog/SECURITY_CONTACTS create mode 100644 vendor/k8s.io/klog/examples/coexist_glog/coexist_glog.go create mode 100644 vendor/k8s.io/klog/examples/log_file/usage_log_file.go create mode 100644 vendor/k8s.io/klog/examples/set_output/usage_set_output.go create mode 100644 vendor/k8s.io/klog/glog/README.md create mode 100644 vendor/k8s.io/klog/glog/glog.go create mode 100644 vendor/k8s.io/klog/glog/glog_test.go create mode 100644 vendor/k8s.io/klog/klog.go create mode 100644 vendor/k8s.io/klog/klog_file.go create mode 100644 vendor/k8s.io/klog/klog_test.go diff --git a/Gopkg.lock b/Gopkg.lock index 79634dde..9916ce9f 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -13,12 +13,15 @@ packages = ["."] revision = "de5bf2ad457846296e2031421a34e2568e304e35" +[[projects]] + name = "github.com/davecgh/go-spew" + packages = ["spew"] + revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" + version = "v1.1.1" + [[projects]] name = "github.com/emicklei/go-restful" - packages = [ - ".", - "log" - ] + packages = [".","log"] revision = "3658237ded108b4134956c1b3050349d93e7b895" version = "v2.7.1" @@ -54,10 +57,7 @@ [[projects]] name = "github.com/gogo/protobuf" - packages = [ - "proto", - "sortkeys" - ] + packages = ["proto","sortkeys"] revision = "1adfc126b41513cc696b209667c8656ea7aac67c" version = "v1.0.0" @@ -69,13 +69,7 @@ [[projects]] name = "github.com/golang/protobuf" - packages = [ - "proto", - "ptypes", - "ptypes/any", - "ptypes/duration", - "ptypes/timestamp" - ] + packages = ["proto","ptypes","ptypes/any","ptypes/duration","ptypes/timestamp"] revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265" version = "v1.1.0" @@ -93,11 +87,7 @@ [[projects]] name = "github.com/googleapis/gnostic" - packages = [ - "OpenAPIv2", - "compiler", - "extensions" - ] + packages = ["OpenAPIv2","compiler","extensions"] revision = "7c663266750e7d82587642f65e60bc4083f1f84e" version = "v0.2.0" @@ -116,12 +106,15 @@ [[projects]] branch = "master" name = "github.com/gregjones/httpcache" - packages = [ - ".", - "diskcache" - ] + packages = [".","diskcache"] revision = "9cad4c3443a7200dd6400aef47183728de563a38" +[[projects]] + name = "github.com/hashicorp/golang-lru" + packages = [".","simplelru"] + revision = "20f1fb78b0740ba8c3cb143a61e86ba5c8669768" + version = "v0.5.0" + [[projects]] branch = "master" name = "github.com/howeyc/gopass" @@ -149,11 +142,7 @@ [[projects]] branch = "master" name = "github.com/mailru/easyjson" - packages = [ - "buffer", - "jlexer", - "jwriter" - ] + packages = ["buffer","jlexer","jwriter"] revision = "3fdea8d05856a0c8df22ed4bc71b3219245e4485" [[projects]] @@ -170,40 +159,20 @@ [[projects]] name = "github.com/openshift/api" - packages = [ - "apps/v1", - "authorization/v1", - "image/docker10", - "image/dockerpre012", - "image/v1", - "pkg/serialization", - "route/v1" - ] + packages = ["apps/v1","authorization/v1","pkg/serialization","route/v1"] revision = "0d921e363e951d89f583292c60d013c318df64dc" version = "v3.9.0" [[projects]] name = "github.com/openshift/client-go" - packages = [ - "apps/clientset/versioned/scheme", - "apps/clientset/versioned/typed/apps/v1", - "authorization/clientset/versioned/scheme", - "authorization/clientset/versioned/typed/authorization/v1", - "image/clientset/versioned/scheme", - "image/clientset/versioned/typed/image/v1", - "route/clientset/versioned/scheme", - "route/clientset/versioned/typed/route/v1" - ] + packages = ["apps/clientset/versioned/scheme","apps/clientset/versioned/typed/apps/v1","authorization/clientset/versioned/scheme","authorization/clientset/versioned/typed/authorization/v1","route/clientset/versioned/scheme","route/clientset/versioned/typed/route/v1"] revision = "1fa528d3be060e4c7178eb69e76d37cf7e699e3c" version = "v3.9.0" [[projects]] branch = "master" name = "github.com/operator-framework/operator-sdk" - packages = [ - "pkg/k8sclient", - "pkg/util/k8sutil" - ] + packages = ["pkg/k8sclient","pkg/sdk","pkg/util/k8sutil"] revision = "b5c345fa798e4ab3cc4eb009a8b2486e3a9e5852" [[projects]] @@ -245,45 +214,27 @@ [[projects]] branch = "master" name = "golang.org/x/net" - packages = [ - "http/httpguts", - "http2", - "http2/hpack", - "idna" - ] + packages = ["context","http/httpguts","http2","http2/hpack","idna"] revision = "afe8f62b1d6bbd81f31868121a50b06d8188e1f9" [[projects]] branch = "master" name = "golang.org/x/sys" - packages = [ - "unix", - "windows" - ] + packages = ["unix","windows"] revision = "c4afb3effaa53fd9a06ca61262dc7ce8df4c081b" [[projects]] name = "golang.org/x/text" - packages = [ - "collate", - "collate/build", - "internal/colltab", - "internal/gen", - "internal/tag", - "internal/triegen", - "internal/ucd", - "language", - "secure/bidirule", - "transform", - "unicode/bidi", - "unicode/cldr", - "unicode/norm", - "unicode/rangetable", - "width" - ] + packages = ["collate","collate/build","internal/colltab","internal/gen","internal/tag","internal/triegen","internal/ucd","language","secure/bidirule","transform","unicode/bidi","unicode/cldr","unicode/norm","unicode/rangetable","width"] revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" version = "v0.3.0" +[[projects]] + branch = "master" + name = "golang.org/x/tools" + packages = ["go/ast/astutil","imports","internal/fastwalk","internal/gopathwalk"] + revision = "91f80e683c10fea00e7f965a1a7cac482ce52541" + [[projects]] name = "gopkg.in/inf.v0" packages = ["."] @@ -298,145 +249,49 @@ [[projects]] name = "k8s.io/api" - packages = [ - "admissionregistration/v1alpha1", - "admissionregistration/v1beta1", - "apps/v1", - "apps/v1beta1", - "apps/v1beta2", - "authentication/v1", - "authentication/v1beta1", - "authorization/v1", - "authorization/v1beta1", - "autoscaling/v1", - "autoscaling/v2beta1", - "batch/v1", - "batch/v1beta1", - "batch/v2alpha1", - "certificates/v1beta1", - "core/v1", - "events/v1beta1", - "extensions/v1beta1", - "networking/v1", - "policy/v1beta1", - "rbac/v1", - "rbac/v1alpha1", - "rbac/v1beta1", - "scheduling/v1alpha1", - "settings/v1alpha1", - "storage/v1", - "storage/v1alpha1", - "storage/v1beta1" - ] + packages = ["admissionregistration/v1alpha1","admissionregistration/v1beta1","apps/v1","apps/v1beta1","apps/v1beta2","authentication/v1","authentication/v1beta1","authorization/v1","authorization/v1beta1","autoscaling/v1","autoscaling/v2beta1","batch/v1","batch/v1beta1","batch/v2alpha1","certificates/v1beta1","core/v1","events/v1beta1","extensions/v1beta1","networking/v1","policy/v1beta1","rbac/v1","rbac/v1alpha1","rbac/v1beta1","scheduling/v1alpha1","settings/v1alpha1","storage/v1","storage/v1alpha1","storage/v1beta1"] revision = "acf347b865f29325eb61f4cd2df11e86e073a5ee" version = "kubernetes-1.9.3" [[projects]] name = "k8s.io/apimachinery" - packages = [ - "pkg/api/errors", - "pkg/api/meta", - "pkg/api/resource", - "pkg/apis/meta/v1", - "pkg/apis/meta/v1/unstructured", - "pkg/apis/meta/v1alpha1", - "pkg/conversion", - "pkg/conversion/queryparams", - "pkg/fields", - "pkg/labels", - "pkg/runtime", - "pkg/runtime/schema", - "pkg/runtime/serializer", - "pkg/runtime/serializer/json", - "pkg/runtime/serializer/protobuf", - "pkg/runtime/serializer/recognizer", - "pkg/runtime/serializer/streaming", - "pkg/runtime/serializer/versioning", - "pkg/selection", - "pkg/types", - "pkg/util/clock", - "pkg/util/errors", - "pkg/util/framer", - "pkg/util/intstr", - "pkg/util/json", - "pkg/util/net", - "pkg/util/runtime", - "pkg/util/sets", - "pkg/util/validation", - "pkg/util/validation/field", - "pkg/util/wait", - "pkg/util/yaml", - "pkg/version", - "pkg/watch", - "third_party/forked/golang/reflect" - ] + packages = ["pkg/api/errors","pkg/api/meta","pkg/api/resource","pkg/apis/meta/internalversion","pkg/apis/meta/v1","pkg/apis/meta/v1/unstructured","pkg/apis/meta/v1alpha1","pkg/conversion","pkg/conversion/queryparams","pkg/fields","pkg/labels","pkg/runtime","pkg/runtime/schema","pkg/runtime/serializer","pkg/runtime/serializer/json","pkg/runtime/serializer/protobuf","pkg/runtime/serializer/recognizer","pkg/runtime/serializer/streaming","pkg/runtime/serializer/versioning","pkg/selection","pkg/types","pkg/util/cache","pkg/util/clock","pkg/util/diff","pkg/util/errors","pkg/util/framer","pkg/util/intstr","pkg/util/json","pkg/util/net","pkg/util/runtime","pkg/util/sets","pkg/util/validation","pkg/util/validation/field","pkg/util/wait","pkg/util/yaml","pkg/version","pkg/watch","third_party/forked/golang/reflect"] revision = "19e3f5aa3adca672c153d324e6b7d82ff8935f03" version = "kubernetes-1.9.3" [[projects]] name = "k8s.io/client-go" - packages = [ - "discovery", - "discovery/cached", - "dynamic", - "kubernetes", - "kubernetes/scheme", - "kubernetes/typed/admissionregistration/v1alpha1", - "kubernetes/typed/admissionregistration/v1beta1", - "kubernetes/typed/apps/v1", - "kubernetes/typed/apps/v1beta1", - "kubernetes/typed/apps/v1beta2", - "kubernetes/typed/authentication/v1", - "kubernetes/typed/authentication/v1beta1", - "kubernetes/typed/authorization/v1", - "kubernetes/typed/authorization/v1beta1", - "kubernetes/typed/autoscaling/v1", - "kubernetes/typed/autoscaling/v2beta1", - "kubernetes/typed/batch/v1", - "kubernetes/typed/batch/v1beta1", - "kubernetes/typed/batch/v2alpha1", - "kubernetes/typed/certificates/v1beta1", - "kubernetes/typed/core/v1", - "kubernetes/typed/events/v1beta1", - "kubernetes/typed/extensions/v1beta1", - "kubernetes/typed/networking/v1", - "kubernetes/typed/policy/v1beta1", - "kubernetes/typed/rbac/v1", - "kubernetes/typed/rbac/v1alpha1", - "kubernetes/typed/rbac/v1beta1", - "kubernetes/typed/scheduling/v1alpha1", - "kubernetes/typed/settings/v1alpha1", - "kubernetes/typed/storage/v1", - "kubernetes/typed/storage/v1alpha1", - "kubernetes/typed/storage/v1beta1", - "pkg/version", - "rest", - "rest/watch", - "tools/auth", - "tools/clientcmd", - "tools/clientcmd/api", - "tools/clientcmd/api/latest", - "tools/clientcmd/api/v1", - "tools/metrics", - "tools/reference", - "transport", - "util/cert", - "util/flowcontrol", - "util/homedir", - "util/integer" - ] + packages = ["discovery","discovery/cached","dynamic","kubernetes","kubernetes/scheme","kubernetes/typed/admissionregistration/v1alpha1","kubernetes/typed/admissionregistration/v1beta1","kubernetes/typed/apps/v1","kubernetes/typed/apps/v1beta1","kubernetes/typed/apps/v1beta2","kubernetes/typed/authentication/v1","kubernetes/typed/authentication/v1beta1","kubernetes/typed/authorization/v1","kubernetes/typed/authorization/v1beta1","kubernetes/typed/autoscaling/v1","kubernetes/typed/autoscaling/v2beta1","kubernetes/typed/batch/v1","kubernetes/typed/batch/v1beta1","kubernetes/typed/batch/v2alpha1","kubernetes/typed/certificates/v1beta1","kubernetes/typed/core/v1","kubernetes/typed/events/v1beta1","kubernetes/typed/extensions/v1beta1","kubernetes/typed/networking/v1","kubernetes/typed/policy/v1beta1","kubernetes/typed/rbac/v1","kubernetes/typed/rbac/v1alpha1","kubernetes/typed/rbac/v1beta1","kubernetes/typed/scheduling/v1alpha1","kubernetes/typed/settings/v1alpha1","kubernetes/typed/storage/v1","kubernetes/typed/storage/v1alpha1","kubernetes/typed/storage/v1beta1","pkg/version","rest","rest/watch","tools/auth","tools/cache","tools/clientcmd","tools/clientcmd/api","tools/clientcmd/api/latest","tools/clientcmd/api/v1","tools/metrics","tools/pager","tools/reference","transport","util/buffer","util/cert","util/flowcontrol","util/homedir","util/integer","util/workqueue"] revision = "9389c055a838d4f208b699b3c7c51b70f2368861" version = "kubernetes-1.9.3" +[[projects]] + branch = "release-1.10" + name = "k8s.io/code-generator" + packages = ["cmd/client-gen","cmd/client-gen/args","cmd/client-gen/generators","cmd/client-gen/generators/fake","cmd/client-gen/generators/scheme","cmd/client-gen/generators/util","cmd/client-gen/path","cmd/client-gen/types","cmd/conversion-gen","cmd/conversion-gen/args","cmd/conversion-gen/generators","cmd/deepcopy-gen","cmd/deepcopy-gen/args","cmd/defaulter-gen","cmd/defaulter-gen/args","cmd/informer-gen","cmd/informer-gen/args","cmd/informer-gen/generators","cmd/lister-gen","cmd/lister-gen/args","cmd/lister-gen/generators","cmd/openapi-gen","cmd/openapi-gen/args","pkg/util"] + revision = "9de8e796a74d16d2a285165727d04c185ebca6dc" + +[[projects]] + branch = "master" + name = "k8s.io/gengo" + packages = ["args","examples/deepcopy-gen/generators","examples/defaulter-gen/generators","examples/set-gen/sets","generator","namer","parser","types"] + revision = "fd15ee9cc2f77baa4f31e59e6acbf21146455073" + +[[projects]] + name = "k8s.io/klog" + packages = ["."] + revision = "a5bc97fbc634d635061f3146511332c7e313a55a" + version = "v0.1.0" + [[projects]] branch = "master" name = "k8s.io/kube-openapi" - packages = ["pkg/common"] + packages = ["pkg/common","pkg/generators"] revision = "4cac20de16b951c103aa40c4bafbc8cefdd18a12" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "80835b5f74f8af3e0a490574de85012f5fbcc865489328453fe6dd107f7ea7f5" + inputs-digest = "a068a092cd123047ddfdd699f59626422ee948af8b1b8048adbefbf250251ea9" solver-name = "gps-cdcl" solver-version = 1 diff --git a/vendor/github.com/davecgh/go-spew/.gitignore b/vendor/github.com/davecgh/go-spew/.gitignore new file mode 100644 index 00000000..00268614 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/.gitignore @@ -0,0 +1,22 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe diff --git a/vendor/github.com/davecgh/go-spew/.travis.yml b/vendor/github.com/davecgh/go-spew/.travis.yml new file mode 100644 index 00000000..1f4cbf54 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/.travis.yml @@ -0,0 +1,28 @@ +language: go +go_import_path: github.com/davecgh/go-spew +go: + - 1.6.x + - 1.7.x + - 1.8.x + - 1.9.x + - 1.10.x + - tip +sudo: false +install: + - go get -v github.com/alecthomas/gometalinter + - gometalinter --install +script: + - export PATH=$PATH:$HOME/gopath/bin + - export GORACE="halt_on_error=1" + - test -z "$(gometalinter --disable-all + --enable=gofmt + --enable=golint + --enable=vet + --enable=gosimple + --enable=unconvert + --deadline=4m ./spew | tee /dev/stderr)" + - go test -v -race -tags safe ./spew + - go test -v -race -tags testcgo ./spew -covermode=atomic -coverprofile=profile.cov +after_success: + - go get -v github.com/mattn/goveralls + - goveralls -coverprofile=profile.cov -service=travis-ci diff --git a/vendor/github.com/davecgh/go-spew/LICENSE b/vendor/github.com/davecgh/go-spew/LICENSE new file mode 100644 index 00000000..bc52e96f --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2012-2016 Dave Collins + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/vendor/github.com/davecgh/go-spew/README.md b/vendor/github.com/davecgh/go-spew/README.md new file mode 100644 index 00000000..f6ed02c3 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/README.md @@ -0,0 +1,201 @@ +go-spew +======= + +[![Build Status](https://img.shields.io/travis/davecgh/go-spew.svg)](https://travis-ci.org/davecgh/go-spew) +[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) +[![Coverage Status](https://img.shields.io/coveralls/davecgh/go-spew.svg)](https://coveralls.io/r/davecgh/go-spew?branch=master) + +Go-spew implements a deep pretty printer for Go data structures to aid in +debugging. A comprehensive suite of tests with 100% test coverage is provided +to ensure proper functionality. See `test_coverage.txt` for the gocov coverage +report. Go-spew is licensed under the liberal ISC license, so it may be used in +open source or commercial projects. + +If you're interested in reading about how this package came to life and some +of the challenges involved in providing a deep pretty printer, there is a blog +post about it +[here](https://web.archive.org/web/20160304013555/https://blog.cyphertite.com/go-spew-a-journey-into-dumping-go-data-structures/). + +## Documentation + +[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/davecgh/go-spew/spew) + +Full `go doc` style documentation for the project can be viewed online without +installing this package by using the excellent GoDoc site here: +http://godoc.org/github.com/davecgh/go-spew/spew + +You can also view the documentation locally once the package is installed with +the `godoc` tool by running `godoc -http=":6060"` and pointing your browser to +http://localhost:6060/pkg/github.com/davecgh/go-spew/spew + +## Installation + +```bash +$ go get -u github.com/davecgh/go-spew/spew +``` + +## Quick Start + +Add this import line to the file you're working in: + +```Go +import "github.com/davecgh/go-spew/spew" +``` + +To dump a variable with full newlines, indentation, type, and pointer +information use Dump, Fdump, or Sdump: + +```Go +spew.Dump(myVar1, myVar2, ...) +spew.Fdump(someWriter, myVar1, myVar2, ...) +str := spew.Sdump(myVar1, myVar2, ...) +``` + +Alternatively, if you would prefer to use format strings with a compacted inline +printing style, use the convenience wrappers Printf, Fprintf, etc with %v (most +compact), %+v (adds pointer addresses), %#v (adds types), or %#+v (adds types +and pointer addresses): + +```Go +spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) +spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) +spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) +spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) +``` + +## Debugging a Web Application Example + +Here is an example of how you can use `spew.Sdump()` to help debug a web application. Please be sure to wrap your output using the `html.EscapeString()` function for safety reasons. You should also only use this debugging technique in a development environment, never in production. + +```Go +package main + +import ( + "fmt" + "html" + "net/http" + + "github.com/davecgh/go-spew/spew" +) + +func handler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/html") + fmt.Fprintf(w, "Hi there, %s!", r.URL.Path[1:]) + fmt.Fprintf(w, "") +} + +func main() { + http.HandleFunc("/", handler) + http.ListenAndServe(":8080", nil) +} +``` + +## Sample Dump Output + +``` +(main.Foo) { + unexportedField: (*main.Bar)(0xf84002e210)({ + flag: (main.Flag) flagTwo, + data: (uintptr) + }), + ExportedField: (map[interface {}]interface {}) { + (string) "one": (bool) true + } +} +([]uint8) { + 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... | + 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0| + 00000020 31 32 |12| +} +``` + +## Sample Formatter Output + +Double pointer to a uint8: +``` + %v: <**>5 + %+v: <**>(0xf8400420d0->0xf8400420c8)5 + %#v: (**uint8)5 + %#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5 +``` + +Pointer to circular struct with a uint8 field and a pointer to itself: +``` + %v: <*>{1 <*>} + %+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)} + %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)} + %#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)} +``` + +## Configuration Options + +Configuration of spew is handled by fields in the ConfigState type. For +convenience, all of the top-level functions use a global state available via the +spew.Config global. + +It is also possible to create a ConfigState instance that provides methods +equivalent to the top-level functions. This allows concurrent configuration +options. See the ConfigState documentation for more details. + +``` +* Indent + String to use for each indentation level for Dump functions. + It is a single space by default. A popular alternative is "\t". + +* MaxDepth + Maximum number of levels to descend into nested data structures. + There is no limit by default. + +* DisableMethods + Disables invocation of error and Stringer interface methods. + Method invocation is enabled by default. + +* DisablePointerMethods + Disables invocation of error and Stringer interface methods on types + which only accept pointer receivers from non-pointer variables. This option + relies on access to the unsafe package, so it will not have any effect when + running in environments without access to the unsafe package such as Google + App Engine or with the "safe" build tag specified. + Pointer method invocation is enabled by default. + +* DisablePointerAddresses + DisablePointerAddresses specifies whether to disable the printing of + pointer addresses. This is useful when diffing data structures in tests. + +* DisableCapacities + DisableCapacities specifies whether to disable the printing of capacities + for arrays, slices, maps and channels. This is useful when diffing data + structures in tests. + +* ContinueOnMethod + Enables recursion into types after invoking error and Stringer interface + methods. Recursion after method invocation is disabled by default. + +* SortKeys + Specifies map keys should be sorted before being printed. Use + this to have a more deterministic, diffable output. Note that + only native types (bool, int, uint, floats, uintptr and string) + and types which implement error or Stringer interfaces are supported, + with other types sorted according to the reflect.Value.String() output + which guarantees display stability. Natural map order is used by + default. + +* SpewKeys + SpewKeys specifies that, as a last resort attempt, map keys should be + spewed to strings and sorted by those strings. This is only considered + if SortKeys is true. + +``` + +## Unsafe Package Dependency + +This package relies on the unsafe package to perform some of the more advanced +features, however it also supports a "limited" mode which allows it to work in +environments where the unsafe package is not available. By default, it will +operate in this mode on Google App Engine and when compiled with GopherJS. The +"safe" build tag may also be specified to force the package to build without +using the unsafe package. + +## License + +Go-spew is licensed under the [copyfree](http://copyfree.org) ISC License. diff --git a/vendor/github.com/davecgh/go-spew/cov_report.sh b/vendor/github.com/davecgh/go-spew/cov_report.sh new file mode 100644 index 00000000..9579497e --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/cov_report.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# This script uses gocov to generate a test coverage report. +# The gocov tool my be obtained with the following command: +# go get github.com/axw/gocov/gocov +# +# It will be installed to $GOPATH/bin, so ensure that location is in your $PATH. + +# Check for gocov. +if ! type gocov >/dev/null 2>&1; then + echo >&2 "This script requires the gocov tool." + echo >&2 "You may obtain it with the following command:" + echo >&2 "go get github.com/axw/gocov/gocov" + exit 1 +fi + +# Only run the cgo tests if gcc is installed. +if type gcc >/dev/null 2>&1; then + (cd spew && gocov test -tags testcgo | gocov report) +else + (cd spew && gocov test | gocov report) +fi diff --git a/vendor/github.com/davecgh/go-spew/spew/bypass.go b/vendor/github.com/davecgh/go-spew/spew/bypass.go new file mode 100644 index 00000000..79299478 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/bypass.go @@ -0,0 +1,145 @@ +// Copyright (c) 2015-2016 Dave Collins +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when the code is not running on Google App Engine, compiled by GopherJS, and +// "-tags safe" is not added to the go build command line. The "disableunsafe" +// tag is deprecated and thus should not be used. +// Go versions prior to 1.4 are disabled because they use a different layout +// for interfaces which make the implementation of unsafeReflectValue more complex. +// +build !js,!appengine,!safe,!disableunsafe,go1.4 + +package spew + +import ( + "reflect" + "unsafe" +) + +const ( + // UnsafeDisabled is a build-time constant which specifies whether or + // not access to the unsafe package is available. + UnsafeDisabled = false + + // ptrSize is the size of a pointer on the current arch. + ptrSize = unsafe.Sizeof((*byte)(nil)) +) + +type flag uintptr + +var ( + // flagRO indicates whether the value field of a reflect.Value + // is read-only. + flagRO flag + + // flagAddr indicates whether the address of the reflect.Value's + // value may be taken. + flagAddr flag +) + +// flagKindMask holds the bits that make up the kind +// part of the flags field. In all the supported versions, +// it is in the lower 5 bits. +const flagKindMask = flag(0x1f) + +// Different versions of Go have used different +// bit layouts for the flags type. This table +// records the known combinations. +var okFlags = []struct { + ro, addr flag +}{{ + // From Go 1.4 to 1.5 + ro: 1 << 5, + addr: 1 << 7, +}, { + // Up to Go tip. + ro: 1<<5 | 1<<6, + addr: 1 << 8, +}} + +var flagValOffset = func() uintptr { + field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") + if !ok { + panic("reflect.Value has no flag field") + } + return field.Offset +}() + +// flagField returns a pointer to the flag field of a reflect.Value. +func flagField(v *reflect.Value) *flag { + return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset)) +} + +// unsafeReflectValue converts the passed reflect.Value into a one that bypasses +// the typical safety restrictions preventing access to unaddressable and +// unexported data. It works by digging the raw pointer to the underlying +// value out of the protected value and generating a new unprotected (unsafe) +// reflect.Value to it. +// +// This allows us to check for implementations of the Stringer and error +// interfaces to be used for pretty printing ordinarily unaddressable and +// inaccessible values such as unexported struct fields. +func unsafeReflectValue(v reflect.Value) reflect.Value { + if !v.IsValid() || (v.CanInterface() && v.CanAddr()) { + return v + } + flagFieldPtr := flagField(&v) + *flagFieldPtr &^= flagRO + *flagFieldPtr |= flagAddr + return v +} + +// Sanity checks against future reflect package changes +// to the type or semantics of the Value.flag field. +func init() { + field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") + if !ok { + panic("reflect.Value has no flag field") + } + if field.Type.Kind() != reflect.TypeOf(flag(0)).Kind() { + panic("reflect.Value flag field has changed kind") + } + type t0 int + var t struct { + A t0 + // t0 will have flagEmbedRO set. + t0 + // a will have flagStickyRO set + a t0 + } + vA := reflect.ValueOf(t).FieldByName("A") + va := reflect.ValueOf(t).FieldByName("a") + vt0 := reflect.ValueOf(t).FieldByName("t0") + + // Infer flagRO from the difference between the flags + // for the (otherwise identical) fields in t. + flagPublic := *flagField(&vA) + flagWithRO := *flagField(&va) | *flagField(&vt0) + flagRO = flagPublic ^ flagWithRO + + // Infer flagAddr from the difference between a value + // taken from a pointer and not. + vPtrA := reflect.ValueOf(&t).Elem().FieldByName("A") + flagNoPtr := *flagField(&vA) + flagPtr := *flagField(&vPtrA) + flagAddr = flagNoPtr ^ flagPtr + + // Check that the inferred flags tally with one of the known versions. + for _, f := range okFlags { + if flagRO == f.ro && flagAddr == f.addr { + return + } + } + panic("reflect.Value read-only flag has changed semantics") +} diff --git a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go new file mode 100644 index 00000000..205c28d6 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go @@ -0,0 +1,38 @@ +// Copyright (c) 2015-2016 Dave Collins +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when the code is running on Google App Engine, compiled by GopherJS, or +// "-tags safe" is added to the go build command line. The "disableunsafe" +// tag is deprecated and thus should not be used. +// +build js appengine safe disableunsafe !go1.4 + +package spew + +import "reflect" + +const ( + // UnsafeDisabled is a build-time constant which specifies whether or + // not access to the unsafe package is available. + UnsafeDisabled = true +) + +// unsafeReflectValue typically converts the passed reflect.Value into a one +// that bypasses the typical safety restrictions preventing access to +// unaddressable and unexported data. However, doing this relies on access to +// the unsafe package. This is a stub version which simply returns the passed +// reflect.Value when the unsafe package is not available. +func unsafeReflectValue(v reflect.Value) reflect.Value { + return v +} diff --git a/vendor/github.com/davecgh/go-spew/spew/common.go b/vendor/github.com/davecgh/go-spew/spew/common.go new file mode 100644 index 00000000..1be8ce94 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/common.go @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "bytes" + "fmt" + "io" + "reflect" + "sort" + "strconv" +) + +// Some constants in the form of bytes to avoid string overhead. This mirrors +// the technique used in the fmt package. +var ( + panicBytes = []byte("(PANIC=") + plusBytes = []byte("+") + iBytes = []byte("i") + trueBytes = []byte("true") + falseBytes = []byte("false") + interfaceBytes = []byte("(interface {})") + commaNewlineBytes = []byte(",\n") + newlineBytes = []byte("\n") + openBraceBytes = []byte("{") + openBraceNewlineBytes = []byte("{\n") + closeBraceBytes = []byte("}") + asteriskBytes = []byte("*") + colonBytes = []byte(":") + colonSpaceBytes = []byte(": ") + openParenBytes = []byte("(") + closeParenBytes = []byte(")") + spaceBytes = []byte(" ") + pointerChainBytes = []byte("->") + nilAngleBytes = []byte("") + maxNewlineBytes = []byte("\n") + maxShortBytes = []byte("") + circularBytes = []byte("") + circularShortBytes = []byte("") + invalidAngleBytes = []byte("") + openBracketBytes = []byte("[") + closeBracketBytes = []byte("]") + percentBytes = []byte("%") + precisionBytes = []byte(".") + openAngleBytes = []byte("<") + closeAngleBytes = []byte(">") + openMapBytes = []byte("map[") + closeMapBytes = []byte("]") + lenEqualsBytes = []byte("len=") + capEqualsBytes = []byte("cap=") +) + +// hexDigits is used to map a decimal value to a hex digit. +var hexDigits = "0123456789abcdef" + +// catchPanic handles any panics that might occur during the handleMethods +// calls. +func catchPanic(w io.Writer, v reflect.Value) { + if err := recover(); err != nil { + w.Write(panicBytes) + fmt.Fprintf(w, "%v", err) + w.Write(closeParenBytes) + } +} + +// handleMethods attempts to call the Error and String methods on the underlying +// type the passed reflect.Value represents and outputes the result to Writer w. +// +// It handles panics in any called methods by catching and displaying the error +// as the formatted value. +func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool) { + // We need an interface to check if the type implements the error or + // Stringer interface. However, the reflect package won't give us an + // interface on certain things like unexported struct fields in order + // to enforce visibility rules. We use unsafe, when it's available, + // to bypass these restrictions since this package does not mutate the + // values. + if !v.CanInterface() { + if UnsafeDisabled { + return false + } + + v = unsafeReflectValue(v) + } + + // Choose whether or not to do error and Stringer interface lookups against + // the base type or a pointer to the base type depending on settings. + // Technically calling one of these methods with a pointer receiver can + // mutate the value, however, types which choose to satisify an error or + // Stringer interface with a pointer receiver should not be mutating their + // state inside these interface methods. + if !cs.DisablePointerMethods && !UnsafeDisabled && !v.CanAddr() { + v = unsafeReflectValue(v) + } + if v.CanAddr() { + v = v.Addr() + } + + // Is it an error or Stringer? + switch iface := v.Interface().(type) { + case error: + defer catchPanic(w, v) + if cs.ContinueOnMethod { + w.Write(openParenBytes) + w.Write([]byte(iface.Error())) + w.Write(closeParenBytes) + w.Write(spaceBytes) + return false + } + + w.Write([]byte(iface.Error())) + return true + + case fmt.Stringer: + defer catchPanic(w, v) + if cs.ContinueOnMethod { + w.Write(openParenBytes) + w.Write([]byte(iface.String())) + w.Write(closeParenBytes) + w.Write(spaceBytes) + return false + } + w.Write([]byte(iface.String())) + return true + } + return false +} + +// printBool outputs a boolean value as true or false to Writer w. +func printBool(w io.Writer, val bool) { + if val { + w.Write(trueBytes) + } else { + w.Write(falseBytes) + } +} + +// printInt outputs a signed integer value to Writer w. +func printInt(w io.Writer, val int64, base int) { + w.Write([]byte(strconv.FormatInt(val, base))) +} + +// printUint outputs an unsigned integer value to Writer w. +func printUint(w io.Writer, val uint64, base int) { + w.Write([]byte(strconv.FormatUint(val, base))) +} + +// printFloat outputs a floating point value using the specified precision, +// which is expected to be 32 or 64bit, to Writer w. +func printFloat(w io.Writer, val float64, precision int) { + w.Write([]byte(strconv.FormatFloat(val, 'g', -1, precision))) +} + +// printComplex outputs a complex value using the specified float precision +// for the real and imaginary parts to Writer w. +func printComplex(w io.Writer, c complex128, floatPrecision int) { + r := real(c) + w.Write(openParenBytes) + w.Write([]byte(strconv.FormatFloat(r, 'g', -1, floatPrecision))) + i := imag(c) + if i >= 0 { + w.Write(plusBytes) + } + w.Write([]byte(strconv.FormatFloat(i, 'g', -1, floatPrecision))) + w.Write(iBytes) + w.Write(closeParenBytes) +} + +// printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x' +// prefix to Writer w. +func printHexPtr(w io.Writer, p uintptr) { + // Null pointer. + num := uint64(p) + if num == 0 { + w.Write(nilAngleBytes) + return + } + + // Max uint64 is 16 bytes in hex + 2 bytes for '0x' prefix + buf := make([]byte, 18) + + // It's simpler to construct the hex string right to left. + base := uint64(16) + i := len(buf) - 1 + for num >= base { + buf[i] = hexDigits[num%base] + num /= base + i-- + } + buf[i] = hexDigits[num] + + // Add '0x' prefix. + i-- + buf[i] = 'x' + i-- + buf[i] = '0' + + // Strip unused leading bytes. + buf = buf[i:] + w.Write(buf) +} + +// valuesSorter implements sort.Interface to allow a slice of reflect.Value +// elements to be sorted. +type valuesSorter struct { + values []reflect.Value + strings []string // either nil or same len and values + cs *ConfigState +} + +// newValuesSorter initializes a valuesSorter instance, which holds a set of +// surrogate keys on which the data should be sorted. It uses flags in +// ConfigState to decide if and how to populate those surrogate keys. +func newValuesSorter(values []reflect.Value, cs *ConfigState) sort.Interface { + vs := &valuesSorter{values: values, cs: cs} + if canSortSimply(vs.values[0].Kind()) { + return vs + } + if !cs.DisableMethods { + vs.strings = make([]string, len(values)) + for i := range vs.values { + b := bytes.Buffer{} + if !handleMethods(cs, &b, vs.values[i]) { + vs.strings = nil + break + } + vs.strings[i] = b.String() + } + } + if vs.strings == nil && cs.SpewKeys { + vs.strings = make([]string, len(values)) + for i := range vs.values { + vs.strings[i] = Sprintf("%#v", vs.values[i].Interface()) + } + } + return vs +} + +// canSortSimply tests whether a reflect.Kind is a primitive that can be sorted +// directly, or whether it should be considered for sorting by surrogate keys +// (if the ConfigState allows it). +func canSortSimply(kind reflect.Kind) bool { + // This switch parallels valueSortLess, except for the default case. + switch kind { + case reflect.Bool: + return true + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: + return true + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: + return true + case reflect.Float32, reflect.Float64: + return true + case reflect.String: + return true + case reflect.Uintptr: + return true + case reflect.Array: + return true + } + return false +} + +// Len returns the number of values in the slice. It is part of the +// sort.Interface implementation. +func (s *valuesSorter) Len() int { + return len(s.values) +} + +// Swap swaps the values at the passed indices. It is part of the +// sort.Interface implementation. +func (s *valuesSorter) Swap(i, j int) { + s.values[i], s.values[j] = s.values[j], s.values[i] + if s.strings != nil { + s.strings[i], s.strings[j] = s.strings[j], s.strings[i] + } +} + +// valueSortLess returns whether the first value should sort before the second +// value. It is used by valueSorter.Less as part of the sort.Interface +// implementation. +func valueSortLess(a, b reflect.Value) bool { + switch a.Kind() { + case reflect.Bool: + return !a.Bool() && b.Bool() + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: + return a.Int() < b.Int() + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: + return a.Uint() < b.Uint() + case reflect.Float32, reflect.Float64: + return a.Float() < b.Float() + case reflect.String: + return a.String() < b.String() + case reflect.Uintptr: + return a.Uint() < b.Uint() + case reflect.Array: + // Compare the contents of both arrays. + l := a.Len() + for i := 0; i < l; i++ { + av := a.Index(i) + bv := b.Index(i) + if av.Interface() == bv.Interface() { + continue + } + return valueSortLess(av, bv) + } + } + return a.String() < b.String() +} + +// Less returns whether the value at index i should sort before the +// value at index j. It is part of the sort.Interface implementation. +func (s *valuesSorter) Less(i, j int) bool { + if s.strings == nil { + return valueSortLess(s.values[i], s.values[j]) + } + return s.strings[i] < s.strings[j] +} + +// sortValues is a sort function that handles both native types and any type that +// can be converted to error or Stringer. Other inputs are sorted according to +// their Value.String() value to ensure display stability. +func sortValues(values []reflect.Value, cs *ConfigState) { + if len(values) == 0 { + return + } + sort.Sort(newValuesSorter(values, cs)) +} diff --git a/vendor/github.com/davecgh/go-spew/spew/common_test.go b/vendor/github.com/davecgh/go-spew/spew/common_test.go new file mode 100644 index 00000000..0f5ce47d --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/common_test.go @@ -0,0 +1,298 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew_test + +import ( + "fmt" + "reflect" + "testing" + + "github.com/davecgh/go-spew/spew" +) + +// custom type to test Stinger interface on non-pointer receiver. +type stringer string + +// String implements the Stringer interface for testing invocation of custom +// stringers on types with non-pointer receivers. +func (s stringer) String() string { + return "stringer " + string(s) +} + +// custom type to test Stinger interface on pointer receiver. +type pstringer string + +// String implements the Stringer interface for testing invocation of custom +// stringers on types with only pointer receivers. +func (s *pstringer) String() string { + return "stringer " + string(*s) +} + +// xref1 and xref2 are cross referencing structs for testing circular reference +// detection. +type xref1 struct { + ps2 *xref2 +} +type xref2 struct { + ps1 *xref1 +} + +// indirCir1, indirCir2, and indirCir3 are used to generate an indirect circular +// reference for testing detection. +type indirCir1 struct { + ps2 *indirCir2 +} +type indirCir2 struct { + ps3 *indirCir3 +} +type indirCir3 struct { + ps1 *indirCir1 +} + +// embed is used to test embedded structures. +type embed struct { + a string +} + +// embedwrap is used to test embedded structures. +type embedwrap struct { + *embed + e *embed +} + +// panicer is used to intentionally cause a panic for testing spew properly +// handles them +type panicer int + +func (p panicer) String() string { + panic("test panic") +} + +// customError is used to test custom error interface invocation. +type customError int + +func (e customError) Error() string { + return fmt.Sprintf("error: %d", int(e)) +} + +// stringizeWants converts a slice of wanted test output into a format suitable +// for a test error message. +func stringizeWants(wants []string) string { + s := "" + for i, want := range wants { + if i > 0 { + s += fmt.Sprintf("want%d: %s", i+1, want) + } else { + s += "want: " + want + } + } + return s +} + +// testFailed returns whether or not a test failed by checking if the result +// of the test is in the slice of wanted strings. +func testFailed(result string, wants []string) bool { + for _, want := range wants { + if result == want { + return false + } + } + return true +} + +type sortableStruct struct { + x int +} + +func (ss sortableStruct) String() string { + return fmt.Sprintf("ss.%d", ss.x) +} + +type unsortableStruct struct { + x int +} + +type sortTestCase struct { + input []reflect.Value + expected []reflect.Value +} + +func helpTestSortValues(tests []sortTestCase, cs *spew.ConfigState, t *testing.T) { + getInterfaces := func(values []reflect.Value) []interface{} { + interfaces := []interface{}{} + for _, v := range values { + interfaces = append(interfaces, v.Interface()) + } + return interfaces + } + + for _, test := range tests { + spew.SortValues(test.input, cs) + // reflect.DeepEqual cannot really make sense of reflect.Value, + // probably because of all the pointer tricks. For instance, + // v(2.0) != v(2.0) on a 32-bits system. Turn them into interface{} + // instead. + input := getInterfaces(test.input) + expected := getInterfaces(test.expected) + if !reflect.DeepEqual(input, expected) { + t.Errorf("Sort mismatch:\n %v != %v", input, expected) + } + } +} + +// TestSortValues ensures the sort functionality for relect.Value based sorting +// works as intended. +func TestSortValues(t *testing.T) { + v := reflect.ValueOf + + a := v("a") + b := v("b") + c := v("c") + embedA := v(embed{"a"}) + embedB := v(embed{"b"}) + embedC := v(embed{"c"}) + tests := []sortTestCase{ + // No values. + { + []reflect.Value{}, + []reflect.Value{}, + }, + // Bools. + { + []reflect.Value{v(false), v(true), v(false)}, + []reflect.Value{v(false), v(false), v(true)}, + }, + // Ints. + { + []reflect.Value{v(2), v(1), v(3)}, + []reflect.Value{v(1), v(2), v(3)}, + }, + // Uints. + { + []reflect.Value{v(uint8(2)), v(uint8(1)), v(uint8(3))}, + []reflect.Value{v(uint8(1)), v(uint8(2)), v(uint8(3))}, + }, + // Floats. + { + []reflect.Value{v(2.0), v(1.0), v(3.0)}, + []reflect.Value{v(1.0), v(2.0), v(3.0)}, + }, + // Strings. + { + []reflect.Value{b, a, c}, + []reflect.Value{a, b, c}, + }, + // Array + { + []reflect.Value{v([3]int{3, 2, 1}), v([3]int{1, 3, 2}), v([3]int{1, 2, 3})}, + []reflect.Value{v([3]int{1, 2, 3}), v([3]int{1, 3, 2}), v([3]int{3, 2, 1})}, + }, + // Uintptrs. + { + []reflect.Value{v(uintptr(2)), v(uintptr(1)), v(uintptr(3))}, + []reflect.Value{v(uintptr(1)), v(uintptr(2)), v(uintptr(3))}, + }, + // SortableStructs. + { + // Note: not sorted - DisableMethods is set. + []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})}, + []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})}, + }, + // UnsortableStructs. + { + // Note: not sorted - SpewKeys is false. + []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, + []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, + }, + // Invalid. + { + []reflect.Value{embedB, embedA, embedC}, + []reflect.Value{embedB, embedA, embedC}, + }, + } + cs := spew.ConfigState{DisableMethods: true, SpewKeys: false} + helpTestSortValues(tests, &cs, t) +} + +// TestSortValuesWithMethods ensures the sort functionality for relect.Value +// based sorting works as intended when using string methods. +func TestSortValuesWithMethods(t *testing.T) { + v := reflect.ValueOf + + a := v("a") + b := v("b") + c := v("c") + tests := []sortTestCase{ + // Ints. + { + []reflect.Value{v(2), v(1), v(3)}, + []reflect.Value{v(1), v(2), v(3)}, + }, + // Strings. + { + []reflect.Value{b, a, c}, + []reflect.Value{a, b, c}, + }, + // SortableStructs. + { + []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})}, + []reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})}, + }, + // UnsortableStructs. + { + // Note: not sorted - SpewKeys is false. + []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, + []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, + }, + } + cs := spew.ConfigState{DisableMethods: false, SpewKeys: false} + helpTestSortValues(tests, &cs, t) +} + +// TestSortValuesWithSpew ensures the sort functionality for relect.Value +// based sorting works as intended when using spew to stringify keys. +func TestSortValuesWithSpew(t *testing.T) { + v := reflect.ValueOf + + a := v("a") + b := v("b") + c := v("c") + tests := []sortTestCase{ + // Ints. + { + []reflect.Value{v(2), v(1), v(3)}, + []reflect.Value{v(1), v(2), v(3)}, + }, + // Strings. + { + []reflect.Value{b, a, c}, + []reflect.Value{a, b, c}, + }, + // SortableStructs. + { + []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})}, + []reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})}, + }, + // UnsortableStructs. + { + []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, + []reflect.Value{v(unsortableStruct{1}), v(unsortableStruct{2}), v(unsortableStruct{3})}, + }, + } + cs := spew.ConfigState{DisableMethods: true, SpewKeys: true} + helpTestSortValues(tests, &cs, t) +} diff --git a/vendor/github.com/davecgh/go-spew/spew/config.go b/vendor/github.com/davecgh/go-spew/spew/config.go new file mode 100644 index 00000000..2e3d22f3 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/config.go @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "bytes" + "fmt" + "io" + "os" +) + +// ConfigState houses the configuration options used by spew to format and +// display values. There is a global instance, Config, that is used to control +// all top-level Formatter and Dump functionality. Each ConfigState instance +// provides methods equivalent to the top-level functions. +// +// The zero value for ConfigState provides no indentation. You would typically +// want to set it to a space or a tab. +// +// Alternatively, you can use NewDefaultConfig to get a ConfigState instance +// with default settings. See the documentation of NewDefaultConfig for default +// values. +type ConfigState struct { + // Indent specifies the string to use for each indentation level. The + // global config instance that all top-level functions use set this to a + // single space by default. If you would like more indentation, you might + // set this to a tab with "\t" or perhaps two spaces with " ". + Indent string + + // MaxDepth controls the maximum number of levels to descend into nested + // data structures. The default, 0, means there is no limit. + // + // NOTE: Circular data structures are properly detected, so it is not + // necessary to set this value unless you specifically want to limit deeply + // nested data structures. + MaxDepth int + + // DisableMethods specifies whether or not error and Stringer interfaces are + // invoked for types that implement them. + DisableMethods bool + + // DisablePointerMethods specifies whether or not to check for and invoke + // error and Stringer interfaces on types which only accept a pointer + // receiver when the current type is not a pointer. + // + // NOTE: This might be an unsafe action since calling one of these methods + // with a pointer receiver could technically mutate the value, however, + // in practice, types which choose to satisify an error or Stringer + // interface with a pointer receiver should not be mutating their state + // inside these interface methods. As a result, this option relies on + // access to the unsafe package, so it will not have any effect when + // running in environments without access to the unsafe package such as + // Google App Engine or with the "safe" build tag specified. + DisablePointerMethods bool + + // DisablePointerAddresses specifies whether to disable the printing of + // pointer addresses. This is useful when diffing data structures in tests. + DisablePointerAddresses bool + + // DisableCapacities specifies whether to disable the printing of capacities + // for arrays, slices, maps and channels. This is useful when diffing + // data structures in tests. + DisableCapacities bool + + // ContinueOnMethod specifies whether or not recursion should continue once + // a custom error or Stringer interface is invoked. The default, false, + // means it will print the results of invoking the custom error or Stringer + // interface and return immediately instead of continuing to recurse into + // the internals of the data type. + // + // NOTE: This flag does not have any effect if method invocation is disabled + // via the DisableMethods or DisablePointerMethods options. + ContinueOnMethod bool + + // SortKeys specifies map keys should be sorted before being printed. Use + // this to have a more deterministic, diffable output. Note that only + // native types (bool, int, uint, floats, uintptr and string) and types + // that support the error or Stringer interfaces (if methods are + // enabled) are supported, with other types sorted according to the + // reflect.Value.String() output which guarantees display stability. + SortKeys bool + + // SpewKeys specifies that, as a last resort attempt, map keys should + // be spewed to strings and sorted by those strings. This is only + // considered if SortKeys is true. + SpewKeys bool +} + +// Config is the active configuration of the top-level functions. +// The configuration can be changed by modifying the contents of spew.Config. +var Config = ConfigState{Indent: " "} + +// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the formatted string as a value that satisfies error. See NewFormatter +// for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Errorf(format, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Errorf(format string, a ...interface{}) (err error) { + return fmt.Errorf(format, c.convertArgs(a)...) +} + +// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprint(w, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Fprint(w io.Writer, a ...interface{}) (n int, err error) { + return fmt.Fprint(w, c.convertArgs(a)...) +} + +// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprintf(w, format, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { + return fmt.Fprintf(w, format, c.convertArgs(a)...) +} + +// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it +// passed with a Formatter interface returned by c.NewFormatter. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprintln(w, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Fprintln(w io.Writer, a ...interface{}) (n int, err error) { + return fmt.Fprintln(w, c.convertArgs(a)...) +} + +// Print is a wrapper for fmt.Print that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Print(c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Print(a ...interface{}) (n int, err error) { + return fmt.Print(c.convertArgs(a)...) +} + +// Printf is a wrapper for fmt.Printf that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Printf(format, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Printf(format string, a ...interface{}) (n int, err error) { + return fmt.Printf(format, c.convertArgs(a)...) +} + +// Println is a wrapper for fmt.Println that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Println(c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Println(a ...interface{}) (n int, err error) { + return fmt.Println(c.convertArgs(a)...) +} + +// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprint(c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Sprint(a ...interface{}) string { + return fmt.Sprint(c.convertArgs(a)...) +} + +// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprintf(format, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Sprintf(format string, a ...interface{}) string { + return fmt.Sprintf(format, c.convertArgs(a)...) +} + +// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it +// were passed with a Formatter interface returned by c.NewFormatter. It +// returns the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprintln(c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Sprintln(a ...interface{}) string { + return fmt.Sprintln(c.convertArgs(a)...) +} + +/* +NewFormatter returns a custom formatter that satisfies the fmt.Formatter +interface. As a result, it integrates cleanly with standard fmt package +printing functions. The formatter is useful for inline printing of smaller data +types similar to the standard %v format specifier. + +The custom formatter only responds to the %v (most compact), %+v (adds pointer +addresses), %#v (adds types), and %#+v (adds types and pointer addresses) verb +combinations. Any other verbs such as %x and %q will be sent to the the +standard fmt package for formatting. In addition, the custom formatter ignores +the width and precision arguments (however they will still work on the format +specifiers not handled by the custom formatter). + +Typically this function shouldn't be called directly. It is much easier to make +use of the custom formatter by calling one of the convenience functions such as +c.Printf, c.Println, or c.Printf. +*/ +func (c *ConfigState) NewFormatter(v interface{}) fmt.Formatter { + return newFormatter(c, v) +} + +// Fdump formats and displays the passed arguments to io.Writer w. It formats +// exactly the same as Dump. +func (c *ConfigState) Fdump(w io.Writer, a ...interface{}) { + fdump(c, w, a...) +} + +/* +Dump displays the passed parameters to standard out with newlines, customizable +indentation, and additional debug information such as complete types and all +pointer addresses used to indirect to the final value. It provides the +following features over the built-in printing facilities provided by the fmt +package: + + * Pointers are dereferenced and followed + * Circular data structures are detected and handled properly + * Custom Stringer/error interfaces are optionally invoked, including + on unexported types + * Custom types which only implement the Stringer/error interfaces via + a pointer receiver are optionally invoked when passing non-pointer + variables + * Byte arrays and slices are dumped like the hexdump -C command which + includes offsets, byte values in hex, and ASCII output + +The configuration options are controlled by modifying the public members +of c. See ConfigState for options documentation. + +See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to +get the formatted result as a string. +*/ +func (c *ConfigState) Dump(a ...interface{}) { + fdump(c, os.Stdout, a...) +} + +// Sdump returns a string with the passed arguments formatted exactly the same +// as Dump. +func (c *ConfigState) Sdump(a ...interface{}) string { + var buf bytes.Buffer + fdump(c, &buf, a...) + return buf.String() +} + +// convertArgs accepts a slice of arguments and returns a slice of the same +// length with each argument converted to a spew Formatter interface using +// the ConfigState associated with s. +func (c *ConfigState) convertArgs(args []interface{}) (formatters []interface{}) { + formatters = make([]interface{}, len(args)) + for index, arg := range args { + formatters[index] = newFormatter(c, arg) + } + return formatters +} + +// NewDefaultConfig returns a ConfigState with the following default settings. +// +// Indent: " " +// MaxDepth: 0 +// DisableMethods: false +// DisablePointerMethods: false +// ContinueOnMethod: false +// SortKeys: false +func NewDefaultConfig() *ConfigState { + return &ConfigState{Indent: " "} +} diff --git a/vendor/github.com/davecgh/go-spew/spew/doc.go b/vendor/github.com/davecgh/go-spew/spew/doc.go new file mode 100644 index 00000000..aacaac6f --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/doc.go @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* +Package spew implements a deep pretty printer for Go data structures to aid in +debugging. + +A quick overview of the additional features spew provides over the built-in +printing facilities for Go data types are as follows: + + * Pointers are dereferenced and followed + * Circular data structures are detected and handled properly + * Custom Stringer/error interfaces are optionally invoked, including + on unexported types + * Custom types which only implement the Stringer/error interfaces via + a pointer receiver are optionally invoked when passing non-pointer + variables + * Byte arrays and slices are dumped like the hexdump -C command which + includes offsets, byte values in hex, and ASCII output (only when using + Dump style) + +There are two different approaches spew allows for dumping Go data structures: + + * Dump style which prints with newlines, customizable indentation, + and additional debug information such as types and all pointer addresses + used to indirect to the final value + * A custom Formatter interface that integrates cleanly with the standard fmt + package and replaces %v, %+v, %#v, and %#+v to provide inline printing + similar to the default %v while providing the additional functionality + outlined above and passing unsupported format verbs such as %x and %q + along to fmt + +Quick Start + +This section demonstrates how to quickly get started with spew. See the +sections below for further details on formatting and configuration options. + +To dump a variable with full newlines, indentation, type, and pointer +information use Dump, Fdump, or Sdump: + spew.Dump(myVar1, myVar2, ...) + spew.Fdump(someWriter, myVar1, myVar2, ...) + str := spew.Sdump(myVar1, myVar2, ...) + +Alternatively, if you would prefer to use format strings with a compacted inline +printing style, use the convenience wrappers Printf, Fprintf, etc with +%v (most compact), %+v (adds pointer addresses), %#v (adds types), or +%#+v (adds types and pointer addresses): + spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) + spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) + spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) + spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) + +Configuration Options + +Configuration of spew is handled by fields in the ConfigState type. For +convenience, all of the top-level functions use a global state available +via the spew.Config global. + +It is also possible to create a ConfigState instance that provides methods +equivalent to the top-level functions. This allows concurrent configuration +options. See the ConfigState documentation for more details. + +The following configuration options are available: + * Indent + String to use for each indentation level for Dump functions. + It is a single space by default. A popular alternative is "\t". + + * MaxDepth + Maximum number of levels to descend into nested data structures. + There is no limit by default. + + * DisableMethods + Disables invocation of error and Stringer interface methods. + Method invocation is enabled by default. + + * DisablePointerMethods + Disables invocation of error and Stringer interface methods on types + which only accept pointer receivers from non-pointer variables. + Pointer method invocation is enabled by default. + + * DisablePointerAddresses + DisablePointerAddresses specifies whether to disable the printing of + pointer addresses. This is useful when diffing data structures in tests. + + * DisableCapacities + DisableCapacities specifies whether to disable the printing of + capacities for arrays, slices, maps and channels. This is useful when + diffing data structures in tests. + + * ContinueOnMethod + Enables recursion into types after invoking error and Stringer interface + methods. Recursion after method invocation is disabled by default. + + * SortKeys + Specifies map keys should be sorted before being printed. Use + this to have a more deterministic, diffable output. Note that + only native types (bool, int, uint, floats, uintptr and string) + and types which implement error or Stringer interfaces are + supported with other types sorted according to the + reflect.Value.String() output which guarantees display + stability. Natural map order is used by default. + + * SpewKeys + Specifies that, as a last resort attempt, map keys should be + spewed to strings and sorted by those strings. This is only + considered if SortKeys is true. + +Dump Usage + +Simply call spew.Dump with a list of variables you want to dump: + + spew.Dump(myVar1, myVar2, ...) + +You may also call spew.Fdump if you would prefer to output to an arbitrary +io.Writer. For example, to dump to standard error: + + spew.Fdump(os.Stderr, myVar1, myVar2, ...) + +A third option is to call spew.Sdump to get the formatted output as a string: + + str := spew.Sdump(myVar1, myVar2, ...) + +Sample Dump Output + +See the Dump example for details on the setup of the types and variables being +shown here. + + (main.Foo) { + unexportedField: (*main.Bar)(0xf84002e210)({ + flag: (main.Flag) flagTwo, + data: (uintptr) + }), + ExportedField: (map[interface {}]interface {}) (len=1) { + (string) (len=3) "one": (bool) true + } + } + +Byte (and uint8) arrays and slices are displayed uniquely like the hexdump -C +command as shown. + ([]uint8) (len=32 cap=32) { + 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... | + 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0| + 00000020 31 32 |12| + } + +Custom Formatter + +Spew provides a custom formatter that implements the fmt.Formatter interface +so that it integrates cleanly with standard fmt package printing functions. The +formatter is useful for inline printing of smaller data types similar to the +standard %v format specifier. + +The custom formatter only responds to the %v (most compact), %+v (adds pointer +addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb +combinations. Any other verbs such as %x and %q will be sent to the the +standard fmt package for formatting. In addition, the custom formatter ignores +the width and precision arguments (however they will still work on the format +specifiers not handled by the custom formatter). + +Custom Formatter Usage + +The simplest way to make use of the spew custom formatter is to call one of the +convenience functions such as spew.Printf, spew.Println, or spew.Printf. The +functions have syntax you are most likely already familiar with: + + spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) + spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) + spew.Println(myVar, myVar2) + spew.Fprintf(os.Stderr, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) + spew.Fprintf(os.Stderr, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) + +See the Index for the full list convenience functions. + +Sample Formatter Output + +Double pointer to a uint8: + %v: <**>5 + %+v: <**>(0xf8400420d0->0xf8400420c8)5 + %#v: (**uint8)5 + %#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5 + +Pointer to circular struct with a uint8 field and a pointer to itself: + %v: <*>{1 <*>} + %+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)} + %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)} + %#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)} + +See the Printf example for details on the setup of variables being shown +here. + +Errors + +Since it is possible for custom Stringer/error interfaces to panic, spew +detects them and handles them internally by printing the panic information +inline with the output. Since spew is intended to provide deep pretty printing +capabilities on structures, it intentionally does not return any errors. +*/ +package spew diff --git a/vendor/github.com/davecgh/go-spew/spew/dump.go b/vendor/github.com/davecgh/go-spew/spew/dump.go new file mode 100644 index 00000000..f78d89fc --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/dump.go @@ -0,0 +1,509 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "bytes" + "encoding/hex" + "fmt" + "io" + "os" + "reflect" + "regexp" + "strconv" + "strings" +) + +var ( + // uint8Type is a reflect.Type representing a uint8. It is used to + // convert cgo types to uint8 slices for hexdumping. + uint8Type = reflect.TypeOf(uint8(0)) + + // cCharRE is a regular expression that matches a cgo char. + // It is used to detect character arrays to hexdump them. + cCharRE = regexp.MustCompile(`^.*\._Ctype_char$`) + + // cUnsignedCharRE is a regular expression that matches a cgo unsigned + // char. It is used to detect unsigned character arrays to hexdump + // them. + cUnsignedCharRE = regexp.MustCompile(`^.*\._Ctype_unsignedchar$`) + + // cUint8tCharRE is a regular expression that matches a cgo uint8_t. + // It is used to detect uint8_t arrays to hexdump them. + cUint8tCharRE = regexp.MustCompile(`^.*\._Ctype_uint8_t$`) +) + +// dumpState contains information about the state of a dump operation. +type dumpState struct { + w io.Writer + depth int + pointers map[uintptr]int + ignoreNextType bool + ignoreNextIndent bool + cs *ConfigState +} + +// indent performs indentation according to the depth level and cs.Indent +// option. +func (d *dumpState) indent() { + if d.ignoreNextIndent { + d.ignoreNextIndent = false + return + } + d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth)) +} + +// unpackValue returns values inside of non-nil interfaces when possible. +// This is useful for data types like structs, arrays, slices, and maps which +// can contain varying types packed inside an interface. +func (d *dumpState) unpackValue(v reflect.Value) reflect.Value { + if v.Kind() == reflect.Interface && !v.IsNil() { + v = v.Elem() + } + return v +} + +// dumpPtr handles formatting of pointers by indirecting them as necessary. +func (d *dumpState) dumpPtr(v reflect.Value) { + // Remove pointers at or below the current depth from map used to detect + // circular refs. + for k, depth := range d.pointers { + if depth >= d.depth { + delete(d.pointers, k) + } + } + + // Keep list of all dereferenced pointers to show later. + pointerChain := make([]uintptr, 0) + + // Figure out how many levels of indirection there are by dereferencing + // pointers and unpacking interfaces down the chain while detecting circular + // references. + nilFound := false + cycleFound := false + indirects := 0 + ve := v + for ve.Kind() == reflect.Ptr { + if ve.IsNil() { + nilFound = true + break + } + indirects++ + addr := ve.Pointer() + pointerChain = append(pointerChain, addr) + if pd, ok := d.pointers[addr]; ok && pd < d.depth { + cycleFound = true + indirects-- + break + } + d.pointers[addr] = d.depth + + ve = ve.Elem() + if ve.Kind() == reflect.Interface { + if ve.IsNil() { + nilFound = true + break + } + ve = ve.Elem() + } + } + + // Display type information. + d.w.Write(openParenBytes) + d.w.Write(bytes.Repeat(asteriskBytes, indirects)) + d.w.Write([]byte(ve.Type().String())) + d.w.Write(closeParenBytes) + + // Display pointer information. + if !d.cs.DisablePointerAddresses && len(pointerChain) > 0 { + d.w.Write(openParenBytes) + for i, addr := range pointerChain { + if i > 0 { + d.w.Write(pointerChainBytes) + } + printHexPtr(d.w, addr) + } + d.w.Write(closeParenBytes) + } + + // Display dereferenced value. + d.w.Write(openParenBytes) + switch { + case nilFound: + d.w.Write(nilAngleBytes) + + case cycleFound: + d.w.Write(circularBytes) + + default: + d.ignoreNextType = true + d.dump(ve) + } + d.w.Write(closeParenBytes) +} + +// dumpSlice handles formatting of arrays and slices. Byte (uint8 under +// reflection) arrays and slices are dumped in hexdump -C fashion. +func (d *dumpState) dumpSlice(v reflect.Value) { + // Determine whether this type should be hex dumped or not. Also, + // for types which should be hexdumped, try to use the underlying data + // first, then fall back to trying to convert them to a uint8 slice. + var buf []uint8 + doConvert := false + doHexDump := false + numEntries := v.Len() + if numEntries > 0 { + vt := v.Index(0).Type() + vts := vt.String() + switch { + // C types that need to be converted. + case cCharRE.MatchString(vts): + fallthrough + case cUnsignedCharRE.MatchString(vts): + fallthrough + case cUint8tCharRE.MatchString(vts): + doConvert = true + + // Try to use existing uint8 slices and fall back to converting + // and copying if that fails. + case vt.Kind() == reflect.Uint8: + // We need an addressable interface to convert the type + // to a byte slice. However, the reflect package won't + // give us an interface on certain things like + // unexported struct fields in order to enforce + // visibility rules. We use unsafe, when available, to + // bypass these restrictions since this package does not + // mutate the values. + vs := v + if !vs.CanInterface() || !vs.CanAddr() { + vs = unsafeReflectValue(vs) + } + if !UnsafeDisabled { + vs = vs.Slice(0, numEntries) + + // Use the existing uint8 slice if it can be + // type asserted. + iface := vs.Interface() + if slice, ok := iface.([]uint8); ok { + buf = slice + doHexDump = true + break + } + } + + // The underlying data needs to be converted if it can't + // be type asserted to a uint8 slice. + doConvert = true + } + + // Copy and convert the underlying type if needed. + if doConvert && vt.ConvertibleTo(uint8Type) { + // Convert and copy each element into a uint8 byte + // slice. + buf = make([]uint8, numEntries) + for i := 0; i < numEntries; i++ { + vv := v.Index(i) + buf[i] = uint8(vv.Convert(uint8Type).Uint()) + } + doHexDump = true + } + } + + // Hexdump the entire slice as needed. + if doHexDump { + indent := strings.Repeat(d.cs.Indent, d.depth) + str := indent + hex.Dump(buf) + str = strings.Replace(str, "\n", "\n"+indent, -1) + str = strings.TrimRight(str, d.cs.Indent) + d.w.Write([]byte(str)) + return + } + + // Recursively call dump for each item. + for i := 0; i < numEntries; i++ { + d.dump(d.unpackValue(v.Index(i))) + if i < (numEntries - 1) { + d.w.Write(commaNewlineBytes) + } else { + d.w.Write(newlineBytes) + } + } +} + +// dump is the main workhorse for dumping a value. It uses the passed reflect +// value to figure out what kind of object we are dealing with and formats it +// appropriately. It is a recursive function, however circular data structures +// are detected and handled properly. +func (d *dumpState) dump(v reflect.Value) { + // Handle invalid reflect values immediately. + kind := v.Kind() + if kind == reflect.Invalid { + d.w.Write(invalidAngleBytes) + return + } + + // Handle pointers specially. + if kind == reflect.Ptr { + d.indent() + d.dumpPtr(v) + return + } + + // Print type information unless already handled elsewhere. + if !d.ignoreNextType { + d.indent() + d.w.Write(openParenBytes) + d.w.Write([]byte(v.Type().String())) + d.w.Write(closeParenBytes) + d.w.Write(spaceBytes) + } + d.ignoreNextType = false + + // Display length and capacity if the built-in len and cap functions + // work with the value's kind and the len/cap itself is non-zero. + valueLen, valueCap := 0, 0 + switch v.Kind() { + case reflect.Array, reflect.Slice, reflect.Chan: + valueLen, valueCap = v.Len(), v.Cap() + case reflect.Map, reflect.String: + valueLen = v.Len() + } + if valueLen != 0 || !d.cs.DisableCapacities && valueCap != 0 { + d.w.Write(openParenBytes) + if valueLen != 0 { + d.w.Write(lenEqualsBytes) + printInt(d.w, int64(valueLen), 10) + } + if !d.cs.DisableCapacities && valueCap != 0 { + if valueLen != 0 { + d.w.Write(spaceBytes) + } + d.w.Write(capEqualsBytes) + printInt(d.w, int64(valueCap), 10) + } + d.w.Write(closeParenBytes) + d.w.Write(spaceBytes) + } + + // Call Stringer/error interfaces if they exist and the handle methods flag + // is enabled + if !d.cs.DisableMethods { + if (kind != reflect.Invalid) && (kind != reflect.Interface) { + if handled := handleMethods(d.cs, d.w, v); handled { + return + } + } + } + + switch kind { + case reflect.Invalid: + // Do nothing. We should never get here since invalid has already + // been handled above. + + case reflect.Bool: + printBool(d.w, v.Bool()) + + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: + printInt(d.w, v.Int(), 10) + + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: + printUint(d.w, v.Uint(), 10) + + case reflect.Float32: + printFloat(d.w, v.Float(), 32) + + case reflect.Float64: + printFloat(d.w, v.Float(), 64) + + case reflect.Complex64: + printComplex(d.w, v.Complex(), 32) + + case reflect.Complex128: + printComplex(d.w, v.Complex(), 64) + + case reflect.Slice: + if v.IsNil() { + d.w.Write(nilAngleBytes) + break + } + fallthrough + + case reflect.Array: + d.w.Write(openBraceNewlineBytes) + d.depth++ + if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { + d.indent() + d.w.Write(maxNewlineBytes) + } else { + d.dumpSlice(v) + } + d.depth-- + d.indent() + d.w.Write(closeBraceBytes) + + case reflect.String: + d.w.Write([]byte(strconv.Quote(v.String()))) + + case reflect.Interface: + // The only time we should get here is for nil interfaces due to + // unpackValue calls. + if v.IsNil() { + d.w.Write(nilAngleBytes) + } + + case reflect.Ptr: + // Do nothing. We should never get here since pointers have already + // been handled above. + + case reflect.Map: + // nil maps should be indicated as different than empty maps + if v.IsNil() { + d.w.Write(nilAngleBytes) + break + } + + d.w.Write(openBraceNewlineBytes) + d.depth++ + if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { + d.indent() + d.w.Write(maxNewlineBytes) + } else { + numEntries := v.Len() + keys := v.MapKeys() + if d.cs.SortKeys { + sortValues(keys, d.cs) + } + for i, key := range keys { + d.dump(d.unpackValue(key)) + d.w.Write(colonSpaceBytes) + d.ignoreNextIndent = true + d.dump(d.unpackValue(v.MapIndex(key))) + if i < (numEntries - 1) { + d.w.Write(commaNewlineBytes) + } else { + d.w.Write(newlineBytes) + } + } + } + d.depth-- + d.indent() + d.w.Write(closeBraceBytes) + + case reflect.Struct: + d.w.Write(openBraceNewlineBytes) + d.depth++ + if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { + d.indent() + d.w.Write(maxNewlineBytes) + } else { + vt := v.Type() + numFields := v.NumField() + for i := 0; i < numFields; i++ { + d.indent() + vtf := vt.Field(i) + d.w.Write([]byte(vtf.Name)) + d.w.Write(colonSpaceBytes) + d.ignoreNextIndent = true + d.dump(d.unpackValue(v.Field(i))) + if i < (numFields - 1) { + d.w.Write(commaNewlineBytes) + } else { + d.w.Write(newlineBytes) + } + } + } + d.depth-- + d.indent() + d.w.Write(closeBraceBytes) + + case reflect.Uintptr: + printHexPtr(d.w, uintptr(v.Uint())) + + case reflect.UnsafePointer, reflect.Chan, reflect.Func: + printHexPtr(d.w, v.Pointer()) + + // There were not any other types at the time this code was written, but + // fall back to letting the default fmt package handle it in case any new + // types are added. + default: + if v.CanInterface() { + fmt.Fprintf(d.w, "%v", v.Interface()) + } else { + fmt.Fprintf(d.w, "%v", v.String()) + } + } +} + +// fdump is a helper function to consolidate the logic from the various public +// methods which take varying writers and config states. +func fdump(cs *ConfigState, w io.Writer, a ...interface{}) { + for _, arg := range a { + if arg == nil { + w.Write(interfaceBytes) + w.Write(spaceBytes) + w.Write(nilAngleBytes) + w.Write(newlineBytes) + continue + } + + d := dumpState{w: w, cs: cs} + d.pointers = make(map[uintptr]int) + d.dump(reflect.ValueOf(arg)) + d.w.Write(newlineBytes) + } +} + +// Fdump formats and displays the passed arguments to io.Writer w. It formats +// exactly the same as Dump. +func Fdump(w io.Writer, a ...interface{}) { + fdump(&Config, w, a...) +} + +// Sdump returns a string with the passed arguments formatted exactly the same +// as Dump. +func Sdump(a ...interface{}) string { + var buf bytes.Buffer + fdump(&Config, &buf, a...) + return buf.String() +} + +/* +Dump displays the passed parameters to standard out with newlines, customizable +indentation, and additional debug information such as complete types and all +pointer addresses used to indirect to the final value. It provides the +following features over the built-in printing facilities provided by the fmt +package: + + * Pointers are dereferenced and followed + * Circular data structures are detected and handled properly + * Custom Stringer/error interfaces are optionally invoked, including + on unexported types + * Custom types which only implement the Stringer/error interfaces via + a pointer receiver are optionally invoked when passing non-pointer + variables + * Byte arrays and slices are dumped like the hexdump -C command which + includes offsets, byte values in hex, and ASCII output + +The configuration options are controlled by an exported package global, +spew.Config. See ConfigState for options documentation. + +See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to +get the formatted result as a string. +*/ +func Dump(a ...interface{}) { + fdump(&Config, os.Stdout, a...) +} diff --git a/vendor/github.com/davecgh/go-spew/spew/dump_test.go b/vendor/github.com/davecgh/go-spew/spew/dump_test.go new file mode 100644 index 00000000..4a31a2ee --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/dump_test.go @@ -0,0 +1,1042 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* +Test Summary: +NOTE: For each test, a nil pointer, a single pointer and double pointer to the +base test element are also tested to ensure proper indirection across all types. + +- Max int8, int16, int32, int64, int +- Max uint8, uint16, uint32, uint64, uint +- Boolean true and false +- Standard complex64 and complex128 +- Array containing standard ints +- Array containing type with custom formatter on pointer receiver only +- Array containing interfaces +- Array containing bytes +- Slice containing standard float32 values +- Slice containing type with custom formatter on pointer receiver only +- Slice containing interfaces +- Slice containing bytes +- Nil slice +- Standard string +- Nil interface +- Sub-interface +- Map with string keys and int vals +- Map with custom formatter type on pointer receiver only keys and vals +- Map with interface keys and values +- Map with nil interface value +- Struct with primitives +- Struct that contains another struct +- Struct that contains custom type with Stringer pointer interface via both + exported and unexported fields +- Struct that contains embedded struct and field to same struct +- Uintptr to 0 (null pointer) +- Uintptr address of real variable +- Unsafe.Pointer to 0 (null pointer) +- Unsafe.Pointer to address of real variable +- Nil channel +- Standard int channel +- Function with no params and no returns +- Function with param and no returns +- Function with multiple params and multiple returns +- Struct that is circular through self referencing +- Structs that are circular through cross referencing +- Structs that are indirectly circular +- Type that panics in its Stringer interface +*/ + +package spew_test + +import ( + "bytes" + "fmt" + "testing" + "unsafe" + + "github.com/davecgh/go-spew/spew" +) + +// dumpTest is used to describe a test to be performed against the Dump method. +type dumpTest struct { + in interface{} + wants []string +} + +// dumpTests houses all of the tests to be performed against the Dump method. +var dumpTests = make([]dumpTest, 0) + +// addDumpTest is a helper method to append the passed input and desired result +// to dumpTests +func addDumpTest(in interface{}, wants ...string) { + test := dumpTest{in, wants} + dumpTests = append(dumpTests, test) +} + +func addIntDumpTests() { + // Max int8. + v := int8(127) + nv := (*int8)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "int8" + vs := "127" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Max int16. + v2 := int16(32767) + nv2 := (*int16)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "int16" + v2s := "32767" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") + + // Max int32. + v3 := int32(2147483647) + nv3 := (*int32)(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "int32" + v3s := "2147483647" + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") + addDumpTest(nv3, "(*"+v3t+")()\n") + + // Max int64. + v4 := int64(9223372036854775807) + nv4 := (*int64)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "int64" + v4s := "9223372036854775807" + addDumpTest(v4, "("+v4t+") "+v4s+"\n") + addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") + addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") + addDumpTest(nv4, "(*"+v4t+")()\n") + + // Max int. + v5 := int(2147483647) + nv5 := (*int)(nil) + pv5 := &v5 + v5Addr := fmt.Sprintf("%p", pv5) + pv5Addr := fmt.Sprintf("%p", &pv5) + v5t := "int" + v5s := "2147483647" + addDumpTest(v5, "("+v5t+") "+v5s+"\n") + addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n") + addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n") + addDumpTest(nv5, "(*"+v5t+")()\n") +} + +func addUintDumpTests() { + // Max uint8. + v := uint8(255) + nv := (*uint8)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "uint8" + vs := "255" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Max uint16. + v2 := uint16(65535) + nv2 := (*uint16)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "uint16" + v2s := "65535" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") + + // Max uint32. + v3 := uint32(4294967295) + nv3 := (*uint32)(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "uint32" + v3s := "4294967295" + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") + addDumpTest(nv3, "(*"+v3t+")()\n") + + // Max uint64. + v4 := uint64(18446744073709551615) + nv4 := (*uint64)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "uint64" + v4s := "18446744073709551615" + addDumpTest(v4, "("+v4t+") "+v4s+"\n") + addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") + addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") + addDumpTest(nv4, "(*"+v4t+")()\n") + + // Max uint. + v5 := uint(4294967295) + nv5 := (*uint)(nil) + pv5 := &v5 + v5Addr := fmt.Sprintf("%p", pv5) + pv5Addr := fmt.Sprintf("%p", &pv5) + v5t := "uint" + v5s := "4294967295" + addDumpTest(v5, "("+v5t+") "+v5s+"\n") + addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n") + addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n") + addDumpTest(nv5, "(*"+v5t+")()\n") +} + +func addBoolDumpTests() { + // Boolean true. + v := bool(true) + nv := (*bool)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "bool" + vs := "true" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Boolean false. + v2 := bool(false) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "bool" + v2s := "false" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") +} + +func addFloatDumpTests() { + // Standard float32. + v := float32(3.1415) + nv := (*float32)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "float32" + vs := "3.1415" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Standard float64. + v2 := float64(3.1415926) + nv2 := (*float64)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "float64" + v2s := "3.1415926" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") +} + +func addComplexDumpTests() { + // Standard complex64. + v := complex(float32(6), -2) + nv := (*complex64)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "complex64" + vs := "(6-2i)" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Standard complex128. + v2 := complex(float64(-6), 2) + nv2 := (*complex128)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "complex128" + v2s := "(-6+2i)" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") +} + +func addArrayDumpTests() { + // Array containing standard ints. + v := [3]int{1, 2, 3} + vLen := fmt.Sprintf("%d", len(v)) + vCap := fmt.Sprintf("%d", cap(v)) + nv := (*[3]int)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "int" + vs := "(len=" + vLen + " cap=" + vCap + ") {\n (" + vt + ") 1,\n (" + + vt + ") 2,\n (" + vt + ") 3\n}" + addDumpTest(v, "([3]"+vt+") "+vs+"\n") + addDumpTest(pv, "(*[3]"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**[3]"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*[3]"+vt+")()\n") + + // Array containing type with custom formatter on pointer receiver only. + v2i0 := pstringer("1") + v2i1 := pstringer("2") + v2i2 := pstringer("3") + v2 := [3]pstringer{v2i0, v2i1, v2i2} + v2i0Len := fmt.Sprintf("%d", len(v2i0)) + v2i1Len := fmt.Sprintf("%d", len(v2i1)) + v2i2Len := fmt.Sprintf("%d", len(v2i2)) + v2Len := fmt.Sprintf("%d", len(v2)) + v2Cap := fmt.Sprintf("%d", cap(v2)) + nv2 := (*[3]pstringer)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "spew_test.pstringer" + v2sp := "(len=" + v2Len + " cap=" + v2Cap + ") {\n (" + v2t + + ") (len=" + v2i0Len + ") stringer 1,\n (" + v2t + + ") (len=" + v2i1Len + ") stringer 2,\n (" + v2t + + ") (len=" + v2i2Len + ") " + "stringer 3\n}" + v2s := v2sp + if spew.UnsafeDisabled { + v2s = "(len=" + v2Len + " cap=" + v2Cap + ") {\n (" + v2t + + ") (len=" + v2i0Len + ") \"1\",\n (" + v2t + ") (len=" + + v2i1Len + ") \"2\",\n (" + v2t + ") (len=" + v2i2Len + + ") " + "\"3\"\n}" + } + addDumpTest(v2, "([3]"+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*[3]"+v2t+")("+v2Addr+")("+v2sp+")\n") + addDumpTest(&pv2, "(**[3]"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2sp+")\n") + addDumpTest(nv2, "(*[3]"+v2t+")()\n") + + // Array containing interfaces. + v3i0 := "one" + v3 := [3]interface{}{v3i0, int(2), uint(3)} + v3i0Len := fmt.Sprintf("%d", len(v3i0)) + v3Len := fmt.Sprintf("%d", len(v3)) + v3Cap := fmt.Sprintf("%d", cap(v3)) + nv3 := (*[3]interface{})(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "[3]interface {}" + v3t2 := "string" + v3t3 := "int" + v3t4 := "uint" + v3s := "(len=" + v3Len + " cap=" + v3Cap + ") {\n (" + v3t2 + ") " + + "(len=" + v3i0Len + ") \"one\",\n (" + v3t3 + ") 2,\n (" + + v3t4 + ") 3\n}" + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") + addDumpTest(nv3, "(*"+v3t+")()\n") + + // Array containing bytes. + v4 := [34]byte{ + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, + 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, + 0x31, 0x32, + } + v4Len := fmt.Sprintf("%d", len(v4)) + v4Cap := fmt.Sprintf("%d", cap(v4)) + nv4 := (*[34]byte)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "[34]uint8" + v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " + + "{\n 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20" + + " |............... |\n" + + " 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30" + + " |!\"#$%&'()*+,-./0|\n" + + " 00000020 31 32 " + + " |12|\n}" + addDumpTest(v4, "("+v4t+") "+v4s+"\n") + addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") + addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") + addDumpTest(nv4, "(*"+v4t+")()\n") +} + +func addSliceDumpTests() { + // Slice containing standard float32 values. + v := []float32{3.14, 6.28, 12.56} + vLen := fmt.Sprintf("%d", len(v)) + vCap := fmt.Sprintf("%d", cap(v)) + nv := (*[]float32)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "float32" + vs := "(len=" + vLen + " cap=" + vCap + ") {\n (" + vt + ") 3.14,\n (" + + vt + ") 6.28,\n (" + vt + ") 12.56\n}" + addDumpTest(v, "([]"+vt+") "+vs+"\n") + addDumpTest(pv, "(*[]"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**[]"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*[]"+vt+")()\n") + + // Slice containing type with custom formatter on pointer receiver only. + v2i0 := pstringer("1") + v2i1 := pstringer("2") + v2i2 := pstringer("3") + v2 := []pstringer{v2i0, v2i1, v2i2} + v2i0Len := fmt.Sprintf("%d", len(v2i0)) + v2i1Len := fmt.Sprintf("%d", len(v2i1)) + v2i2Len := fmt.Sprintf("%d", len(v2i2)) + v2Len := fmt.Sprintf("%d", len(v2)) + v2Cap := fmt.Sprintf("%d", cap(v2)) + nv2 := (*[]pstringer)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "spew_test.pstringer" + v2s := "(len=" + v2Len + " cap=" + v2Cap + ") {\n (" + v2t + ") (len=" + + v2i0Len + ") stringer 1,\n (" + v2t + ") (len=" + v2i1Len + + ") stringer 2,\n (" + v2t + ") (len=" + v2i2Len + ") " + + "stringer 3\n}" + addDumpTest(v2, "([]"+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*[]"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**[]"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*[]"+v2t+")()\n") + + // Slice containing interfaces. + v3i0 := "one" + v3 := []interface{}{v3i0, int(2), uint(3), nil} + v3i0Len := fmt.Sprintf("%d", len(v3i0)) + v3Len := fmt.Sprintf("%d", len(v3)) + v3Cap := fmt.Sprintf("%d", cap(v3)) + nv3 := (*[]interface{})(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "[]interface {}" + v3t2 := "string" + v3t3 := "int" + v3t4 := "uint" + v3t5 := "interface {}" + v3s := "(len=" + v3Len + " cap=" + v3Cap + ") {\n (" + v3t2 + ") " + + "(len=" + v3i0Len + ") \"one\",\n (" + v3t3 + ") 2,\n (" + + v3t4 + ") 3,\n (" + v3t5 + ") \n}" + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") + addDumpTest(nv3, "(*"+v3t+")()\n") + + // Slice containing bytes. + v4 := []byte{ + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, + 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, + 0x31, 0x32, + } + v4Len := fmt.Sprintf("%d", len(v4)) + v4Cap := fmt.Sprintf("%d", cap(v4)) + nv4 := (*[]byte)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "[]uint8" + v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " + + "{\n 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20" + + " |............... |\n" + + " 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30" + + " |!\"#$%&'()*+,-./0|\n" + + " 00000020 31 32 " + + " |12|\n}" + addDumpTest(v4, "("+v4t+") "+v4s+"\n") + addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") + addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") + addDumpTest(nv4, "(*"+v4t+")()\n") + + // Nil slice. + v5 := []int(nil) + nv5 := (*[]int)(nil) + pv5 := &v5 + v5Addr := fmt.Sprintf("%p", pv5) + pv5Addr := fmt.Sprintf("%p", &pv5) + v5t := "[]int" + v5s := "" + addDumpTest(v5, "("+v5t+") "+v5s+"\n") + addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n") + addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n") + addDumpTest(nv5, "(*"+v5t+")()\n") +} + +func addStringDumpTests() { + // Standard string. + v := "test" + vLen := fmt.Sprintf("%d", len(v)) + nv := (*string)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "string" + vs := "(len=" + vLen + ") \"test\"" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") +} + +func addInterfaceDumpTests() { + // Nil interface. + var v interface{} + nv := (*interface{})(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "interface {}" + vs := "" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Sub-interface. + v2 := interface{}(uint16(65535)) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "uint16" + v2s := "65535" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") +} + +func addMapDumpTests() { + // Map with string keys and int vals. + k := "one" + kk := "two" + m := map[string]int{k: 1, kk: 2} + klen := fmt.Sprintf("%d", len(k)) // not kLen to shut golint up + kkLen := fmt.Sprintf("%d", len(kk)) + mLen := fmt.Sprintf("%d", len(m)) + nilMap := map[string]int(nil) + nm := (*map[string]int)(nil) + pm := &m + mAddr := fmt.Sprintf("%p", pm) + pmAddr := fmt.Sprintf("%p", &pm) + mt := "map[string]int" + mt1 := "string" + mt2 := "int" + ms := "(len=" + mLen + ") {\n (" + mt1 + ") (len=" + klen + ") " + + "\"one\": (" + mt2 + ") 1,\n (" + mt1 + ") (len=" + kkLen + + ") \"two\": (" + mt2 + ") 2\n}" + ms2 := "(len=" + mLen + ") {\n (" + mt1 + ") (len=" + kkLen + ") " + + "\"two\": (" + mt2 + ") 2,\n (" + mt1 + ") (len=" + klen + + ") \"one\": (" + mt2 + ") 1\n}" + addDumpTest(m, "("+mt+") "+ms+"\n", "("+mt+") "+ms2+"\n") + addDumpTest(pm, "(*"+mt+")("+mAddr+")("+ms+")\n", + "(*"+mt+")("+mAddr+")("+ms2+")\n") + addDumpTest(&pm, "(**"+mt+")("+pmAddr+"->"+mAddr+")("+ms+")\n", + "(**"+mt+")("+pmAddr+"->"+mAddr+")("+ms2+")\n") + addDumpTest(nm, "(*"+mt+")()\n") + addDumpTest(nilMap, "("+mt+") \n") + + // Map with custom formatter type on pointer receiver only keys and vals. + k2 := pstringer("one") + v2 := pstringer("1") + m2 := map[pstringer]pstringer{k2: v2} + k2Len := fmt.Sprintf("%d", len(k2)) + v2Len := fmt.Sprintf("%d", len(v2)) + m2Len := fmt.Sprintf("%d", len(m2)) + nilMap2 := map[pstringer]pstringer(nil) + nm2 := (*map[pstringer]pstringer)(nil) + pm2 := &m2 + m2Addr := fmt.Sprintf("%p", pm2) + pm2Addr := fmt.Sprintf("%p", &pm2) + m2t := "map[spew_test.pstringer]spew_test.pstringer" + m2t1 := "spew_test.pstringer" + m2t2 := "spew_test.pstringer" + m2s := "(len=" + m2Len + ") {\n (" + m2t1 + ") (len=" + k2Len + ") " + + "stringer one: (" + m2t2 + ") (len=" + v2Len + ") stringer 1\n}" + if spew.UnsafeDisabled { + m2s = "(len=" + m2Len + ") {\n (" + m2t1 + ") (len=" + k2Len + + ") " + "\"one\": (" + m2t2 + ") (len=" + v2Len + + ") \"1\"\n}" + } + addDumpTest(m2, "("+m2t+") "+m2s+"\n") + addDumpTest(pm2, "(*"+m2t+")("+m2Addr+")("+m2s+")\n") + addDumpTest(&pm2, "(**"+m2t+")("+pm2Addr+"->"+m2Addr+")("+m2s+")\n") + addDumpTest(nm2, "(*"+m2t+")()\n") + addDumpTest(nilMap2, "("+m2t+") \n") + + // Map with interface keys and values. + k3 := "one" + k3Len := fmt.Sprintf("%d", len(k3)) + m3 := map[interface{}]interface{}{k3: 1} + m3Len := fmt.Sprintf("%d", len(m3)) + nilMap3 := map[interface{}]interface{}(nil) + nm3 := (*map[interface{}]interface{})(nil) + pm3 := &m3 + m3Addr := fmt.Sprintf("%p", pm3) + pm3Addr := fmt.Sprintf("%p", &pm3) + m3t := "map[interface {}]interface {}" + m3t1 := "string" + m3t2 := "int" + m3s := "(len=" + m3Len + ") {\n (" + m3t1 + ") (len=" + k3Len + ") " + + "\"one\": (" + m3t2 + ") 1\n}" + addDumpTest(m3, "("+m3t+") "+m3s+"\n") + addDumpTest(pm3, "(*"+m3t+")("+m3Addr+")("+m3s+")\n") + addDumpTest(&pm3, "(**"+m3t+")("+pm3Addr+"->"+m3Addr+")("+m3s+")\n") + addDumpTest(nm3, "(*"+m3t+")()\n") + addDumpTest(nilMap3, "("+m3t+") \n") + + // Map with nil interface value. + k4 := "nil" + k4Len := fmt.Sprintf("%d", len(k4)) + m4 := map[string]interface{}{k4: nil} + m4Len := fmt.Sprintf("%d", len(m4)) + nilMap4 := map[string]interface{}(nil) + nm4 := (*map[string]interface{})(nil) + pm4 := &m4 + m4Addr := fmt.Sprintf("%p", pm4) + pm4Addr := fmt.Sprintf("%p", &pm4) + m4t := "map[string]interface {}" + m4t1 := "string" + m4t2 := "interface {}" + m4s := "(len=" + m4Len + ") {\n (" + m4t1 + ") (len=" + k4Len + ")" + + " \"nil\": (" + m4t2 + ") \n}" + addDumpTest(m4, "("+m4t+") "+m4s+"\n") + addDumpTest(pm4, "(*"+m4t+")("+m4Addr+")("+m4s+")\n") + addDumpTest(&pm4, "(**"+m4t+")("+pm4Addr+"->"+m4Addr+")("+m4s+")\n") + addDumpTest(nm4, "(*"+m4t+")()\n") + addDumpTest(nilMap4, "("+m4t+") \n") +} + +func addStructDumpTests() { + // Struct with primitives. + type s1 struct { + a int8 + b uint8 + } + v := s1{127, 255} + nv := (*s1)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.s1" + vt2 := "int8" + vt3 := "uint8" + vs := "{\n a: (" + vt2 + ") 127,\n b: (" + vt3 + ") 255\n}" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Struct that contains another struct. + type s2 struct { + s1 s1 + b bool + } + v2 := s2{s1{127, 255}, true} + nv2 := (*s2)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "spew_test.s2" + v2t2 := "spew_test.s1" + v2t3 := "int8" + v2t4 := "uint8" + v2t5 := "bool" + v2s := "{\n s1: (" + v2t2 + ") {\n a: (" + v2t3 + ") 127,\n b: (" + + v2t4 + ") 255\n },\n b: (" + v2t5 + ") true\n}" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") + + // Struct that contains custom type with Stringer pointer interface via both + // exported and unexported fields. + type s3 struct { + s pstringer + S pstringer + } + v3 := s3{"test", "test2"} + nv3 := (*s3)(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "spew_test.s3" + v3t2 := "spew_test.pstringer" + v3s := "{\n s: (" + v3t2 + ") (len=4) stringer test,\n S: (" + v3t2 + + ") (len=5) stringer test2\n}" + v3sp := v3s + if spew.UnsafeDisabled { + v3s = "{\n s: (" + v3t2 + ") (len=4) \"test\",\n S: (" + + v3t2 + ") (len=5) \"test2\"\n}" + v3sp = "{\n s: (" + v3t2 + ") (len=4) \"test\",\n S: (" + + v3t2 + ") (len=5) stringer test2\n}" + } + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3sp+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3sp+")\n") + addDumpTest(nv3, "(*"+v3t+")()\n") + + // Struct that contains embedded struct and field to same struct. + e := embed{"embedstr"} + eLen := fmt.Sprintf("%d", len("embedstr")) + v4 := embedwrap{embed: &e, e: &e} + nv4 := (*embedwrap)(nil) + pv4 := &v4 + eAddr := fmt.Sprintf("%p", &e) + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "spew_test.embedwrap" + v4t2 := "spew_test.embed" + v4t3 := "string" + v4s := "{\n embed: (*" + v4t2 + ")(" + eAddr + ")({\n a: (" + v4t3 + + ") (len=" + eLen + ") \"embedstr\"\n }),\n e: (*" + v4t2 + + ")(" + eAddr + ")({\n a: (" + v4t3 + ") (len=" + eLen + ")" + + " \"embedstr\"\n })\n}" + addDumpTest(v4, "("+v4t+") "+v4s+"\n") + addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") + addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") + addDumpTest(nv4, "(*"+v4t+")()\n") +} + +func addUintptrDumpTests() { + // Null pointer. + v := uintptr(0) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "uintptr" + vs := "" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + + // Address of real variable. + i := 1 + v2 := uintptr(unsafe.Pointer(&i)) + nv2 := (*uintptr)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "uintptr" + v2s := fmt.Sprintf("%p", &i) + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") +} + +func addUnsafePointerDumpTests() { + // Null pointer. + v := unsafe.Pointer(nil) + nv := (*unsafe.Pointer)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "unsafe.Pointer" + vs := "" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Address of real variable. + i := 1 + v2 := unsafe.Pointer(&i) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "unsafe.Pointer" + v2s := fmt.Sprintf("%p", &i) + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv, "(*"+vt+")()\n") +} + +func addChanDumpTests() { + // Nil channel. + var v chan int + pv := &v + nv := (*chan int)(nil) + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "chan int" + vs := "" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Real channel. + v2 := make(chan int) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "chan int" + v2s := fmt.Sprintf("%p", v2) + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") +} + +func addFuncDumpTests() { + // Function with no params and no returns. + v := addIntDumpTests + nv := (*func())(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "func()" + vs := fmt.Sprintf("%p", v) + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Function with param and no returns. + v2 := TestDump + nv2 := (*func(*testing.T))(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "func(*testing.T)" + v2s := fmt.Sprintf("%p", v2) + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") + + // Function with multiple params and multiple returns. + var v3 = func(i int, s string) (b bool, err error) { + return true, nil + } + nv3 := (*func(int, string) (bool, error))(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "func(int, string) (bool, error)" + v3s := fmt.Sprintf("%p", v3) + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") + addDumpTest(nv3, "(*"+v3t+")()\n") +} + +func addCircularDumpTests() { + // Struct that is circular through self referencing. + type circular struct { + c *circular + } + v := circular{nil} + v.c = &v + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.circular" + vs := "{\n c: (*" + vt + ")(" + vAddr + ")({\n c: (*" + vt + ")(" + + vAddr + ")()\n })\n}" + vs2 := "{\n c: (*" + vt + ")(" + vAddr + ")()\n}" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs2+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs2+")\n") + + // Structs that are circular through cross referencing. + v2 := xref1{nil} + ts2 := xref2{&v2} + v2.ps2 = &ts2 + pv2 := &v2 + ts2Addr := fmt.Sprintf("%p", &ts2) + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "spew_test.xref1" + v2t2 := "spew_test.xref2" + v2s := "{\n ps2: (*" + v2t2 + ")(" + ts2Addr + ")({\n ps1: (*" + v2t + + ")(" + v2Addr + ")({\n ps2: (*" + v2t2 + ")(" + ts2Addr + + ")()\n })\n })\n}" + v2s2 := "{\n ps2: (*" + v2t2 + ")(" + ts2Addr + ")({\n ps1: (*" + v2t + + ")(" + v2Addr + ")()\n })\n}" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s2+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s2+")\n") + + // Structs that are indirectly circular. + v3 := indirCir1{nil} + tic2 := indirCir2{nil} + tic3 := indirCir3{&v3} + tic2.ps3 = &tic3 + v3.ps2 = &tic2 + pv3 := &v3 + tic2Addr := fmt.Sprintf("%p", &tic2) + tic3Addr := fmt.Sprintf("%p", &tic3) + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "spew_test.indirCir1" + v3t2 := "spew_test.indirCir2" + v3t3 := "spew_test.indirCir3" + v3s := "{\n ps2: (*" + v3t2 + ")(" + tic2Addr + ")({\n ps3: (*" + v3t3 + + ")(" + tic3Addr + ")({\n ps1: (*" + v3t + ")(" + v3Addr + + ")({\n ps2: (*" + v3t2 + ")(" + tic2Addr + + ")()\n })\n })\n })\n}" + v3s2 := "{\n ps2: (*" + v3t2 + ")(" + tic2Addr + ")({\n ps3: (*" + v3t3 + + ")(" + tic3Addr + ")({\n ps1: (*" + v3t + ")(" + v3Addr + + ")()\n })\n })\n}" + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s2+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s2+")\n") +} + +func addPanicDumpTests() { + // Type that panics in its Stringer interface. + v := panicer(127) + nv := (*panicer)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.panicer" + vs := "(PANIC=test panic)127" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") +} + +func addErrorDumpTests() { + // Type that has a custom Error interface. + v := customError(127) + nv := (*customError)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.customError" + vs := "error: 127" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") +} + +// TestDump executes all of the tests described by dumpTests. +func TestDump(t *testing.T) { + // Setup tests. + addIntDumpTests() + addUintDumpTests() + addBoolDumpTests() + addFloatDumpTests() + addComplexDumpTests() + addArrayDumpTests() + addSliceDumpTests() + addStringDumpTests() + addInterfaceDumpTests() + addMapDumpTests() + addStructDumpTests() + addUintptrDumpTests() + addUnsafePointerDumpTests() + addChanDumpTests() + addFuncDumpTests() + addCircularDumpTests() + addPanicDumpTests() + addErrorDumpTests() + addCgoDumpTests() + + t.Logf("Running %d tests", len(dumpTests)) + for i, test := range dumpTests { + buf := new(bytes.Buffer) + spew.Fdump(buf, test.in) + s := buf.String() + if testFailed(s, test.wants) { + t.Errorf("Dump #%d\n got: %s %s", i, s, stringizeWants(test.wants)) + continue + } + } +} + +func TestDumpSortedKeys(t *testing.T) { + cfg := spew.ConfigState{SortKeys: true} + s := cfg.Sdump(map[int]string{1: "1", 3: "3", 2: "2"}) + expected := "(map[int]string) (len=3) {\n(int) 1: (string) (len=1) " + + "\"1\",\n(int) 2: (string) (len=1) \"2\",\n(int) 3: (string) " + + "(len=1) \"3\"\n" + + "}\n" + if s != expected { + t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) + } + + s = cfg.Sdump(map[stringer]int{"1": 1, "3": 3, "2": 2}) + expected = "(map[spew_test.stringer]int) (len=3) {\n" + + "(spew_test.stringer) (len=1) stringer 1: (int) 1,\n" + + "(spew_test.stringer) (len=1) stringer 2: (int) 2,\n" + + "(spew_test.stringer) (len=1) stringer 3: (int) 3\n" + + "}\n" + if s != expected { + t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) + } + + s = cfg.Sdump(map[pstringer]int{pstringer("1"): 1, pstringer("3"): 3, pstringer("2"): 2}) + expected = "(map[spew_test.pstringer]int) (len=3) {\n" + + "(spew_test.pstringer) (len=1) stringer 1: (int) 1,\n" + + "(spew_test.pstringer) (len=1) stringer 2: (int) 2,\n" + + "(spew_test.pstringer) (len=1) stringer 3: (int) 3\n" + + "}\n" + if spew.UnsafeDisabled { + expected = "(map[spew_test.pstringer]int) (len=3) {\n" + + "(spew_test.pstringer) (len=1) \"1\": (int) 1,\n" + + "(spew_test.pstringer) (len=1) \"2\": (int) 2,\n" + + "(spew_test.pstringer) (len=1) \"3\": (int) 3\n" + + "}\n" + } + if s != expected { + t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) + } + + s = cfg.Sdump(map[customError]int{customError(1): 1, customError(3): 3, customError(2): 2}) + expected = "(map[spew_test.customError]int) (len=3) {\n" + + "(spew_test.customError) error: 1: (int) 1,\n" + + "(spew_test.customError) error: 2: (int) 2,\n" + + "(spew_test.customError) error: 3: (int) 3\n" + + "}\n" + if s != expected { + t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) + } + +} diff --git a/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go b/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go new file mode 100644 index 00000000..108baa55 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go @@ -0,0 +1,101 @@ +// Copyright (c) 2013-2016 Dave Collins +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when both cgo is supported and "-tags testcgo" is added to the go test +// command line. This means the cgo tests are only added (and hence run) when +// specifially requested. This configuration is used because spew itself +// does not require cgo to run even though it does handle certain cgo types +// specially. Rather than forcing all clients to require cgo and an external +// C compiler just to run the tests, this scheme makes them optional. +// +build cgo,testcgo + +package spew_test + +import ( + "fmt" + + "github.com/davecgh/go-spew/spew/testdata" +) + +func addCgoDumpTests() { + // C char pointer. + v := testdata.GetCgoCharPointer() + nv := testdata.GetCgoNullCharPointer() + pv := &v + vcAddr := fmt.Sprintf("%p", v) + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "*testdata._Ctype_char" + vs := "116" + addDumpTest(v, "("+vt+")("+vcAddr+")("+vs+")\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+"->"+vcAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+"->"+vcAddr+")("+vs+")\n") + addDumpTest(nv, "("+vt+")()\n") + + // C char array. + v2, v2l, v2c := testdata.GetCgoCharArray() + v2Len := fmt.Sprintf("%d", v2l) + v2Cap := fmt.Sprintf("%d", v2c) + v2t := "[6]testdata._Ctype_char" + v2s := "(len=" + v2Len + " cap=" + v2Cap + ") " + + "{\n 00000000 74 65 73 74 32 00 " + + " |test2.|\n}" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + + // C unsigned char array. + v3, v3l, v3c := testdata.GetCgoUnsignedCharArray() + v3Len := fmt.Sprintf("%d", v3l) + v3Cap := fmt.Sprintf("%d", v3c) + v3t := "[6]testdata._Ctype_unsignedchar" + v3t2 := "[6]testdata._Ctype_uchar" + v3s := "(len=" + v3Len + " cap=" + v3Cap + ") " + + "{\n 00000000 74 65 73 74 33 00 " + + " |test3.|\n}" + addDumpTest(v3, "("+v3t+") "+v3s+"\n", "("+v3t2+") "+v3s+"\n") + + // C signed char array. + v4, v4l, v4c := testdata.GetCgoSignedCharArray() + v4Len := fmt.Sprintf("%d", v4l) + v4Cap := fmt.Sprintf("%d", v4c) + v4t := "[6]testdata._Ctype_schar" + v4t2 := "testdata._Ctype_schar" + v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " + + "{\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 101,\n (" + v4t2 + + ") 115,\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 52,\n (" + v4t2 + + ") 0\n}" + addDumpTest(v4, "("+v4t+") "+v4s+"\n") + + // C uint8_t array. + v5, v5l, v5c := testdata.GetCgoUint8tArray() + v5Len := fmt.Sprintf("%d", v5l) + v5Cap := fmt.Sprintf("%d", v5c) + v5t := "[6]testdata._Ctype_uint8_t" + v5t2 := "[6]testdata._Ctype_uchar" + v5s := "(len=" + v5Len + " cap=" + v5Cap + ") " + + "{\n 00000000 74 65 73 74 35 00 " + + " |test5.|\n}" + addDumpTest(v5, "("+v5t+") "+v5s+"\n", "("+v5t2+") "+v5s+"\n") + + // C typedefed unsigned char array. + v6, v6l, v6c := testdata.GetCgoTypdefedUnsignedCharArray() + v6Len := fmt.Sprintf("%d", v6l) + v6Cap := fmt.Sprintf("%d", v6c) + v6t := "[6]testdata._Ctype_custom_uchar_t" + v6t2 := "[6]testdata._Ctype_uchar" + v6s := "(len=" + v6Len + " cap=" + v6Cap + ") " + + "{\n 00000000 74 65 73 74 36 00 " + + " |test6.|\n}" + addDumpTest(v6, "("+v6t+") "+v6s+"\n", "("+v6t2+") "+v6s+"\n") +} diff --git a/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go b/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go new file mode 100644 index 00000000..52a0971f --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go @@ -0,0 +1,26 @@ +// Copyright (c) 2013 Dave Collins +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when either cgo is not supported or "-tags testcgo" is not added to the go +// test command line. This file intentionally does not setup any cgo tests in +// this scenario. +// +build !cgo !testcgo + +package spew_test + +func addCgoDumpTests() { + // Don't add any tests for cgo since this file is only compiled when + // there should not be any cgo tests. +} diff --git a/vendor/github.com/davecgh/go-spew/spew/example_test.go b/vendor/github.com/davecgh/go-spew/spew/example_test.go new file mode 100644 index 00000000..c6ec8c6d --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/example_test.go @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew_test + +import ( + "fmt" + + "github.com/davecgh/go-spew/spew" +) + +type Flag int + +const ( + flagOne Flag = iota + flagTwo +) + +var flagStrings = map[Flag]string{ + flagOne: "flagOne", + flagTwo: "flagTwo", +} + +func (f Flag) String() string { + if s, ok := flagStrings[f]; ok { + return s + } + return fmt.Sprintf("Unknown flag (%d)", int(f)) +} + +type Bar struct { + data uintptr +} + +type Foo struct { + unexportedField Bar + ExportedField map[interface{}]interface{} +} + +// This example demonstrates how to use Dump to dump variables to stdout. +func ExampleDump() { + // The following package level declarations are assumed for this example: + /* + type Flag int + + const ( + flagOne Flag = iota + flagTwo + ) + + var flagStrings = map[Flag]string{ + flagOne: "flagOne", + flagTwo: "flagTwo", + } + + func (f Flag) String() string { + if s, ok := flagStrings[f]; ok { + return s + } + return fmt.Sprintf("Unknown flag (%d)", int(f)) + } + + type Bar struct { + data uintptr + } + + type Foo struct { + unexportedField Bar + ExportedField map[interface{}]interface{} + } + */ + + // Setup some sample data structures for the example. + bar := Bar{uintptr(0)} + s1 := Foo{bar, map[interface{}]interface{}{"one": true}} + f := Flag(5) + b := []byte{ + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, + 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, + 0x31, 0x32, + } + + // Dump! + spew.Dump(s1, f, b) + + // Output: + // (spew_test.Foo) { + // unexportedField: (spew_test.Bar) { + // data: (uintptr) + // }, + // ExportedField: (map[interface {}]interface {}) (len=1) { + // (string) (len=3) "one": (bool) true + // } + // } + // (spew_test.Flag) Unknown flag (5) + // ([]uint8) (len=34 cap=34) { + // 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... | + // 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0| + // 00000020 31 32 |12| + // } + // +} + +// This example demonstrates how to use Printf to display a variable with a +// format string and inline formatting. +func ExamplePrintf() { + // Create a double pointer to a uint 8. + ui8 := uint8(5) + pui8 := &ui8 + ppui8 := &pui8 + + // Create a circular data type. + type circular struct { + ui8 uint8 + c *circular + } + c := circular{ui8: 1} + c.c = &c + + // Print! + spew.Printf("ppui8: %v\n", ppui8) + spew.Printf("circular: %v\n", c) + + // Output: + // ppui8: <**>5 + // circular: {1 <*>{1 <*>}} +} + +// This example demonstrates how to use a ConfigState. +func ExampleConfigState() { + // Modify the indent level of the ConfigState only. The global + // configuration is not modified. + scs := spew.ConfigState{Indent: "\t"} + + // Output using the ConfigState instance. + v := map[string]int{"one": 1} + scs.Printf("v: %v\n", v) + scs.Dump(v) + + // Output: + // v: map[one:1] + // (map[string]int) (len=1) { + // (string) (len=3) "one": (int) 1 + // } +} + +// This example demonstrates how to use ConfigState.Dump to dump variables to +// stdout +func ExampleConfigState_Dump() { + // See the top-level Dump example for details on the types used in this + // example. + + // Create two ConfigState instances with different indentation. + scs := spew.ConfigState{Indent: "\t"} + scs2 := spew.ConfigState{Indent: " "} + + // Setup some sample data structures for the example. + bar := Bar{uintptr(0)} + s1 := Foo{bar, map[interface{}]interface{}{"one": true}} + + // Dump using the ConfigState instances. + scs.Dump(s1) + scs2.Dump(s1) + + // Output: + // (spew_test.Foo) { + // unexportedField: (spew_test.Bar) { + // data: (uintptr) + // }, + // ExportedField: (map[interface {}]interface {}) (len=1) { + // (string) (len=3) "one": (bool) true + // } + // } + // (spew_test.Foo) { + // unexportedField: (spew_test.Bar) { + // data: (uintptr) + // }, + // ExportedField: (map[interface {}]interface {}) (len=1) { + // (string) (len=3) "one": (bool) true + // } + // } + // +} + +// This example demonstrates how to use ConfigState.Printf to display a variable +// with a format string and inline formatting. +func ExampleConfigState_Printf() { + // See the top-level Dump example for details on the types used in this + // example. + + // Create two ConfigState instances and modify the method handling of the + // first ConfigState only. + scs := spew.NewDefaultConfig() + scs2 := spew.NewDefaultConfig() + scs.DisableMethods = true + + // Alternatively + // scs := spew.ConfigState{Indent: " ", DisableMethods: true} + // scs2 := spew.ConfigState{Indent: " "} + + // This is of type Flag which implements a Stringer and has raw value 1. + f := flagTwo + + // Dump using the ConfigState instances. + scs.Printf("f: %v\n", f) + scs2.Printf("f: %v\n", f) + + // Output: + // f: 1 + // f: flagTwo +} diff --git a/vendor/github.com/davecgh/go-spew/spew/format.go b/vendor/github.com/davecgh/go-spew/spew/format.go new file mode 100644 index 00000000..b04edb7d --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/format.go @@ -0,0 +1,419 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "bytes" + "fmt" + "reflect" + "strconv" + "strings" +) + +// supportedFlags is a list of all the character flags supported by fmt package. +const supportedFlags = "0-+# " + +// formatState implements the fmt.Formatter interface and contains information +// about the state of a formatting operation. The NewFormatter function can +// be used to get a new Formatter which can be used directly as arguments +// in standard fmt package printing calls. +type formatState struct { + value interface{} + fs fmt.State + depth int + pointers map[uintptr]int + ignoreNextType bool + cs *ConfigState +} + +// buildDefaultFormat recreates the original format string without precision +// and width information to pass in to fmt.Sprintf in the case of an +// unrecognized type. Unless new types are added to the language, this +// function won't ever be called. +func (f *formatState) buildDefaultFormat() (format string) { + buf := bytes.NewBuffer(percentBytes) + + for _, flag := range supportedFlags { + if f.fs.Flag(int(flag)) { + buf.WriteRune(flag) + } + } + + buf.WriteRune('v') + + format = buf.String() + return format +} + +// constructOrigFormat recreates the original format string including precision +// and width information to pass along to the standard fmt package. This allows +// automatic deferral of all format strings this package doesn't support. +func (f *formatState) constructOrigFormat(verb rune) (format string) { + buf := bytes.NewBuffer(percentBytes) + + for _, flag := range supportedFlags { + if f.fs.Flag(int(flag)) { + buf.WriteRune(flag) + } + } + + if width, ok := f.fs.Width(); ok { + buf.WriteString(strconv.Itoa(width)) + } + + if precision, ok := f.fs.Precision(); ok { + buf.Write(precisionBytes) + buf.WriteString(strconv.Itoa(precision)) + } + + buf.WriteRune(verb) + + format = buf.String() + return format +} + +// unpackValue returns values inside of non-nil interfaces when possible and +// ensures that types for values which have been unpacked from an interface +// are displayed when the show types flag is also set. +// This is useful for data types like structs, arrays, slices, and maps which +// can contain varying types packed inside an interface. +func (f *formatState) unpackValue(v reflect.Value) reflect.Value { + if v.Kind() == reflect.Interface { + f.ignoreNextType = false + if !v.IsNil() { + v = v.Elem() + } + } + return v +} + +// formatPtr handles formatting of pointers by indirecting them as necessary. +func (f *formatState) formatPtr(v reflect.Value) { + // Display nil if top level pointer is nil. + showTypes := f.fs.Flag('#') + if v.IsNil() && (!showTypes || f.ignoreNextType) { + f.fs.Write(nilAngleBytes) + return + } + + // Remove pointers at or below the current depth from map used to detect + // circular refs. + for k, depth := range f.pointers { + if depth >= f.depth { + delete(f.pointers, k) + } + } + + // Keep list of all dereferenced pointers to possibly show later. + pointerChain := make([]uintptr, 0) + + // Figure out how many levels of indirection there are by derferencing + // pointers and unpacking interfaces down the chain while detecting circular + // references. + nilFound := false + cycleFound := false + indirects := 0 + ve := v + for ve.Kind() == reflect.Ptr { + if ve.IsNil() { + nilFound = true + break + } + indirects++ + addr := ve.Pointer() + pointerChain = append(pointerChain, addr) + if pd, ok := f.pointers[addr]; ok && pd < f.depth { + cycleFound = true + indirects-- + break + } + f.pointers[addr] = f.depth + + ve = ve.Elem() + if ve.Kind() == reflect.Interface { + if ve.IsNil() { + nilFound = true + break + } + ve = ve.Elem() + } + } + + // Display type or indirection level depending on flags. + if showTypes && !f.ignoreNextType { + f.fs.Write(openParenBytes) + f.fs.Write(bytes.Repeat(asteriskBytes, indirects)) + f.fs.Write([]byte(ve.Type().String())) + f.fs.Write(closeParenBytes) + } else { + if nilFound || cycleFound { + indirects += strings.Count(ve.Type().String(), "*") + } + f.fs.Write(openAngleBytes) + f.fs.Write([]byte(strings.Repeat("*", indirects))) + f.fs.Write(closeAngleBytes) + } + + // Display pointer information depending on flags. + if f.fs.Flag('+') && (len(pointerChain) > 0) { + f.fs.Write(openParenBytes) + for i, addr := range pointerChain { + if i > 0 { + f.fs.Write(pointerChainBytes) + } + printHexPtr(f.fs, addr) + } + f.fs.Write(closeParenBytes) + } + + // Display dereferenced value. + switch { + case nilFound: + f.fs.Write(nilAngleBytes) + + case cycleFound: + f.fs.Write(circularShortBytes) + + default: + f.ignoreNextType = true + f.format(ve) + } +} + +// format is the main workhorse for providing the Formatter interface. It +// uses the passed reflect value to figure out what kind of object we are +// dealing with and formats it appropriately. It is a recursive function, +// however circular data structures are detected and handled properly. +func (f *formatState) format(v reflect.Value) { + // Handle invalid reflect values immediately. + kind := v.Kind() + if kind == reflect.Invalid { + f.fs.Write(invalidAngleBytes) + return + } + + // Handle pointers specially. + if kind == reflect.Ptr { + f.formatPtr(v) + return + } + + // Print type information unless already handled elsewhere. + if !f.ignoreNextType && f.fs.Flag('#') { + f.fs.Write(openParenBytes) + f.fs.Write([]byte(v.Type().String())) + f.fs.Write(closeParenBytes) + } + f.ignoreNextType = false + + // Call Stringer/error interfaces if they exist and the handle methods + // flag is enabled. + if !f.cs.DisableMethods { + if (kind != reflect.Invalid) && (kind != reflect.Interface) { + if handled := handleMethods(f.cs, f.fs, v); handled { + return + } + } + } + + switch kind { + case reflect.Invalid: + // Do nothing. We should never get here since invalid has already + // been handled above. + + case reflect.Bool: + printBool(f.fs, v.Bool()) + + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: + printInt(f.fs, v.Int(), 10) + + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: + printUint(f.fs, v.Uint(), 10) + + case reflect.Float32: + printFloat(f.fs, v.Float(), 32) + + case reflect.Float64: + printFloat(f.fs, v.Float(), 64) + + case reflect.Complex64: + printComplex(f.fs, v.Complex(), 32) + + case reflect.Complex128: + printComplex(f.fs, v.Complex(), 64) + + case reflect.Slice: + if v.IsNil() { + f.fs.Write(nilAngleBytes) + break + } + fallthrough + + case reflect.Array: + f.fs.Write(openBracketBytes) + f.depth++ + if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { + f.fs.Write(maxShortBytes) + } else { + numEntries := v.Len() + for i := 0; i < numEntries; i++ { + if i > 0 { + f.fs.Write(spaceBytes) + } + f.ignoreNextType = true + f.format(f.unpackValue(v.Index(i))) + } + } + f.depth-- + f.fs.Write(closeBracketBytes) + + case reflect.String: + f.fs.Write([]byte(v.String())) + + case reflect.Interface: + // The only time we should get here is for nil interfaces due to + // unpackValue calls. + if v.IsNil() { + f.fs.Write(nilAngleBytes) + } + + case reflect.Ptr: + // Do nothing. We should never get here since pointers have already + // been handled above. + + case reflect.Map: + // nil maps should be indicated as different than empty maps + if v.IsNil() { + f.fs.Write(nilAngleBytes) + break + } + + f.fs.Write(openMapBytes) + f.depth++ + if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { + f.fs.Write(maxShortBytes) + } else { + keys := v.MapKeys() + if f.cs.SortKeys { + sortValues(keys, f.cs) + } + for i, key := range keys { + if i > 0 { + f.fs.Write(spaceBytes) + } + f.ignoreNextType = true + f.format(f.unpackValue(key)) + f.fs.Write(colonBytes) + f.ignoreNextType = true + f.format(f.unpackValue(v.MapIndex(key))) + } + } + f.depth-- + f.fs.Write(closeMapBytes) + + case reflect.Struct: + numFields := v.NumField() + f.fs.Write(openBraceBytes) + f.depth++ + if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { + f.fs.Write(maxShortBytes) + } else { + vt := v.Type() + for i := 0; i < numFields; i++ { + if i > 0 { + f.fs.Write(spaceBytes) + } + vtf := vt.Field(i) + if f.fs.Flag('+') || f.fs.Flag('#') { + f.fs.Write([]byte(vtf.Name)) + f.fs.Write(colonBytes) + } + f.format(f.unpackValue(v.Field(i))) + } + } + f.depth-- + f.fs.Write(closeBraceBytes) + + case reflect.Uintptr: + printHexPtr(f.fs, uintptr(v.Uint())) + + case reflect.UnsafePointer, reflect.Chan, reflect.Func: + printHexPtr(f.fs, v.Pointer()) + + // There were not any other types at the time this code was written, but + // fall back to letting the default fmt package handle it if any get added. + default: + format := f.buildDefaultFormat() + if v.CanInterface() { + fmt.Fprintf(f.fs, format, v.Interface()) + } else { + fmt.Fprintf(f.fs, format, v.String()) + } + } +} + +// Format satisfies the fmt.Formatter interface. See NewFormatter for usage +// details. +func (f *formatState) Format(fs fmt.State, verb rune) { + f.fs = fs + + // Use standard formatting for verbs that are not v. + if verb != 'v' { + format := f.constructOrigFormat(verb) + fmt.Fprintf(fs, format, f.value) + return + } + + if f.value == nil { + if fs.Flag('#') { + fs.Write(interfaceBytes) + } + fs.Write(nilAngleBytes) + return + } + + f.format(reflect.ValueOf(f.value)) +} + +// newFormatter is a helper function to consolidate the logic from the various +// public methods which take varying config states. +func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter { + fs := &formatState{value: v, cs: cs} + fs.pointers = make(map[uintptr]int) + return fs +} + +/* +NewFormatter returns a custom formatter that satisfies the fmt.Formatter +interface. As a result, it integrates cleanly with standard fmt package +printing functions. The formatter is useful for inline printing of smaller data +types similar to the standard %v format specifier. + +The custom formatter only responds to the %v (most compact), %+v (adds pointer +addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb +combinations. Any other verbs such as %x and %q will be sent to the the +standard fmt package for formatting. In addition, the custom formatter ignores +the width and precision arguments (however they will still work on the format +specifiers not handled by the custom formatter). + +Typically this function shouldn't be called directly. It is much easier to make +use of the custom formatter by calling one of the convenience functions such as +Printf, Println, or Fprintf. +*/ +func NewFormatter(v interface{}) fmt.Formatter { + return newFormatter(&Config, v) +} diff --git a/vendor/github.com/davecgh/go-spew/spew/format_test.go b/vendor/github.com/davecgh/go-spew/spew/format_test.go new file mode 100644 index 00000000..87ee9651 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/format_test.go @@ -0,0 +1,1558 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* +Test Summary: +NOTE: For each test, a nil pointer, a single pointer and double pointer to the +base test element are also tested to ensure proper indirection across all types. + +- Max int8, int16, int32, int64, int +- Max uint8, uint16, uint32, uint64, uint +- Boolean true and false +- Standard complex64 and complex128 +- Array containing standard ints +- Array containing type with custom formatter on pointer receiver only +- Array containing interfaces +- Slice containing standard float32 values +- Slice containing type with custom formatter on pointer receiver only +- Slice containing interfaces +- Nil slice +- Standard string +- Nil interface +- Sub-interface +- Map with string keys and int vals +- Map with custom formatter type on pointer receiver only keys and vals +- Map with interface keys and values +- Map with nil interface value +- Struct with primitives +- Struct that contains another struct +- Struct that contains custom type with Stringer pointer interface via both + exported and unexported fields +- Struct that contains embedded struct and field to same struct +- Uintptr to 0 (null pointer) +- Uintptr address of real variable +- Unsafe.Pointer to 0 (null pointer) +- Unsafe.Pointer to address of real variable +- Nil channel +- Standard int channel +- Function with no params and no returns +- Function with param and no returns +- Function with multiple params and multiple returns +- Struct that is circular through self referencing +- Structs that are circular through cross referencing +- Structs that are indirectly circular +- Type that panics in its Stringer interface +- Type that has a custom Error interface +- %x passthrough with uint +- %#x passthrough with uint +- %f passthrough with precision +- %f passthrough with width and precision +- %d passthrough with width +- %q passthrough with string +*/ + +package spew_test + +import ( + "bytes" + "fmt" + "testing" + "unsafe" + + "github.com/davecgh/go-spew/spew" +) + +// formatterTest is used to describe a test to be performed against NewFormatter. +type formatterTest struct { + format string + in interface{} + wants []string +} + +// formatterTests houses all of the tests to be performed against NewFormatter. +var formatterTests = make([]formatterTest, 0) + +// addFormatterTest is a helper method to append the passed input and desired +// result to formatterTests. +func addFormatterTest(format string, in interface{}, wants ...string) { + test := formatterTest{format, in, wants} + formatterTests = append(formatterTests, test) +} + +func addIntFormatterTests() { + // Max int8. + v := int8(127) + nv := (*int8)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "int8" + vs := "127" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Max int16. + v2 := int16(32767) + nv2 := (*int16)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "int16" + v2s := "32767" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Max int32. + v3 := int32(2147483647) + nv3 := (*int32)(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "int32" + v3s := "2147483647" + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s) + addFormatterTest("%v", &pv3, "<**>"+v3s) + addFormatterTest("%v", nv3, "") + addFormatterTest("%+v", v3, v3s) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + + // Max int64. + v4 := int64(9223372036854775807) + nv4 := (*int64)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "int64" + v4s := "9223372036854775807" + addFormatterTest("%v", v4, v4s) + addFormatterTest("%v", pv4, "<*>"+v4s) + addFormatterTest("%v", &pv4, "<**>"+v4s) + addFormatterTest("%v", nv4, "") + addFormatterTest("%+v", v4, v4s) + addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) + addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%#v", v4, "("+v4t+")"+v4s) + addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s) + addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s) + addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") + addFormatterTest("%#+v", v4, "("+v4t+")"+v4s) + addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s) + addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") + + // Max int. + v5 := int(2147483647) + nv5 := (*int)(nil) + pv5 := &v5 + v5Addr := fmt.Sprintf("%p", pv5) + pv5Addr := fmt.Sprintf("%p", &pv5) + v5t := "int" + v5s := "2147483647" + addFormatterTest("%v", v5, v5s) + addFormatterTest("%v", pv5, "<*>"+v5s) + addFormatterTest("%v", &pv5, "<**>"+v5s) + addFormatterTest("%v", nv5, "") + addFormatterTest("%+v", v5, v5s) + addFormatterTest("%+v", pv5, "<*>("+v5Addr+")"+v5s) + addFormatterTest("%+v", &pv5, "<**>("+pv5Addr+"->"+v5Addr+")"+v5s) + addFormatterTest("%+v", nv5, "") + addFormatterTest("%#v", v5, "("+v5t+")"+v5s) + addFormatterTest("%#v", pv5, "(*"+v5t+")"+v5s) + addFormatterTest("%#v", &pv5, "(**"+v5t+")"+v5s) + addFormatterTest("%#v", nv5, "(*"+v5t+")"+"") + addFormatterTest("%#+v", v5, "("+v5t+")"+v5s) + addFormatterTest("%#+v", pv5, "(*"+v5t+")("+v5Addr+")"+v5s) + addFormatterTest("%#+v", &pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")"+v5s) + addFormatterTest("%#+v", nv5, "(*"+v5t+")"+"") +} + +func addUintFormatterTests() { + // Max uint8. + v := uint8(255) + nv := (*uint8)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "uint8" + vs := "255" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Max uint16. + v2 := uint16(65535) + nv2 := (*uint16)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "uint16" + v2s := "65535" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Max uint32. + v3 := uint32(4294967295) + nv3 := (*uint32)(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "uint32" + v3s := "4294967295" + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s) + addFormatterTest("%v", &pv3, "<**>"+v3s) + addFormatterTest("%v", nv3, "") + addFormatterTest("%+v", v3, v3s) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + + // Max uint64. + v4 := uint64(18446744073709551615) + nv4 := (*uint64)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "uint64" + v4s := "18446744073709551615" + addFormatterTest("%v", v4, v4s) + addFormatterTest("%v", pv4, "<*>"+v4s) + addFormatterTest("%v", &pv4, "<**>"+v4s) + addFormatterTest("%v", nv4, "") + addFormatterTest("%+v", v4, v4s) + addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) + addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%#v", v4, "("+v4t+")"+v4s) + addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s) + addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s) + addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") + addFormatterTest("%#+v", v4, "("+v4t+")"+v4s) + addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s) + addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") + + // Max uint. + v5 := uint(4294967295) + nv5 := (*uint)(nil) + pv5 := &v5 + v5Addr := fmt.Sprintf("%p", pv5) + pv5Addr := fmt.Sprintf("%p", &pv5) + v5t := "uint" + v5s := "4294967295" + addFormatterTest("%v", v5, v5s) + addFormatterTest("%v", pv5, "<*>"+v5s) + addFormatterTest("%v", &pv5, "<**>"+v5s) + addFormatterTest("%v", nv5, "") + addFormatterTest("%+v", v5, v5s) + addFormatterTest("%+v", pv5, "<*>("+v5Addr+")"+v5s) + addFormatterTest("%+v", &pv5, "<**>("+pv5Addr+"->"+v5Addr+")"+v5s) + addFormatterTest("%+v", nv5, "") + addFormatterTest("%#v", v5, "("+v5t+")"+v5s) + addFormatterTest("%#v", pv5, "(*"+v5t+")"+v5s) + addFormatterTest("%#v", &pv5, "(**"+v5t+")"+v5s) + addFormatterTest("%#v", nv5, "(*"+v5t+")"+"") + addFormatterTest("%#+v", v5, "("+v5t+")"+v5s) + addFormatterTest("%#+v", pv5, "(*"+v5t+")("+v5Addr+")"+v5s) + addFormatterTest("%#+v", &pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")"+v5s) + addFormatterTest("%#v", nv5, "(*"+v5t+")"+"") +} + +func addBoolFormatterTests() { + // Boolean true. + v := bool(true) + nv := (*bool)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "bool" + vs := "true" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Boolean false. + v2 := bool(false) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "bool" + v2s := "false" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) +} + +func addFloatFormatterTests() { + // Standard float32. + v := float32(3.1415) + nv := (*float32)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "float32" + vs := "3.1415" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Standard float64. + v2 := float64(3.1415926) + nv2 := (*float64)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "float64" + v2s := "3.1415926" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") +} + +func addComplexFormatterTests() { + // Standard complex64. + v := complex(float32(6), -2) + nv := (*complex64)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "complex64" + vs := "(6-2i)" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Standard complex128. + v2 := complex(float64(-6), 2) + nv2 := (*complex128)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "complex128" + v2s := "(-6+2i)" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") +} + +func addArrayFormatterTests() { + // Array containing standard ints. + v := [3]int{1, 2, 3} + nv := (*[3]int)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "[3]int" + vs := "[1 2 3]" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Array containing type with custom formatter on pointer receiver only. + v2 := [3]pstringer{"1", "2", "3"} + nv2 := (*[3]pstringer)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "[3]spew_test.pstringer" + v2sp := "[stringer 1 stringer 2 stringer 3]" + v2s := v2sp + if spew.UnsafeDisabled { + v2s = "[1 2 3]" + } + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2sp) + addFormatterTest("%v", &pv2, "<**>"+v2sp) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2sp) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2sp) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2sp) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2sp) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2sp) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2sp) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Array containing interfaces. + v3 := [3]interface{}{"one", int(2), uint(3)} + nv3 := (*[3]interface{})(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "[3]interface {}" + v3t2 := "string" + v3t3 := "int" + v3t4 := "uint" + v3s := "[one 2 3]" + v3s2 := "[(" + v3t2 + ")one (" + v3t3 + ")2 (" + v3t4 + ")3]" + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s) + addFormatterTest("%v", &pv3, "<**>"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%+v", v3, v3s) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s2) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2) + addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") +} + +func addSliceFormatterTests() { + // Slice containing standard float32 values. + v := []float32{3.14, 6.28, 12.56} + nv := (*[]float32)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "[]float32" + vs := "[3.14 6.28 12.56]" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Slice containing type with custom formatter on pointer receiver only. + v2 := []pstringer{"1", "2", "3"} + nv2 := (*[]pstringer)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "[]spew_test.pstringer" + v2s := "[stringer 1 stringer 2 stringer 3]" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Slice containing interfaces. + v3 := []interface{}{"one", int(2), uint(3), nil} + nv3 := (*[]interface{})(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "[]interface {}" + v3t2 := "string" + v3t3 := "int" + v3t4 := "uint" + v3t5 := "interface {}" + v3s := "[one 2 3 ]" + v3s2 := "[(" + v3t2 + ")one (" + v3t3 + ")2 (" + v3t4 + ")3 (" + v3t5 + + ")]" + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s) + addFormatterTest("%v", &pv3, "<**>"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%+v", v3, v3s) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s2) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2) + addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") + + // Nil slice. + var v4 []int + nv4 := (*[]int)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "[]int" + v4s := "" + addFormatterTest("%v", v4, v4s) + addFormatterTest("%v", pv4, "<*>"+v4s) + addFormatterTest("%v", &pv4, "<**>"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%+v", v4, v4s) + addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) + addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%#v", v4, "("+v4t+")"+v4s) + addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s) + addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s) + addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") + addFormatterTest("%#+v", v4, "("+v4t+")"+v4s) + addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s) + addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") +} + +func addStringFormatterTests() { + // Standard string. + v := "test" + nv := (*string)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "string" + vs := "test" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") +} + +func addInterfaceFormatterTests() { + // Nil interface. + var v interface{} + nv := (*interface{})(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "interface {}" + vs := "" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Sub-interface. + v2 := interface{}(uint16(65535)) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "uint16" + v2s := "65535" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) +} + +func addMapFormatterTests() { + // Map with string keys and int vals. + v := map[string]int{"one": 1, "two": 2} + nilMap := map[string]int(nil) + nv := (*map[string]int)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "map[string]int" + vs := "map[one:1 two:2]" + vs2 := "map[two:2 one:1]" + addFormatterTest("%v", v, vs, vs2) + addFormatterTest("%v", pv, "<*>"+vs, "<*>"+vs2) + addFormatterTest("%v", &pv, "<**>"+vs, "<**>"+vs2) + addFormatterTest("%+v", nilMap, "") + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs, vs2) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs, "<*>("+vAddr+")"+vs2) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs, + "<**>("+pvAddr+"->"+vAddr+")"+vs2) + addFormatterTest("%+v", nilMap, "") + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs, "("+vt+")"+vs2) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs, "(*"+vt+")"+vs2) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs, "(**"+vt+")"+vs2) + addFormatterTest("%#v", nilMap, "("+vt+")"+"") + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs, "("+vt+")"+vs2) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs, + "(*"+vt+")("+vAddr+")"+vs2) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs, + "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs2) + addFormatterTest("%#+v", nilMap, "("+vt+")"+"") + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Map with custom formatter type on pointer receiver only keys and vals. + v2 := map[pstringer]pstringer{"one": "1"} + nv2 := (*map[pstringer]pstringer)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "map[spew_test.pstringer]spew_test.pstringer" + v2s := "map[stringer one:stringer 1]" + if spew.UnsafeDisabled { + v2s = "map[one:1]" + } + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Map with interface keys and values. + v3 := map[interface{}]interface{}{"one": 1} + nv3 := (*map[interface{}]interface{})(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "map[interface {}]interface {}" + v3t1 := "string" + v3t2 := "int" + v3s := "map[one:1]" + v3s2 := "map[(" + v3t1 + ")one:(" + v3t2 + ")1]" + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s) + addFormatterTest("%v", &pv3, "<**>"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%+v", v3, v3s) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s2) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2) + addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") + + // Map with nil interface value + v4 := map[string]interface{}{"nil": nil} + nv4 := (*map[string]interface{})(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "map[string]interface {}" + v4t1 := "interface {}" + v4s := "map[nil:]" + v4s2 := "map[nil:(" + v4t1 + ")]" + addFormatterTest("%v", v4, v4s) + addFormatterTest("%v", pv4, "<*>"+v4s) + addFormatterTest("%v", &pv4, "<**>"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%+v", v4, v4s) + addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) + addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%#v", v4, "("+v4t+")"+v4s2) + addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s2) + addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s2) + addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") + addFormatterTest("%#+v", v4, "("+v4t+")"+v4s2) + addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s2) + addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s2) + addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") +} + +func addStructFormatterTests() { + // Struct with primitives. + type s1 struct { + a int8 + b uint8 + } + v := s1{127, 255} + nv := (*s1)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.s1" + vt2 := "int8" + vt3 := "uint8" + vs := "{127 255}" + vs2 := "{a:127 b:255}" + vs3 := "{a:(" + vt2 + ")127 b:(" + vt3 + ")255}" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs2) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs2) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs2) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs3) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs3) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs3) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs3) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs3) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs3) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Struct that contains another struct. + type s2 struct { + s1 s1 + b bool + } + v2 := s2{s1{127, 255}, true} + nv2 := (*s2)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "spew_test.s2" + v2t2 := "spew_test.s1" + v2t3 := "int8" + v2t4 := "uint8" + v2t5 := "bool" + v2s := "{{127 255} true}" + v2s2 := "{s1:{a:127 b:255} b:true}" + v2s3 := "{s1:(" + v2t2 + "){a:(" + v2t3 + ")127 b:(" + v2t4 + ")255} b:(" + + v2t5 + ")true}" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s2) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s2) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s2) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s3) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s3) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s3) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s3) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s3) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s3) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Struct that contains custom type with Stringer pointer interface via both + // exported and unexported fields. + type s3 struct { + s pstringer + S pstringer + } + v3 := s3{"test", "test2"} + nv3 := (*s3)(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "spew_test.s3" + v3t2 := "spew_test.pstringer" + v3s := "{stringer test stringer test2}" + v3sp := v3s + v3s2 := "{s:stringer test S:stringer test2}" + v3s2p := v3s2 + v3s3 := "{s:(" + v3t2 + ")stringer test S:(" + v3t2 + ")stringer test2}" + v3s3p := v3s3 + if spew.UnsafeDisabled { + v3s = "{test test2}" + v3sp = "{test stringer test2}" + v3s2 = "{s:test S:test2}" + v3s2p = "{s:test S:stringer test2}" + v3s3 = "{s:(" + v3t2 + ")test S:(" + v3t2 + ")test2}" + v3s3p = "{s:(" + v3t2 + ")test S:(" + v3t2 + ")stringer test2}" + } + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3sp) + addFormatterTest("%v", &pv3, "<**>"+v3sp) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%+v", v3, v3s2) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s2p) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s2p) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s3) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s3p) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s3p) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s3) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s3p) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s3p) + addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") + + // Struct that contains embedded struct and field to same struct. + e := embed{"embedstr"} + v4 := embedwrap{embed: &e, e: &e} + nv4 := (*embedwrap)(nil) + pv4 := &v4 + eAddr := fmt.Sprintf("%p", &e) + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "spew_test.embedwrap" + v4t2 := "spew_test.embed" + v4t3 := "string" + v4s := "{<*>{embedstr} <*>{embedstr}}" + v4s2 := "{embed:<*>(" + eAddr + "){a:embedstr} e:<*>(" + eAddr + + "){a:embedstr}}" + v4s3 := "{embed:(*" + v4t2 + "){a:(" + v4t3 + ")embedstr} e:(*" + v4t2 + + "){a:(" + v4t3 + ")embedstr}}" + v4s4 := "{embed:(*" + v4t2 + ")(" + eAddr + "){a:(" + v4t3 + + ")embedstr} e:(*" + v4t2 + ")(" + eAddr + "){a:(" + v4t3 + ")embedstr}}" + addFormatterTest("%v", v4, v4s) + addFormatterTest("%v", pv4, "<*>"+v4s) + addFormatterTest("%v", &pv4, "<**>"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%+v", v4, v4s2) + addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s2) + addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s2) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%#v", v4, "("+v4t+")"+v4s3) + addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s3) + addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s3) + addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") + addFormatterTest("%#+v", v4, "("+v4t+")"+v4s4) + addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s4) + addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s4) + addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") +} + +func addUintptrFormatterTests() { + // Null pointer. + v := uintptr(0) + nv := (*uintptr)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "uintptr" + vs := "" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Address of real variable. + i := 1 + v2 := uintptr(unsafe.Pointer(&i)) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "uintptr" + v2s := fmt.Sprintf("%p", &i) + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) +} + +func addUnsafePointerFormatterTests() { + // Null pointer. + v := unsafe.Pointer(nil) + nv := (*unsafe.Pointer)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "unsafe.Pointer" + vs := "" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Address of real variable. + i := 1 + v2 := unsafe.Pointer(&i) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "unsafe.Pointer" + v2s := fmt.Sprintf("%p", &i) + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) +} + +func addChanFormatterTests() { + // Nil channel. + var v chan int + pv := &v + nv := (*chan int)(nil) + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "chan int" + vs := "" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Real channel. + v2 := make(chan int) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "chan int" + v2s := fmt.Sprintf("%p", v2) + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) +} + +func addFuncFormatterTests() { + // Function with no params and no returns. + v := addIntFormatterTests + nv := (*func())(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "func()" + vs := fmt.Sprintf("%p", v) + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Function with param and no returns. + v2 := TestFormatter + nv2 := (*func(*testing.T))(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "func(*testing.T)" + v2s := fmt.Sprintf("%p", v2) + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Function with multiple params and multiple returns. + var v3 = func(i int, s string) (b bool, err error) { + return true, nil + } + nv3 := (*func(int, string) (bool, error))(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "func(int, string) (bool, error)" + v3s := fmt.Sprintf("%p", v3) + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s) + addFormatterTest("%v", &pv3, "<**>"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%+v", v3, v3s) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") +} + +func addCircularFormatterTests() { + // Struct that is circular through self referencing. + type circular struct { + c *circular + } + v := circular{nil} + v.c = &v + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.circular" + vs := "{<*>{<*>}}" + vs2 := "{<*>}" + vs3 := "{c:<*>(" + vAddr + "){c:<*>(" + vAddr + ")}}" + vs4 := "{c:<*>(" + vAddr + ")}" + vs5 := "{c:(*" + vt + "){c:(*" + vt + ")}}" + vs6 := "{c:(*" + vt + ")}" + vs7 := "{c:(*" + vt + ")(" + vAddr + "){c:(*" + vt + ")(" + vAddr + + ")}}" + vs8 := "{c:(*" + vt + ")(" + vAddr + ")}" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs2) + addFormatterTest("%v", &pv, "<**>"+vs2) + addFormatterTest("%+v", v, vs3) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs4) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs4) + addFormatterTest("%#v", v, "("+vt+")"+vs5) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs6) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs6) + addFormatterTest("%#+v", v, "("+vt+")"+vs7) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs8) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs8) + + // Structs that are circular through cross referencing. + v2 := xref1{nil} + ts2 := xref2{&v2} + v2.ps2 = &ts2 + pv2 := &v2 + ts2Addr := fmt.Sprintf("%p", &ts2) + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "spew_test.xref1" + v2t2 := "spew_test.xref2" + v2s := "{<*>{<*>{<*>}}}" + v2s2 := "{<*>{<*>}}" + v2s3 := "{ps2:<*>(" + ts2Addr + "){ps1:<*>(" + v2Addr + "){ps2:<*>(" + + ts2Addr + ")}}}" + v2s4 := "{ps2:<*>(" + ts2Addr + "){ps1:<*>(" + v2Addr + ")}}" + v2s5 := "{ps2:(*" + v2t2 + "){ps1:(*" + v2t + "){ps2:(*" + v2t2 + + ")}}}" + v2s6 := "{ps2:(*" + v2t2 + "){ps1:(*" + v2t + ")}}" + v2s7 := "{ps2:(*" + v2t2 + ")(" + ts2Addr + "){ps1:(*" + v2t + + ")(" + v2Addr + "){ps2:(*" + v2t2 + ")(" + ts2Addr + + ")}}}" + v2s8 := "{ps2:(*" + v2t2 + ")(" + ts2Addr + "){ps1:(*" + v2t + + ")(" + v2Addr + ")}}" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s2) + addFormatterTest("%v", &pv2, "<**>"+v2s2) + addFormatterTest("%+v", v2, v2s3) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s4) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s4) + addFormatterTest("%#v", v2, "("+v2t+")"+v2s5) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s6) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s6) + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s7) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s8) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s8) + + // Structs that are indirectly circular. + v3 := indirCir1{nil} + tic2 := indirCir2{nil} + tic3 := indirCir3{&v3} + tic2.ps3 = &tic3 + v3.ps2 = &tic2 + pv3 := &v3 + tic2Addr := fmt.Sprintf("%p", &tic2) + tic3Addr := fmt.Sprintf("%p", &tic3) + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "spew_test.indirCir1" + v3t2 := "spew_test.indirCir2" + v3t3 := "spew_test.indirCir3" + v3s := "{<*>{<*>{<*>{<*>}}}}" + v3s2 := "{<*>{<*>{<*>}}}" + v3s3 := "{ps2:<*>(" + tic2Addr + "){ps3:<*>(" + tic3Addr + "){ps1:<*>(" + + v3Addr + "){ps2:<*>(" + tic2Addr + ")}}}}" + v3s4 := "{ps2:<*>(" + tic2Addr + "){ps3:<*>(" + tic3Addr + "){ps1:<*>(" + + v3Addr + ")}}}" + v3s5 := "{ps2:(*" + v3t2 + "){ps3:(*" + v3t3 + "){ps1:(*" + v3t + + "){ps2:(*" + v3t2 + ")}}}}" + v3s6 := "{ps2:(*" + v3t2 + "){ps3:(*" + v3t3 + "){ps1:(*" + v3t + + ")}}}" + v3s7 := "{ps2:(*" + v3t2 + ")(" + tic2Addr + "){ps3:(*" + v3t3 + ")(" + + tic3Addr + "){ps1:(*" + v3t + ")(" + v3Addr + "){ps2:(*" + v3t2 + + ")(" + tic2Addr + ")}}}}" + v3s8 := "{ps2:(*" + v3t2 + ")(" + tic2Addr + "){ps3:(*" + v3t3 + ")(" + + tic3Addr + "){ps1:(*" + v3t + ")(" + v3Addr + ")}}}" + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s2) + addFormatterTest("%v", &pv3, "<**>"+v3s2) + addFormatterTest("%+v", v3, v3s3) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s4) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s4) + addFormatterTest("%#v", v3, "("+v3t+")"+v3s5) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s6) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s6) + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s7) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s8) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s8) +} + +func addPanicFormatterTests() { + // Type that panics in its Stringer interface. + v := panicer(127) + nv := (*panicer)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.panicer" + vs := "(PANIC=test panic)127" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") +} + +func addErrorFormatterTests() { + // Type that has a custom Error interface. + v := customError(127) + nv := (*customError)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.customError" + vs := "error: 127" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") +} + +func addPassthroughFormatterTests() { + // %x passthrough with uint. + v := uint(4294967295) + pv := &v + vAddr := fmt.Sprintf("%x", pv) + pvAddr := fmt.Sprintf("%x", &pv) + vs := "ffffffff" + addFormatterTest("%x", v, vs) + addFormatterTest("%x", pv, vAddr) + addFormatterTest("%x", &pv, pvAddr) + + // %#x passthrough with uint. + v2 := int(2147483647) + pv2 := &v2 + v2Addr := fmt.Sprintf("%#x", pv2) + pv2Addr := fmt.Sprintf("%#x", &pv2) + v2s := "0x7fffffff" + addFormatterTest("%#x", v2, v2s) + addFormatterTest("%#x", pv2, v2Addr) + addFormatterTest("%#x", &pv2, pv2Addr) + + // %f passthrough with precision. + addFormatterTest("%.2f", 3.1415, "3.14") + addFormatterTest("%.3f", 3.1415, "3.142") + addFormatterTest("%.4f", 3.1415, "3.1415") + + // %f passthrough with width and precision. + addFormatterTest("%5.2f", 3.1415, " 3.14") + addFormatterTest("%6.3f", 3.1415, " 3.142") + addFormatterTest("%7.4f", 3.1415, " 3.1415") + + // %d passthrough with width. + addFormatterTest("%3d", 127, "127") + addFormatterTest("%4d", 127, " 127") + addFormatterTest("%5d", 127, " 127") + + // %q passthrough with string. + addFormatterTest("%q", "test", "\"test\"") +} + +// TestFormatter executes all of the tests described by formatterTests. +func TestFormatter(t *testing.T) { + // Setup tests. + addIntFormatterTests() + addUintFormatterTests() + addBoolFormatterTests() + addFloatFormatterTests() + addComplexFormatterTests() + addArrayFormatterTests() + addSliceFormatterTests() + addStringFormatterTests() + addInterfaceFormatterTests() + addMapFormatterTests() + addStructFormatterTests() + addUintptrFormatterTests() + addUnsafePointerFormatterTests() + addChanFormatterTests() + addFuncFormatterTests() + addCircularFormatterTests() + addPanicFormatterTests() + addErrorFormatterTests() + addPassthroughFormatterTests() + + t.Logf("Running %d tests", len(formatterTests)) + for i, test := range formatterTests { + buf := new(bytes.Buffer) + spew.Fprintf(buf, test.format, test.in) + s := buf.String() + if testFailed(s, test.wants) { + t.Errorf("Formatter #%d format: %s got: %s %s", i, test.format, s, + stringizeWants(test.wants)) + continue + } + } +} + +type testStruct struct { + x int +} + +func (ts testStruct) String() string { + return fmt.Sprintf("ts.%d", ts.x) +} + +type testStructP struct { + x int +} + +func (ts *testStructP) String() string { + return fmt.Sprintf("ts.%d", ts.x) +} + +func TestPrintSortedKeys(t *testing.T) { + cfg := spew.ConfigState{SortKeys: true} + s := cfg.Sprint(map[int]string{1: "1", 3: "3", 2: "2"}) + expected := "map[1:1 2:2 3:3]" + if s != expected { + t.Errorf("Sorted keys mismatch 1:\n %v %v", s, expected) + } + + s = cfg.Sprint(map[stringer]int{"1": 1, "3": 3, "2": 2}) + expected = "map[stringer 1:1 stringer 2:2 stringer 3:3]" + if s != expected { + t.Errorf("Sorted keys mismatch 2:\n %v %v", s, expected) + } + + s = cfg.Sprint(map[pstringer]int{pstringer("1"): 1, pstringer("3"): 3, pstringer("2"): 2}) + expected = "map[stringer 1:1 stringer 2:2 stringer 3:3]" + if spew.UnsafeDisabled { + expected = "map[1:1 2:2 3:3]" + } + if s != expected { + t.Errorf("Sorted keys mismatch 3:\n %v %v", s, expected) + } + + s = cfg.Sprint(map[testStruct]int{{1}: 1, {3}: 3, {2}: 2}) + expected = "map[ts.1:1 ts.2:2 ts.3:3]" + if s != expected { + t.Errorf("Sorted keys mismatch 4:\n %v %v", s, expected) + } + + if !spew.UnsafeDisabled { + s = cfg.Sprint(map[testStructP]int{{1}: 1, {3}: 3, {2}: 2}) + expected = "map[ts.1:1 ts.2:2 ts.3:3]" + if s != expected { + t.Errorf("Sorted keys mismatch 5:\n %v %v", s, expected) + } + } + + s = cfg.Sprint(map[customError]int{customError(1): 1, customError(3): 3, customError(2): 2}) + expected = "map[error: 1:1 error: 2:2 error: 3:3]" + if s != expected { + t.Errorf("Sorted keys mismatch 6:\n %v %v", s, expected) + } +} diff --git a/vendor/github.com/davecgh/go-spew/spew/internal_test.go b/vendor/github.com/davecgh/go-spew/spew/internal_test.go new file mode 100644 index 00000000..e312b4fa --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/internal_test.go @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* +This test file is part of the spew package rather than than the spew_test +package because it needs access to internals to properly test certain cases +which are not possible via the public interface since they should never happen. +*/ + +package spew + +import ( + "bytes" + "reflect" + "testing" +) + +// dummyFmtState implements a fake fmt.State to use for testing invalid +// reflect.Value handling. This is necessary because the fmt package catches +// invalid values before invoking the formatter on them. +type dummyFmtState struct { + bytes.Buffer +} + +func (dfs *dummyFmtState) Flag(f int) bool { + return f == int('+') +} + +func (dfs *dummyFmtState) Precision() (int, bool) { + return 0, false +} + +func (dfs *dummyFmtState) Width() (int, bool) { + return 0, false +} + +// TestInvalidReflectValue ensures the dump and formatter code handles an +// invalid reflect value properly. This needs access to internal state since it +// should never happen in real code and therefore can't be tested via the public +// API. +func TestInvalidReflectValue(t *testing.T) { + i := 1 + + // Dump invalid reflect value. + v := new(reflect.Value) + buf := new(bytes.Buffer) + d := dumpState{w: buf, cs: &Config} + d.dump(*v) + s := buf.String() + want := "" + if s != want { + t.Errorf("InvalidReflectValue #%d\n got: %s want: %s", i, s, want) + } + i++ + + // Formatter invalid reflect value. + buf2 := new(dummyFmtState) + f := formatState{value: *v, cs: &Config, fs: buf2} + f.format(*v) + s = buf2.String() + want = "" + if s != want { + t.Errorf("InvalidReflectValue #%d got: %s want: %s", i, s, want) + } +} + +// SortValues makes the internal sortValues function available to the test +// package. +func SortValues(values []reflect.Value, cs *ConfigState) { + sortValues(values, cs) +} diff --git a/vendor/github.com/davecgh/go-spew/spew/internalunsafe_test.go b/vendor/github.com/davecgh/go-spew/spew/internalunsafe_test.go new file mode 100644 index 00000000..80dc2217 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/internalunsafe_test.go @@ -0,0 +1,101 @@ +// Copyright (c) 2013-2016 Dave Collins + +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. + +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when the code is not running on Google App Engine, compiled by GopherJS, and +// "-tags safe" is not added to the go build command line. The "disableunsafe" +// tag is deprecated and thus should not be used. +// +build !js,!appengine,!safe,!disableunsafe,go1.4 + +/* +This test file is part of the spew package rather than than the spew_test +package because it needs access to internals to properly test certain cases +which are not possible via the public interface since they should never happen. +*/ + +package spew + +import ( + "bytes" + "reflect" + "testing" +) + +// changeKind uses unsafe to intentionally change the kind of a reflect.Value to +// the maximum kind value which does not exist. This is needed to test the +// fallback code which punts to the standard fmt library for new types that +// might get added to the language. +func changeKind(v *reflect.Value, readOnly bool) { + flags := flagField(v) + if readOnly { + *flags |= flagRO + } else { + *flags &^= flagRO + } + *flags |= flagKindMask +} + +// TestAddedReflectValue tests functionaly of the dump and formatter code which +// falls back to the standard fmt library for new types that might get added to +// the language. +func TestAddedReflectValue(t *testing.T) { + i := 1 + + // Dump using a reflect.Value that is exported. + v := reflect.ValueOf(int8(5)) + changeKind(&v, false) + buf := new(bytes.Buffer) + d := dumpState{w: buf, cs: &Config} + d.dump(v) + s := buf.String() + want := "(int8) 5" + if s != want { + t.Errorf("TestAddedReflectValue #%d\n got: %s want: %s", i, s, want) + } + i++ + + // Dump using a reflect.Value that is not exported. + changeKind(&v, true) + buf.Reset() + d.dump(v) + s = buf.String() + want = "(int8) " + if s != want { + t.Errorf("TestAddedReflectValue #%d\n got: %s want: %s", i, s, want) + } + i++ + + // Formatter using a reflect.Value that is exported. + changeKind(&v, false) + buf2 := new(dummyFmtState) + f := formatState{value: v, cs: &Config, fs: buf2} + f.format(v) + s = buf2.String() + want = "5" + if s != want { + t.Errorf("TestAddedReflectValue #%d got: %s want: %s", i, s, want) + } + i++ + + // Formatter using a reflect.Value that is not exported. + changeKind(&v, true) + buf2.Reset() + f = formatState{value: v, cs: &Config, fs: buf2} + f.format(v) + s = buf2.String() + want = "" + if s != want { + t.Errorf("TestAddedReflectValue #%d got: %s want: %s", i, s, want) + } +} diff --git a/vendor/github.com/davecgh/go-spew/spew/spew.go b/vendor/github.com/davecgh/go-spew/spew/spew.go new file mode 100644 index 00000000..32c0e338 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/spew.go @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "fmt" + "io" +) + +// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the formatted string as a value that satisfies error. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Errorf(format, spew.NewFormatter(a), spew.NewFormatter(b)) +func Errorf(format string, a ...interface{}) (err error) { + return fmt.Errorf(format, convertArgs(a)...) +} + +// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprint(w, spew.NewFormatter(a), spew.NewFormatter(b)) +func Fprint(w io.Writer, a ...interface{}) (n int, err error) { + return fmt.Fprint(w, convertArgs(a)...) +} + +// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprintf(w, format, spew.NewFormatter(a), spew.NewFormatter(b)) +func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { + return fmt.Fprintf(w, format, convertArgs(a)...) +} + +// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it +// passed with a default Formatter interface returned by NewFormatter. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprintln(w, spew.NewFormatter(a), spew.NewFormatter(b)) +func Fprintln(w io.Writer, a ...interface{}) (n int, err error) { + return fmt.Fprintln(w, convertArgs(a)...) +} + +// Print is a wrapper for fmt.Print that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Print(spew.NewFormatter(a), spew.NewFormatter(b)) +func Print(a ...interface{}) (n int, err error) { + return fmt.Print(convertArgs(a)...) +} + +// Printf is a wrapper for fmt.Printf that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Printf(format, spew.NewFormatter(a), spew.NewFormatter(b)) +func Printf(format string, a ...interface{}) (n int, err error) { + return fmt.Printf(format, convertArgs(a)...) +} + +// Println is a wrapper for fmt.Println that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Println(spew.NewFormatter(a), spew.NewFormatter(b)) +func Println(a ...interface{}) (n int, err error) { + return fmt.Println(convertArgs(a)...) +} + +// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprint(spew.NewFormatter(a), spew.NewFormatter(b)) +func Sprint(a ...interface{}) string { + return fmt.Sprint(convertArgs(a)...) +} + +// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprintf(format, spew.NewFormatter(a), spew.NewFormatter(b)) +func Sprintf(format string, a ...interface{}) string { + return fmt.Sprintf(format, convertArgs(a)...) +} + +// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it +// were passed with a default Formatter interface returned by NewFormatter. It +// returns the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprintln(spew.NewFormatter(a), spew.NewFormatter(b)) +func Sprintln(a ...interface{}) string { + return fmt.Sprintln(convertArgs(a)...) +} + +// convertArgs accepts a slice of arguments and returns a slice of the same +// length with each argument converted to a default spew Formatter interface. +func convertArgs(args []interface{}) (formatters []interface{}) { + formatters = make([]interface{}, len(args)) + for index, arg := range args { + formatters[index] = NewFormatter(arg) + } + return formatters +} diff --git a/vendor/github.com/davecgh/go-spew/spew/spew_test.go b/vendor/github.com/davecgh/go-spew/spew/spew_test.go new file mode 100644 index 00000000..b70466c6 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/spew_test.go @@ -0,0 +1,320 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew_test + +import ( + "bytes" + "fmt" + "io/ioutil" + "os" + "testing" + + "github.com/davecgh/go-spew/spew" +) + +// spewFunc is used to identify which public function of the spew package or +// ConfigState a test applies to. +type spewFunc int + +const ( + fCSFdump spewFunc = iota + fCSFprint + fCSFprintf + fCSFprintln + fCSPrint + fCSPrintln + fCSSdump + fCSSprint + fCSSprintf + fCSSprintln + fCSErrorf + fCSNewFormatter + fErrorf + fFprint + fFprintln + fPrint + fPrintln + fSdump + fSprint + fSprintf + fSprintln +) + +// Map of spewFunc values to names for pretty printing. +var spewFuncStrings = map[spewFunc]string{ + fCSFdump: "ConfigState.Fdump", + fCSFprint: "ConfigState.Fprint", + fCSFprintf: "ConfigState.Fprintf", + fCSFprintln: "ConfigState.Fprintln", + fCSSdump: "ConfigState.Sdump", + fCSPrint: "ConfigState.Print", + fCSPrintln: "ConfigState.Println", + fCSSprint: "ConfigState.Sprint", + fCSSprintf: "ConfigState.Sprintf", + fCSSprintln: "ConfigState.Sprintln", + fCSErrorf: "ConfigState.Errorf", + fCSNewFormatter: "ConfigState.NewFormatter", + fErrorf: "spew.Errorf", + fFprint: "spew.Fprint", + fFprintln: "spew.Fprintln", + fPrint: "spew.Print", + fPrintln: "spew.Println", + fSdump: "spew.Sdump", + fSprint: "spew.Sprint", + fSprintf: "spew.Sprintf", + fSprintln: "spew.Sprintln", +} + +func (f spewFunc) String() string { + if s, ok := spewFuncStrings[f]; ok { + return s + } + return fmt.Sprintf("Unknown spewFunc (%d)", int(f)) +} + +// spewTest is used to describe a test to be performed against the public +// functions of the spew package or ConfigState. +type spewTest struct { + cs *spew.ConfigState + f spewFunc + format string + in interface{} + want string +} + +// spewTests houses the tests to be performed against the public functions of +// the spew package and ConfigState. +// +// These tests are only intended to ensure the public functions are exercised +// and are intentionally not exhaustive of types. The exhaustive type +// tests are handled in the dump and format tests. +var spewTests []spewTest + +// redirStdout is a helper function to return the standard output from f as a +// byte slice. +func redirStdout(f func()) ([]byte, error) { + tempFile, err := ioutil.TempFile("", "ss-test") + if err != nil { + return nil, err + } + fileName := tempFile.Name() + defer os.Remove(fileName) // Ignore error + + origStdout := os.Stdout + os.Stdout = tempFile + f() + os.Stdout = origStdout + tempFile.Close() + + return ioutil.ReadFile(fileName) +} + +func initSpewTests() { + // Config states with various settings. + scsDefault := spew.NewDefaultConfig() + scsNoMethods := &spew.ConfigState{Indent: " ", DisableMethods: true} + scsNoPmethods := &spew.ConfigState{Indent: " ", DisablePointerMethods: true} + scsMaxDepth := &spew.ConfigState{Indent: " ", MaxDepth: 1} + scsContinue := &spew.ConfigState{Indent: " ", ContinueOnMethod: true} + scsNoPtrAddr := &spew.ConfigState{DisablePointerAddresses: true} + scsNoCap := &spew.ConfigState{DisableCapacities: true} + + // Variables for tests on types which implement Stringer interface with and + // without a pointer receiver. + ts := stringer("test") + tps := pstringer("test") + + type ptrTester struct { + s *struct{} + } + tptr := &ptrTester{s: &struct{}{}} + + // depthTester is used to test max depth handling for structs, array, slices + // and maps. + type depthTester struct { + ic indirCir1 + arr [1]string + slice []string + m map[string]int + } + dt := depthTester{indirCir1{nil}, [1]string{"arr"}, []string{"slice"}, + map[string]int{"one": 1}} + + // Variable for tests on types which implement error interface. + te := customError(10) + + spewTests = []spewTest{ + {scsDefault, fCSFdump, "", int8(127), "(int8) 127\n"}, + {scsDefault, fCSFprint, "", int16(32767), "32767"}, + {scsDefault, fCSFprintf, "%v", int32(2147483647), "2147483647"}, + {scsDefault, fCSFprintln, "", int(2147483647), "2147483647\n"}, + {scsDefault, fCSPrint, "", int64(9223372036854775807), "9223372036854775807"}, + {scsDefault, fCSPrintln, "", uint8(255), "255\n"}, + {scsDefault, fCSSdump, "", uint8(64), "(uint8) 64\n"}, + {scsDefault, fCSSprint, "", complex(1, 2), "(1+2i)"}, + {scsDefault, fCSSprintf, "%v", complex(float32(3), 4), "(3+4i)"}, + {scsDefault, fCSSprintln, "", complex(float64(5), 6), "(5+6i)\n"}, + {scsDefault, fCSErrorf, "%#v", uint16(65535), "(uint16)65535"}, + {scsDefault, fCSNewFormatter, "%v", uint32(4294967295), "4294967295"}, + {scsDefault, fErrorf, "%v", uint64(18446744073709551615), "18446744073709551615"}, + {scsDefault, fFprint, "", float32(3.14), "3.14"}, + {scsDefault, fFprintln, "", float64(6.28), "6.28\n"}, + {scsDefault, fPrint, "", true, "true"}, + {scsDefault, fPrintln, "", false, "false\n"}, + {scsDefault, fSdump, "", complex(-10, -20), "(complex128) (-10-20i)\n"}, + {scsDefault, fSprint, "", complex(-1, -2), "(-1-2i)"}, + {scsDefault, fSprintf, "%v", complex(float32(-3), -4), "(-3-4i)"}, + {scsDefault, fSprintln, "", complex(float64(-5), -6), "(-5-6i)\n"}, + {scsNoMethods, fCSFprint, "", ts, "test"}, + {scsNoMethods, fCSFprint, "", &ts, "<*>test"}, + {scsNoMethods, fCSFprint, "", tps, "test"}, + {scsNoMethods, fCSFprint, "", &tps, "<*>test"}, + {scsNoPmethods, fCSFprint, "", ts, "stringer test"}, + {scsNoPmethods, fCSFprint, "", &ts, "<*>stringer test"}, + {scsNoPmethods, fCSFprint, "", tps, "test"}, + {scsNoPmethods, fCSFprint, "", &tps, "<*>stringer test"}, + {scsMaxDepth, fCSFprint, "", dt, "{{} [] [] map[]}"}, + {scsMaxDepth, fCSFdump, "", dt, "(spew_test.depthTester) {\n" + + " ic: (spew_test.indirCir1) {\n \n },\n" + + " arr: ([1]string) (len=1 cap=1) {\n \n },\n" + + " slice: ([]string) (len=1 cap=1) {\n \n },\n" + + " m: (map[string]int) (len=1) {\n \n }\n}\n"}, + {scsContinue, fCSFprint, "", ts, "(stringer test) test"}, + {scsContinue, fCSFdump, "", ts, "(spew_test.stringer) " + + "(len=4) (stringer test) \"test\"\n"}, + {scsContinue, fCSFprint, "", te, "(error: 10) 10"}, + {scsContinue, fCSFdump, "", te, "(spew_test.customError) " + + "(error: 10) 10\n"}, + {scsNoPtrAddr, fCSFprint, "", tptr, "<*>{<*>{}}"}, + {scsNoPtrAddr, fCSSdump, "", tptr, "(*spew_test.ptrTester)({\ns: (*struct {})({\n})\n})\n"}, + {scsNoCap, fCSSdump, "", make([]string, 0, 10), "([]string) {\n}\n"}, + {scsNoCap, fCSSdump, "", make([]string, 1, 10), "([]string) (len=1) {\n(string) \"\"\n}\n"}, + } +} + +// TestSpew executes all of the tests described by spewTests. +func TestSpew(t *testing.T) { + initSpewTests() + + t.Logf("Running %d tests", len(spewTests)) + for i, test := range spewTests { + buf := new(bytes.Buffer) + switch test.f { + case fCSFdump: + test.cs.Fdump(buf, test.in) + + case fCSFprint: + test.cs.Fprint(buf, test.in) + + case fCSFprintf: + test.cs.Fprintf(buf, test.format, test.in) + + case fCSFprintln: + test.cs.Fprintln(buf, test.in) + + case fCSPrint: + b, err := redirStdout(func() { test.cs.Print(test.in) }) + if err != nil { + t.Errorf("%v #%d %v", test.f, i, err) + continue + } + buf.Write(b) + + case fCSPrintln: + b, err := redirStdout(func() { test.cs.Println(test.in) }) + if err != nil { + t.Errorf("%v #%d %v", test.f, i, err) + continue + } + buf.Write(b) + + case fCSSdump: + str := test.cs.Sdump(test.in) + buf.WriteString(str) + + case fCSSprint: + str := test.cs.Sprint(test.in) + buf.WriteString(str) + + case fCSSprintf: + str := test.cs.Sprintf(test.format, test.in) + buf.WriteString(str) + + case fCSSprintln: + str := test.cs.Sprintln(test.in) + buf.WriteString(str) + + case fCSErrorf: + err := test.cs.Errorf(test.format, test.in) + buf.WriteString(err.Error()) + + case fCSNewFormatter: + fmt.Fprintf(buf, test.format, test.cs.NewFormatter(test.in)) + + case fErrorf: + err := spew.Errorf(test.format, test.in) + buf.WriteString(err.Error()) + + case fFprint: + spew.Fprint(buf, test.in) + + case fFprintln: + spew.Fprintln(buf, test.in) + + case fPrint: + b, err := redirStdout(func() { spew.Print(test.in) }) + if err != nil { + t.Errorf("%v #%d %v", test.f, i, err) + continue + } + buf.Write(b) + + case fPrintln: + b, err := redirStdout(func() { spew.Println(test.in) }) + if err != nil { + t.Errorf("%v #%d %v", test.f, i, err) + continue + } + buf.Write(b) + + case fSdump: + str := spew.Sdump(test.in) + buf.WriteString(str) + + case fSprint: + str := spew.Sprint(test.in) + buf.WriteString(str) + + case fSprintf: + str := spew.Sprintf(test.format, test.in) + buf.WriteString(str) + + case fSprintln: + str := spew.Sprintln(test.in) + buf.WriteString(str) + + default: + t.Errorf("%v #%d unrecognized function", test.f, i) + continue + } + s := buf.String() + if test.want != s { + t.Errorf("ConfigState #%d\n got: %s want: %s", i, s, test.want) + continue + } + } +} diff --git a/vendor/github.com/davecgh/go-spew/spew/testdata/dumpcgo.go b/vendor/github.com/davecgh/go-spew/spew/testdata/dumpcgo.go new file mode 100644 index 00000000..5c87dd45 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/testdata/dumpcgo.go @@ -0,0 +1,82 @@ +// Copyright (c) 2013 Dave Collins +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when both cgo is supported and "-tags testcgo" is added to the go test +// command line. This code should really only be in the dumpcgo_test.go file, +// but unfortunately Go will not allow cgo in test files, so this is a +// workaround to allow cgo types to be tested. This configuration is used +// because spew itself does not require cgo to run even though it does handle +// certain cgo types specially. Rather than forcing all clients to require cgo +// and an external C compiler just to run the tests, this scheme makes them +// optional. +// +build cgo,testcgo + +package testdata + +/* +#include +typedef unsigned char custom_uchar_t; + +char *ncp = 0; +char *cp = "test"; +char ca[6] = {'t', 'e', 's', 't', '2', '\0'}; +unsigned char uca[6] = {'t', 'e', 's', 't', '3', '\0'}; +signed char sca[6] = {'t', 'e', 's', 't', '4', '\0'}; +uint8_t ui8ta[6] = {'t', 'e', 's', 't', '5', '\0'}; +custom_uchar_t tuca[6] = {'t', 'e', 's', 't', '6', '\0'}; +*/ +import "C" + +// GetCgoNullCharPointer returns a null char pointer via cgo. This is only +// used for tests. +func GetCgoNullCharPointer() interface{} { + return C.ncp +} + +// GetCgoCharPointer returns a char pointer via cgo. This is only used for +// tests. +func GetCgoCharPointer() interface{} { + return C.cp +} + +// GetCgoCharArray returns a char array via cgo and the array's len and cap. +// This is only used for tests. +func GetCgoCharArray() (interface{}, int, int) { + return C.ca, len(C.ca), cap(C.ca) +} + +// GetCgoUnsignedCharArray returns an unsigned char array via cgo and the +// array's len and cap. This is only used for tests. +func GetCgoUnsignedCharArray() (interface{}, int, int) { + return C.uca, len(C.uca), cap(C.uca) +} + +// GetCgoSignedCharArray returns a signed char array via cgo and the array's len +// and cap. This is only used for tests. +func GetCgoSignedCharArray() (interface{}, int, int) { + return C.sca, len(C.sca), cap(C.sca) +} + +// GetCgoUint8tArray returns a uint8_t array via cgo and the array's len and +// cap. This is only used for tests. +func GetCgoUint8tArray() (interface{}, int, int) { + return C.ui8ta, len(C.ui8ta), cap(C.ui8ta) +} + +// GetCgoTypdefedUnsignedCharArray returns a typedefed unsigned char array via +// cgo and the array's len and cap. This is only used for tests. +func GetCgoTypdefedUnsignedCharArray() (interface{}, int, int) { + return C.tuca, len(C.tuca), cap(C.tuca) +} diff --git a/vendor/github.com/davecgh/go-spew/test_coverage.txt b/vendor/github.com/davecgh/go-spew/test_coverage.txt new file mode 100644 index 00000000..2cd087a2 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/test_coverage.txt @@ -0,0 +1,61 @@ + +github.com/davecgh/go-spew/spew/dump.go dumpState.dump 100.00% (88/88) +github.com/davecgh/go-spew/spew/format.go formatState.format 100.00% (82/82) +github.com/davecgh/go-spew/spew/format.go formatState.formatPtr 100.00% (52/52) +github.com/davecgh/go-spew/spew/dump.go dumpState.dumpPtr 100.00% (44/44) +github.com/davecgh/go-spew/spew/dump.go dumpState.dumpSlice 100.00% (39/39) +github.com/davecgh/go-spew/spew/common.go handleMethods 100.00% (30/30) +github.com/davecgh/go-spew/spew/common.go printHexPtr 100.00% (18/18) +github.com/davecgh/go-spew/spew/common.go unsafeReflectValue 100.00% (13/13) +github.com/davecgh/go-spew/spew/format.go formatState.constructOrigFormat 100.00% (12/12) +github.com/davecgh/go-spew/spew/dump.go fdump 100.00% (11/11) +github.com/davecgh/go-spew/spew/format.go formatState.Format 100.00% (11/11) +github.com/davecgh/go-spew/spew/common.go init 100.00% (10/10) +github.com/davecgh/go-spew/spew/common.go printComplex 100.00% (9/9) +github.com/davecgh/go-spew/spew/common.go valuesSorter.Less 100.00% (8/8) +github.com/davecgh/go-spew/spew/format.go formatState.buildDefaultFormat 100.00% (7/7) +github.com/davecgh/go-spew/spew/format.go formatState.unpackValue 100.00% (5/5) +github.com/davecgh/go-spew/spew/dump.go dumpState.indent 100.00% (4/4) +github.com/davecgh/go-spew/spew/common.go catchPanic 100.00% (4/4) +github.com/davecgh/go-spew/spew/config.go ConfigState.convertArgs 100.00% (4/4) +github.com/davecgh/go-spew/spew/spew.go convertArgs 100.00% (4/4) +github.com/davecgh/go-spew/spew/format.go newFormatter 100.00% (3/3) +github.com/davecgh/go-spew/spew/dump.go Sdump 100.00% (3/3) +github.com/davecgh/go-spew/spew/common.go printBool 100.00% (3/3) +github.com/davecgh/go-spew/spew/common.go sortValues 100.00% (3/3) +github.com/davecgh/go-spew/spew/config.go ConfigState.Sdump 100.00% (3/3) +github.com/davecgh/go-spew/spew/dump.go dumpState.unpackValue 100.00% (3/3) +github.com/davecgh/go-spew/spew/spew.go Printf 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Println 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Sprint 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Sprintf 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Sprintln 100.00% (1/1) +github.com/davecgh/go-spew/spew/common.go printFloat 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go NewDefaultConfig 100.00% (1/1) +github.com/davecgh/go-spew/spew/common.go printInt 100.00% (1/1) +github.com/davecgh/go-spew/spew/common.go printUint 100.00% (1/1) +github.com/davecgh/go-spew/spew/common.go valuesSorter.Len 100.00% (1/1) +github.com/davecgh/go-spew/spew/common.go valuesSorter.Swap 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Errorf 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Fprint 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Fprintf 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Fprintln 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Print 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Printf 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Println 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Sprint 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Sprintf 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Sprintln 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.NewFormatter 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Fdump 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Dump 100.00% (1/1) +github.com/davecgh/go-spew/spew/dump.go Fdump 100.00% (1/1) +github.com/davecgh/go-spew/spew/dump.go Dump 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Fprintln 100.00% (1/1) +github.com/davecgh/go-spew/spew/format.go NewFormatter 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Errorf 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Fprint 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Fprintf 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Print 100.00% (1/1) +github.com/davecgh/go-spew/spew ------------------------------- 100.00% (505/505) + diff --git a/vendor/github.com/hashicorp/golang-lru/.gitignore b/vendor/github.com/hashicorp/golang-lru/.gitignore new file mode 100644 index 00000000..83656241 --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/.gitignore @@ -0,0 +1,23 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test diff --git a/vendor/github.com/hashicorp/golang-lru/2q.go b/vendor/github.com/hashicorp/golang-lru/2q.go new file mode 100644 index 00000000..e474cd07 --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/2q.go @@ -0,0 +1,223 @@ +package lru + +import ( + "fmt" + "sync" + + "github.com/hashicorp/golang-lru/simplelru" +) + +const ( + // Default2QRecentRatio is the ratio of the 2Q cache dedicated + // to recently added entries that have only been accessed once. + Default2QRecentRatio = 0.25 + + // Default2QGhostEntries is the default ratio of ghost + // entries kept to track entries recently evicted + Default2QGhostEntries = 0.50 +) + +// TwoQueueCache is a thread-safe fixed size 2Q cache. +// 2Q is an enhancement over the standard LRU cache +// in that it tracks both frequently and recently used +// entries separately. This avoids a burst in access to new +// entries from evicting frequently used entries. It adds some +// additional tracking overhead to the standard LRU cache, and is +// computationally about 2x the cost, and adds some metadata over +// head. The ARCCache is similar, but does not require setting any +// parameters. +type TwoQueueCache struct { + size int + recentSize int + + recent simplelru.LRUCache + frequent simplelru.LRUCache + recentEvict simplelru.LRUCache + lock sync.RWMutex +} + +// New2Q creates a new TwoQueueCache using the default +// values for the parameters. +func New2Q(size int) (*TwoQueueCache, error) { + return New2QParams(size, Default2QRecentRatio, Default2QGhostEntries) +} + +// New2QParams creates a new TwoQueueCache using the provided +// parameter values. +func New2QParams(size int, recentRatio float64, ghostRatio float64) (*TwoQueueCache, error) { + if size <= 0 { + return nil, fmt.Errorf("invalid size") + } + if recentRatio < 0.0 || recentRatio > 1.0 { + return nil, fmt.Errorf("invalid recent ratio") + } + if ghostRatio < 0.0 || ghostRatio > 1.0 { + return nil, fmt.Errorf("invalid ghost ratio") + } + + // Determine the sub-sizes + recentSize := int(float64(size) * recentRatio) + evictSize := int(float64(size) * ghostRatio) + + // Allocate the LRUs + recent, err := simplelru.NewLRU(size, nil) + if err != nil { + return nil, err + } + frequent, err := simplelru.NewLRU(size, nil) + if err != nil { + return nil, err + } + recentEvict, err := simplelru.NewLRU(evictSize, nil) + if err != nil { + return nil, err + } + + // Initialize the cache + c := &TwoQueueCache{ + size: size, + recentSize: recentSize, + recent: recent, + frequent: frequent, + recentEvict: recentEvict, + } + return c, nil +} + +// Get looks up a key's value from the cache. +func (c *TwoQueueCache) Get(key interface{}) (value interface{}, ok bool) { + c.lock.Lock() + defer c.lock.Unlock() + + // Check if this is a frequent value + if val, ok := c.frequent.Get(key); ok { + return val, ok + } + + // If the value is contained in recent, then we + // promote it to frequent + if val, ok := c.recent.Peek(key); ok { + c.recent.Remove(key) + c.frequent.Add(key, val) + return val, ok + } + + // No hit + return nil, false +} + +// Add adds a value to the cache. +func (c *TwoQueueCache) Add(key, value interface{}) { + c.lock.Lock() + defer c.lock.Unlock() + + // Check if the value is frequently used already, + // and just update the value + if c.frequent.Contains(key) { + c.frequent.Add(key, value) + return + } + + // Check if the value is recently used, and promote + // the value into the frequent list + if c.recent.Contains(key) { + c.recent.Remove(key) + c.frequent.Add(key, value) + return + } + + // If the value was recently evicted, add it to the + // frequently used list + if c.recentEvict.Contains(key) { + c.ensureSpace(true) + c.recentEvict.Remove(key) + c.frequent.Add(key, value) + return + } + + // Add to the recently seen list + c.ensureSpace(false) + c.recent.Add(key, value) + return +} + +// ensureSpace is used to ensure we have space in the cache +func (c *TwoQueueCache) ensureSpace(recentEvict bool) { + // If we have space, nothing to do + recentLen := c.recent.Len() + freqLen := c.frequent.Len() + if recentLen+freqLen < c.size { + return + } + + // If the recent buffer is larger than + // the target, evict from there + if recentLen > 0 && (recentLen > c.recentSize || (recentLen == c.recentSize && !recentEvict)) { + k, _, _ := c.recent.RemoveOldest() + c.recentEvict.Add(k, nil) + return + } + + // Remove from the frequent list otherwise + c.frequent.RemoveOldest() +} + +// Len returns the number of items in the cache. +func (c *TwoQueueCache) Len() int { + c.lock.RLock() + defer c.lock.RUnlock() + return c.recent.Len() + c.frequent.Len() +} + +// Keys returns a slice of the keys in the cache. +// The frequently used keys are first in the returned slice. +func (c *TwoQueueCache) Keys() []interface{} { + c.lock.RLock() + defer c.lock.RUnlock() + k1 := c.frequent.Keys() + k2 := c.recent.Keys() + return append(k1, k2...) +} + +// Remove removes the provided key from the cache. +func (c *TwoQueueCache) Remove(key interface{}) { + c.lock.Lock() + defer c.lock.Unlock() + if c.frequent.Remove(key) { + return + } + if c.recent.Remove(key) { + return + } + if c.recentEvict.Remove(key) { + return + } +} + +// Purge is used to completely clear the cache. +func (c *TwoQueueCache) Purge() { + c.lock.Lock() + defer c.lock.Unlock() + c.recent.Purge() + c.frequent.Purge() + c.recentEvict.Purge() +} + +// Contains is used to check if the cache contains a key +// without updating recency or frequency. +func (c *TwoQueueCache) Contains(key interface{}) bool { + c.lock.RLock() + defer c.lock.RUnlock() + return c.frequent.Contains(key) || c.recent.Contains(key) +} + +// Peek is used to inspect the cache value of a key +// without updating recency or frequency. +func (c *TwoQueueCache) Peek(key interface{}) (value interface{}, ok bool) { + c.lock.RLock() + defer c.lock.RUnlock() + if val, ok := c.frequent.Peek(key); ok { + return val, ok + } + return c.recent.Peek(key) +} diff --git a/vendor/github.com/hashicorp/golang-lru/2q_test.go b/vendor/github.com/hashicorp/golang-lru/2q_test.go new file mode 100644 index 00000000..1b0f3518 --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/2q_test.go @@ -0,0 +1,306 @@ +package lru + +import ( + "math/rand" + "testing" +) + +func Benchmark2Q_Rand(b *testing.B) { + l, err := New2Q(8192) + if err != nil { + b.Fatalf("err: %v", err) + } + + trace := make([]int64, b.N*2) + for i := 0; i < b.N*2; i++ { + trace[i] = rand.Int63() % 32768 + } + + b.ResetTimer() + + var hit, miss int + for i := 0; i < 2*b.N; i++ { + if i%2 == 0 { + l.Add(trace[i], trace[i]) + } else { + _, ok := l.Get(trace[i]) + if ok { + hit++ + } else { + miss++ + } + } + } + b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss)) +} + +func Benchmark2Q_Freq(b *testing.B) { + l, err := New2Q(8192) + if err != nil { + b.Fatalf("err: %v", err) + } + + trace := make([]int64, b.N*2) + for i := 0; i < b.N*2; i++ { + if i%2 == 0 { + trace[i] = rand.Int63() % 16384 + } else { + trace[i] = rand.Int63() % 32768 + } + } + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + l.Add(trace[i], trace[i]) + } + var hit, miss int + for i := 0; i < b.N; i++ { + _, ok := l.Get(trace[i]) + if ok { + hit++ + } else { + miss++ + } + } + b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss)) +} + +func Test2Q_RandomOps(t *testing.T) { + size := 128 + l, err := New2Q(128) + if err != nil { + t.Fatalf("err: %v", err) + } + + n := 200000 + for i := 0; i < n; i++ { + key := rand.Int63() % 512 + r := rand.Int63() + switch r % 3 { + case 0: + l.Add(key, key) + case 1: + l.Get(key) + case 2: + l.Remove(key) + } + + if l.recent.Len()+l.frequent.Len() > size { + t.Fatalf("bad: recent: %d freq: %d", + l.recent.Len(), l.frequent.Len()) + } + } +} + +func Test2Q_Get_RecentToFrequent(t *testing.T) { + l, err := New2Q(128) + if err != nil { + t.Fatalf("err: %v", err) + } + + // Touch all the entries, should be in t1 + for i := 0; i < 128; i++ { + l.Add(i, i) + } + if n := l.recent.Len(); n != 128 { + t.Fatalf("bad: %d", n) + } + if n := l.frequent.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + + // Get should upgrade to t2 + for i := 0; i < 128; i++ { + _, ok := l.Get(i) + if !ok { + t.Fatalf("missing: %d", i) + } + } + if n := l.recent.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + if n := l.frequent.Len(); n != 128 { + t.Fatalf("bad: %d", n) + } + + // Get be from t2 + for i := 0; i < 128; i++ { + _, ok := l.Get(i) + if !ok { + t.Fatalf("missing: %d", i) + } + } + if n := l.recent.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + if n := l.frequent.Len(); n != 128 { + t.Fatalf("bad: %d", n) + } +} + +func Test2Q_Add_RecentToFrequent(t *testing.T) { + l, err := New2Q(128) + if err != nil { + t.Fatalf("err: %v", err) + } + + // Add initially to recent + l.Add(1, 1) + if n := l.recent.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } + if n := l.frequent.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + + // Add should upgrade to frequent + l.Add(1, 1) + if n := l.recent.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + if n := l.frequent.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } + + // Add should remain in frequent + l.Add(1, 1) + if n := l.recent.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + if n := l.frequent.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } +} + +func Test2Q_Add_RecentEvict(t *testing.T) { + l, err := New2Q(4) + if err != nil { + t.Fatalf("err: %v", err) + } + + // Add 1,2,3,4,5 -> Evict 1 + l.Add(1, 1) + l.Add(2, 2) + l.Add(3, 3) + l.Add(4, 4) + l.Add(5, 5) + if n := l.recent.Len(); n != 4 { + t.Fatalf("bad: %d", n) + } + if n := l.recentEvict.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } + if n := l.frequent.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + + // Pull in the recently evicted + l.Add(1, 1) + if n := l.recent.Len(); n != 3 { + t.Fatalf("bad: %d", n) + } + if n := l.recentEvict.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } + if n := l.frequent.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } + + // Add 6, should cause another recent evict + l.Add(6, 6) + if n := l.recent.Len(); n != 3 { + t.Fatalf("bad: %d", n) + } + if n := l.recentEvict.Len(); n != 2 { + t.Fatalf("bad: %d", n) + } + if n := l.frequent.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } +} + +func Test2Q(t *testing.T) { + l, err := New2Q(128) + if err != nil { + t.Fatalf("err: %v", err) + } + + for i := 0; i < 256; i++ { + l.Add(i, i) + } + if l.Len() != 128 { + t.Fatalf("bad len: %v", l.Len()) + } + + for i, k := range l.Keys() { + if v, ok := l.Get(k); !ok || v != k || v != i+128 { + t.Fatalf("bad key: %v", k) + } + } + for i := 0; i < 128; i++ { + _, ok := l.Get(i) + if ok { + t.Fatalf("should be evicted") + } + } + for i := 128; i < 256; i++ { + _, ok := l.Get(i) + if !ok { + t.Fatalf("should not be evicted") + } + } + for i := 128; i < 192; i++ { + l.Remove(i) + _, ok := l.Get(i) + if ok { + t.Fatalf("should be deleted") + } + } + + l.Purge() + if l.Len() != 0 { + t.Fatalf("bad len: %v", l.Len()) + } + if _, ok := l.Get(200); ok { + t.Fatalf("should contain nothing") + } +} + +// Test that Contains doesn't update recent-ness +func Test2Q_Contains(t *testing.T) { + l, err := New2Q(2) + if err != nil { + t.Fatalf("err: %v", err) + } + + l.Add(1, 1) + l.Add(2, 2) + if !l.Contains(1) { + t.Errorf("1 should be contained") + } + + l.Add(3, 3) + if l.Contains(1) { + t.Errorf("Contains should not have updated recent-ness of 1") + } +} + +// Test that Peek doesn't update recent-ness +func Test2Q_Peek(t *testing.T) { + l, err := New2Q(2) + if err != nil { + t.Fatalf("err: %v", err) + } + + l.Add(1, 1) + l.Add(2, 2) + if v, ok := l.Peek(1); !ok || v != 1 { + t.Errorf("1 should be set to 1: %v, %v", v, ok) + } + + l.Add(3, 3) + if l.Contains(1) { + t.Errorf("should not have updated recent-ness of 1") + } +} diff --git a/vendor/github.com/hashicorp/golang-lru/LICENSE b/vendor/github.com/hashicorp/golang-lru/LICENSE new file mode 100644 index 00000000..be2cc4df --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/LICENSE @@ -0,0 +1,362 @@ +Mozilla Public License, version 2.0 + +1. Definitions + +1.1. "Contributor" + + means each individual or legal entity that creates, contributes to the + creation of, or owns Covered Software. + +1.2. "Contributor Version" + + means the combination of the Contributions of others (if any) used by a + Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + + means Source Code Form to which the initial Contributor has attached the + notice in Exhibit A, the Executable Form of such Source Code Form, and + Modifications of such Source Code Form, in each case including portions + thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + a. that the initial Contributor has attached the notice described in + Exhibit B to the Covered Software; or + + b. that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the terms of + a Secondary License. + +1.6. "Executable Form" + + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + + means a work that combines Covered Software with other material, in a + separate file or files, that is not Covered Software. + +1.8. "License" + + means this document. + +1.9. "Licensable" + + means having the right to grant, to the maximum extent possible, whether + at the time of the initial grant or subsequently, any and all of the + rights conveyed by this License. + +1.10. "Modifications" + + means any of the following: + + a. any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered Software; or + + b. any new file in Source Code Form that contains any Covered Software. + +1.11. "Patent Claims" of a Contributor + + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the License, + by the making, using, selling, offering for sale, having made, import, + or transfer of either its Contributions or its Contributor Version. + +1.12. "Secondary License" + + means either the GNU General Public License, Version 2.0, the GNU Lesser + General Public License, Version 2.1, the GNU Affero General Public + License, Version 3.0, or any later versions of those licenses. + +1.13. "Source Code Form" + + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that controls, is + controlled by, or is under common control with You. For purposes of this + definition, "control" means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + + +2. License Grants and Conditions + +2.1. Grants + + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + a. under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + + b. under Patent Claims of such Contributor to make, use, sell, offer for + sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + +2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + + a. for any code that a Contributor has removed from Covered Software; or + + b. for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + c. under Patent Claims infringed by Covered Software in the absence of + its Contributions. + + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + +2.5. Representation + + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights to + grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + +2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in + Section 2.1. + + +3. Responsibilities + +3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + +3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + a. such Covered Software must also be made available in Source Code Form, + as described in Section 3.1, and You must inform recipients of the + Executable Form how they can obtain a copy of such Source Code Form by + reasonable means in a timely manner, at a charge no more than the cost + of distribution to the recipient; and + + b. You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter the + recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + +3.4. Notices + + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, or + limitations of liability) contained within the Source Code Form of the + Covered Software, except that You may alter any license notices to the + extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + + If it is impossible for You to comply with any of the terms of this License + with respect to some or all of the Covered Software due to statute, + judicial order, or regulation then You must: (a) comply with the terms of + this License to the maximum extent possible; and (b) describe the + limitations and the code they affect. Such description must be placed in a + text file included with all distributions of the Covered Software under + this License. Except to the extent prohibited by statute or regulation, + such description must be sufficiently detailed for a recipient of ordinary + skill to be able to understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You + fail to comply with any of its terms. However, if You become compliant, + then the rights granted under this License from a particular Contributor + are reinstated (a) provisionally, unless and until such Contributor + explicitly and finally terminates Your grants, and (b) on an ongoing + basis, if such Contributor fails to notify You of the non-compliance by + some reasonable means prior to 60 days after You have come back into + compliance. Moreover, Your grants from a particular Contributor are + reinstated on an ongoing basis if such Contributor notifies You of the + non-compliance by some reasonable means, this is the first time You have + received notice of non-compliance with this License from such + Contributor, and You become compliant prior to 30 days after Your receipt + of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user + license agreements (excluding distributors and resellers) which have been + validly granted by You or Your distributors under this License prior to + termination shall survive termination. + +6. Disclaimer of Warranty + + Covered Software is provided under this License on an "as is" basis, + without warranty of any kind, either expressed, implied, or statutory, + including, without limitation, warranties that the Covered Software is free + of defects, merchantable, fit for a particular purpose or non-infringing. + The entire risk as to the quality and performance of the Covered Software + is with You. Should any Covered Software prove defective in any respect, + You (not any Contributor) assume the cost of any necessary servicing, + repair, or correction. This disclaimer of warranty constitutes an essential + part of this License. No use of any Covered Software is authorized under + this License except under this disclaimer. + +7. Limitation of Liability + + Under no circumstances and under no legal theory, whether tort (including + negligence), contract, or otherwise, shall any Contributor, or anyone who + distributes Covered Software as permitted above, be liable to You for any + direct, indirect, special, incidental, or consequential damages of any + character including, without limitation, damages for lost profits, loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses, even if such party shall have been + informed of the possibility of such damages. This limitation of liability + shall not apply to liability for death or personal injury resulting from + such party's negligence to the extent applicable law prohibits such + limitation. Some jurisdictions do not allow the exclusion or limitation of + incidental or consequential damages, so this exclusion and limitation may + not apply to You. + +8. Litigation + + Any litigation relating to this License may be brought only in the courts + of a jurisdiction where the defendant maintains its principal place of + business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. Nothing + in this Section shall prevent a party's ability to bring cross-claims or + counter-claims. + +9. Miscellaneous + + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides that + the language of a contract shall be construed against the drafter shall not + be used to construe this License against a Contributor. + + +10. Versions of the License + +10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + +10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + +10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses If You choose to distribute Source Code Form that is + Incompatible With Secondary Licenses under the terms of this version of + the License, the notice described in Exhibit B of this License must be + attached. + +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the + terms of the Mozilla Public License, v. + 2.0. If a copy of the MPL was not + distributed with this file, You can + obtain one at + http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, +then You may include the notice in a location (such as a LICENSE file in a +relevant directory) where a recipient would be likely to look for such a +notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice + + This Source Code Form is "Incompatible + With Secondary Licenses", as defined by + the Mozilla Public License, v. 2.0. diff --git a/vendor/github.com/hashicorp/golang-lru/README.md b/vendor/github.com/hashicorp/golang-lru/README.md new file mode 100644 index 00000000..33e58cfa --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/README.md @@ -0,0 +1,25 @@ +golang-lru +========== + +This provides the `lru` package which implements a fixed-size +thread safe LRU cache. It is based on the cache in Groupcache. + +Documentation +============= + +Full docs are available on [Godoc](http://godoc.org/github.com/hashicorp/golang-lru) + +Example +======= + +Using the LRU is very simple: + +```go +l, _ := New(128) +for i := 0; i < 256; i++ { + l.Add(i, nil) +} +if l.Len() != 128 { + panic(fmt.Sprintf("bad len: %v", l.Len())) +} +``` diff --git a/vendor/github.com/hashicorp/golang-lru/arc.go b/vendor/github.com/hashicorp/golang-lru/arc.go new file mode 100644 index 00000000..555225a2 --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/arc.go @@ -0,0 +1,257 @@ +package lru + +import ( + "sync" + + "github.com/hashicorp/golang-lru/simplelru" +) + +// ARCCache is a thread-safe fixed size Adaptive Replacement Cache (ARC). +// ARC is an enhancement over the standard LRU cache in that tracks both +// frequency and recency of use. This avoids a burst in access to new +// entries from evicting the frequently used older entries. It adds some +// additional tracking overhead to a standard LRU cache, computationally +// it is roughly 2x the cost, and the extra memory overhead is linear +// with the size of the cache. ARC has been patented by IBM, but is +// similar to the TwoQueueCache (2Q) which requires setting parameters. +type ARCCache struct { + size int // Size is the total capacity of the cache + p int // P is the dynamic preference towards T1 or T2 + + t1 simplelru.LRUCache // T1 is the LRU for recently accessed items + b1 simplelru.LRUCache // B1 is the LRU for evictions from t1 + + t2 simplelru.LRUCache // T2 is the LRU for frequently accessed items + b2 simplelru.LRUCache // B2 is the LRU for evictions from t2 + + lock sync.RWMutex +} + +// NewARC creates an ARC of the given size +func NewARC(size int) (*ARCCache, error) { + // Create the sub LRUs + b1, err := simplelru.NewLRU(size, nil) + if err != nil { + return nil, err + } + b2, err := simplelru.NewLRU(size, nil) + if err != nil { + return nil, err + } + t1, err := simplelru.NewLRU(size, nil) + if err != nil { + return nil, err + } + t2, err := simplelru.NewLRU(size, nil) + if err != nil { + return nil, err + } + + // Initialize the ARC + c := &ARCCache{ + size: size, + p: 0, + t1: t1, + b1: b1, + t2: t2, + b2: b2, + } + return c, nil +} + +// Get looks up a key's value from the cache. +func (c *ARCCache) Get(key interface{}) (value interface{}, ok bool) { + c.lock.Lock() + defer c.lock.Unlock() + + // If the value is contained in T1 (recent), then + // promote it to T2 (frequent) + if val, ok := c.t1.Peek(key); ok { + c.t1.Remove(key) + c.t2.Add(key, val) + return val, ok + } + + // Check if the value is contained in T2 (frequent) + if val, ok := c.t2.Get(key); ok { + return val, ok + } + + // No hit + return nil, false +} + +// Add adds a value to the cache. +func (c *ARCCache) Add(key, value interface{}) { + c.lock.Lock() + defer c.lock.Unlock() + + // Check if the value is contained in T1 (recent), and potentially + // promote it to frequent T2 + if c.t1.Contains(key) { + c.t1.Remove(key) + c.t2.Add(key, value) + return + } + + // Check if the value is already in T2 (frequent) and update it + if c.t2.Contains(key) { + c.t2.Add(key, value) + return + } + + // Check if this value was recently evicted as part of the + // recently used list + if c.b1.Contains(key) { + // T1 set is too small, increase P appropriately + delta := 1 + b1Len := c.b1.Len() + b2Len := c.b2.Len() + if b2Len > b1Len { + delta = b2Len / b1Len + } + if c.p+delta >= c.size { + c.p = c.size + } else { + c.p += delta + } + + // Potentially need to make room in the cache + if c.t1.Len()+c.t2.Len() >= c.size { + c.replace(false) + } + + // Remove from B1 + c.b1.Remove(key) + + // Add the key to the frequently used list + c.t2.Add(key, value) + return + } + + // Check if this value was recently evicted as part of the + // frequently used list + if c.b2.Contains(key) { + // T2 set is too small, decrease P appropriately + delta := 1 + b1Len := c.b1.Len() + b2Len := c.b2.Len() + if b1Len > b2Len { + delta = b1Len / b2Len + } + if delta >= c.p { + c.p = 0 + } else { + c.p -= delta + } + + // Potentially need to make room in the cache + if c.t1.Len()+c.t2.Len() >= c.size { + c.replace(true) + } + + // Remove from B2 + c.b2.Remove(key) + + // Add the key to the frequently used list + c.t2.Add(key, value) + return + } + + // Potentially need to make room in the cache + if c.t1.Len()+c.t2.Len() >= c.size { + c.replace(false) + } + + // Keep the size of the ghost buffers trim + if c.b1.Len() > c.size-c.p { + c.b1.RemoveOldest() + } + if c.b2.Len() > c.p { + c.b2.RemoveOldest() + } + + // Add to the recently seen list + c.t1.Add(key, value) + return +} + +// replace is used to adaptively evict from either T1 or T2 +// based on the current learned value of P +func (c *ARCCache) replace(b2ContainsKey bool) { + t1Len := c.t1.Len() + if t1Len > 0 && (t1Len > c.p || (t1Len == c.p && b2ContainsKey)) { + k, _, ok := c.t1.RemoveOldest() + if ok { + c.b1.Add(k, nil) + } + } else { + k, _, ok := c.t2.RemoveOldest() + if ok { + c.b2.Add(k, nil) + } + } +} + +// Len returns the number of cached entries +func (c *ARCCache) Len() int { + c.lock.RLock() + defer c.lock.RUnlock() + return c.t1.Len() + c.t2.Len() +} + +// Keys returns all the cached keys +func (c *ARCCache) Keys() []interface{} { + c.lock.RLock() + defer c.lock.RUnlock() + k1 := c.t1.Keys() + k2 := c.t2.Keys() + return append(k1, k2...) +} + +// Remove is used to purge a key from the cache +func (c *ARCCache) Remove(key interface{}) { + c.lock.Lock() + defer c.lock.Unlock() + if c.t1.Remove(key) { + return + } + if c.t2.Remove(key) { + return + } + if c.b1.Remove(key) { + return + } + if c.b2.Remove(key) { + return + } +} + +// Purge is used to clear the cache +func (c *ARCCache) Purge() { + c.lock.Lock() + defer c.lock.Unlock() + c.t1.Purge() + c.t2.Purge() + c.b1.Purge() + c.b2.Purge() +} + +// Contains is used to check if the cache contains a key +// without updating recency or frequency. +func (c *ARCCache) Contains(key interface{}) bool { + c.lock.RLock() + defer c.lock.RUnlock() + return c.t1.Contains(key) || c.t2.Contains(key) +} + +// Peek is used to inspect the cache value of a key +// without updating recency or frequency. +func (c *ARCCache) Peek(key interface{}) (value interface{}, ok bool) { + c.lock.RLock() + defer c.lock.RUnlock() + if val, ok := c.t1.Peek(key); ok { + return val, ok + } + return c.t2.Peek(key) +} diff --git a/vendor/github.com/hashicorp/golang-lru/arc_test.go b/vendor/github.com/hashicorp/golang-lru/arc_test.go new file mode 100644 index 00000000..e2d9b68c --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/arc_test.go @@ -0,0 +1,377 @@ +package lru + +import ( + "math/rand" + "testing" + "time" +) + +func init() { + rand.Seed(time.Now().Unix()) +} + +func BenchmarkARC_Rand(b *testing.B) { + l, err := NewARC(8192) + if err != nil { + b.Fatalf("err: %v", err) + } + + trace := make([]int64, b.N*2) + for i := 0; i < b.N*2; i++ { + trace[i] = rand.Int63() % 32768 + } + + b.ResetTimer() + + var hit, miss int + for i := 0; i < 2*b.N; i++ { + if i%2 == 0 { + l.Add(trace[i], trace[i]) + } else { + _, ok := l.Get(trace[i]) + if ok { + hit++ + } else { + miss++ + } + } + } + b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss)) +} + +func BenchmarkARC_Freq(b *testing.B) { + l, err := NewARC(8192) + if err != nil { + b.Fatalf("err: %v", err) + } + + trace := make([]int64, b.N*2) + for i := 0; i < b.N*2; i++ { + if i%2 == 0 { + trace[i] = rand.Int63() % 16384 + } else { + trace[i] = rand.Int63() % 32768 + } + } + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + l.Add(trace[i], trace[i]) + } + var hit, miss int + for i := 0; i < b.N; i++ { + _, ok := l.Get(trace[i]) + if ok { + hit++ + } else { + miss++ + } + } + b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss)) +} + +func TestARC_RandomOps(t *testing.T) { + size := 128 + l, err := NewARC(128) + if err != nil { + t.Fatalf("err: %v", err) + } + + n := 200000 + for i := 0; i < n; i++ { + key := rand.Int63() % 512 + r := rand.Int63() + switch r % 3 { + case 0: + l.Add(key, key) + case 1: + l.Get(key) + case 2: + l.Remove(key) + } + + if l.t1.Len()+l.t2.Len() > size { + t.Fatalf("bad: t1: %d t2: %d b1: %d b2: %d p: %d", + l.t1.Len(), l.t2.Len(), l.b1.Len(), l.b2.Len(), l.p) + } + if l.b1.Len()+l.b2.Len() > size { + t.Fatalf("bad: t1: %d t2: %d b1: %d b2: %d p: %d", + l.t1.Len(), l.t2.Len(), l.b1.Len(), l.b2.Len(), l.p) + } + } +} + +func TestARC_Get_RecentToFrequent(t *testing.T) { + l, err := NewARC(128) + if err != nil { + t.Fatalf("err: %v", err) + } + + // Touch all the entries, should be in t1 + for i := 0; i < 128; i++ { + l.Add(i, i) + } + if n := l.t1.Len(); n != 128 { + t.Fatalf("bad: %d", n) + } + if n := l.t2.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + + // Get should upgrade to t2 + for i := 0; i < 128; i++ { + _, ok := l.Get(i) + if !ok { + t.Fatalf("missing: %d", i) + } + } + if n := l.t1.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + if n := l.t2.Len(); n != 128 { + t.Fatalf("bad: %d", n) + } + + // Get be from t2 + for i := 0; i < 128; i++ { + _, ok := l.Get(i) + if !ok { + t.Fatalf("missing: %d", i) + } + } + if n := l.t1.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + if n := l.t2.Len(); n != 128 { + t.Fatalf("bad: %d", n) + } +} + +func TestARC_Add_RecentToFrequent(t *testing.T) { + l, err := NewARC(128) + if err != nil { + t.Fatalf("err: %v", err) + } + + // Add initially to t1 + l.Add(1, 1) + if n := l.t1.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } + if n := l.t2.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + + // Add should upgrade to t2 + l.Add(1, 1) + if n := l.t1.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + if n := l.t2.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } + + // Add should remain in t2 + l.Add(1, 1) + if n := l.t1.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + if n := l.t2.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } +} + +func TestARC_Adaptive(t *testing.T) { + l, err := NewARC(4) + if err != nil { + t.Fatalf("err: %v", err) + } + + // Fill t1 + for i := 0; i < 4; i++ { + l.Add(i, i) + } + if n := l.t1.Len(); n != 4 { + t.Fatalf("bad: %d", n) + } + + // Move to t2 + l.Get(0) + l.Get(1) + if n := l.t2.Len(); n != 2 { + t.Fatalf("bad: %d", n) + } + + // Evict from t1 + l.Add(4, 4) + if n := l.b1.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } + + // Current state + // t1 : (MRU) [4, 3] (LRU) + // t2 : (MRU) [1, 0] (LRU) + // b1 : (MRU) [2] (LRU) + // b2 : (MRU) [] (LRU) + + // Add 2, should cause hit on b1 + l.Add(2, 2) + if n := l.b1.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } + if l.p != 1 { + t.Fatalf("bad: %d", l.p) + } + if n := l.t2.Len(); n != 3 { + t.Fatalf("bad: %d", n) + } + + // Current state + // t1 : (MRU) [4] (LRU) + // t2 : (MRU) [2, 1, 0] (LRU) + // b1 : (MRU) [3] (LRU) + // b2 : (MRU) [] (LRU) + + // Add 4, should migrate to t2 + l.Add(4, 4) + if n := l.t1.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + if n := l.t2.Len(); n != 4 { + t.Fatalf("bad: %d", n) + } + + // Current state + // t1 : (MRU) [] (LRU) + // t2 : (MRU) [4, 2, 1, 0] (LRU) + // b1 : (MRU) [3] (LRU) + // b2 : (MRU) [] (LRU) + + // Add 4, should evict to b2 + l.Add(5, 5) + if n := l.t1.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } + if n := l.t2.Len(); n != 3 { + t.Fatalf("bad: %d", n) + } + if n := l.b2.Len(); n != 1 { + t.Fatalf("bad: %d", n) + } + + // Current state + // t1 : (MRU) [5] (LRU) + // t2 : (MRU) [4, 2, 1] (LRU) + // b1 : (MRU) [3] (LRU) + // b2 : (MRU) [0] (LRU) + + // Add 0, should decrease p + l.Add(0, 0) + if n := l.t1.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + if n := l.t2.Len(); n != 4 { + t.Fatalf("bad: %d", n) + } + if n := l.b1.Len(); n != 2 { + t.Fatalf("bad: %d", n) + } + if n := l.b2.Len(); n != 0 { + t.Fatalf("bad: %d", n) + } + if l.p != 0 { + t.Fatalf("bad: %d", l.p) + } + + // Current state + // t1 : (MRU) [] (LRU) + // t2 : (MRU) [0, 4, 2, 1] (LRU) + // b1 : (MRU) [5, 3] (LRU) + // b2 : (MRU) [0] (LRU) +} + +func TestARC(t *testing.T) { + l, err := NewARC(128) + if err != nil { + t.Fatalf("err: %v", err) + } + + for i := 0; i < 256; i++ { + l.Add(i, i) + } + if l.Len() != 128 { + t.Fatalf("bad len: %v", l.Len()) + } + + for i, k := range l.Keys() { + if v, ok := l.Get(k); !ok || v != k || v != i+128 { + t.Fatalf("bad key: %v", k) + } + } + for i := 0; i < 128; i++ { + _, ok := l.Get(i) + if ok { + t.Fatalf("should be evicted") + } + } + for i := 128; i < 256; i++ { + _, ok := l.Get(i) + if !ok { + t.Fatalf("should not be evicted") + } + } + for i := 128; i < 192; i++ { + l.Remove(i) + _, ok := l.Get(i) + if ok { + t.Fatalf("should be deleted") + } + } + + l.Purge() + if l.Len() != 0 { + t.Fatalf("bad len: %v", l.Len()) + } + if _, ok := l.Get(200); ok { + t.Fatalf("should contain nothing") + } +} + +// Test that Contains doesn't update recent-ness +func TestARC_Contains(t *testing.T) { + l, err := NewARC(2) + if err != nil { + t.Fatalf("err: %v", err) + } + + l.Add(1, 1) + l.Add(2, 2) + if !l.Contains(1) { + t.Errorf("1 should be contained") + } + + l.Add(3, 3) + if l.Contains(1) { + t.Errorf("Contains should not have updated recent-ness of 1") + } +} + +// Test that Peek doesn't update recent-ness +func TestARC_Peek(t *testing.T) { + l, err := NewARC(2) + if err != nil { + t.Fatalf("err: %v", err) + } + + l.Add(1, 1) + l.Add(2, 2) + if v, ok := l.Peek(1); !ok || v != 1 { + t.Errorf("1 should be set to 1: %v, %v", v, ok) + } + + l.Add(3, 3) + if l.Contains(1) { + t.Errorf("should not have updated recent-ness of 1") + } +} diff --git a/vendor/github.com/hashicorp/golang-lru/doc.go b/vendor/github.com/hashicorp/golang-lru/doc.go new file mode 100644 index 00000000..2547df97 --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/doc.go @@ -0,0 +1,21 @@ +// Package lru provides three different LRU caches of varying sophistication. +// +// Cache is a simple LRU cache. It is based on the +// LRU implementation in groupcache: +// https://github.com/golang/groupcache/tree/master/lru +// +// TwoQueueCache tracks frequently used and recently used entries separately. +// This avoids a burst of accesses from taking out frequently used entries, +// at the cost of about 2x computational overhead and some extra bookkeeping. +// +// ARCCache is an adaptive replacement cache. It tracks recent evictions as +// well as recent usage in both the frequent and recent caches. Its +// computational overhead is comparable to TwoQueueCache, but the memory +// overhead is linear with the size of the cache. +// +// ARC has been patented by IBM, so do not use it if that is problematic for +// your program. +// +// All caches in this package take locks while operating, and are therefore +// thread-safe for consumers. +package lru diff --git a/vendor/github.com/hashicorp/golang-lru/go.mod b/vendor/github.com/hashicorp/golang-lru/go.mod new file mode 100644 index 00000000..824cb97e --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/go.mod @@ -0,0 +1 @@ +module github.com/hashicorp/golang-lru diff --git a/vendor/github.com/hashicorp/golang-lru/lru.go b/vendor/github.com/hashicorp/golang-lru/lru.go new file mode 100644 index 00000000..c8d9b0a2 --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/lru.go @@ -0,0 +1,110 @@ +package lru + +import ( + "sync" + + "github.com/hashicorp/golang-lru/simplelru" +) + +// Cache is a thread-safe fixed size LRU cache. +type Cache struct { + lru simplelru.LRUCache + lock sync.RWMutex +} + +// New creates an LRU of the given size. +func New(size int) (*Cache, error) { + return NewWithEvict(size, nil) +} + +// NewWithEvict constructs a fixed size cache with the given eviction +// callback. +func NewWithEvict(size int, onEvicted func(key interface{}, value interface{})) (*Cache, error) { + lru, err := simplelru.NewLRU(size, simplelru.EvictCallback(onEvicted)) + if err != nil { + return nil, err + } + c := &Cache{ + lru: lru, + } + return c, nil +} + +// Purge is used to completely clear the cache. +func (c *Cache) Purge() { + c.lock.Lock() + c.lru.Purge() + c.lock.Unlock() +} + +// Add adds a value to the cache. Returns true if an eviction occurred. +func (c *Cache) Add(key, value interface{}) (evicted bool) { + c.lock.Lock() + defer c.lock.Unlock() + return c.lru.Add(key, value) +} + +// Get looks up a key's value from the cache. +func (c *Cache) Get(key interface{}) (value interface{}, ok bool) { + c.lock.Lock() + defer c.lock.Unlock() + return c.lru.Get(key) +} + +// Contains checks if a key is in the cache, without updating the +// recent-ness or deleting it for being stale. +func (c *Cache) Contains(key interface{}) bool { + c.lock.RLock() + defer c.lock.RUnlock() + return c.lru.Contains(key) +} + +// Peek returns the key value (or undefined if not found) without updating +// the "recently used"-ness of the key. +func (c *Cache) Peek(key interface{}) (value interface{}, ok bool) { + c.lock.RLock() + defer c.lock.RUnlock() + return c.lru.Peek(key) +} + +// ContainsOrAdd checks if a key is in the cache without updating the +// recent-ness or deleting it for being stale, and if not, adds the value. +// Returns whether found and whether an eviction occurred. +func (c *Cache) ContainsOrAdd(key, value interface{}) (ok, evicted bool) { + c.lock.Lock() + defer c.lock.Unlock() + + if c.lru.Contains(key) { + return true, false + } + evicted = c.lru.Add(key, value) + return false, evicted +} + +// Remove removes the provided key from the cache. +func (c *Cache) Remove(key interface{}) { + c.lock.Lock() + c.lru.Remove(key) + c.lock.Unlock() +} + +// RemoveOldest removes the oldest item from the cache. +func (c *Cache) RemoveOldest() { + c.lock.Lock() + c.lru.RemoveOldest() + c.lock.Unlock() +} + +// Keys returns a slice of the keys in the cache, from oldest to newest. +func (c *Cache) Keys() []interface{} { + c.lock.RLock() + defer c.lock.RUnlock() + return c.lru.Keys() +} + +// Len returns the number of items in the cache. +func (c *Cache) Len() int { + c.lock.RLock() + defer c.lock.RUnlock() + return c.lru.Len() +} diff --git a/vendor/github.com/hashicorp/golang-lru/lru_test.go b/vendor/github.com/hashicorp/golang-lru/lru_test.go new file mode 100644 index 00000000..e7e23505 --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/lru_test.go @@ -0,0 +1,221 @@ +package lru + +import ( + "math/rand" + "testing" +) + +func BenchmarkLRU_Rand(b *testing.B) { + l, err := New(8192) + if err != nil { + b.Fatalf("err: %v", err) + } + + trace := make([]int64, b.N*2) + for i := 0; i < b.N*2; i++ { + trace[i] = rand.Int63() % 32768 + } + + b.ResetTimer() + + var hit, miss int + for i := 0; i < 2*b.N; i++ { + if i%2 == 0 { + l.Add(trace[i], trace[i]) + } else { + _, ok := l.Get(trace[i]) + if ok { + hit++ + } else { + miss++ + } + } + } + b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss)) +} + +func BenchmarkLRU_Freq(b *testing.B) { + l, err := New(8192) + if err != nil { + b.Fatalf("err: %v", err) + } + + trace := make([]int64, b.N*2) + for i := 0; i < b.N*2; i++ { + if i%2 == 0 { + trace[i] = rand.Int63() % 16384 + } else { + trace[i] = rand.Int63() % 32768 + } + } + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + l.Add(trace[i], trace[i]) + } + var hit, miss int + for i := 0; i < b.N; i++ { + _, ok := l.Get(trace[i]) + if ok { + hit++ + } else { + miss++ + } + } + b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss)) +} + +func TestLRU(t *testing.T) { + evictCounter := 0 + onEvicted := func(k interface{}, v interface{}) { + if k != v { + t.Fatalf("Evict values not equal (%v!=%v)", k, v) + } + evictCounter++ + } + l, err := NewWithEvict(128, onEvicted) + if err != nil { + t.Fatalf("err: %v", err) + } + + for i := 0; i < 256; i++ { + l.Add(i, i) + } + if l.Len() != 128 { + t.Fatalf("bad len: %v", l.Len()) + } + + if evictCounter != 128 { + t.Fatalf("bad evict count: %v", evictCounter) + } + + for i, k := range l.Keys() { + if v, ok := l.Get(k); !ok || v != k || v != i+128 { + t.Fatalf("bad key: %v", k) + } + } + for i := 0; i < 128; i++ { + _, ok := l.Get(i) + if ok { + t.Fatalf("should be evicted") + } + } + for i := 128; i < 256; i++ { + _, ok := l.Get(i) + if !ok { + t.Fatalf("should not be evicted") + } + } + for i := 128; i < 192; i++ { + l.Remove(i) + _, ok := l.Get(i) + if ok { + t.Fatalf("should be deleted") + } + } + + l.Get(192) // expect 192 to be last key in l.Keys() + + for i, k := range l.Keys() { + if (i < 63 && k != i+193) || (i == 63 && k != 192) { + t.Fatalf("out of order key: %v", k) + } + } + + l.Purge() + if l.Len() != 0 { + t.Fatalf("bad len: %v", l.Len()) + } + if _, ok := l.Get(200); ok { + t.Fatalf("should contain nothing") + } +} + +// test that Add returns true/false if an eviction occurred +func TestLRUAdd(t *testing.T) { + evictCounter := 0 + onEvicted := func(k interface{}, v interface{}) { + evictCounter++ + } + + l, err := NewWithEvict(1, onEvicted) + if err != nil { + t.Fatalf("err: %v", err) + } + + if l.Add(1, 1) == true || evictCounter != 0 { + t.Errorf("should not have an eviction") + } + if l.Add(2, 2) == false || evictCounter != 1 { + t.Errorf("should have an eviction") + } +} + +// test that Contains doesn't update recent-ness +func TestLRUContains(t *testing.T) { + l, err := New(2) + if err != nil { + t.Fatalf("err: %v", err) + } + + l.Add(1, 1) + l.Add(2, 2) + if !l.Contains(1) { + t.Errorf("1 should be contained") + } + + l.Add(3, 3) + if l.Contains(1) { + t.Errorf("Contains should not have updated recent-ness of 1") + } +} + +// test that Contains doesn't update recent-ness +func TestLRUContainsOrAdd(t *testing.T) { + l, err := New(2) + if err != nil { + t.Fatalf("err: %v", err) + } + + l.Add(1, 1) + l.Add(2, 2) + contains, evict := l.ContainsOrAdd(1, 1) + if !contains { + t.Errorf("1 should be contained") + } + if evict { + t.Errorf("nothing should be evicted here") + } + + l.Add(3, 3) + contains, evict = l.ContainsOrAdd(1, 1) + if contains { + t.Errorf("1 should not have been contained") + } + if !evict { + t.Errorf("an eviction should have occurred") + } + if !l.Contains(1) { + t.Errorf("now 1 should be contained") + } +} + +// test that Peek doesn't update recent-ness +func TestLRUPeek(t *testing.T) { + l, err := New(2) + if err != nil { + t.Fatalf("err: %v", err) + } + + l.Add(1, 1) + l.Add(2, 2) + if v, ok := l.Peek(1); !ok || v != 1 { + t.Errorf("1 should be set to 1: %v, %v", v, ok) + } + + l.Add(3, 3) + if l.Contains(1) { + t.Errorf("should not have updated recent-ness of 1") + } +} diff --git a/vendor/github.com/hashicorp/golang-lru/simplelru/lru.go b/vendor/github.com/hashicorp/golang-lru/simplelru/lru.go new file mode 100644 index 00000000..5673773b --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/simplelru/lru.go @@ -0,0 +1,161 @@ +package simplelru + +import ( + "container/list" + "errors" +) + +// EvictCallback is used to get a callback when a cache entry is evicted +type EvictCallback func(key interface{}, value interface{}) + +// LRU implements a non-thread safe fixed size LRU cache +type LRU struct { + size int + evictList *list.List + items map[interface{}]*list.Element + onEvict EvictCallback +} + +// entry is used to hold a value in the evictList +type entry struct { + key interface{} + value interface{} +} + +// NewLRU constructs an LRU of the given size +func NewLRU(size int, onEvict EvictCallback) (*LRU, error) { + if size <= 0 { + return nil, errors.New("Must provide a positive size") + } + c := &LRU{ + size: size, + evictList: list.New(), + items: make(map[interface{}]*list.Element), + onEvict: onEvict, + } + return c, nil +} + +// Purge is used to completely clear the cache. +func (c *LRU) Purge() { + for k, v := range c.items { + if c.onEvict != nil { + c.onEvict(k, v.Value.(*entry).value) + } + delete(c.items, k) + } + c.evictList.Init() +} + +// Add adds a value to the cache. Returns true if an eviction occurred. +func (c *LRU) Add(key, value interface{}) (evicted bool) { + // Check for existing item + if ent, ok := c.items[key]; ok { + c.evictList.MoveToFront(ent) + ent.Value.(*entry).value = value + return false + } + + // Add new item + ent := &entry{key, value} + entry := c.evictList.PushFront(ent) + c.items[key] = entry + + evict := c.evictList.Len() > c.size + // Verify size not exceeded + if evict { + c.removeOldest() + } + return evict +} + +// Get looks up a key's value from the cache. +func (c *LRU) Get(key interface{}) (value interface{}, ok bool) { + if ent, ok := c.items[key]; ok { + c.evictList.MoveToFront(ent) + return ent.Value.(*entry).value, true + } + return +} + +// Contains checks if a key is in the cache, without updating the recent-ness +// or deleting it for being stale. +func (c *LRU) Contains(key interface{}) (ok bool) { + _, ok = c.items[key] + return ok +} + +// Peek returns the key value (or undefined if not found) without updating +// the "recently used"-ness of the key. +func (c *LRU) Peek(key interface{}) (value interface{}, ok bool) { + var ent *list.Element + if ent, ok = c.items[key]; ok { + return ent.Value.(*entry).value, true + } + return nil, ok +} + +// Remove removes the provided key from the cache, returning if the +// key was contained. +func (c *LRU) Remove(key interface{}) (present bool) { + if ent, ok := c.items[key]; ok { + c.removeElement(ent) + return true + } + return false +} + +// RemoveOldest removes the oldest item from the cache. +func (c *LRU) RemoveOldest() (key interface{}, value interface{}, ok bool) { + ent := c.evictList.Back() + if ent != nil { + c.removeElement(ent) + kv := ent.Value.(*entry) + return kv.key, kv.value, true + } + return nil, nil, false +} + +// GetOldest returns the oldest entry +func (c *LRU) GetOldest() (key interface{}, value interface{}, ok bool) { + ent := c.evictList.Back() + if ent != nil { + kv := ent.Value.(*entry) + return kv.key, kv.value, true + } + return nil, nil, false +} + +// Keys returns a slice of the keys in the cache, from oldest to newest. +func (c *LRU) Keys() []interface{} { + keys := make([]interface{}, len(c.items)) + i := 0 + for ent := c.evictList.Back(); ent != nil; ent = ent.Prev() { + keys[i] = ent.Value.(*entry).key + i++ + } + return keys +} + +// Len returns the number of items in the cache. +func (c *LRU) Len() int { + return c.evictList.Len() +} + +// removeOldest removes the oldest item from the cache. +func (c *LRU) removeOldest() { + ent := c.evictList.Back() + if ent != nil { + c.removeElement(ent) + } +} + +// removeElement is used to remove a given list element from the cache +func (c *LRU) removeElement(e *list.Element) { + c.evictList.Remove(e) + kv := e.Value.(*entry) + delete(c.items, kv.key) + if c.onEvict != nil { + c.onEvict(kv.key, kv.value) + } +} diff --git a/vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go b/vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go new file mode 100644 index 00000000..74c70774 --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go @@ -0,0 +1,36 @@ +package simplelru + +// LRUCache is the interface for simple LRU cache. +type LRUCache interface { + // Adds a value to the cache, returns true if an eviction occurred and + // updates the "recently used"-ness of the key. + Add(key, value interface{}) bool + + // Returns key's value from the cache and + // updates the "recently used"-ness of the key. #value, isFound + Get(key interface{}) (value interface{}, ok bool) + + // Check if a key exsists in cache without updating the recent-ness. + Contains(key interface{}) (ok bool) + + // Returns key's value without updating the "recently used"-ness of the key. + Peek(key interface{}) (value interface{}, ok bool) + + // Removes a key from the cache. + Remove(key interface{}) bool + + // Removes the oldest entry from cache. + RemoveOldest() (interface{}, interface{}, bool) + + // Returns the oldest entry from the cache. #key, value, isFound + GetOldest() (interface{}, interface{}, bool) + + // Returns a slice of the keys in the cache, from oldest to newest. + Keys() []interface{} + + // Returns the number of items in the cache. + Len() int + + // Clear all cache entries + Purge() +} diff --git a/vendor/github.com/hashicorp/golang-lru/simplelru/lru_test.go b/vendor/github.com/hashicorp/golang-lru/simplelru/lru_test.go new file mode 100644 index 00000000..ca5676e1 --- /dev/null +++ b/vendor/github.com/hashicorp/golang-lru/simplelru/lru_test.go @@ -0,0 +1,167 @@ +package simplelru + +import "testing" + +func TestLRU(t *testing.T) { + evictCounter := 0 + onEvicted := func(k interface{}, v interface{}) { + if k != v { + t.Fatalf("Evict values not equal (%v!=%v)", k, v) + } + evictCounter++ + } + l, err := NewLRU(128, onEvicted) + if err != nil { + t.Fatalf("err: %v", err) + } + + for i := 0; i < 256; i++ { + l.Add(i, i) + } + if l.Len() != 128 { + t.Fatalf("bad len: %v", l.Len()) + } + + if evictCounter != 128 { + t.Fatalf("bad evict count: %v", evictCounter) + } + + for i, k := range l.Keys() { + if v, ok := l.Get(k); !ok || v != k || v != i+128 { + t.Fatalf("bad key: %v", k) + } + } + for i := 0; i < 128; i++ { + _, ok := l.Get(i) + if ok { + t.Fatalf("should be evicted") + } + } + for i := 128; i < 256; i++ { + _, ok := l.Get(i) + if !ok { + t.Fatalf("should not be evicted") + } + } + for i := 128; i < 192; i++ { + ok := l.Remove(i) + if !ok { + t.Fatalf("should be contained") + } + ok = l.Remove(i) + if ok { + t.Fatalf("should not be contained") + } + _, ok = l.Get(i) + if ok { + t.Fatalf("should be deleted") + } + } + + l.Get(192) // expect 192 to be last key in l.Keys() + + for i, k := range l.Keys() { + if (i < 63 && k != i+193) || (i == 63 && k != 192) { + t.Fatalf("out of order key: %v", k) + } + } + + l.Purge() + if l.Len() != 0 { + t.Fatalf("bad len: %v", l.Len()) + } + if _, ok := l.Get(200); ok { + t.Fatalf("should contain nothing") + } +} + +func TestLRU_GetOldest_RemoveOldest(t *testing.T) { + l, err := NewLRU(128, nil) + if err != nil { + t.Fatalf("err: %v", err) + } + for i := 0; i < 256; i++ { + l.Add(i, i) + } + k, _, ok := l.GetOldest() + if !ok { + t.Fatalf("missing") + } + if k.(int) != 128 { + t.Fatalf("bad: %v", k) + } + + k, _, ok = l.RemoveOldest() + if !ok { + t.Fatalf("missing") + } + if k.(int) != 128 { + t.Fatalf("bad: %v", k) + } + + k, _, ok = l.RemoveOldest() + if !ok { + t.Fatalf("missing") + } + if k.(int) != 129 { + t.Fatalf("bad: %v", k) + } +} + +// Test that Add returns true/false if an eviction occurred +func TestLRU_Add(t *testing.T) { + evictCounter := 0 + onEvicted := func(k interface{}, v interface{}) { + evictCounter++ + } + + l, err := NewLRU(1, onEvicted) + if err != nil { + t.Fatalf("err: %v", err) + } + + if l.Add(1, 1) == true || evictCounter != 0 { + t.Errorf("should not have an eviction") + } + if l.Add(2, 2) == false || evictCounter != 1 { + t.Errorf("should have an eviction") + } +} + +// Test that Contains doesn't update recent-ness +func TestLRU_Contains(t *testing.T) { + l, err := NewLRU(2, nil) + if err != nil { + t.Fatalf("err: %v", err) + } + + l.Add(1, 1) + l.Add(2, 2) + if !l.Contains(1) { + t.Errorf("1 should be contained") + } + + l.Add(3, 3) + if l.Contains(1) { + t.Errorf("Contains should not have updated recent-ness of 1") + } +} + +// Test that Peek doesn't update recent-ness +func TestLRU_Peek(t *testing.T) { + l, err := NewLRU(2, nil) + if err != nil { + t.Fatalf("err: %v", err) + } + + l.Add(1, 1) + l.Add(2, 2) + if v, ok := l.Peek(1); !ok || v != 1 { + t.Errorf("1 should be set to 1: %v, %v", v, ok) + } + + l.Add(3, 3) + if l.Contains(1) { + t.Errorf("should not have updated recent-ness of 1") + } +} diff --git a/vendor/golang.org/x/tools/.gitattributes b/vendor/golang.org/x/tools/.gitattributes new file mode 100644 index 00000000..d2f212e5 --- /dev/null +++ b/vendor/golang.org/x/tools/.gitattributes @@ -0,0 +1,10 @@ +# Treat all files in this repo as binary, with no git magic updating +# line endings. Windows users contributing to Go will need to use a +# modern version of git and editors capable of LF line endings. +# +# We'll prevent accidental CRLF line endings from entering the repo +# via the git-review gofmt checks. +# +# See golang.org/issue/9281 + +* -text diff --git a/vendor/golang.org/x/tools/.gitignore b/vendor/golang.org/x/tools/.gitignore new file mode 100644 index 00000000..5a9d62ef --- /dev/null +++ b/vendor/golang.org/x/tools/.gitignore @@ -0,0 +1,2 @@ +# Add no patterns to .gitignore except for files generated by the build. +last-change diff --git a/vendor/golang.org/x/tools/AUTHORS b/vendor/golang.org/x/tools/AUTHORS new file mode 100644 index 00000000..15167cd7 --- /dev/null +++ b/vendor/golang.org/x/tools/AUTHORS @@ -0,0 +1,3 @@ +# This source code refers to The Go Authors for copyright purposes. +# The master list of authors is in the main Go distribution, +# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/tools/CONTRIBUTING.md b/vendor/golang.org/x/tools/CONTRIBUTING.md new file mode 100644 index 00000000..d0485e88 --- /dev/null +++ b/vendor/golang.org/x/tools/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# Contributing to Go + +Go is an open source project. + +It is the work of hundreds of contributors. We appreciate your help! + +## Filing issues + +When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions: + +1. What version of Go are you using (`go version`)? +2. What operating system and processor architecture are you using? +3. What did you do? +4. What did you expect to see? +5. What did you see instead? + +General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. +The gophers there will answer or ask you to file an issue if you've tripped over a bug. + +## Contributing code + +Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) +before sending patches. + +Unless otherwise noted, the Go source files are distributed under +the BSD-style license found in the LICENSE file. diff --git a/vendor/golang.org/x/tools/CONTRIBUTORS b/vendor/golang.org/x/tools/CONTRIBUTORS new file mode 100644 index 00000000..1c4577e9 --- /dev/null +++ b/vendor/golang.org/x/tools/CONTRIBUTORS @@ -0,0 +1,3 @@ +# This source code was written by the Go contributors. +# The master list of contributors is in the main Go distribution, +# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/tools/LICENSE b/vendor/golang.org/x/tools/LICENSE new file mode 100644 index 00000000..6a66aea5 --- /dev/null +++ b/vendor/golang.org/x/tools/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/golang.org/x/tools/PATENTS b/vendor/golang.org/x/tools/PATENTS new file mode 100644 index 00000000..73309904 --- /dev/null +++ b/vendor/golang.org/x/tools/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Go project. + +Google hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) +patent license to make, have made, use, offer to sell, sell, import, +transfer and otherwise run, modify and propagate the contents of this +implementation of Go, where such license applies only to those patent +claims, both currently owned or controlled by Google and acquired in +the future, licensable by Google that are necessarily infringed by this +implementation of Go. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute or +order or agree to the institution of patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging +that this implementation of Go or any code incorporated within this +implementation of Go constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of Go +shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/tools/README.md b/vendor/golang.org/x/tools/README.md new file mode 100644 index 00000000..20be9e1a --- /dev/null +++ b/vendor/golang.org/x/tools/README.md @@ -0,0 +1,27 @@ +# Go Tools + +This subrepository holds the source for various packages and tools that support +the Go programming language. + +Some of the tools, `godoc` and `vet` for example, are included in binary Go +distributions. + +Others, including the Go `guru` and the test coverage tool, can be fetched with +`go get`. + +Packages include a type-checker for Go and an implementation of the +Static Single Assignment form (SSA) representation for Go programs. + +## Download/Install + +The easiest way to install is to run `go get -u golang.org/x/tools/...`. You can +also manually git clone the repository to `$GOPATH/src/golang.org/x/tools`. + +## Report Issues / Send Patches + +This repository uses Gerrit for code changes. To learn how to submit changes to +this repository, see https://golang.org/doc/contribute.html. + +The main issue tracker for the tools repository is located at +https://github.com/golang/go/issues. Prefix your issue with "x/tools/(your +subdir):" in the subject line, so it is easy to find. diff --git a/vendor/golang.org/x/tools/benchmark/parse/parse.go b/vendor/golang.org/x/tools/benchmark/parse/parse.go new file mode 100644 index 00000000..b37e6f0f --- /dev/null +++ b/vendor/golang.org/x/tools/benchmark/parse/parse.go @@ -0,0 +1,131 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package parse provides support for parsing benchmark results as +// generated by 'go test -bench'. +package parse // import "golang.org/x/tools/benchmark/parse" + +import ( + "bufio" + "bytes" + "fmt" + "io" + "strconv" + "strings" +) + +// Flags used by Benchmark.Measured to indicate +// which measurements a Benchmark contains. +const ( + NsPerOp = 1 << iota + MBPerS + AllocedBytesPerOp + AllocsPerOp +) + +// Benchmark is one run of a single benchmark. +type Benchmark struct { + Name string // benchmark name + N int // number of iterations + NsPerOp float64 // nanoseconds per iteration + AllocedBytesPerOp uint64 // bytes allocated per iteration + AllocsPerOp uint64 // allocs per iteration + MBPerS float64 // MB processed per second + Measured int // which measurements were recorded + Ord int // ordinal position within a benchmark run +} + +// ParseLine extracts a Benchmark from a single line of testing.B +// output. +func ParseLine(line string) (*Benchmark, error) { + fields := strings.Fields(line) + + // Two required, positional fields: Name and iterations. + if len(fields) < 2 { + return nil, fmt.Errorf("two fields required, have %d", len(fields)) + } + if !strings.HasPrefix(fields[0], "Benchmark") { + return nil, fmt.Errorf(`first field does not start with "Benchmark"`) + } + n, err := strconv.Atoi(fields[1]) + if err != nil { + return nil, err + } + b := &Benchmark{Name: fields[0], N: n} + + // Parse any remaining pairs of fields; we've parsed one pair already. + for i := 1; i < len(fields)/2; i++ { + b.parseMeasurement(fields[i*2], fields[i*2+1]) + } + return b, nil +} + +func (b *Benchmark) parseMeasurement(quant string, unit string) { + switch unit { + case "ns/op": + if f, err := strconv.ParseFloat(quant, 64); err == nil { + b.NsPerOp = f + b.Measured |= NsPerOp + } + case "MB/s": + if f, err := strconv.ParseFloat(quant, 64); err == nil { + b.MBPerS = f + b.Measured |= MBPerS + } + case "B/op": + if i, err := strconv.ParseUint(quant, 10, 64); err == nil { + b.AllocedBytesPerOp = i + b.Measured |= AllocedBytesPerOp + } + case "allocs/op": + if i, err := strconv.ParseUint(quant, 10, 64); err == nil { + b.AllocsPerOp = i + b.Measured |= AllocsPerOp + } + } +} + +func (b *Benchmark) String() string { + buf := new(bytes.Buffer) + fmt.Fprintf(buf, "%s %d", b.Name, b.N) + if (b.Measured & NsPerOp) != 0 { + fmt.Fprintf(buf, " %.2f ns/op", b.NsPerOp) + } + if (b.Measured & MBPerS) != 0 { + fmt.Fprintf(buf, " %.2f MB/s", b.MBPerS) + } + if (b.Measured & AllocedBytesPerOp) != 0 { + fmt.Fprintf(buf, " %d B/op", b.AllocedBytesPerOp) + } + if (b.Measured & AllocsPerOp) != 0 { + fmt.Fprintf(buf, " %d allocs/op", b.AllocsPerOp) + } + return buf.String() +} + +// Set is a collection of benchmarks from one +// testing.B run, keyed by name to facilitate comparison. +type Set map[string][]*Benchmark + +// ParseSet extracts a Set from testing.B output. +// ParseSet preserves the order of benchmarks that have identical +// names. +func ParseSet(r io.Reader) (Set, error) { + bb := make(Set) + scan := bufio.NewScanner(r) + ord := 0 + for scan.Scan() { + if b, err := ParseLine(scan.Text()); err == nil { + b.Ord = ord + ord++ + bb[b.Name] = append(bb[b.Name], b) + } + } + + if err := scan.Err(); err != nil { + return nil, err + } + + return bb, nil +} diff --git a/vendor/golang.org/x/tools/benchmark/parse/parse_test.go b/vendor/golang.org/x/tools/benchmark/parse/parse_test.go new file mode 100644 index 00000000..06db8489 --- /dev/null +++ b/vendor/golang.org/x/tools/benchmark/parse/parse_test.go @@ -0,0 +1,154 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package parse + +import ( + "reflect" + "strings" + "testing" +) + +func TestParseLine(t *testing.T) { + cases := []struct { + line string + want *Benchmark + err bool // expect an error + }{ + { + line: "BenchmarkEncrypt 100000000 19.6 ns/op", + want: &Benchmark{ + Name: "BenchmarkEncrypt", + N: 100000000, NsPerOp: 19.6, + Measured: NsPerOp, + }, + }, + { + line: "BenchmarkEncrypt 100000000 19.6 ns/op 817.77 MB/s", + want: &Benchmark{ + Name: "BenchmarkEncrypt", + N: 100000000, NsPerOp: 19.6, MBPerS: 817.77, + Measured: NsPerOp | MBPerS, + }, + }, + { + line: "BenchmarkEncrypt 100000000 19.6 ns/op 817.77", + want: &Benchmark{ + Name: "BenchmarkEncrypt", + N: 100000000, NsPerOp: 19.6, + Measured: NsPerOp, + }, + }, + { + line: "BenchmarkEncrypt 100000000 19.6 ns/op 817.77 MB/s 5 allocs/op", + want: &Benchmark{ + Name: "BenchmarkEncrypt", + N: 100000000, NsPerOp: 19.6, MBPerS: 817.77, AllocsPerOp: 5, + Measured: NsPerOp | MBPerS | AllocsPerOp, + }, + }, + { + line: "BenchmarkEncrypt 100000000 19.6 ns/op 817.77 MB/s 3 B/op 5 allocs/op", + want: &Benchmark{ + Name: "BenchmarkEncrypt", + N: 100000000, NsPerOp: 19.6, MBPerS: 817.77, AllocedBytesPerOp: 3, AllocsPerOp: 5, + Measured: NsPerOp | MBPerS | AllocedBytesPerOp | AllocsPerOp, + }, + }, + // error handling cases + { + line: "BenchPress 100 19.6 ns/op", // non-benchmark + err: true, + }, + { + line: "BenchmarkEncrypt lots 19.6 ns/op", // non-int iterations + err: true, + }, + { + line: "BenchmarkBridge 100000000 19.6 smoots", // unknown unit + want: &Benchmark{ + Name: "BenchmarkBridge", + N: 100000000, + }, + }, + { + line: "PASS", + err: true, + }, + } + + for _, tt := range cases { + have, err := ParseLine(tt.line) + if tt.err && err == nil { + t.Errorf("parsing line %q should have failed", tt.line) + continue + } + if !reflect.DeepEqual(have, tt.want) { + t.Errorf("parsed line %q incorrectly, want %v have %v", tt.line, tt.want, have) + } + } +} + +func TestParseSet(t *testing.T) { + // Test two things: + // 1. The noise that can accompany testing.B output gets ignored. + // 2. Benchmarks with the same name have their order preserved. + in := ` + ? crypto [no test files] + PASS + pem_decrypt_test.go:17: test 4. %!s(x509.PEMCipher=5) + ... [output truncated] + + BenchmarkEncrypt 100000000 19.6 ns/op + BenchmarkEncrypt 5000000 517 ns/op + === RUN TestChunk + --- PASS: TestChunk (0.00 seconds) + --- SKIP: TestLinuxSendfile (0.00 seconds) + fs_test.go:716: skipping; linux-only test + BenchmarkReadRequestApachebench 1000000 2960 ns/op 27.70 MB/s 839 B/op 9 allocs/op + BenchmarkClientServerParallel64 50000 59192 ns/op 7028 B/op 60 allocs/op + ok net/http 95.783s + ` + + want := Set{ + "BenchmarkReadRequestApachebench": []*Benchmark{ + { + Name: "BenchmarkReadRequestApachebench", + N: 1000000, NsPerOp: 2960, MBPerS: 27.70, AllocedBytesPerOp: 839, AllocsPerOp: 9, + Measured: NsPerOp | MBPerS | AllocedBytesPerOp | AllocsPerOp, + Ord: 2, + }, + }, + "BenchmarkClientServerParallel64": []*Benchmark{ + { + Name: "BenchmarkClientServerParallel64", + N: 50000, NsPerOp: 59192, AllocedBytesPerOp: 7028, AllocsPerOp: 60, + Measured: NsPerOp | AllocedBytesPerOp | AllocsPerOp, + Ord: 3, + }, + }, + "BenchmarkEncrypt": []*Benchmark{ + { + Name: "BenchmarkEncrypt", + N: 100000000, NsPerOp: 19.6, + Measured: NsPerOp, + Ord: 0, + }, + { + Name: "BenchmarkEncrypt", + N: 5000000, NsPerOp: 517, + Measured: NsPerOp, + Ord: 1, + }, + }, + } + + have, err := ParseSet(strings.NewReader(in)) + if err != nil { + t.Fatalf("unexpected err during ParseSet: %v", err) + } + if !reflect.DeepEqual(want, have) { + t.Errorf("parsed bench set incorrectly, want %v have %v", want, have) + } +} diff --git a/vendor/golang.org/x/tools/blog/atom/atom.go b/vendor/golang.org/x/tools/blog/atom/atom.go new file mode 100644 index 00000000..542c50e6 --- /dev/null +++ b/vendor/golang.org/x/tools/blog/atom/atom.go @@ -0,0 +1,61 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Adapted from encoding/xml/read_test.go. + +// Package atom defines XML data structures for an Atom feed. +package atom // import "golang.org/x/tools/blog/atom" + +import ( + "encoding/xml" + "time" +) + +type Feed struct { + XMLName xml.Name `xml:"http://www.w3.org/2005/Atom feed"` + Title string `xml:"title"` + ID string `xml:"id"` + Link []Link `xml:"link"` + Updated TimeStr `xml:"updated"` + Author *Person `xml:"author"` + Entry []*Entry `xml:"entry"` +} + +type Entry struct { + Title string `xml:"title"` + ID string `xml:"id"` + Link []Link `xml:"link"` + Published TimeStr `xml:"published"` + Updated TimeStr `xml:"updated"` + Author *Person `xml:"author"` + Summary *Text `xml:"summary"` + Content *Text `xml:"content"` +} + +type Link struct { + Rel string `xml:"rel,attr,omitempty"` + Href string `xml:"href,attr"` + Type string `xml:"type,attr,omitempty"` + HrefLang string `xml:"hreflang,attr,omitempty"` + Title string `xml:"title,attr,omitempty"` + Length uint `xml:"length,attr,omitempty"` +} + +type Person struct { + Name string `xml:"name"` + URI string `xml:"uri,omitempty"` + Email string `xml:"email,omitempty"` + InnerXML string `xml:",innerxml"` +} + +type Text struct { + Type string `xml:"type,attr"` + Body string `xml:",chardata"` +} + +type TimeStr string + +func Time(t time.Time) TimeStr { + return TimeStr(t.Format("2006-01-02T15:04:05-07:00")) +} diff --git a/vendor/golang.org/x/tools/blog/blog.go b/vendor/golang.org/x/tools/blog/blog.go new file mode 100644 index 00000000..73c184d4 --- /dev/null +++ b/vendor/golang.org/x/tools/blog/blog.go @@ -0,0 +1,456 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package blog implements a web server for articles written in present format. +package blog // import "golang.org/x/tools/blog" + +import ( + "bytes" + "encoding/json" + "encoding/xml" + "fmt" + "html/template" + "log" + "net/http" + "os" + "path/filepath" + "regexp" + "sort" + "strings" + "time" + + "golang.org/x/tools/blog/atom" + "golang.org/x/tools/present" +) + +var ( + validJSONPFunc = regexp.MustCompile(`(?i)^[a-z_][a-z0-9_.]*$`) + // used to serve relative paths when ServeLocalLinks is enabled. + golangOrgAbsLinkReplacer = strings.NewReplacer( + `href="https://golang.org/pkg`, `href="/pkg`, + `href="https://golang.org/cmd`, `href="/cmd`, + ) +) + +// Config specifies Server configuration values. +type Config struct { + ContentPath string // Relative or absolute location of article files and related content. + TemplatePath string // Relative or absolute location of template files. + + BaseURL string // Absolute base URL (for permalinks; no trailing slash). + BasePath string // Base URL path relative to server root (no trailing slash). + GodocURL string // The base URL of godoc (for menu bar; no trailing slash). + Hostname string // Server host name, used for rendering ATOM feeds. + + HomeArticles int // Articles to display on the home page. + FeedArticles int // Articles to include in Atom and JSON feeds. + FeedTitle string // The title of the Atom XML feed + + PlayEnabled bool + ServeLocalLinks bool // rewrite golang.org/{pkg,cmd} links to host-less, relative paths. +} + +// Doc represents an article adorned with presentation data. +type Doc struct { + *present.Doc + Permalink string // Canonical URL for this document. + Path string // Path relative to server root (including base). + HTML template.HTML // rendered article + + Related []*Doc + Newer, Older *Doc +} + +// Server implements an http.Handler that serves blog articles. +type Server struct { + cfg Config + docs []*Doc + tags []string + docPaths map[string]*Doc // key is path without BasePath. + docTags map[string][]*Doc + template struct { + home, index, article, doc *template.Template + } + atomFeed []byte // pre-rendered Atom feed + jsonFeed []byte // pre-rendered JSON feed + content http.Handler +} + +// NewServer constructs a new Server using the specified config. +func NewServer(cfg Config) (*Server, error) { + present.PlayEnabled = cfg.PlayEnabled + + if notExist(cfg.TemplatePath) { + return nil, fmt.Errorf("template directory not found: %s", cfg.TemplatePath) + } + root := filepath.Join(cfg.TemplatePath, "root.tmpl") + parse := func(name string) (*template.Template, error) { + path := filepath.Join(cfg.TemplatePath, name) + if notExist(path) { + return nil, fmt.Errorf("template %s was not found in %s", name, cfg.TemplatePath) + } + t := template.New("").Funcs(funcMap) + return t.ParseFiles(root, path) + } + + s := &Server{cfg: cfg} + + // Parse templates. + var err error + s.template.home, err = parse("home.tmpl") + if err != nil { + return nil, err + } + s.template.index, err = parse("index.tmpl") + if err != nil { + return nil, err + } + s.template.article, err = parse("article.tmpl") + if err != nil { + return nil, err + } + p := present.Template().Funcs(funcMap) + s.template.doc, err = p.ParseFiles(filepath.Join(cfg.TemplatePath, "doc.tmpl")) + if err != nil { + return nil, err + } + + // Load content. + err = s.loadDocs(filepath.Clean(cfg.ContentPath)) + if err != nil { + return nil, err + } + + err = s.renderAtomFeed() + if err != nil { + return nil, err + } + + err = s.renderJSONFeed() + if err != nil { + return nil, err + } + + // Set up content file server. + s.content = http.StripPrefix(s.cfg.BasePath, http.FileServer(http.Dir(cfg.ContentPath))) + + return s, nil +} + +var funcMap = template.FuncMap{ + "sectioned": sectioned, + "authors": authors, +} + +// sectioned returns true if the provided Doc contains more than one section. +// This is used to control whether to display the table of contents and headings. +func sectioned(d *present.Doc) bool { + return len(d.Sections) > 1 +} + +// authors returns a comma-separated list of author names. +func authors(authors []present.Author) string { + var b bytes.Buffer + last := len(authors) - 1 + for i, a := range authors { + if i > 0 { + if i == last { + b.WriteString(" and ") + } else { + b.WriteString(", ") + } + } + b.WriteString(authorName(a)) + } + return b.String() +} + +// authorName returns the first line of the Author text: the author's name. +func authorName(a present.Author) string { + el := a.TextElem() + if len(el) == 0 { + return "" + } + text, ok := el[0].(present.Text) + if !ok || len(text.Lines) == 0 { + return "" + } + return text.Lines[0] +} + +// loadDocs reads all content from the provided file system root, renders all +// the articles it finds, adds them to the Server's docs field, computes the +// denormalized docPaths, docTags, and tags fields, and populates the various +// helper fields (Next, Previous, Related) for each Doc. +func (s *Server) loadDocs(root string) error { + // Read content into docs field. + const ext = ".article" + fn := func(p string, info os.FileInfo, err error) error { + if filepath.Ext(p) != ext { + return nil + } + f, err := os.Open(p) + if err != nil { + return err + } + defer f.Close() + d, err := present.Parse(f, p, 0) + if err != nil { + return err + } + var html bytes.Buffer + err = d.Render(&html, s.template.doc) + if err != nil { + return err + } + p = p[len(root) : len(p)-len(ext)] // trim root and extension + p = filepath.ToSlash(p) + s.docs = append(s.docs, &Doc{ + Doc: d, + Path: s.cfg.BasePath + p, + Permalink: s.cfg.BaseURL + p, + HTML: template.HTML(html.String()), + }) + return nil + } + err := filepath.Walk(root, fn) + if err != nil { + return err + } + sort.Sort(docsByTime(s.docs)) + + // Pull out doc paths and tags and put in reverse-associating maps. + s.docPaths = make(map[string]*Doc) + s.docTags = make(map[string][]*Doc) + for _, d := range s.docs { + s.docPaths[strings.TrimPrefix(d.Path, s.cfg.BasePath)] = d + for _, t := range d.Tags { + s.docTags[t] = append(s.docTags[t], d) + } + } + + // Pull out unique sorted list of tags. + for t := range s.docTags { + s.tags = append(s.tags, t) + } + sort.Strings(s.tags) + + // Set up presentation-related fields, Newer, Older, and Related. + for _, doc := range s.docs { + // Newer, Older: docs adjacent to doc + for i := range s.docs { + if s.docs[i] != doc { + continue + } + if i > 0 { + doc.Newer = s.docs[i-1] + } + if i+1 < len(s.docs) { + doc.Older = s.docs[i+1] + } + break + } + + // Related: all docs that share tags with doc. + related := make(map[*Doc]bool) + for _, t := range doc.Tags { + for _, d := range s.docTags[t] { + if d != doc { + related[d] = true + } + } + } + for d := range related { + doc.Related = append(doc.Related, d) + } + sort.Sort(docsByTime(doc.Related)) + } + + return nil +} + +// renderAtomFeed generates an XML Atom feed and stores it in the Server's +// atomFeed field. +func (s *Server) renderAtomFeed() error { + var updated time.Time + if len(s.docs) > 0 { + updated = s.docs[0].Time + } + feed := atom.Feed{ + Title: s.cfg.FeedTitle, + ID: "tag:" + s.cfg.Hostname + ",2013:" + s.cfg.Hostname, + Updated: atom.Time(updated), + Link: []atom.Link{{ + Rel: "self", + Href: s.cfg.BaseURL + "/feed.atom", + }}, + } + for i, doc := range s.docs { + if i >= s.cfg.FeedArticles { + break + } + e := &atom.Entry{ + Title: doc.Title, + ID: feed.ID + doc.Path, + Link: []atom.Link{{ + Rel: "alternate", + Href: doc.Permalink, + }}, + Published: atom.Time(doc.Time), + Updated: atom.Time(doc.Time), + Summary: &atom.Text{ + Type: "html", + Body: summary(doc), + }, + Content: &atom.Text{ + Type: "html", + Body: string(doc.HTML), + }, + Author: &atom.Person{ + Name: authors(doc.Authors), + }, + } + feed.Entry = append(feed.Entry, e) + } + data, err := xml.Marshal(&feed) + if err != nil { + return err + } + s.atomFeed = data + return nil +} + +type jsonItem struct { + Title string + Link string + Time time.Time + Summary string + Content string + Author string +} + +// renderJSONFeed generates a JSON feed and stores it in the Server's jsonFeed +// field. +func (s *Server) renderJSONFeed() error { + var feed []jsonItem + for i, doc := range s.docs { + if i >= s.cfg.FeedArticles { + break + } + item := jsonItem{ + Title: doc.Title, + Link: doc.Permalink, + Time: doc.Time, + Summary: summary(doc), + Content: string(doc.HTML), + Author: authors(doc.Authors), + } + feed = append(feed, item) + } + data, err := json.Marshal(feed) + if err != nil { + return err + } + s.jsonFeed = data + return nil +} + +// summary returns the first paragraph of text from the provided Doc. +func summary(d *Doc) string { + if len(d.Sections) == 0 { + return "" + } + for _, elem := range d.Sections[0].Elem { + text, ok := elem.(present.Text) + if !ok || text.Pre { + // skip everything but non-text elements + continue + } + var buf bytes.Buffer + for _, s := range text.Lines { + buf.WriteString(string(present.Style(s))) + buf.WriteByte('\n') + } + return buf.String() + } + return "" +} + +// rootData encapsulates data destined for the root template. +type rootData struct { + Doc *Doc + BasePath string + GodocURL string + Data interface{} +} + +// ServeHTTP serves the front, index, and article pages +// as well as the ATOM and JSON feeds. +func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { + var ( + d = rootData{BasePath: s.cfg.BasePath, GodocURL: s.cfg.GodocURL} + t *template.Template + ) + switch p := strings.TrimPrefix(r.URL.Path, s.cfg.BasePath); p { + case "/": + d.Data = s.docs + if len(s.docs) > s.cfg.HomeArticles { + d.Data = s.docs[:s.cfg.HomeArticles] + } + t = s.template.home + case "/index": + d.Data = s.docs + t = s.template.index + case "/feed.atom", "/feeds/posts/default": + w.Header().Set("Content-type", "application/atom+xml; charset=utf-8") + w.Write(s.atomFeed) + return + case "/.json": + if p := r.FormValue("jsonp"); validJSONPFunc.MatchString(p) { + w.Header().Set("Content-type", "application/javascript; charset=utf-8") + fmt.Fprintf(w, "%v(%s)", p, s.jsonFeed) + return + } + w.Header().Set("Content-type", "application/json; charset=utf-8") + w.Write(s.jsonFeed) + return + default: + doc, ok := s.docPaths[p] + if !ok { + // Not a doc; try to just serve static content. + s.content.ServeHTTP(w, r) + return + } + d.Doc = doc + t = s.template.article + } + var err error + if s.cfg.ServeLocalLinks { + var buf bytes.Buffer + err = t.ExecuteTemplate(&buf, "root", d) + if err != nil { + log.Println(err) + return + } + _, err = golangOrgAbsLinkReplacer.WriteString(w, buf.String()) + } else { + err = t.ExecuteTemplate(w, "root", d) + } + if err != nil { + log.Println(err) + } +} + +// docsByTime implements sort.Interface, sorting Docs by their Time field. +type docsByTime []*Doc + +func (s docsByTime) Len() int { return len(s) } +func (s docsByTime) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s docsByTime) Less(i, j int) bool { return s[i].Time.After(s[j].Time) } + +// notExist reports whether the path exists or not. +func notExist(path string) bool { + _, err := os.Stat(path) + return os.IsNotExist(err) +} diff --git a/vendor/golang.org/x/tools/blog/blog_test.go b/vendor/golang.org/x/tools/blog/blog_test.go new file mode 100644 index 00000000..c84be2a7 --- /dev/null +++ b/vendor/golang.org/x/tools/blog/blog_test.go @@ -0,0 +1,44 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package blog + +import ( + "bytes" + "testing" +) + +func TestLinkRewrite(t *testing.T) { + tests := []struct { + input string + output string + }{ + { + `For instance, the bytes package from the standard library exports the Buffer type.`, + `For instance, the bytes package from the standard library exports the Buffer type.`}, + { + `(The gofmt command has a -r flag that provides a syntax-aware search and replace, making large-scale refactoring easier.)`, + `(The gofmt command has a -r flag that provides a syntax-aware search and replace, making large-scale refactoring easier.)`, + }, + { + `BSD license.
Terms of Service `, + `BSD license.
Terms of Service `, + }, + { + `For instance, the websocket package from the go.net sub-repository has an import path of "golang.org/x/net/websocket".`, + `For instance, the websocket package from the go.net sub-repository has an import path of "golang.org/x/net/websocket".`, + }, + } + for _, test := range tests { + var buf bytes.Buffer + _, err := golangOrgAbsLinkReplacer.WriteString(&buf, test.input) + if err != nil { + t.Errorf("unexpected error during replacing links. Got: %#v, Want: nil.\n", err) + continue + } + if got, want := buf.String(), test.output; got != want { + t.Errorf("WriteString(%q) = %q. Expected: %q", test.input, got, want) + } + } +} diff --git a/vendor/golang.org/x/tools/cmd/benchcmp/benchcmp.go b/vendor/golang.org/x/tools/cmd/benchcmp/benchcmp.go new file mode 100644 index 00000000..32f3a1c8 --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/benchcmp/benchcmp.go @@ -0,0 +1,184 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "flag" + "fmt" + "os" + "sort" + "strconv" + "text/tabwriter" + + "golang.org/x/tools/benchmark/parse" +) + +var ( + changedOnly = flag.Bool("changed", false, "show only benchmarks that have changed") + magSort = flag.Bool("mag", false, "sort benchmarks by magnitude of change") + best = flag.Bool("best", false, "compare best times from old and new") +) + +const usageFooter = ` +Each input file should be from: + go test -run=NONE -bench=. > [old,new].txt + +Benchcmp compares old and new for each benchmark. + +If -test.benchmem=true is added to the "go test" command +benchcmp will also compare memory allocations. +` + +func main() { + flag.Usage = func() { + fmt.Fprintf(os.Stderr, "usage: %s old.txt new.txt\n\n", os.Args[0]) + flag.PrintDefaults() + fmt.Fprint(os.Stderr, usageFooter) + os.Exit(2) + } + flag.Parse() + if flag.NArg() != 2 { + flag.Usage() + } + + before := parseFile(flag.Arg(0)) + after := parseFile(flag.Arg(1)) + + cmps, warnings := Correlate(before, after) + + for _, warn := range warnings { + fmt.Fprintln(os.Stderr, warn) + } + + if len(cmps) == 0 { + fatal("benchcmp: no repeated benchmarks") + } + + w := new(tabwriter.Writer) + w.Init(os.Stdout, 0, 0, 5, ' ', 0) + defer w.Flush() + + var header bool // Has the header has been displayed yet for a given block? + + if *magSort { + sort.Sort(ByDeltaNsPerOp(cmps)) + } else { + sort.Sort(ByParseOrder(cmps)) + } + for _, cmp := range cmps { + if !cmp.Measured(parse.NsPerOp) { + continue + } + if delta := cmp.DeltaNsPerOp(); !*changedOnly || delta.Changed() { + if !header { + fmt.Fprint(w, "benchmark\told ns/op\tnew ns/op\tdelta\n") + header = true + } + fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", cmp.Name(), formatNs(cmp.Before.NsPerOp), formatNs(cmp.After.NsPerOp), delta.Percent()) + } + } + + header = false + if *magSort { + sort.Sort(ByDeltaMBPerS(cmps)) + } + for _, cmp := range cmps { + if !cmp.Measured(parse.MBPerS) { + continue + } + if delta := cmp.DeltaMBPerS(); !*changedOnly || delta.Changed() { + if !header { + fmt.Fprint(w, "\nbenchmark\told MB/s\tnew MB/s\tspeedup\n") + header = true + } + fmt.Fprintf(w, "%s\t%.2f\t%.2f\t%s\n", cmp.Name(), cmp.Before.MBPerS, cmp.After.MBPerS, delta.Multiple()) + } + } + + header = false + if *magSort { + sort.Sort(ByDeltaAllocsPerOp(cmps)) + } + for _, cmp := range cmps { + if !cmp.Measured(parse.AllocsPerOp) { + continue + } + if delta := cmp.DeltaAllocsPerOp(); !*changedOnly || delta.Changed() { + if !header { + fmt.Fprint(w, "\nbenchmark\told allocs\tnew allocs\tdelta\n") + header = true + } + fmt.Fprintf(w, "%s\t%d\t%d\t%s\n", cmp.Name(), cmp.Before.AllocsPerOp, cmp.After.AllocsPerOp, delta.Percent()) + } + } + + header = false + if *magSort { + sort.Sort(ByDeltaAllocedBytesPerOp(cmps)) + } + for _, cmp := range cmps { + if !cmp.Measured(parse.AllocedBytesPerOp) { + continue + } + if delta := cmp.DeltaAllocedBytesPerOp(); !*changedOnly || delta.Changed() { + if !header { + fmt.Fprint(w, "\nbenchmark\told bytes\tnew bytes\tdelta\n") + header = true + } + fmt.Fprintf(w, "%s\t%d\t%d\t%s\n", cmp.Name(), cmp.Before.AllocedBytesPerOp, cmp.After.AllocedBytesPerOp, cmp.DeltaAllocedBytesPerOp().Percent()) + } + } +} + +func fatal(msg interface{}) { + fmt.Fprintln(os.Stderr, msg) + os.Exit(1) +} + +func parseFile(path string) parse.Set { + f, err := os.Open(path) + if err != nil { + fatal(err) + } + defer f.Close() + bb, err := parse.ParseSet(f) + if err != nil { + fatal(err) + } + if *best { + selectBest(bb) + } + return bb +} + +func selectBest(bs parse.Set) { + for name, bb := range bs { + if len(bb) < 2 { + continue + } + ord := bb[0].Ord + best := bb[0] + for _, b := range bb { + if b.NsPerOp < best.NsPerOp { + b.Ord = ord + best = b + } + } + bs[name] = []*parse.Benchmark{best} + } +} + +// formatNs formats ns measurements to expose a useful amount of +// precision. It mirrors the ns precision logic of testing.B. +func formatNs(ns float64) string { + prec := 0 + switch { + case ns < 10: + prec = 2 + case ns < 100: + prec = 1 + } + return strconv.FormatFloat(ns, 'f', prec, 64) +} diff --git a/vendor/golang.org/x/tools/cmd/benchcmp/benchcmp_test.go b/vendor/golang.org/x/tools/cmd/benchcmp/benchcmp_test.go new file mode 100644 index 00000000..22260795 --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/benchcmp/benchcmp_test.go @@ -0,0 +1,59 @@ +package main + +import ( + "reflect" + "testing" + + "golang.org/x/tools/benchmark/parse" +) + +func TestSelectBest(t *testing.T) { + have := parse.Set{ + "Benchmark1": []*parse.Benchmark{ + { + Name: "Benchmark1", + N: 10, NsPerOp: 100, Measured: parse.NsPerOp, + Ord: 0, + }, + { + Name: "Benchmark1", + N: 10, NsPerOp: 50, Measured: parse.NsPerOp, + Ord: 3, + }, + }, + "Benchmark2": []*parse.Benchmark{ + { + Name: "Benchmark2", + N: 10, NsPerOp: 60, Measured: parse.NsPerOp, + Ord: 1, + }, + { + Name: "Benchmark2", + N: 10, NsPerOp: 500, Measured: parse.NsPerOp, + Ord: 2, + }, + }, + } + + want := parse.Set{ + "Benchmark1": []*parse.Benchmark{ + { + Name: "Benchmark1", + N: 10, NsPerOp: 50, Measured: parse.NsPerOp, + Ord: 0, + }, + }, + "Benchmark2": []*parse.Benchmark{ + { + Name: "Benchmark2", + N: 10, NsPerOp: 60, Measured: parse.NsPerOp, + Ord: 1, + }, + }, + } + + selectBest(have) + if !reflect.DeepEqual(want, have) { + t.Errorf("filtered bench set incorrectly, want %v have %v", want, have) + } +} diff --git a/vendor/golang.org/x/tools/cmd/benchcmp/compare.go b/vendor/golang.org/x/tools/cmd/benchcmp/compare.go new file mode 100644 index 00000000..c3f5e89c --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/benchcmp/compare.go @@ -0,0 +1,156 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "fmt" + "math" + + "golang.org/x/tools/benchmark/parse" +) + +// BenchCmp is a pair of benchmarks. +type BenchCmp struct { + Before *parse.Benchmark + After *parse.Benchmark +} + +// Correlate correlates benchmarks from two BenchSets. +func Correlate(before, after parse.Set) (cmps []BenchCmp, warnings []string) { + cmps = make([]BenchCmp, 0, len(after)) + for name, beforebb := range before { + afterbb := after[name] + if len(beforebb) != len(afterbb) { + warnings = append(warnings, fmt.Sprintf("ignoring %s: before has %d instances, after has %d", name, len(beforebb), len(afterbb))) + continue + } + for i, beforeb := range beforebb { + afterb := afterbb[i] + cmps = append(cmps, BenchCmp{beforeb, afterb}) + } + } + return +} + +func (c BenchCmp) Name() string { return c.Before.Name } +func (c BenchCmp) String() string { return fmt.Sprintf("<%s, %s>", c.Before, c.After) } +func (c BenchCmp) Measured(flag int) bool { return (c.Before.Measured & c.After.Measured & flag) != 0 } +func (c BenchCmp) DeltaNsPerOp() Delta { return Delta{c.Before.NsPerOp, c.After.NsPerOp} } +func (c BenchCmp) DeltaMBPerS() Delta { return Delta{c.Before.MBPerS, c.After.MBPerS} } +func (c BenchCmp) DeltaAllocedBytesPerOp() Delta { + return Delta{float64(c.Before.AllocedBytesPerOp), float64(c.After.AllocedBytesPerOp)} +} +func (c BenchCmp) DeltaAllocsPerOp() Delta { + return Delta{float64(c.Before.AllocsPerOp), float64(c.After.AllocsPerOp)} +} + +// Delta is the before and after value for a benchmark measurement. +// Both must be non-negative. +type Delta struct { + Before float64 + After float64 +} + +// mag calculates the magnitude of a change, regardless of the direction of +// the change. mag is intended for sorting and has no independent meaning. +func (d Delta) mag() float64 { + switch { + case d.Before != 0 && d.After != 0 && d.Before >= d.After: + return d.After / d.Before + case d.Before != 0 && d.After != 0 && d.Before < d.After: + return d.Before / d.After + case d.Before == 0 && d.After == 0: + return 1 + default: + // 0 -> 1 or 1 -> 0 + // These are significant changes and worth surfacing. + return math.Inf(1) + } +} + +// Changed reports whether the benchmark quantities are different. +func (d Delta) Changed() bool { return d.Before != d.After } + +// Float64 returns After / Before. If Before is 0, Float64 returns +// 1 if After is also 0, and +Inf otherwise. +func (d Delta) Float64() float64 { + switch { + case d.Before != 0: + return d.After / d.Before + case d.After == 0: + return 1 + default: + return math.Inf(1) + } +} + +// Percent formats a Delta as a percent change, ranging from -100% up. +func (d Delta) Percent() string { + return fmt.Sprintf("%+.2f%%", 100*d.Float64()-100) +} + +// Multiple formats a Delta as a multiplier, ranging from 0.00x up. +func (d Delta) Multiple() string { + return fmt.Sprintf("%.2fx", d.Float64()) +} + +func (d Delta) String() string { + return fmt.Sprintf("Δ(%f, %f)", d.Before, d.After) +} + +// ByParseOrder sorts BenchCmps to match the order in +// which the Before benchmarks were presented to Parse. +type ByParseOrder []BenchCmp + +func (x ByParseOrder) Len() int { return len(x) } +func (x ByParseOrder) Swap(i, j int) { x[i], x[j] = x[j], x[i] } +func (x ByParseOrder) Less(i, j int) bool { return x[i].Before.Ord < x[j].Before.Ord } + +// lessByDelta provides lexicographic ordering: +// * largest delta by magnitude +// * alphabetic by name +func lessByDelta(i, j BenchCmp, calcDelta func(BenchCmp) Delta) bool { + iDelta, jDelta := calcDelta(i).mag(), calcDelta(j).mag() + if iDelta != jDelta { + return iDelta < jDelta + } + return i.Name() < j.Name() +} + +// ByDeltaNsPerOp sorts BenchCmps lexicographically by change +// in ns/op, descending, then by benchmark name. +type ByDeltaNsPerOp []BenchCmp + +func (x ByDeltaNsPerOp) Len() int { return len(x) } +func (x ByDeltaNsPerOp) Swap(i, j int) { x[i], x[j] = x[j], x[i] } +func (x ByDeltaNsPerOp) Less(i, j int) bool { return lessByDelta(x[i], x[j], BenchCmp.DeltaNsPerOp) } + +// ByDeltaMBPerS sorts BenchCmps lexicographically by change +// in MB/s, descending, then by benchmark name. +type ByDeltaMBPerS []BenchCmp + +func (x ByDeltaMBPerS) Len() int { return len(x) } +func (x ByDeltaMBPerS) Swap(i, j int) { x[i], x[j] = x[j], x[i] } +func (x ByDeltaMBPerS) Less(i, j int) bool { return lessByDelta(x[i], x[j], BenchCmp.DeltaMBPerS) } + +// ByDeltaAllocedBytesPerOp sorts BenchCmps lexicographically by change +// in B/op, descending, then by benchmark name. +type ByDeltaAllocedBytesPerOp []BenchCmp + +func (x ByDeltaAllocedBytesPerOp) Len() int { return len(x) } +func (x ByDeltaAllocedBytesPerOp) Swap(i, j int) { x[i], x[j] = x[j], x[i] } +func (x ByDeltaAllocedBytesPerOp) Less(i, j int) bool { + return lessByDelta(x[i], x[j], BenchCmp.DeltaAllocedBytesPerOp) +} + +// ByDeltaAllocsPerOp sorts BenchCmps lexicographically by change +// in allocs/op, descending, then by benchmark name. +type ByDeltaAllocsPerOp []BenchCmp + +func (x ByDeltaAllocsPerOp) Len() int { return len(x) } +func (x ByDeltaAllocsPerOp) Swap(i, j int) { x[i], x[j] = x[j], x[i] } +func (x ByDeltaAllocsPerOp) Less(i, j int) bool { + return lessByDelta(x[i], x[j], BenchCmp.DeltaAllocsPerOp) +} diff --git a/vendor/golang.org/x/tools/cmd/benchcmp/compare_test.go b/vendor/golang.org/x/tools/cmd/benchcmp/compare_test.go new file mode 100644 index 00000000..3403796d --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/benchcmp/compare_test.go @@ -0,0 +1,133 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "math" + "reflect" + "sort" + "testing" + + "golang.org/x/tools/benchmark/parse" +) + +func TestDelta(t *testing.T) { + cases := []struct { + before float64 + after float64 + mag float64 + f float64 + changed bool + pct string + mult string + }{ + {before: 1, after: 1, mag: 1, f: 1, changed: false, pct: "+0.00%", mult: "1.00x"}, + {before: 1, after: 2, mag: 0.5, f: 2, changed: true, pct: "+100.00%", mult: "2.00x"}, + {before: 2, after: 1, mag: 0.5, f: 0.5, changed: true, pct: "-50.00%", mult: "0.50x"}, + {before: 0, after: 0, mag: 1, f: 1, changed: false, pct: "+0.00%", mult: "1.00x"}, + {before: 1, after: 0, mag: math.Inf(1), f: 0, changed: true, pct: "-100.00%", mult: "0.00x"}, + {before: 0, after: 1, mag: math.Inf(1), f: math.Inf(1), changed: true, pct: "+Inf%", mult: "+Infx"}, + } + for _, tt := range cases { + d := Delta{tt.before, tt.after} + if want, have := tt.mag, d.mag(); want != have { + t.Errorf("%s.mag(): want %f have %f", d, want, have) + } + if want, have := tt.f, d.Float64(); want != have { + t.Errorf("%s.Float64(): want %f have %f", d, want, have) + } + if want, have := tt.changed, d.Changed(); want != have { + t.Errorf("%s.Changed(): want %t have %t", d, want, have) + } + if want, have := tt.pct, d.Percent(); want != have { + t.Errorf("%s.Percent(): want %q have %q", d, want, have) + } + if want, have := tt.mult, d.Multiple(); want != have { + t.Errorf("%s.Multiple(): want %q have %q", d, want, have) + } + } +} + +func TestCorrelate(t *testing.T) { + // Benches that are going to be successfully correlated get N thus: + // 0x + // Read this: " of , from ". + before := parse.Set{ + "BenchmarkOneEach": []*parse.Benchmark{{Name: "BenchmarkOneEach", N: 0x11b}}, + "BenchmarkOneToNone": []*parse.Benchmark{{Name: "BenchmarkOneToNone"}}, + "BenchmarkOneToTwo": []*parse.Benchmark{{Name: "BenchmarkOneToTwo"}}, + "BenchmarkTwoToOne": []*parse.Benchmark{ + {Name: "BenchmarkTwoToOne"}, + {Name: "BenchmarkTwoToOne"}, + }, + "BenchmarkTwoEach": []*parse.Benchmark{ + {Name: "BenchmarkTwoEach", N: 0x12b}, + {Name: "BenchmarkTwoEach", N: 0x22b}, + }, + } + + after := parse.Set{ + "BenchmarkOneEach": []*parse.Benchmark{{Name: "BenchmarkOneEach", N: 0x11a}}, + "BenchmarkNoneToOne": []*parse.Benchmark{{Name: "BenchmarkNoneToOne"}}, + "BenchmarkTwoToOne": []*parse.Benchmark{{Name: "BenchmarkTwoToOne"}}, + "BenchmarkOneToTwo": []*parse.Benchmark{ + {Name: "BenchmarkOneToTwo"}, + {Name: "BenchmarkOneToTwo"}, + }, + "BenchmarkTwoEach": []*parse.Benchmark{ + {Name: "BenchmarkTwoEach", N: 0x12a}, + {Name: "BenchmarkTwoEach", N: 0x22a}, + }, + } + + pairs, errs := Correlate(before, after) + + // Fail to match: BenchmarkOneToNone, BenchmarkOneToTwo, BenchmarkTwoToOne. + // Correlate does not notice BenchmarkNoneToOne. + if len(errs) != 3 { + t.Errorf("Correlated expected 4 errors, got %d: %v", len(errs), errs) + } + + // Want three correlated pairs: one BenchmarkOneEach, two BenchmarkTwoEach. + if len(pairs) != 3 { + t.Fatalf("Correlated expected 3 pairs, got %v", pairs) + } + + for _, pair := range pairs { + if pair.Before.N&0xF != 0xb { + t.Errorf("unexpected Before in pair %s", pair) + } + if pair.After.N&0xF != 0xa { + t.Errorf("unexpected After in pair %s", pair) + } + if pair.Before.N>>4 != pair.After.N>>4 { + t.Errorf("mismatched pair %s", pair) + } + } +} + +func TestBenchCmpSorting(t *testing.T) { + c := []BenchCmp{ + {&parse.Benchmark{Name: "BenchmarkMuchFaster", NsPerOp: 10, Ord: 3}, &parse.Benchmark{Name: "BenchmarkMuchFaster", NsPerOp: 1}}, + {&parse.Benchmark{Name: "BenchmarkSameB", NsPerOp: 5, Ord: 1}, &parse.Benchmark{Name: "BenchmarkSameB", NsPerOp: 5}}, + {&parse.Benchmark{Name: "BenchmarkSameA", NsPerOp: 5, Ord: 2}, &parse.Benchmark{Name: "BenchmarkSameA", NsPerOp: 5}}, + {&parse.Benchmark{Name: "BenchmarkSlower", NsPerOp: 10, Ord: 0}, &parse.Benchmark{Name: "BenchmarkSlower", NsPerOp: 11}}, + } + + // Test just one magnitude-based sort order; they are symmetric. + sort.Sort(ByDeltaNsPerOp(c)) + want := []string{"BenchmarkMuchFaster", "BenchmarkSlower", "BenchmarkSameA", "BenchmarkSameB"} + have := []string{c[0].Name(), c[1].Name(), c[2].Name(), c[3].Name()} + if !reflect.DeepEqual(want, have) { + t.Errorf("ByDeltaNsOp incorrect sorting: want %v have %v", want, have) + } + + sort.Sort(ByParseOrder(c)) + want = []string{"BenchmarkSlower", "BenchmarkSameB", "BenchmarkSameA", "BenchmarkMuchFaster"} + have = []string{c[0].Name(), c[1].Name(), c[2].Name(), c[3].Name()} + if !reflect.DeepEqual(want, have) { + t.Errorf("ByParseOrder incorrect sorting: want %v have %v", want, have) + } +} diff --git a/vendor/golang.org/x/tools/cmd/benchcmp/doc.go b/vendor/golang.org/x/tools/cmd/benchcmp/doc.go new file mode 100644 index 00000000..f5c7a361 --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/benchcmp/doc.go @@ -0,0 +1,37 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +/* + +The benchcmp command displays performance changes between benchmarks. + +Benchcmp parses the output of two 'go test' benchmark runs, +correlates the results per benchmark, and displays the deltas. + +To measure the performance impact of a change, use 'go test' +to run benchmarks before and after the change: + + go test -run=NONE -bench=. ./... > old.txt + # make changes + go test -run=NONE -bench=. ./... > new.txt + +Then feed the benchmark results to benchcmp: + + benchcmp old.txt new.txt + +Benchcmp will summarize and display the performance changes, +in a format like this: + + $ benchcmp old.txt new.txt + benchmark old ns/op new ns/op delta + BenchmarkConcat 523 68.6 -86.88% + + benchmark old allocs new allocs delta + BenchmarkConcat 3 1 -66.67% + + benchmark old bytes new bytes delta + BenchmarkConcat 80 48 -40.00% + +*/ +package main // import "golang.org/x/tools/cmd/benchcmp" diff --git a/vendor/golang.org/x/tools/cmd/bundle/.gitignore b/vendor/golang.org/x/tools/cmd/bundle/.gitignore new file mode 100644 index 00000000..caaeb09d --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/bundle/.gitignore @@ -0,0 +1 @@ +testdata/out.got diff --git a/vendor/golang.org/x/tools/cmd/bundle/main.go b/vendor/golang.org/x/tools/cmd/bundle/main.go new file mode 100644 index 00000000..7c552683 --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/bundle/main.go @@ -0,0 +1,467 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Bundle creates a single-source-file version of a source package +// suitable for inclusion in a particular target package. +// +// Usage: +// +// bundle [-o file] [-dst path] [-pkg name] [-prefix p] [-import old=new] +// +// The src argument specifies the import path of the package to bundle. +// The bundling of a directory of source files into a single source file +// necessarily imposes a number of constraints. +// The package being bundled must not use cgo; must not use conditional +// file compilation, whether with build tags or system-specific file names +// like code_amd64.go; must not depend on any special comments, which +// may not be preserved; must not use any assembly sources; +// must not use renaming imports; and must not use reflection-based APIs +// that depend on the specific names of types or struct fields. +// +// By default, bundle writes the bundled code to standard output. +// If the -o argument is given, bundle writes to the named file +// and also includes a ``//go:generate'' comment giving the exact +// command line used, for regenerating the file with ``go generate.'' +// +// Bundle customizes its output for inclusion in a particular package, the destination package. +// By default bundle assumes the destination is the package in the current directory, +// but the destination package can be specified explicitly using the -dst option, +// which takes an import path as its argument. +// If the source package imports the destination package, bundle will remove +// those imports and rewrite any references to use direct references to the +// corresponding symbols. +// Bundle also must write a package declaration in the output and must +// choose a name to use in that declaration. +// If the -package option is given, bundle uses that name. +// Otherwise, if the -dst option is given, bundle uses the last +// element of the destination import path. +// Otherwise, by default bundle uses the package name found in the +// package sources in the current directory. +// +// To avoid collisions, bundle inserts a prefix at the beginning of +// every package-level const, func, type, and var identifier in src's code, +// updating references accordingly. The default prefix is the package name +// of the source package followed by an underscore. The -prefix option +// specifies an alternate prefix. +// +// Occasionally it is necessary to rewrite imports during the bundling +// process. The -import option, which may be repeated, specifies that +// an import of "old" should be rewritten to import "new" instead. +// +// Example +// +// Bundle archive/zip for inclusion in cmd/dist: +// +// cd $GOROOT/src/cmd/dist +// bundle -o zip.go archive/zip +// +// Bundle golang.org/x/net/http2 for inclusion in net/http, +// prefixing all identifiers by "http2" instead of "http2_", +// and rewriting the import "golang.org/x/net/http2/hpack" +// to "internal/golang.org/x/net/http2/hpack": +// +// cd $GOROOT/src/net/http +// bundle -o h2_bundle.go \ +// -prefix http2 \ +// -import golang.org/x/net/http2/hpack=internal/golang.org/x/net/http2/hpack \ +// golang.org/x/net/http2 +// +// Two ways to update the http2 bundle: +// +// go generate net/http +// +// cd $GOROOT/src/net/http +// go generate +// +// Update both bundles, restricting ``go generate'' to running bundle commands: +// +// go generate -run bundle cmd/dist net/http +// +package main + +import ( + "bytes" + "flag" + "fmt" + "go/ast" + "go/build" + "go/format" + "go/parser" + "go/printer" + "go/token" + "go/types" + "io/ioutil" + "log" + "os" + "path" + "strconv" + "strings" + + "golang.org/x/tools/go/loader" +) + +var ( + outputFile = flag.String("o", "", "write output to `file` (default standard output)") + dstPath = flag.String("dst", "", "set destination import `path` (default taken from current directory)") + pkgName = flag.String("pkg", "", "set destination package `name` (default taken from current directory)") + prefix = flag.String("prefix", "&_", "set bundled identifier prefix to `p` (default is \"&_\", where & stands for the original name)") + underscore = flag.Bool("underscore", false, "rewrite golang.org to golang_org in imports; temporary workaround for golang.org/issue/16333") + + importMap = map[string]string{} +) + +func init() { + flag.Var(flagFunc(addImportMap), "import", "rewrite import using `map`, of form old=new (can be repeated)") +} + +func addImportMap(s string) { + if strings.Count(s, "=") != 1 { + log.Fatal("-import argument must be of the form old=new") + } + i := strings.Index(s, "=") + old, new := s[:i], s[i+1:] + if old == "" || new == "" { + log.Fatal("-import argument must be of the form old=new; old and new must be non-empty") + } + importMap[old] = new +} + +func usage() { + fmt.Fprintf(os.Stderr, "Usage: bundle [options] \n") + flag.PrintDefaults() +} + +func main() { + log.SetPrefix("bundle: ") + log.SetFlags(0) + + flag.Usage = usage + flag.Parse() + args := flag.Args() + if len(args) != 1 { + usage() + os.Exit(2) + } + + if *dstPath != "" { + if *pkgName == "" { + *pkgName = path.Base(*dstPath) + } + } else { + wd, _ := os.Getwd() + pkg, err := build.ImportDir(wd, 0) + if err != nil { + log.Fatalf("cannot find package in current directory: %v", err) + } + *dstPath = pkg.ImportPath + if *pkgName == "" { + *pkgName = pkg.Name + } + } + + code, err := bundle(args[0], *dstPath, *pkgName, *prefix) + if err != nil { + log.Fatal(err) + } + if *outputFile != "" { + err := ioutil.WriteFile(*outputFile, code, 0666) + if err != nil { + log.Fatal(err) + } + } else { + _, err := os.Stdout.Write(code) + if err != nil { + log.Fatal(err) + } + } +} + +// isStandardImportPath is copied from cmd/go in the standard library. +func isStandardImportPath(path string) bool { + i := strings.Index(path, "/") + if i < 0 { + i = len(path) + } + elem := path[:i] + return !strings.Contains(elem, ".") +} + +var ctxt = &build.Default + +func bundle(src, dst, dstpkg, prefix string) ([]byte, error) { + // Load the initial package. + conf := loader.Config{ParserMode: parser.ParseComments, Build: ctxt} + conf.TypeCheckFuncBodies = func(p string) bool { return p == src } + conf.Import(src) + + lprog, err := conf.Load() + if err != nil { + return nil, err + } + + // Because there was a single Import call and Load succeeded, + // InitialPackages is guaranteed to hold the sole requested package. + info := lprog.InitialPackages()[0] + if strings.Contains(prefix, "&") { + prefix = strings.Replace(prefix, "&", info.Files[0].Name.Name, -1) + } + + objsToUpdate := make(map[types.Object]bool) + var rename func(from types.Object) + rename = func(from types.Object) { + if !objsToUpdate[from] { + objsToUpdate[from] = true + + // Renaming a type that is used as an embedded field + // requires renaming the field too. e.g. + // type T int // if we rename this to U.. + // var s struct {T} + // print(s.T) // ...this must change too + if _, ok := from.(*types.TypeName); ok { + for id, obj := range info.Uses { + if obj == from { + if field := info.Defs[id]; field != nil { + rename(field) + } + } + } + } + } + } + + // Rename each package-level object. + scope := info.Pkg.Scope() + for _, name := range scope.Names() { + rename(scope.Lookup(name)) + } + + var out bytes.Buffer + + fmt.Fprintf(&out, "// Code generated by golang.org/x/tools/cmd/bundle. DO NOT EDIT.\n") + if *outputFile != "" { + fmt.Fprintf(&out, "//go:generate bundle %s\n", strings.Join(os.Args[1:], " ")) + } else { + fmt.Fprintf(&out, "// $ bundle %s\n", strings.Join(os.Args[1:], " ")) + } + fmt.Fprintf(&out, "\n") + + // Concatenate package comments from all files... + for _, f := range info.Files { + if doc := f.Doc.Text(); strings.TrimSpace(doc) != "" { + for _, line := range strings.Split(doc, "\n") { + fmt.Fprintf(&out, "// %s\n", line) + } + } + } + // ...but don't let them become the actual package comment. + fmt.Fprintln(&out) + + fmt.Fprintf(&out, "package %s\n\n", dstpkg) + + // BUG(adonovan,shurcooL): bundle may generate incorrect code + // due to shadowing between identifiers and imported package names. + // + // The generated code will either fail to compile or + // (unlikely) compile successfully but have different behavior + // than the original package. The risk of this happening is higher + // when the original package has renamed imports (they're typically + // renamed in order to resolve a shadow inside that particular .go file). + + // TODO(adonovan,shurcooL): + // - detect shadowing issues, and either return error or resolve them + // - preserve comments from the original import declarations. + + // pkgStd and pkgExt are sets of printed import specs. This is done + // to deduplicate instances of the same import name and path. + var pkgStd = make(map[string]bool) + var pkgExt = make(map[string]bool) + for _, f := range info.Files { + for _, imp := range f.Imports { + path, err := strconv.Unquote(imp.Path.Value) + if err != nil { + log.Fatalf("invalid import path string: %v", err) // Shouldn't happen here since conf.Load succeeded. + } + if path == dst { + continue + } + if newPath, ok := importMap[path]; ok { + path = newPath + } + + var name string + if imp.Name != nil { + name = imp.Name.Name + } + spec := fmt.Sprintf("%s %q", name, path) + if isStandardImportPath(path) { + pkgStd[spec] = true + } else { + if *underscore { + spec = strings.Replace(spec, "golang.org/", "golang_org/", 1) + } + pkgExt[spec] = true + } + } + } + + // Print a single declaration that imports all necessary packages. + fmt.Fprintln(&out, "import (") + for p := range pkgStd { + fmt.Fprintf(&out, "\t%s\n", p) + } + if len(pkgExt) > 0 { + fmt.Fprintln(&out) + } + for p := range pkgExt { + fmt.Fprintf(&out, "\t%s\n", p) + } + fmt.Fprint(&out, ")\n\n") + + // Modify and print each file. + for _, f := range info.Files { + // Update renamed identifiers. + for id, obj := range info.Defs { + if objsToUpdate[obj] { + id.Name = prefix + obj.Name() + } + } + for id, obj := range info.Uses { + if objsToUpdate[obj] { + id.Name = prefix + obj.Name() + } + } + + // For each qualified identifier that refers to the + // destination package, remove the qualifier. + // The "@@@." strings are removed in postprocessing. + ast.Inspect(f, func(n ast.Node) bool { + if sel, ok := n.(*ast.SelectorExpr); ok { + if id, ok := sel.X.(*ast.Ident); ok { + if obj, ok := info.Uses[id].(*types.PkgName); ok { + if obj.Imported().Path() == dst { + id.Name = "@@@" + } + } + } + } + return true + }) + + last := f.Package + if len(f.Imports) > 0 { + imp := f.Imports[len(f.Imports)-1] + last = imp.End() + if imp.Comment != nil { + if e := imp.Comment.End(); e > last { + last = e + } + } + } + + // Pretty-print package-level declarations. + // but no package or import declarations. + var buf bytes.Buffer + for _, decl := range f.Decls { + if decl, ok := decl.(*ast.GenDecl); ok && decl.Tok == token.IMPORT { + continue + } + + beg, end := sourceRange(decl) + + printComments(&out, f.Comments, last, beg) + + buf.Reset() + format.Node(&buf, lprog.Fset, &printer.CommentedNode{Node: decl, Comments: f.Comments}) + // Remove each "@@@." in the output. + // TODO(adonovan): not hygienic. + out.Write(bytes.Replace(buf.Bytes(), []byte("@@@."), nil, -1)) + + last = printSameLineComment(&out, f.Comments, lprog.Fset, end) + + out.WriteString("\n\n") + } + + printLastComments(&out, f.Comments, last) + } + + // Now format the entire thing. + result, err := format.Source(out.Bytes()) + if err != nil { + log.Fatalf("formatting failed: %v", err) + } + + return result, nil +} + +// sourceRange returns the [beg, end) interval of source code +// belonging to decl (incl. associated comments). +func sourceRange(decl ast.Decl) (beg, end token.Pos) { + beg = decl.Pos() + end = decl.End() + + var doc, com *ast.CommentGroup + + switch d := decl.(type) { + case *ast.GenDecl: + doc = d.Doc + if len(d.Specs) > 0 { + switch spec := d.Specs[len(d.Specs)-1].(type) { + case *ast.ValueSpec: + com = spec.Comment + case *ast.TypeSpec: + com = spec.Comment + } + } + case *ast.FuncDecl: + doc = d.Doc + } + + if doc != nil { + beg = doc.Pos() + } + if com != nil && com.End() > end { + end = com.End() + } + + return beg, end +} + +func printComments(out *bytes.Buffer, comments []*ast.CommentGroup, pos, end token.Pos) { + for _, cg := range comments { + if pos <= cg.Pos() && cg.Pos() < end { + for _, c := range cg.List { + fmt.Fprintln(out, c.Text) + } + fmt.Fprintln(out) + } + } +} + +const infinity = 1 << 30 + +func printLastComments(out *bytes.Buffer, comments []*ast.CommentGroup, pos token.Pos) { + printComments(out, comments, pos, infinity) +} + +func printSameLineComment(out *bytes.Buffer, comments []*ast.CommentGroup, fset *token.FileSet, pos token.Pos) token.Pos { + tf := fset.File(pos) + for _, cg := range comments { + if pos <= cg.Pos() && tf.Line(cg.Pos()) == tf.Line(pos) { + for _, c := range cg.List { + fmt.Fprintln(out, c.Text) + } + return cg.End() + } + } + return pos +} + +type flagFunc func(string) + +func (f flagFunc) Set(s string) error { + f(s) + return nil +} + +func (f flagFunc) String() string { return "" } diff --git a/vendor/golang.org/x/tools/cmd/bundle/main_test.go b/vendor/golang.org/x/tools/cmd/bundle/main_test.go new file mode 100644 index 00000000..b96f7d9d --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/bundle/main_test.go @@ -0,0 +1,74 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build go1.9 + +package main + +import ( + "bytes" + "io/ioutil" + "os" + "os/exec" + "runtime" + "testing" + + "golang.org/x/tools/go/buildutil" +) + +func TestBundle(t *testing.T) { + load := func(name string) string { + data, err := ioutil.ReadFile(name) + if err != nil { + t.Fatal(err) + } + return string(data) + } + + ctxt = buildutil.FakeContext(map[string]map[string]string{ + "initial": { + "a.go": load("testdata/src/initial/a.go"), + "b.go": load("testdata/src/initial/b.go"), + "c.go": load("testdata/src/initial/c.go"), + }, + "domain.name/importdecl": { + "p.go": load("testdata/src/domain.name/importdecl/p.go"), + }, + "fmt": { + "print.go": `package fmt; func Println(...interface{})`, + }, + }) + + os.Args = os.Args[:1] // avoid e.g. -test=short in the output + out, err := bundle("initial", "github.com/dest", "dest", "prefix") + if err != nil { + t.Fatal(err) + } + if got, want := string(out), load("testdata/out.golden"); got != want { + t.Errorf("-- got --\n%s\n-- want --\n%s\n-- diff --", got, want) + + if err := ioutil.WriteFile("testdata/out.got", out, 0644); err != nil { + t.Fatal(err) + } + t.Log(diff("testdata/out.golden", "testdata/out.got")) + } +} + +func diff(a, b string) string { + var cmd *exec.Cmd + switch runtime.GOOS { + case "plan9": + cmd = exec.Command("/bin/diff", "-c", a, b) + default: + cmd = exec.Command("/usr/bin/diff", "-u", a, b) + } + var out bytes.Buffer + cmd.Stdout = &out + cmd.Stderr = &out + cmd.Run() // nonzero exit is expected + if out.Len() == 0 { + return "(failed to compute diff)" + } + return out.String() +} diff --git a/vendor/golang.org/x/tools/cmd/bundle/testdata/out.golden b/vendor/golang.org/x/tools/cmd/bundle/testdata/out.golden new file mode 100644 index 00000000..5260fdd1 --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/bundle/testdata/out.golden @@ -0,0 +1,62 @@ +// Code generated by golang.org/x/tools/cmd/bundle. DO NOT EDIT. +// $ bundle + +// The package doc comment +// + +package dest + +import ( + "fmt" + . "fmt" + _ "fmt" + renamedfmt "fmt" + renamedfmt2 "fmt" + + "domain.name/importdecl" +) + +// init functions are not renamed +func init() { prefixfoo() } + +// Type S. +type prefixS struct { + prefixt + u int +} /* multi-line +comment +*/ + +// non-associated comment + +/* + non-associated comment2 +*/ + +// Function bar. +func prefixbar(s *prefixS) { + fmt.Println(s.prefixt, s.u) // comment inside function +} + +// file-end comment + +type prefixt int // type1 + +// const1 +const prefixc = 1 // const2 + +func prefixfoo() { + fmt.Println(importdecl.F()) +} + +// zinit +const ( + prefixz1 = iota // z1 + prefixz2 // z2 +) // zend + +func prefixbaz() { + renamedfmt.Println() + renamedfmt2.Println() + Println() +} diff --git a/vendor/golang.org/x/tools/cmd/bundle/testdata/src/domain.name/importdecl/p.go b/vendor/golang.org/x/tools/cmd/bundle/testdata/src/domain.name/importdecl/p.go new file mode 100644 index 00000000..36dfd154 --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/bundle/testdata/src/domain.name/importdecl/p.go @@ -0,0 +1,3 @@ +package importdecl + +func F() int { return 1 } diff --git a/vendor/golang.org/x/tools/cmd/bundle/testdata/src/initial/a.go b/vendor/golang.org/x/tools/cmd/bundle/testdata/src/initial/a.go new file mode 100644 index 00000000..ded6c64c --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/bundle/testdata/src/initial/a.go @@ -0,0 +1,27 @@ +package initial + +import "fmt" // this comment should not be visible + +// init functions are not renamed +func init() { foo() } + +// Type S. +type S struct { + t + u int +} /* multi-line +comment +*/ + +// non-associated comment + +/* + non-associated comment2 +*/ + +// Function bar. +func bar(s *S) { + fmt.Println(s.t, s.u) // comment inside function +} + +// file-end comment diff --git a/vendor/golang.org/x/tools/cmd/bundle/testdata/src/initial/b.go b/vendor/golang.org/x/tools/cmd/bundle/testdata/src/initial/b.go new file mode 100644 index 00000000..31d5cabe --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/bundle/testdata/src/initial/b.go @@ -0,0 +1,23 @@ +// The package doc comment +package initial + +import ( + "fmt" + + "domain.name/importdecl" +) + +type t int // type1 + +// const1 +const c = 1 // const2 + +func foo() { + fmt.Println(importdecl.F()) +} + +// zinit +const ( + z1 = iota // z1 + z2 // z2 +) // zend diff --git a/vendor/golang.org/x/tools/cmd/bundle/testdata/src/initial/c.go b/vendor/golang.org/x/tools/cmd/bundle/testdata/src/initial/c.go new file mode 100644 index 00000000..6a9cbc69 --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/bundle/testdata/src/initial/c.go @@ -0,0 +1,12 @@ +package initial + +import _ "fmt" +import renamedfmt "fmt" +import renamedfmt2 "fmt" +import . "fmt" + +func baz() { + renamedfmt.Println() + renamedfmt2.Println() + Println() +} diff --git a/vendor/golang.org/x/tools/cmd/callgraph/main.go b/vendor/golang.org/x/tools/cmd/callgraph/main.go new file mode 100644 index 00000000..2e09bc44 --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/callgraph/main.go @@ -0,0 +1,349 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// callgraph: a tool for reporting the call graph of a Go program. +// See Usage for details, or run with -help. +package main // import "golang.org/x/tools/cmd/callgraph" + +// TODO(adonovan): +// +// Features: +// - restrict graph to a single package +// - output +// - functions reachable from root (use digraph tool?) +// - unreachable functions (use digraph tool?) +// - dynamic (runtime) types +// - indexed output (numbered nodes) +// - JSON output +// - additional template fields: +// callee file/line/col + +import ( + "bufio" + "bytes" + "flag" + "fmt" + "go/build" + "go/token" + "io" + "log" + "os" + "runtime" + "text/template" + + "golang.org/x/tools/go/buildutil" + "golang.org/x/tools/go/callgraph" + "golang.org/x/tools/go/callgraph/cha" + "golang.org/x/tools/go/callgraph/rta" + "golang.org/x/tools/go/callgraph/static" + "golang.org/x/tools/go/packages" + "golang.org/x/tools/go/pointer" + "golang.org/x/tools/go/ssa" + "golang.org/x/tools/go/ssa/ssautil" +) + +// flags +var ( + algoFlag = flag.String("algo", "rta", + `Call graph construction algorithm (static, cha, rta, pta)`) + + testFlag = flag.Bool("test", false, + "Loads test code (*_test.go) for imported packages") + + formatFlag = flag.String("format", + "{{.Caller}}\t--{{.Dynamic}}-{{.Line}}:{{.Column}}-->\t{{.Callee}}", + "A template expression specifying how to format an edge") + + ptalogFlag = flag.String("ptalog", "", + "Location of the points-to analysis log file, or empty to disable logging.") +) + +func init() { + flag.Var((*buildutil.TagsFlag)(&build.Default.BuildTags), "tags", buildutil.TagsFlagDoc) +} + +const Usage = `callgraph: display the the call graph of a Go program. + +Usage: + + callgraph [-algo=static|cha|rta|pta] [-test] [-format=...] package... + +Flags: + +-algo Specifies the call-graph construction algorithm, one of: + + static static calls only (unsound) + cha Class Hierarchy Analysis + rta Rapid Type Analysis + pta inclusion-based Points-To Analysis + + The algorithms are ordered by increasing precision in their + treatment of dynamic calls (and thus also computational cost). + RTA and PTA require a whole program (main or test), and + include only functions reachable from main. + +-test Include the package's tests in the analysis. + +-format Specifies the format in which each call graph edge is displayed. + One of: + + digraph output suitable for input to + golang.org/x/tools/cmd/digraph. + graphviz output in AT&T GraphViz (.dot) format. + + All other values are interpreted using text/template syntax. + The default value is: + + {{.Caller}}\t--{{.Dynamic}}-{{.Line}}:{{.Column}}-->\t{{.Callee}} + + The structure passed to the template is (effectively): + + type Edge struct { + Caller *ssa.Function // calling function + Callee *ssa.Function // called function + + // Call site: + Filename string // containing file + Offset int // offset within file of '(' + Line int // line number + Column int // column number of call + Dynamic string // "static" or "dynamic" + Description string // e.g. "static method call" + } + + Caller and Callee are *ssa.Function values, which print as + "(*sync/atomic.Mutex).Lock", but other attributes may be + derived from them, e.g. Caller.Pkg.Pkg.Path yields the + import path of the enclosing package. Consult the go/ssa + API documentation for details. + +Examples: + + Show the call graph of the trivial web server application: + + callgraph -format digraph $GOROOT/src/net/http/triv.go + + Same, but show only the packages of each function: + + callgraph -format '{{.Caller.Pkg.Pkg.Path}} -> {{.Callee.Pkg.Pkg.Path}}' \ + $GOROOT/src/net/http/triv.go | sort | uniq + + Show functions that make dynamic calls into the 'fmt' test package, + using the pointer analysis algorithm: + + callgraph -format='{{.Caller}} -{{.Dynamic}}-> {{.Callee}}' -test -algo=pta fmt | + sed -ne 's/-dynamic-/--/p' | + sed -ne 's/-->.*fmt_test.*$//p' | sort | uniq + + Show all functions directly called by the callgraph tool's main function: + + callgraph -format=digraph golang.org/x/tools/cmd/callgraph | + digraph succs golang.org/x/tools/cmd/callgraph.main +` + +func init() { + // If $GOMAXPROCS isn't set, use the full capacity of the machine. + // For small machines, use at least 4 threads. + if os.Getenv("GOMAXPROCS") == "" { + n := runtime.NumCPU() + if n < 4 { + n = 4 + } + runtime.GOMAXPROCS(n) + } +} + +func main() { + flag.Parse() + if err := doCallgraph("", "", *algoFlag, *formatFlag, *testFlag, flag.Args()); err != nil { + fmt.Fprintf(os.Stderr, "callgraph: %s\n", err) + os.Exit(1) + } +} + +var stdout io.Writer = os.Stdout + +func doCallgraph(dir, gopath, algo, format string, tests bool, args []string) error { + if len(args) == 0 { + fmt.Fprintln(os.Stderr, Usage) + return nil + } + + cfg := &packages.Config{ + Mode: packages.LoadAllSyntax, + Tests: tests, + Dir: dir, + } + if gopath != "" { + cfg.Env = append(os.Environ(), "GOPATH="+gopath) // to enable testing + } + initial, err := packages.Load(cfg, args...) + if err != nil { + return err + } + if packages.PrintErrors(initial) > 0 { + return fmt.Errorf("packages contain errors") + } + + // Create and build SSA-form program representation. + prog, pkgs := ssautil.AllPackages(initial, 0) + prog.Build() + + // -- call graph construction ------------------------------------------ + + var cg *callgraph.Graph + + switch algo { + case "static": + cg = static.CallGraph(prog) + + case "cha": + cg = cha.CallGraph(prog) + + case "pta": + // Set up points-to analysis log file. + var ptalog io.Writer + if *ptalogFlag != "" { + if f, err := os.Create(*ptalogFlag); err != nil { + log.Fatalf("Failed to create PTA log file: %s", err) + } else { + buf := bufio.NewWriter(f) + ptalog = buf + defer func() { + if err := buf.Flush(); err != nil { + log.Printf("flush: %s", err) + } + if err := f.Close(); err != nil { + log.Printf("close: %s", err) + } + }() + } + } + + mains, err := mainPackages(pkgs) + if err != nil { + return err + } + config := &pointer.Config{ + Mains: mains, + BuildCallGraph: true, + Log: ptalog, + } + ptares, err := pointer.Analyze(config) + if err != nil { + return err // internal error in pointer analysis + } + cg = ptares.CallGraph + + case "rta": + mains, err := mainPackages(pkgs) + if err != nil { + return err + } + var roots []*ssa.Function + for _, main := range mains { + roots = append(roots, main.Func("init"), main.Func("main")) + } + rtares := rta.Analyze(roots, true) + cg = rtares.CallGraph + + // NB: RTA gives us Reachable and RuntimeTypes too. + + default: + return fmt.Errorf("unknown algorithm: %s", algo) + } + + cg.DeleteSyntheticNodes() + + // -- output------------------------------------------------------------ + + var before, after string + + // Pre-canned formats. + switch format { + case "digraph": + format = `{{printf "%q %q" .Caller .Callee}}` + + case "graphviz": + before = "digraph callgraph {\n" + after = "}\n" + format = ` {{printf "%q" .Caller}} -> {{printf "%q" .Callee}}` + } + + tmpl, err := template.New("-format").Parse(format) + if err != nil { + return fmt.Errorf("invalid -format template: %v", err) + } + + // Allocate these once, outside the traversal. + var buf bytes.Buffer + data := Edge{fset: prog.Fset} + + fmt.Fprint(stdout, before) + if err := callgraph.GraphVisitEdges(cg, func(edge *callgraph.Edge) error { + data.position.Offset = -1 + data.edge = edge + data.Caller = edge.Caller.Func + data.Callee = edge.Callee.Func + + buf.Reset() + if err := tmpl.Execute(&buf, &data); err != nil { + return err + } + stdout.Write(buf.Bytes()) + if len := buf.Len(); len == 0 || buf.Bytes()[len-1] != '\n' { + fmt.Fprintln(stdout) + } + return nil + }); err != nil { + return err + } + fmt.Fprint(stdout, after) + return nil +} + +// mainPackages returns the main packages to analyze. +// Each resulting package is named "main" and has a main function. +func mainPackages(pkgs []*ssa.Package) ([]*ssa.Package, error) { + var mains []*ssa.Package + for _, p := range pkgs { + if p != nil && p.Pkg.Name() == "main" && p.Func("main") != nil { + mains = append(mains, p) + } + } + if len(mains) == 0 { + return nil, fmt.Errorf("no main packages") + } + return mains, nil +} + +type Edge struct { + Caller *ssa.Function + Callee *ssa.Function + + edge *callgraph.Edge + fset *token.FileSet + position token.Position // initialized lazily +} + +func (e *Edge) pos() *token.Position { + if e.position.Offset == -1 { + e.position = e.fset.Position(e.edge.Pos()) // called lazily + } + return &e.position +} + +func (e *Edge) Filename() string { return e.pos().Filename } +func (e *Edge) Column() int { return e.pos().Column } +func (e *Edge) Line() int { return e.pos().Line } +func (e *Edge) Offset() int { return e.pos().Offset } + +func (e *Edge) Dynamic() string { + if e.edge.Site != nil && e.edge.Site.Common().StaticCallee() == nil { + return "dynamic" + } + return "static" +} + +func (e *Edge) Description() string { return e.edge.Description() } diff --git a/vendor/golang.org/x/tools/cmd/callgraph/main_test.go b/vendor/golang.org/x/tools/cmd/callgraph/main_test.go new file mode 100644 index 00000000..54953c70 --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/callgraph/main_test.go @@ -0,0 +1,99 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// No testdata on Android. + +// +build !android +// +build go1.11 + +package main + +import ( + "bytes" + "fmt" + "log" + "os" + "path/filepath" + "strings" + "testing" +) + +func init() { + // This test currently requires GOPATH mode. + // Explicitly disabling module mode should suffix, but + // we'll also turn off GOPROXY just for good measure. + if err := os.Setenv("GO111MODULE", "off"); err != nil { + log.Fatal(err) + } + if err := os.Setenv("GOPROXY", "off"); err != nil { + log.Fatal(err) + } +} + +func TestCallgraph(t *testing.T) { + gopath, err := filepath.Abs("testdata") + if err != nil { + t.Fatal(err) + } + + for _, test := range []struct { + algo string + tests bool + want []string + }{ + {"rta", false, []string{ + // rta imprecisely shows cross product of {main,main2} x {C,D} + `pkg.main --> (pkg.C).f`, + `pkg.main --> (pkg.D).f`, + `pkg.main --> pkg.main2`, + `pkg.main2 --> (pkg.C).f`, + `pkg.main2 --> (pkg.D).f`, + }}, + {"pta", false, []string{ + // pta distinguishes main->C, main2->D. Also has a root node. + ` --> pkg.init`, + ` --> pkg.main`, + `pkg.main --> (pkg.C).f`, + `pkg.main --> pkg.main2`, + `pkg.main2 --> (pkg.D).f`, + }}, + // tests: both the package's main and the test's main are called. + // The callgraph includes all the guts of the "testing" package. + {"rta", true, []string{ + `pkg.test.main --> testing.MainStart`, + `testing.runExample --> pkg.Example`, + `pkg.Example --> (pkg.C).f`, + `pkg.main --> (pkg.C).f`, + }}, + {"pta", true, []string{ + ` --> pkg.test.main`, + ` --> pkg.main`, + `pkg.test.main --> testing.MainStart`, + `testing.runExample --> pkg.Example`, + `pkg.Example --> (pkg.C).f`, + `pkg.main --> (pkg.C).f`, + }}, + } { + const format = "{{.Caller}} --> {{.Callee}}" + stdout = new(bytes.Buffer) + if err := doCallgraph("testdata/src", gopath, test.algo, format, test.tests, []string{"pkg"}); err != nil { + t.Error(err) + continue + } + + edges := make(map[string]bool) + for _, line := range strings.Split(fmt.Sprint(stdout), "\n") { + edges[line] = true + } + for _, edge := range test.want { + if !edges[edge] { + t.Errorf("callgraph(%q, %t): missing edge: %s", + test.algo, test.tests, edge) + } + } + if t.Failed() { + t.Log("got:\n", stdout) + } + } +} diff --git a/vendor/golang.org/x/tools/cmd/callgraph/testdata/src/pkg/pkg.go b/vendor/golang.org/x/tools/cmd/callgraph/testdata/src/pkg/pkg.go new file mode 100644 index 00000000..b81c97fb --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/callgraph/testdata/src/pkg/pkg.go @@ -0,0 +1,25 @@ +package main + +type I interface { + f() +} + +type C int + +func (C) f() {} + +type D int + +func (D) f() {} + +func main() { + var i I = C(0) + i.f() // dynamic call + + main2() +} + +func main2() { + var i I = D(0) + i.f() // dynamic call +} diff --git a/vendor/golang.org/x/tools/cmd/callgraph/testdata/src/pkg/pkg_test.go b/vendor/golang.org/x/tools/cmd/callgraph/testdata/src/pkg/pkg_test.go new file mode 100644 index 00000000..0dae2c31 --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/callgraph/testdata/src/pkg/pkg_test.go @@ -0,0 +1,10 @@ +package main + +// An Example function must have an "Output:" comment for the go build +// system to generate a call to it from the test main package. + +func Example() { + C(0).f() + + // Output: +} diff --git a/vendor/golang.org/x/tools/cmd/compilebench/main.go b/vendor/golang.org/x/tools/cmd/compilebench/main.go new file mode 100644 index 00000000..4d3b74ef --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/compilebench/main.go @@ -0,0 +1,378 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Compilebench benchmarks the speed of the Go compiler. +// +// Usage: +// +// compilebench [options] +// +// It times the compilation of various packages and prints results in +// the format used by package testing (and expected by golang.org/x/perf/cmd/benchstat). +// +// The options are: +// +// -alloc +// Report allocations. +// +// -compile exe +// Use exe as the path to the cmd/compile binary. +// +// -compileflags 'list' +// Pass the space-separated list of flags to the compilation. +// +// -count n +// Run each benchmark n times (default 1). +// +// -cpuprofile file +// Write a CPU profile of the compiler to file. +// +// -memprofile file +// Write a memory profile of the compiler to file. +// +// -memprofilerate rate +// Set runtime.MemProfileRate during compilation. +// +// -obj +// Report object file statistics. +// +// -pkg +// Benchmark compiling a single package. +// +// -run regexp +// Only run benchmarks with names matching regexp. +// +// Although -cpuprofile and -memprofile are intended to write a +// combined profile for all the executed benchmarks to file, +// today they write only the profile for the last benchmark executed. +// +// The default memory profiling rate is one profile sample per 512 kB +// allocated (see ``go doc runtime.MemProfileRate''). +// Lowering the rate (for example, -memprofilerate 64000) produces +// a more fine-grained and therefore accurate profile, but it also incurs +// execution cost. For benchmark comparisons, never use timings +// obtained with a low -memprofilerate option. +// +// Example +// +// Assuming the base version of the compiler has been saved with +// ``toolstash save,'' this sequence compares the old and new compiler: +// +// compilebench -count 10 -compile $(toolstash -n compile) >old.txt +// compilebench -count 10 >new.txt +// benchstat old.txt new.txt +// +package main + +import ( + "bytes" + "encoding/json" + "flag" + "fmt" + "io/ioutil" + "log" + "os" + "os/exec" + "path/filepath" + "regexp" + "strconv" + "strings" + "time" +) + +var ( + goroot string + compiler string + runRE *regexp.Regexp + is6g bool +) + +var ( + flagGoCmd = flag.String("go", "go", "path to \"go\" command") + flagAlloc = flag.Bool("alloc", false, "report allocations") + flagObj = flag.Bool("obj", false, "report object file stats") + flagCompiler = flag.String("compile", "", "use `exe` as the cmd/compile binary") + flagCompilerFlags = flag.String("compileflags", "", "additional `flags` to pass to compile") + flagRun = flag.String("run", "", "run benchmarks matching `regexp`") + flagCount = flag.Int("count", 1, "run benchmarks `n` times") + flagCpuprofile = flag.String("cpuprofile", "", "write CPU profile to `file`") + flagMemprofile = flag.String("memprofile", "", "write memory profile to `file`") + flagMemprofilerate = flag.Int64("memprofilerate", -1, "set memory profile `rate`") + flagPackage = flag.String("pkg", "", "if set, benchmark the package at path `pkg`") + flagShort = flag.Bool("short", false, "skip long-running benchmarks") +) + +var tests = []struct { + name string + dir string + long bool +}{ + {"BenchmarkTemplate", "html/template", false}, + {"BenchmarkUnicode", "unicode", false}, + {"BenchmarkGoTypes", "go/types", false}, + {"BenchmarkCompiler", "cmd/compile/internal/gc", false}, + {"BenchmarkSSA", "cmd/compile/internal/ssa", false}, + {"BenchmarkFlate", "compress/flate", false}, + {"BenchmarkGoParser", "go/parser", false}, + {"BenchmarkReflect", "reflect", false}, + {"BenchmarkTar", "archive/tar", false}, + {"BenchmarkXML", "encoding/xml", false}, + {"BenchmarkStdCmd", "", true}, + {"BenchmarkHelloSize", "", false}, + {"BenchmarkCmdGoSize", "", true}, +} + +func usage() { + fmt.Fprintf(os.Stderr, "usage: compilebench [options]\n") + fmt.Fprintf(os.Stderr, "options:\n") + flag.PrintDefaults() + os.Exit(2) +} + +func main() { + log.SetFlags(0) + log.SetPrefix("compilebench: ") + flag.Usage = usage + flag.Parse() + if flag.NArg() != 0 { + usage() + } + + s, err := exec.Command(*flagGoCmd, "env", "GOROOT").CombinedOutput() + if err != nil { + log.Fatalf("%s env GOROOT: %v", *flagGoCmd, err) + } + goroot = strings.TrimSpace(string(s)) + os.Setenv("GOROOT", goroot) // for any subcommands + + compiler = *flagCompiler + if compiler == "" { + out, err := exec.Command(*flagGoCmd, "tool", "-n", "compile").CombinedOutput() + if err != nil { + out, err = exec.Command(*flagGoCmd, "tool", "-n", "6g").CombinedOutput() + is6g = true + if err != nil { + out, err = exec.Command(*flagGoCmd, "tool", "-n", "compile").CombinedOutput() + log.Fatalf("go tool -n compiler: %v\n%s", err, out) + } + } + compiler = strings.TrimSpace(string(out)) + } + + if *flagRun != "" { + r, err := regexp.Compile(*flagRun) + if err != nil { + log.Fatalf("invalid -run argument: %v", err) + } + runRE = r + } + + for i := 0; i < *flagCount; i++ { + if *flagPackage != "" { + runBuild("BenchmarkPkg", *flagPackage, i) + continue + } + for _, tt := range tests { + if tt.long && *flagShort { + continue + } + if runRE == nil || runRE.MatchString(tt.name) { + runBuild(tt.name, tt.dir, i) + } + } + } +} + +func runCmd(name string, cmd *exec.Cmd) { + start := time.Now() + out, err := cmd.CombinedOutput() + if err != nil { + log.Printf("%v: %v\n%s", name, err, out) + return + } + fmt.Printf("%s 1 %d ns/op\n", name, time.Since(start).Nanoseconds()) +} + +func runStdCmd() { + args := []string{"build", "-a"} + if *flagCompilerFlags != "" { + args = append(args, "-gcflags", *flagCompilerFlags) + } + args = append(args, "std", "cmd") + cmd := exec.Command(*flagGoCmd, args...) + cmd.Dir = filepath.Join(goroot, "src") + runCmd("BenchmarkStdCmd", cmd) +} + +// path is either a path to a file ("$GOROOT/test/helloworld.go") or a package path ("cmd/go"). +func runSize(name, path string) { + cmd := exec.Command(*flagGoCmd, "build", "-o", "_compilebenchout_", path) + cmd.Stdout = os.Stderr + cmd.Stderr = os.Stderr + if err := cmd.Run(); err != nil { + log.Print(err) + return + } + defer os.Remove("_compilebenchout_") + info, err := os.Stat("_compilebenchout_") + if err != nil { + log.Print(err) + return + } + out, err := exec.Command("size", "_compilebenchout_").CombinedOutput() + if err != nil { + log.Printf("size: %v\n%s", err, out) + return + } + lines := strings.Split(string(out), "\n") + if len(lines) < 2 { + log.Printf("not enough output from size: %s", out) + return + } + f := strings.Fields(lines[1]) + if strings.HasPrefix(lines[0], "__TEXT") && len(f) >= 2 { // OS X + fmt.Printf("%s 1 %s text-bytes %s data-bytes %v exe-bytes\n", name, f[0], f[1], info.Size()) + } else if strings.Contains(lines[0], "bss") && len(f) >= 3 { + fmt.Printf("%s 1 %s text-bytes %s data-bytes %s bss-bytes %v exe-bytes\n", name, f[0], f[1], f[2], info.Size()) + } +} + +func runBuild(name, dir string, count int) { + switch name { + case "BenchmarkStdCmd": + runStdCmd() + return + case "BenchmarkCmdGoSize": + runSize("BenchmarkCmdGoSize", "cmd/go") + return + case "BenchmarkHelloSize": + runSize("BenchmarkHelloSize", filepath.Join(goroot, "test/helloworld.go")) + return + } + + // Make sure dependencies needed by go tool compile are installed to GOROOT/pkg. + out, err := exec.Command(*flagGoCmd, "build", "-i", dir).CombinedOutput() + if err != nil { + log.Printf("go build -i %s: %v\n%s", dir, err, out) + return + } + + // Find dir and source file list. + var pkg struct { + Dir string + GoFiles []string + } + out, err = exec.Command(*flagGoCmd, "list", "-json", dir).Output() + if err != nil { + log.Printf("go list -json %s: %v\n", dir, err) + return + } + if err := json.Unmarshal(out, &pkg); err != nil { + log.Printf("go list -json %s: unmarshal: %v", dir, err) + return + } + + args := []string{"-o", "_compilebench_.o"} + if is6g { + *flagMemprofilerate = -1 + *flagAlloc = false + *flagCpuprofile = "" + *flagMemprofile = "" + } + if *flagMemprofilerate >= 0 { + args = append(args, "-memprofilerate", fmt.Sprint(*flagMemprofilerate)) + } + args = append(args, strings.Fields(*flagCompilerFlags)...) + if *flagAlloc || *flagCpuprofile != "" || *flagMemprofile != "" { + if *flagAlloc || *flagMemprofile != "" { + args = append(args, "-memprofile", "_compilebench_.memprof") + } + if *flagCpuprofile != "" { + args = append(args, "-cpuprofile", "_compilebench_.cpuprof") + } + } + args = append(args, pkg.GoFiles...) + cmd := exec.Command(compiler, args...) + cmd.Dir = pkg.Dir + cmd.Stdout = os.Stderr + cmd.Stderr = os.Stderr + start := time.Now() + err = cmd.Run() + if err != nil { + log.Printf("%v: %v", name, err) + return + } + end := time.Now() + + var allocs, allocbytes int64 + if *flagAlloc || *flagMemprofile != "" { + out, err := ioutil.ReadFile(pkg.Dir + "/_compilebench_.memprof") + if err != nil { + log.Print("cannot find memory profile after compilation") + } + for _, line := range strings.Split(string(out), "\n") { + f := strings.Fields(line) + if len(f) < 4 || f[0] != "#" || f[2] != "=" { + continue + } + val, err := strconv.ParseInt(f[3], 0, 64) + if err != nil { + continue + } + switch f[1] { + case "TotalAlloc": + allocbytes = val + case "Mallocs": + allocs = val + } + } + + if *flagMemprofile != "" { + if err := ioutil.WriteFile(*flagMemprofile, out, 0666); err != nil { + log.Print(err) + } + } + os.Remove(pkg.Dir + "/_compilebench_.memprof") + } + + if *flagCpuprofile != "" { + out, err := ioutil.ReadFile(pkg.Dir + "/_compilebench_.cpuprof") + if err != nil { + log.Print(err) + } + outpath := *flagCpuprofile + if *flagCount != 1 { + outpath = fmt.Sprintf("%s_%d", outpath, count) + } + if err := ioutil.WriteFile(outpath, out, 0666); err != nil { + log.Print(err) + } + os.Remove(pkg.Dir + "/_compilebench_.cpuprof") + } + + wallns := end.Sub(start).Nanoseconds() + userns := cmd.ProcessState.UserTime().Nanoseconds() + + fmt.Printf("%s 1 %d ns/op %d user-ns/op", name, wallns, userns) + if *flagAlloc { + fmt.Printf(" %d B/op %d allocs/op", allocbytes, allocs) + } + + opath := pkg.Dir + "/_compilebench_.o" + if *flagObj { + // TODO(josharian): object files are big; just read enough to find what we seek. + data, err := ioutil.ReadFile(opath) + if err != nil { + log.Print(err) + } + // Find start of export data. + i := bytes.Index(data, []byte("\n$$B\n")) + len("\n$$B\n") + // Count bytes to end of export data. + nexport := bytes.Index(data[i:], []byte("\n$$\n")) + fmt.Printf(" %d object-bytes %d export-bytes", len(data), nexport) + } + fmt.Println() + + os.Remove(opath) +} diff --git a/vendor/golang.org/x/tools/cmd/cover/README b/vendor/golang.org/x/tools/cmd/cover/README new file mode 100644 index 00000000..ff9523d4 --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/cover/README @@ -0,0 +1,2 @@ +NOTE: For Go releases 1.5 and later, this tool lives in the +standard repository. The code here is not maintained. diff --git a/vendor/golang.org/x/tools/cmd/cover/cover.go b/vendor/golang.org/x/tools/cmd/cover/cover.go new file mode 100644 index 00000000..e0933649 --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/cover/cover.go @@ -0,0 +1,722 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "bytes" + "flag" + "fmt" + "go/ast" + "go/parser" + "go/printer" + "go/token" + "io" + "io/ioutil" + "log" + "os" + "path/filepath" + "sort" + "strconv" + "strings" +) + +const usageMessage = "" + + `Usage of 'go tool cover': +Given a coverage profile produced by 'go test': + go test -coverprofile=c.out + +Open a web browser displaying annotated source code: + go tool cover -html=c.out + +Write out an HTML file instead of launching a web browser: + go tool cover -html=c.out -o coverage.html + +Display coverage percentages to stdout for each function: + go tool cover -func=c.out + +Finally, to generate modified source code with coverage annotations +(what go test -cover does): + go tool cover -mode=set -var=CoverageVariableName program.go +` + +func usage() { + fmt.Fprintln(os.Stderr, usageMessage) + fmt.Fprintln(os.Stderr, "Flags:") + flag.PrintDefaults() + fmt.Fprintln(os.Stderr, "\n Only one of -html, -func, or -mode may be set.") + os.Exit(2) +} + +var ( + mode = flag.String("mode", "", "coverage mode: set, count, atomic") + varVar = flag.String("var", "GoCover", "name of coverage variable to generate") + output = flag.String("o", "", "file for output; default: stdout") + htmlOut = flag.String("html", "", "generate HTML representation of coverage profile") + funcOut = flag.String("func", "", "output coverage profile information for each function") +) + +var profile string // The profile to read; the value of -html or -func + +var counterStmt func(*File, ast.Expr) ast.Stmt + +const ( + atomicPackagePath = "sync/atomic" + atomicPackageName = "_cover_atomic_" +) + +func main() { + flag.Usage = usage + flag.Parse() + + // Usage information when no arguments. + if flag.NFlag() == 0 && flag.NArg() == 0 { + flag.Usage() + } + + err := parseFlags() + if err != nil { + fmt.Fprintln(os.Stderr, err) + fmt.Fprintln(os.Stderr, `For usage information, run "go tool cover -help"`) + os.Exit(2) + } + + // Generate coverage-annotated source. + if *mode != "" { + annotate(flag.Arg(0)) + return + } + + // Output HTML or function coverage information. + if *htmlOut != "" { + err = htmlOutput(profile, *output) + } else { + err = funcOutput(profile, *output) + } + + if err != nil { + fmt.Fprintf(os.Stderr, "cover: %v\n", err) + os.Exit(2) + } +} + +// parseFlags sets the profile and counterStmt globals and performs validations. +func parseFlags() error { + profile = *htmlOut + if *funcOut != "" { + if profile != "" { + return fmt.Errorf("too many options") + } + profile = *funcOut + } + + // Must either display a profile or rewrite Go source. + if (profile == "") == (*mode == "") { + return fmt.Errorf("too many options") + } + + if *mode != "" { + switch *mode { + case "set": + counterStmt = setCounterStmt + case "count": + counterStmt = incCounterStmt + case "atomic": + counterStmt = atomicCounterStmt + default: + return fmt.Errorf("unknown -mode %v", *mode) + } + + if flag.NArg() == 0 { + return fmt.Errorf("missing source file") + } else if flag.NArg() == 1 { + return nil + } + } else if flag.NArg() == 0 { + return nil + } + return fmt.Errorf("too many arguments") +} + +// Block represents the information about a basic block to be recorded in the analysis. +// Note: Our definition of basic block is based on control structures; we don't break +// apart && and ||. We could but it doesn't seem important enough to bother. +type Block struct { + startByte token.Pos + endByte token.Pos + numStmt int +} + +// File is a wrapper for the state of a file used in the parser. +// The basic parse tree walker is a method of this type. +type File struct { + fset *token.FileSet + name string // Name of file. + astFile *ast.File + blocks []Block + atomicPkg string // Package name for "sync/atomic" in this file. +} + +// Visit implements the ast.Visitor interface. +func (f *File) Visit(node ast.Node) ast.Visitor { + switch n := node.(type) { + case *ast.BlockStmt: + // If it's a switch or select, the body is a list of case clauses; don't tag the block itself. + if len(n.List) > 0 { + switch n.List[0].(type) { + case *ast.CaseClause: // switch + for _, n := range n.List { + clause := n.(*ast.CaseClause) + clause.Body = f.addCounters(clause.Pos(), clause.End(), clause.Body, false) + } + return f + case *ast.CommClause: // select + for _, n := range n.List { + clause := n.(*ast.CommClause) + clause.Body = f.addCounters(clause.Pos(), clause.End(), clause.Body, false) + } + return f + } + } + n.List = f.addCounters(n.Lbrace, n.Rbrace+1, n.List, true) // +1 to step past closing brace. + case *ast.IfStmt: + ast.Walk(f, n.Body) + if n.Else == nil { + return nil + } + // The elses are special, because if we have + // if x { + // } else if y { + // } + // we want to cover the "if y". To do this, we need a place to drop the counter, + // so we add a hidden block: + // if x { + // } else { + // if y { + // } + // } + switch stmt := n.Else.(type) { + case *ast.IfStmt: + block := &ast.BlockStmt{ + Lbrace: n.Body.End(), // Start at end of the "if" block so the covered part looks like it starts at the "else". + List: []ast.Stmt{stmt}, + Rbrace: stmt.End(), + } + n.Else = block + case *ast.BlockStmt: + stmt.Lbrace = n.Body.End() // Start at end of the "if" block so the covered part looks like it starts at the "else". + default: + panic("unexpected node type in if") + } + ast.Walk(f, n.Else) + return nil + case *ast.SelectStmt: + // Don't annotate an empty select - creates a syntax error. + if n.Body == nil || len(n.Body.List) == 0 { + return nil + } + case *ast.SwitchStmt: + // Don't annotate an empty switch - creates a syntax error. + if n.Body == nil || len(n.Body.List) == 0 { + return nil + } + case *ast.TypeSwitchStmt: + // Don't annotate an empty type switch - creates a syntax error. + if n.Body == nil || len(n.Body.List) == 0 { + return nil + } + } + return f +} + +// unquote returns the unquoted string. +func unquote(s string) string { + t, err := strconv.Unquote(s) + if err != nil { + log.Fatalf("cover: improperly quoted string %q\n", s) + } + return t +} + +// addImport adds an import for the specified path, if one does not already exist, and returns +// the local package name. +func (f *File) addImport(path string) string { + // Does the package already import it? + for _, s := range f.astFile.Imports { + if unquote(s.Path.Value) == path { + if s.Name != nil { + return s.Name.Name + } + return filepath.Base(path) + } + } + newImport := &ast.ImportSpec{ + Name: ast.NewIdent(atomicPackageName), + Path: &ast.BasicLit{ + Kind: token.STRING, + Value: fmt.Sprintf("%q", path), + }, + } + impDecl := &ast.GenDecl{ + Tok: token.IMPORT, + Specs: []ast.Spec{ + newImport, + }, + } + // Make the new import the first Decl in the file. + astFile := f.astFile + astFile.Decls = append(astFile.Decls, nil) + copy(astFile.Decls[1:], astFile.Decls[0:]) + astFile.Decls[0] = impDecl + astFile.Imports = append(astFile.Imports, newImport) + + // Now refer to the package, just in case it ends up unused. + // That is, append to the end of the file the declaration + // var _ = _cover_atomic_.AddUint32 + reference := &ast.GenDecl{ + Tok: token.VAR, + Specs: []ast.Spec{ + &ast.ValueSpec{ + Names: []*ast.Ident{ + ast.NewIdent("_"), + }, + Values: []ast.Expr{ + &ast.SelectorExpr{ + X: ast.NewIdent(atomicPackageName), + Sel: ast.NewIdent("AddUint32"), + }, + }, + }, + }, + } + astFile.Decls = append(astFile.Decls, reference) + return atomicPackageName +} + +var slashslash = []byte("//") + +// initialComments returns the prefix of content containing only +// whitespace and line comments. Any +build directives must appear +// within this region. This approach is more reliable than using +// go/printer to print a modified AST containing comments. +// +func initialComments(content []byte) []byte { + // Derived from go/build.Context.shouldBuild. + end := 0 + p := content + for len(p) > 0 { + line := p + if i := bytes.IndexByte(line, '\n'); i >= 0 { + line, p = line[:i], p[i+1:] + } else { + p = p[len(p):] + } + line = bytes.TrimSpace(line) + if len(line) == 0 { // Blank line. + end = len(content) - len(p) + continue + } + if !bytes.HasPrefix(line, slashslash) { // Not comment line. + break + } + } + return content[:end] +} + +func annotate(name string) { + fset := token.NewFileSet() + content, err := ioutil.ReadFile(name) + if err != nil { + log.Fatalf("cover: %s: %s", name, err) + } + parsedFile, err := parser.ParseFile(fset, name, content, parser.ParseComments) + if err != nil { + log.Fatalf("cover: %s: %s", name, err) + } + parsedFile.Comments = trimComments(parsedFile, fset) + + file := &File{ + fset: fset, + name: name, + astFile: parsedFile, + } + if *mode == "atomic" { + file.atomicPkg = file.addImport(atomicPackagePath) + } + ast.Walk(file, file.astFile) + fd := os.Stdout + if *output != "" { + var err error + fd, err = os.Create(*output) + if err != nil { + log.Fatalf("cover: %s", err) + } + } + fd.Write(initialComments(content)) // Retain '// +build' directives. + file.print(fd) + // After printing the source tree, add some declarations for the counters etc. + // We could do this by adding to the tree, but it's easier just to print the text. + file.addVariables(fd) +} + +// trimComments drops all but the //go: comments, some of which are semantically important. +// We drop all others because they can appear in places that cause our counters +// to appear in syntactically incorrect places. //go: appears at the beginning of +// the line and is syntactically safe. +func trimComments(file *ast.File, fset *token.FileSet) []*ast.CommentGroup { + var comments []*ast.CommentGroup + for _, group := range file.Comments { + var list []*ast.Comment + for _, comment := range group.List { + if strings.HasPrefix(comment.Text, "//go:") && fset.Position(comment.Slash).Column == 1 { + list = append(list, comment) + } + } + if list != nil { + comments = append(comments, &ast.CommentGroup{List: list}) + } + } + return comments +} + +func (f *File) print(w io.Writer) { + printer.Fprint(w, f.fset, f.astFile) +} + +// intLiteral returns an ast.BasicLit representing the integer value. +func (f *File) intLiteral(i int) *ast.BasicLit { + node := &ast.BasicLit{ + Kind: token.INT, + Value: fmt.Sprint(i), + } + return node +} + +// index returns an ast.BasicLit representing the number of counters present. +func (f *File) index() *ast.BasicLit { + return f.intLiteral(len(f.blocks)) +} + +// setCounterStmt returns the expression: __count[23] = 1. +func setCounterStmt(f *File, counter ast.Expr) ast.Stmt { + return &ast.AssignStmt{ + Lhs: []ast.Expr{counter}, + Tok: token.ASSIGN, + Rhs: []ast.Expr{f.intLiteral(1)}, + } +} + +// incCounterStmt returns the expression: __count[23]++. +func incCounterStmt(f *File, counter ast.Expr) ast.Stmt { + return &ast.IncDecStmt{ + X: counter, + Tok: token.INC, + } +} + +// atomicCounterStmt returns the expression: atomic.AddUint32(&__count[23], 1) +func atomicCounterStmt(f *File, counter ast.Expr) ast.Stmt { + return &ast.ExprStmt{ + X: &ast.CallExpr{ + Fun: &ast.SelectorExpr{ + X: ast.NewIdent(f.atomicPkg), + Sel: ast.NewIdent("AddUint32"), + }, + Args: []ast.Expr{&ast.UnaryExpr{ + Op: token.AND, + X: counter, + }, + f.intLiteral(1), + }, + }, + } +} + +// newCounter creates a new counter expression of the appropriate form. +func (f *File) newCounter(start, end token.Pos, numStmt int) ast.Stmt { + counter := &ast.IndexExpr{ + X: &ast.SelectorExpr{ + X: ast.NewIdent(*varVar), + Sel: ast.NewIdent("Count"), + }, + Index: f.index(), + } + stmt := counterStmt(f, counter) + f.blocks = append(f.blocks, Block{start, end, numStmt}) + return stmt +} + +// addCounters takes a list of statements and adds counters to the beginning of +// each basic block at the top level of that list. For instance, given +// +// S1 +// if cond { +// S2 +// } +// S3 +// +// counters will be added before S1 and before S3. The block containing S2 +// will be visited in a separate call. +// TODO: Nested simple blocks get unnecessary (but correct) counters +func (f *File) addCounters(pos, blockEnd token.Pos, list []ast.Stmt, extendToClosingBrace bool) []ast.Stmt { + // Special case: make sure we add a counter to an empty block. Can't do this below + // or we will add a counter to an empty statement list after, say, a return statement. + if len(list) == 0 { + return []ast.Stmt{f.newCounter(pos, blockEnd, 0)} + } + // We have a block (statement list), but it may have several basic blocks due to the + // appearance of statements that affect the flow of control. + var newList []ast.Stmt + for { + // Find first statement that affects flow of control (break, continue, if, etc.). + // It will be the last statement of this basic block. + var last int + end := blockEnd + for last = 0; last < len(list); last++ { + end = f.statementBoundary(list[last]) + if f.endsBasicSourceBlock(list[last]) { + extendToClosingBrace = false // Block is broken up now. + last++ + break + } + } + if extendToClosingBrace { + end = blockEnd + } + if pos != end { // Can have no source to cover if e.g. blocks abut. + newList = append(newList, f.newCounter(pos, end, last)) + } + newList = append(newList, list[0:last]...) + list = list[last:] + if len(list) == 0 { + break + } + pos = list[0].Pos() + } + return newList +} + +// hasFuncLiteral reports the existence and position of the first func literal +// in the node, if any. If a func literal appears, it usually marks the termination +// of a basic block because the function body is itself a block. +// Therefore we draw a line at the start of the body of the first function literal we find. +// TODO: what if there's more than one? Probably doesn't matter much. +func hasFuncLiteral(n ast.Node) (bool, token.Pos) { + if n == nil { + return false, 0 + } + var literal funcLitFinder + ast.Walk(&literal, n) + return literal.found(), token.Pos(literal) +} + +// statementBoundary finds the location in s that terminates the current basic +// block in the source. +func (f *File) statementBoundary(s ast.Stmt) token.Pos { + // Control flow statements are easy. + switch s := s.(type) { + case *ast.BlockStmt: + // Treat blocks like basic blocks to avoid overlapping counters. + return s.Lbrace + case *ast.IfStmt: + found, pos := hasFuncLiteral(s.Init) + if found { + return pos + } + found, pos = hasFuncLiteral(s.Cond) + if found { + return pos + } + return s.Body.Lbrace + case *ast.ForStmt: + found, pos := hasFuncLiteral(s.Init) + if found { + return pos + } + found, pos = hasFuncLiteral(s.Cond) + if found { + return pos + } + found, pos = hasFuncLiteral(s.Post) + if found { + return pos + } + return s.Body.Lbrace + case *ast.LabeledStmt: + return f.statementBoundary(s.Stmt) + case *ast.RangeStmt: + found, pos := hasFuncLiteral(s.X) + if found { + return pos + } + return s.Body.Lbrace + case *ast.SwitchStmt: + found, pos := hasFuncLiteral(s.Init) + if found { + return pos + } + found, pos = hasFuncLiteral(s.Tag) + if found { + return pos + } + return s.Body.Lbrace + case *ast.SelectStmt: + return s.Body.Lbrace + case *ast.TypeSwitchStmt: + found, pos := hasFuncLiteral(s.Init) + if found { + return pos + } + return s.Body.Lbrace + } + // If not a control flow statement, it is a declaration, expression, call, etc. and it may have a function literal. + // If it does, that's tricky because we want to exclude the body of the function from this block. + // Draw a line at the start of the body of the first function literal we find. + // TODO: what if there's more than one? Probably doesn't matter much. + found, pos := hasFuncLiteral(s) + if found { + return pos + } + return s.End() +} + +// endsBasicSourceBlock reports whether s changes the flow of control: break, if, etc., +// or if it's just problematic, for instance contains a function literal, which will complicate +// accounting due to the block-within-an expression. +func (f *File) endsBasicSourceBlock(s ast.Stmt) bool { + switch s := s.(type) { + case *ast.BlockStmt: + // Treat blocks like basic blocks to avoid overlapping counters. + return true + case *ast.BranchStmt: + return true + case *ast.ForStmt: + return true + case *ast.IfStmt: + return true + case *ast.LabeledStmt: + return f.endsBasicSourceBlock(s.Stmt) + case *ast.RangeStmt: + return true + case *ast.SwitchStmt: + return true + case *ast.SelectStmt: + return true + case *ast.TypeSwitchStmt: + return true + case *ast.ExprStmt: + // Calls to panic change the flow. + // We really should verify that "panic" is the predefined function, + // but without type checking we can't and the likelihood of it being + // an actual problem is vanishingly small. + if call, ok := s.X.(*ast.CallExpr); ok { + if ident, ok := call.Fun.(*ast.Ident); ok && ident.Name == "panic" && len(call.Args) == 1 { + return true + } + } + } + found, _ := hasFuncLiteral(s) + return found +} + +// funcLitFinder implements the ast.Visitor pattern to find the location of any +// function literal in a subtree. +type funcLitFinder token.Pos + +func (f *funcLitFinder) Visit(node ast.Node) (w ast.Visitor) { + if f.found() { + return nil // Prune search. + } + switch n := node.(type) { + case *ast.FuncLit: + *f = funcLitFinder(n.Body.Lbrace) + return nil // Prune search. + } + return f +} + +func (f *funcLitFinder) found() bool { + return token.Pos(*f) != token.NoPos +} + +// Sort interface for []block1; used for self-check in addVariables. + +type block1 struct { + Block + index int +} + +type blockSlice []block1 + +func (b blockSlice) Len() int { return len(b) } +func (b blockSlice) Less(i, j int) bool { return b[i].startByte < b[j].startByte } +func (b blockSlice) Swap(i, j int) { b[i], b[j] = b[j], b[i] } + +// offset translates a token position into a 0-indexed byte offset. +func (f *File) offset(pos token.Pos) int { + return f.fset.Position(pos).Offset +} + +// addVariables adds to the end of the file the declarations to set up the counter and position variables. +func (f *File) addVariables(w io.Writer) { + // Self-check: Verify that the instrumented basic blocks are disjoint. + t := make([]block1, len(f.blocks)) + for i := range f.blocks { + t[i].Block = f.blocks[i] + t[i].index = i + } + sort.Sort(blockSlice(t)) + for i := 1; i < len(t); i++ { + if t[i-1].endByte > t[i].startByte { + fmt.Fprintf(os.Stderr, "cover: internal error: block %d overlaps block %d\n", t[i-1].index, t[i].index) + // Note: error message is in byte positions, not token positions. + fmt.Fprintf(os.Stderr, "\t%s:#%d,#%d %s:#%d,#%d\n", + f.name, f.offset(t[i-1].startByte), f.offset(t[i-1].endByte), + f.name, f.offset(t[i].startByte), f.offset(t[i].endByte)) + } + } + + // Declare the coverage struct as a package-level variable. + fmt.Fprintf(w, "\nvar %s = struct {\n", *varVar) + fmt.Fprintf(w, "\tCount [%d]uint32\n", len(f.blocks)) + fmt.Fprintf(w, "\tPos [3 * %d]uint32\n", len(f.blocks)) + fmt.Fprintf(w, "\tNumStmt [%d]uint16\n", len(f.blocks)) + fmt.Fprintf(w, "} {\n") + + // Initialize the position array field. + fmt.Fprintf(w, "\tPos: [3 * %d]uint32{\n", len(f.blocks)) + + // A nice long list of positions. Each position is encoded as follows to reduce size: + // - 32-bit starting line number + // - 32-bit ending line number + // - (16 bit ending column number << 16) | (16-bit starting column number). + for i, block := range f.blocks { + start := f.fset.Position(block.startByte) + end := f.fset.Position(block.endByte) + fmt.Fprintf(w, "\t\t%d, %d, %#x, // [%d]\n", start.Line, end.Line, (end.Column&0xFFFF)<<16|(start.Column&0xFFFF), i) + } + + // Close the position array. + fmt.Fprintf(w, "\t},\n") + + // Initialize the position array field. + fmt.Fprintf(w, "\tNumStmt: [%d]uint16{\n", len(f.blocks)) + + // A nice long list of statements-per-block, so we can give a conventional + // valuation of "percent covered". To save space, it's a 16-bit number, so we + // clamp it if it overflows - won't matter in practice. + for i, block := range f.blocks { + n := block.numStmt + if n > 1<<16-1 { + n = 1<<16 - 1 + } + fmt.Fprintf(w, "\t\t%d, // %d\n", n, i) + } + + // Close the statements-per-block array. + fmt.Fprintf(w, "\t},\n") + + // Close the struct initialization. + fmt.Fprintf(w, "}\n") +} diff --git a/vendor/golang.org/x/tools/cmd/cover/cover_test.go b/vendor/golang.org/x/tools/cmd/cover/cover_test.go new file mode 100644 index 00000000..a18778b5 --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/cover/cover_test.go @@ -0,0 +1,94 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// No testdata on Android. + +// +build !android + +package main_test + +import ( + "bytes" + "fmt" + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "testing" +) + +const ( + // Data directory, also the package directory for the test. + testdata = "testdata" + + // Binaries we compile. + testcover = "./testcover.exe" +) + +var ( + // Files we use. + testMain = filepath.Join(testdata, "main.go") + testTest = filepath.Join(testdata, "test.go") + coverInput = filepath.Join(testdata, "test_line.go") + coverOutput = filepath.Join(testdata, "test_cover.go") +) + +var debug = false // Keeps the rewritten files around if set. + +// Run this shell script, but do it in Go so it can be run by "go test". +// +// replace the word LINE with the line number < testdata/test.go > testdata/test_line.go +// go build -o ./testcover +// ./testcover -mode=count -var=CoverTest -o ./testdata/test_cover.go testdata/test_line.go +// go run ./testdata/main.go ./testdata/test.go +// +func TestCover(t *testing.T) { + // Read in the test file (testTest) and write it, with LINEs specified, to coverInput. + file, err := ioutil.ReadFile(testTest) + if err != nil { + t.Fatal(err) + } + lines := bytes.Split(file, []byte("\n")) + for i, line := range lines { + lines[i] = bytes.Replace(line, []byte("LINE"), []byte(fmt.Sprint(i+1)), -1) + } + err = ioutil.WriteFile(coverInput, bytes.Join(lines, []byte("\n")), 0666) + if err != nil { + t.Fatal(err) + } + + // defer removal of test_line.go + if !debug { + defer os.Remove(coverInput) + } + + // go build -o testcover + cmd := exec.Command("go", "build", "-o", testcover) + run(cmd, t) + + // defer removal of testcover + defer os.Remove(testcover) + + // ./testcover -mode=count -var=coverTest -o ./testdata/test_cover.go testdata/test_line.go + cmd = exec.Command(testcover, "-mode=count", "-var=coverTest", "-o", coverOutput, coverInput) + run(cmd, t) + + // defer removal of ./testdata/test_cover.go + if !debug { + defer os.Remove(coverOutput) + } + + // go run ./testdata/main.go ./testdata/test.go + cmd = exec.Command("go", "run", testMain, coverOutput) + run(cmd, t) +} + +func run(c *exec.Cmd, t *testing.T) { + c.Stdout = os.Stdout + c.Stderr = os.Stderr + err := c.Run() + if err != nil { + t.Fatal(err) + } +} diff --git a/vendor/golang.org/x/tools/cmd/cover/doc.go b/vendor/golang.org/x/tools/cmd/cover/doc.go new file mode 100644 index 00000000..b74d5b3c --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/cover/doc.go @@ -0,0 +1,27 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +/* +Cover is a program for analyzing the coverage profiles generated by +'go test -coverprofile=cover.out'. + +Cover is also used by 'go test -cover' to rewrite the source code with +annotations to track which parts of each function are executed. +It operates on one Go source file at a time, computing approximate +basic block information by studying the source. It is thus more portable +than binary-rewriting coverage tools, but also a little less capable. +For instance, it does not probe inside && and || expressions, and can +be mildly confused by single statements with multiple function literals. + +For usage information, please see: + go help testflag + go tool cover -help + +No longer maintained: + +For Go releases 1.5 and later, this tool lives in the +standard repository. The code here is not maintained. + +*/ +package main // import "golang.org/x/tools/cmd/cover" diff --git a/vendor/golang.org/x/tools/cmd/cover/func.go b/vendor/golang.org/x/tools/cmd/cover/func.go new file mode 100644 index 00000000..41d9fcec --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/cover/func.go @@ -0,0 +1,166 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file implements the visitor that computes the (line, column)-(line-column) range for each function. + +package main + +import ( + "bufio" + "fmt" + "go/ast" + "go/build" + "go/parser" + "go/token" + "os" + "path/filepath" + "text/tabwriter" + + "golang.org/x/tools/cover" +) + +// funcOutput takes two file names as arguments, a coverage profile to read as input and an output +// file to write ("" means to write to standard output). The function reads the profile and produces +// as output the coverage data broken down by function, like this: +// +// fmt/format.go:30: init 100.0% +// fmt/format.go:57: clearflags 100.0% +// ... +// fmt/scan.go:1046: doScan 100.0% +// fmt/scan.go:1075: advance 96.2% +// fmt/scan.go:1119: doScanf 96.8% +// total: (statements) 91.9% + +func funcOutput(profile, outputFile string) error { + profiles, err := cover.ParseProfiles(profile) + if err != nil { + return err + } + + var out *bufio.Writer + if outputFile == "" { + out = bufio.NewWriter(os.Stdout) + } else { + fd, err := os.Create(outputFile) + if err != nil { + return err + } + defer fd.Close() + out = bufio.NewWriter(fd) + } + defer out.Flush() + + tabber := tabwriter.NewWriter(out, 1, 8, 1, '\t', 0) + defer tabber.Flush() + + var total, covered int64 + for _, profile := range profiles { + fn := profile.FileName + file, err := findFile(fn) + if err != nil { + return err + } + funcs, err := findFuncs(file) + if err != nil { + return err + } + // Now match up functions and profile blocks. + for _, f := range funcs { + c, t := f.coverage(profile) + fmt.Fprintf(tabber, "%s:%d:\t%s\t%.1f%%\n", fn, f.startLine, f.name, 100.0*float64(c)/float64(t)) + total += t + covered += c + } + } + fmt.Fprintf(tabber, "total:\t(statements)\t%.1f%%\n", 100.0*float64(covered)/float64(total)) + + return nil +} + +// findFuncs parses the file and returns a slice of FuncExtent descriptors. +func findFuncs(name string) ([]*FuncExtent, error) { + fset := token.NewFileSet() + parsedFile, err := parser.ParseFile(fset, name, nil, 0) + if err != nil { + return nil, err + } + visitor := &FuncVisitor{ + fset: fset, + name: name, + astFile: parsedFile, + } + ast.Walk(visitor, visitor.astFile) + return visitor.funcs, nil +} + +// FuncExtent describes a function's extent in the source by file and position. +type FuncExtent struct { + name string + startLine int + startCol int + endLine int + endCol int +} + +// FuncVisitor implements the visitor that builds the function position list for a file. +type FuncVisitor struct { + fset *token.FileSet + name string // Name of file. + astFile *ast.File + funcs []*FuncExtent +} + +// Visit implements the ast.Visitor interface. +func (v *FuncVisitor) Visit(node ast.Node) ast.Visitor { + switch n := node.(type) { + case *ast.FuncDecl: + start := v.fset.Position(n.Pos()) + end := v.fset.Position(n.End()) + fe := &FuncExtent{ + name: n.Name.Name, + startLine: start.Line, + startCol: start.Column, + endLine: end.Line, + endCol: end.Column, + } + v.funcs = append(v.funcs, fe) + } + return v +} + +// coverage returns the fraction of the statements in the function that were covered, as a numerator and denominator. +func (f *FuncExtent) coverage(profile *cover.Profile) (num, den int64) { + // We could avoid making this n^2 overall by doing a single scan and annotating the functions, + // but the sizes of the data structures is never very large and the scan is almost instantaneous. + var covered, total int64 + // The blocks are sorted, so we can stop counting as soon as we reach the end of the relevant block. + for _, b := range profile.Blocks { + if b.StartLine > f.endLine || (b.StartLine == f.endLine && b.StartCol >= f.endCol) { + // Past the end of the function. + break + } + if b.EndLine < f.startLine || (b.EndLine == f.startLine && b.EndCol <= f.startCol) { + // Before the beginning of the function + continue + } + total += int64(b.NumStmt) + if b.Count > 0 { + covered += int64(b.NumStmt) + } + } + if total == 0 { + total = 1 // Avoid zero denominator. + } + return covered, total +} + +// findFile finds the location of the named file in GOROOT, GOPATH etc. +func findFile(file string) (string, error) { + dir, file := filepath.Split(file) + pkg, err := build.Import(dir, ".", build.FindOnly) + if err != nil { + return "", fmt.Errorf("can't find %q: %v", file, err) + } + return filepath.Join(pkg.Dir, file), nil +} diff --git a/vendor/golang.org/x/tools/cmd/cover/html.go b/vendor/golang.org/x/tools/cmd/cover/html.go new file mode 100644 index 00000000..ef50e2bf --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/cover/html.go @@ -0,0 +1,284 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "bufio" + "bytes" + "fmt" + "html/template" + "io" + "io/ioutil" + "math" + "os" + "os/exec" + "path/filepath" + "runtime" + + "golang.org/x/tools/cover" +) + +// htmlOutput reads the profile data from profile and generates an HTML +// coverage report, writing it to outfile. If outfile is empty, +// it writes the report to a temporary file and opens it in a web browser. +func htmlOutput(profile, outfile string) error { + profiles, err := cover.ParseProfiles(profile) + if err != nil { + return err + } + + var d templateData + + for _, profile := range profiles { + fn := profile.FileName + if profile.Mode == "set" { + d.Set = true + } + file, err := findFile(fn) + if err != nil { + return err + } + src, err := ioutil.ReadFile(file) + if err != nil { + return fmt.Errorf("can't read %q: %v", fn, err) + } + var buf bytes.Buffer + err = htmlGen(&buf, src, profile.Boundaries(src)) + if err != nil { + return err + } + d.Files = append(d.Files, &templateFile{ + Name: fn, + Body: template.HTML(buf.String()), + Coverage: percentCovered(profile), + }) + } + + var out *os.File + if outfile == "" { + var dir string + dir, err = ioutil.TempDir("", "cover") + if err != nil { + return err + } + out, err = os.Create(filepath.Join(dir, "coverage.html")) + } else { + out, err = os.Create(outfile) + } + if err != nil { + return err + } + err = htmlTemplate.Execute(out, d) + if err == nil { + err = out.Close() + } + if err != nil { + return err + } + + if outfile == "" { + if !startBrowser("file://" + out.Name()) { + fmt.Fprintf(os.Stderr, "HTML output written to %s\n", out.Name()) + } + } + + return nil +} + +// percentCovered returns, as a percentage, the fraction of the statements in +// the profile covered by the test run. +// In effect, it reports the coverage of a given source file. +func percentCovered(p *cover.Profile) float64 { + var total, covered int64 + for _, b := range p.Blocks { + total += int64(b.NumStmt) + if b.Count > 0 { + covered += int64(b.NumStmt) + } + } + if total == 0 { + return 0 + } + return float64(covered) / float64(total) * 100 +} + +// htmlGen generates an HTML coverage report with the provided filename, +// source code, and tokens, and writes it to the given Writer. +func htmlGen(w io.Writer, src []byte, boundaries []cover.Boundary) error { + dst := bufio.NewWriter(w) + for i := range src { + for len(boundaries) > 0 && boundaries[0].Offset == i { + b := boundaries[0] + if b.Start { + n := 0 + if b.Count > 0 { + n = int(math.Floor(b.Norm*9)) + 1 + } + fmt.Fprintf(dst, ``, n, b.Count) + } else { + dst.WriteString("") + } + boundaries = boundaries[1:] + } + switch b := src[i]; b { + case '>': + dst.WriteString(">") + case '<': + dst.WriteString("<") + case '&': + dst.WriteString("&") + case '\t': + dst.WriteString(" ") + default: + dst.WriteByte(b) + } + } + return dst.Flush() +} + +// startBrowser tries to open the URL in a browser +// and reports whether it succeeds. +func startBrowser(url string) bool { + // try to start the browser + var args []string + switch runtime.GOOS { + case "darwin": + args = []string{"open"} + case "windows": + args = []string{"cmd", "/c", "start"} + default: + args = []string{"xdg-open"} + } + cmd := exec.Command(args[0], append(args[1:], url)...) + return cmd.Start() == nil +} + +// rgb returns an rgb value for the specified coverage value +// between 0 (no coverage) and 10 (max coverage). +func rgb(n int) string { + if n == 0 { + return "rgb(192, 0, 0)" // Red + } + // Gradient from gray to green. + r := 128 - 12*(n-1) + g := 128 + 12*(n-1) + b := 128 + 3*(n-1) + return fmt.Sprintf("rgb(%v, %v, %v)", r, g, b) +} + +// colors generates the CSS rules for coverage colors. +func colors() template.CSS { + var buf bytes.Buffer + for i := 0; i < 11; i++ { + fmt.Fprintf(&buf, ".cov%v { color: %v }\n", i, rgb(i)) + } + return template.CSS(buf.String()) +} + +var htmlTemplate = template.Must(template.New("html").Funcs(template.FuncMap{ + "colors": colors, +}).Parse(tmplHTML)) + +type templateData struct { + Files []*templateFile + Set bool +} + +type templateFile struct { + Name string + Body template.HTML + Coverage float64 +} + +const tmplHTML = ` + + + + + + + +
+ +
+ not tracked + {{if .Set}} + not covered + covered + {{else}} + no coverage + low coverage + * + * + * + * + * + * + * + * + high coverage + {{end}} +
+
+
+ {{range $i, $f := .Files}} +
{{$f.Body}}
+ {{end}} +
+ + + +` diff --git a/vendor/golang.org/x/tools/cmd/cover/testdata/main.go b/vendor/golang.org/x/tools/cmd/cover/testdata/main.go new file mode 100644 index 00000000..6ed39c4f --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/cover/testdata/main.go @@ -0,0 +1,112 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test runner for coverage test. This file is not coverage-annotated; test.go is. +// It knows the coverage counter is called "coverTest". + +package main + +import ( + "fmt" + "os" +) + +func main() { + testAll() + verify() +} + +type block struct { + count uint32 + line uint32 +} + +var counters = make(map[block]bool) + +// check records the location and expected value for a counter. +func check(line, count uint32) { + b := block{ + count, + line, + } + counters[b] = true +} + +// checkVal is a version of check that returns its extra argument, +// so it can be used in conditionals. +func checkVal(line, count uint32, val int) int { + b := block{ + count, + line, + } + counters[b] = true + return val +} + +var PASS = true + +// verify checks the expected counts against the actual. It runs after the test has completed. +func verify() { + for b := range counters { + got, index := count(b.line) + if b.count == anything && got != 0 { + got = anything + } + if got != b.count { + fmt.Fprintf(os.Stderr, "test_go:%d expected count %d got %d [counter %d]\n", b.line, b.count, got, index) + PASS = false + } + } + verifyPanic() + if !PASS { + fmt.Fprintf(os.Stderr, "FAIL\n") + os.Exit(2) + } +} + +// verifyPanic is a special check for the known counter that should be +// after the panic call in testPanic. +func verifyPanic() { + if coverTest.Count[panicIndex-1] != 1 { + // Sanity check for test before panic. + fmt.Fprintf(os.Stderr, "bad before panic") + PASS = false + } + if coverTest.Count[panicIndex] != 0 { + fmt.Fprintf(os.Stderr, "bad at panic: %d should be 0\n", coverTest.Count[panicIndex]) + PASS = false + } + if coverTest.Count[panicIndex+1] != 1 { + fmt.Fprintf(os.Stderr, "bad after panic") + PASS = false + } +} + +// count returns the count and index for the counter at the specified line. +func count(line uint32) (uint32, int) { + // Linear search is fine. Choose perfect fit over approximate. + // We can have a closing brace for a range on the same line as a condition for an "else if" + // and we don't want that brace to steal the count for the condition on the "if". + // Therefore we test for a perfect (lo==line && hi==line) match, but if we can't + // find that we take the first imperfect match. + index := -1 + indexLo := uint32(1e9) + for i := range coverTest.Count { + lo, hi := coverTest.Pos[3*i], coverTest.Pos[3*i+1] + if lo == line && line == hi { + return coverTest.Count[i], i + } + // Choose the earliest match (the counters are in unpredictable order). + if lo <= line && line <= hi && indexLo > lo { + index = i + indexLo = lo + } + } + if index == -1 { + fmt.Fprintln(os.Stderr, "cover_test: no counter for line", line) + PASS = false + return 0, 0 + } + return coverTest.Count[index], index +} diff --git a/vendor/golang.org/x/tools/cmd/cover/testdata/test.go b/vendor/golang.org/x/tools/cmd/cover/testdata/test.go new file mode 100644 index 00000000..9013950a --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/cover/testdata/test.go @@ -0,0 +1,218 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This program is processed by the cover command, and then testAll is called. +// The test driver in main.go can then compare the coverage statistics with expectation. + +// The word LINE is replaced by the line number in this file. When the file is executed, +// the coverage processing has changed the line numbers, so we can't use runtime.Caller. + +package main + +const anything = 1e9 // Just some unlikely value that means "we got here, don't care how often" + +func testAll() { + testSimple() + testBlockRun() + testIf() + testFor() + testRange() + testSwitch() + testTypeSwitch() + testSelect1() + testSelect2() + testPanic() + testEmptySwitches() +} + +// The indexes of the counters in testPanic are known to main.go +const panicIndex = 3 + +// This test appears first because the index of its counters is known to main.go +func testPanic() { + defer func() { + recover() + }() + check(LINE, 1) + panic("should not get next line") + check(LINE, 0) // this is GoCover.Count[panicIndex] + // The next counter is in testSimple and it will be non-zero. + // If the panic above does not trigger a counter, the test will fail + // because GoCover.Count[panicIndex] will be the one in testSimple. +} + +func testSimple() { + check(LINE, 1) +} + +func testIf() { + if true { + check(LINE, 1) + } else { + check(LINE, 0) + } + if false { + check(LINE, 0) + } else { + check(LINE, 1) + } + for i := 0; i < 3; i++ { + if checkVal(LINE, 3, i) <= 2 { + check(LINE, 3) + } + if checkVal(LINE, 3, i) <= 1 { + check(LINE, 2) + } + if checkVal(LINE, 3, i) <= 0 { + check(LINE, 1) + } + } + for i := 0; i < 3; i++ { + if checkVal(LINE, 3, i) <= 1 { + check(LINE, 2) + } else { + check(LINE, 1) + } + } + for i := 0; i < 3; i++ { + if checkVal(LINE, 3, i) <= 0 { + check(LINE, 1) + } else if checkVal(LINE, 2, i) <= 1 { + check(LINE, 1) + } else if checkVal(LINE, 1, i) <= 2 { + check(LINE, 1) + } else if checkVal(LINE, 0, i) <= 3 { + check(LINE, 0) + } + } + if func(a, b int) bool { return a < b }(3, 4) { + check(LINE, 1) + } +} + +func testFor() { + for i := 0; i < 10; func() { i++; check(LINE, 10) }() { + check(LINE, 10) + } +} + +func testRange() { + for _, f := range []func(){ + func() { check(LINE, 1) }, + } { + f() + check(LINE, 1) + } +} + +func testBlockRun() { + check(LINE, 1) + { + check(LINE, 1) + } + { + check(LINE, 1) + } + check(LINE, 1) + { + check(LINE, 1) + } + { + check(LINE, 1) + } + check(LINE, 1) +} + +func testSwitch() { + for i := 0; i < 5; func() { i++; check(LINE, 5) }() { + switch i { + case 0: + check(LINE, 1) + case 1: + check(LINE, 1) + case 2: + check(LINE, 1) + default: + check(LINE, 2) + } + } +} + +func testTypeSwitch() { + var x = []interface{}{1, 2.0, "hi"} + for _, v := range x { + switch func() { check(LINE, 3) }(); v.(type) { + case int: + check(LINE, 1) + case float64: + check(LINE, 1) + case string: + check(LINE, 1) + case complex128: + check(LINE, 0) + default: + check(LINE, 0) + } + } +} + +func testSelect1() { + c := make(chan int) + go func() { + for i := 0; i < 1000; i++ { + c <- i + } + }() + for { + select { + case <-c: + check(LINE, anything) + case <-c: + check(LINE, anything) + default: + check(LINE, 1) + return + } + } +} + +func testSelect2() { + c1 := make(chan int, 1000) + c2 := make(chan int, 1000) + for i := 0; i < 1000; i++ { + c1 <- i + c2 <- i + } + for { + select { + case <-c1: + check(LINE, 1000) + case <-c2: + check(LINE, 1000) + default: + check(LINE, 1) + return + } + } +} + +// Empty control statements created syntax errors. This function +// is here just to be sure that those are handled correctly now. +func testEmptySwitches() { + check(LINE, 1) + switch 3 { + } + check(LINE, 1) + switch i := (interface{})(3).(int); i { + } + check(LINE, 1) + c := make(chan int) + go func() { + check(LINE, 1) + c <- 1 + select {} + }() + <-c + check(LINE, 1) +} diff --git a/vendor/golang.org/x/tools/cmd/digraph/digraph.go b/vendor/golang.org/x/tools/cmd/digraph/digraph.go new file mode 100644 index 00000000..8ef2e45e --- /dev/null +++ b/vendor/golang.org/x/tools/cmd/digraph/digraph.go @@ -0,0 +1,541 @@ +// The digraph command performs queries over unlabelled directed graphs +// represented in text form. It is intended to integrate nicely with +// typical UNIX command pipelines. +// +// Since directed graphs (import graphs, reference graphs, call graphs, +// etc) often arise during software tool development and debugging, this +// command is included in the go.tools repository. +// +// TODO(adonovan): +// - support input files other than stdin +// - support alternative formats (AT&T GraphViz, CSV, etc), +// a comment syntax, etc. +// - allow queries to nest, like Blaze query language. +// +package main // import "golang.org/x/tools/cmd/digraph" + +import ( + "bufio" + "bytes" + "errors" + "flag" + "fmt" + "io" + "os" + "sort" + "strconv" + "unicode" + "unicode/utf8" +) + +const Usage = `digraph: queries over directed graphs in text form. + +Graph format: + + Each line contains zero or more words. Words are separated by + unquoted whitespace; words may contain Go-style double-quoted portions, + allowing spaces and other characters to be expressed. + + Each field declares a node, and if there are more than one, + an edge from the first to each subsequent one. + The graph is provided on the standard input. + + For instance, the following (acyclic) graph specifies a partial order + among the subtasks of getting dressed: + + % cat clothes.txt + socks shoes + "boxer shorts" pants + pants belt shoes + shirt tie sweater + sweater jacket + hat + + The line "shirt tie sweater" indicates the two edges shirt -> tie and + shirt -> sweater, not shirt -> tie -> sweater. + +Supported queries: + + nodes + the set of all nodes + degree + the in-degree and out-degree of each node. + preds