├── .gitignore ├── LICENSE ├── Nut.toml ├── README.md ├── download.go ├── go.go ├── install.go ├── list.go ├── main.go ├── manifest.go ├── new.go ├── pkg.go ├── project.go ├── rewrite.go ├── rewrite_test.go ├── set.go ├── setting.go ├── vcs.go └── vendor └── _nuts ├── github.com ├── BurntSushi │ └── toml │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── COMPATIBLE │ │ ├── COPYING │ │ ├── Makefile │ │ ├── README.md │ │ ├── cmd │ │ ├── toml-test-decoder │ │ │ ├── COPYING │ │ │ ├── README.md │ │ │ └── main.go │ │ ├── toml-test-encoder │ │ │ ├── COPYING │ │ │ ├── README.md │ │ │ └── main.go │ │ └── tomlv │ │ │ ├── COPYING │ │ │ ├── README.md │ │ │ └── main.go │ │ ├── decode.go │ │ ├── decode_meta.go │ │ ├── decode_test.go │ │ ├── doc.go │ │ ├── encode.go │ │ ├── encode_test.go │ │ ├── encoding_types.go │ │ ├── encoding_types_1.1.go │ │ ├── lex.go │ │ ├── parse.go │ │ ├── session.vim │ │ ├── type_check.go │ │ └── type_fields.go └── codegangsta │ └── cli │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── app.go │ ├── app_test.go │ ├── autocomplete │ ├── bash_autocomplete │ └── zsh_autocomplete │ ├── cli.go │ ├── cli_test.go │ ├── command.go │ ├── command_test.go │ ├── context.go │ ├── context_test.go │ ├── flag.go │ ├── flag_test.go │ ├── help.go │ └── helpers_test.go └── golang.org └── x └── tools ├── .gitattributes ├── .gitignore ├── AUTHORS ├── CONTRIBUTORS ├── LICENSE ├── PATENTS ├── README ├── benchmark └── parse │ ├── parse.go │ └── parse_test.go ├── blog ├── atom │ └── atom.go └── blog.go ├── cmd ├── benchcmp │ ├── benchcmp.go │ ├── benchcmp_test.go │ ├── compare.go │ ├── compare_test.go │ └── doc.go ├── callgraph │ ├── main.go │ ├── main_test.go │ └── testdata │ │ └── src │ │ └── pkg │ │ ├── pkg.go │ │ └── pkg_test.go ├── cover │ ├── cover.go │ ├── cover_test.go │ ├── doc.go │ ├── func.go │ ├── html.go │ └── testdata │ │ ├── main.go │ │ └── test.go ├── digraph │ ├── digraph.go │ └── digraph_test.go ├── eg │ └── eg.go ├── godex │ ├── doc.go │ ├── gc.go │ ├── gccgo.go │ ├── godex.go │ ├── print.go │ ├── source.go │ └── writetype.go ├── godoc │ ├── README.godoc-app │ ├── appinit.go │ ├── blog.go │ ├── codewalk.go │ ├── dl.go │ ├── doc.go │ ├── godoc_test.go │ ├── handlers.go │ ├── main.go │ ├── play.go │ ├── remotesearch.go │ ├── setup-godoc-app.bash │ └── x.go ├── goimports │ ├── doc.go │ └── goimports.go ├── gomvpkg │ └── main.go ├── gorename │ └── main.go ├── gotype │ ├── doc.go │ └── gotype.go ├── html2article │ └── conv.go ├── oracle │ ├── emacs-test.bash │ ├── main.go │ ├── oracle.el │ └── oracle.vim ├── present │ ├── appengine.go │ ├── dir.go │ ├── doc.go │ ├── local.go │ ├── play.go │ ├── static │ │ ├── article.css │ │ ├── dir.css │ │ ├── dir.js │ │ ├── favicon.ico │ │ ├── jquery-ui.js │ │ ├── print.css │ │ ├── slides.js │ │ └── styles.css │ └── templates │ │ ├── action.tmpl │ │ ├── article.tmpl │ │ ├── dir.tmpl │ │ └── slides.tmpl ├── ssadump │ └── main.go ├── stringer │ ├── endtoend_test.go │ ├── golden_test.go │ ├── stringer.go │ ├── testdata │ │ ├── cgo.go │ │ ├── day.go │ │ ├── gap.go │ │ ├── num.go │ │ ├── number.go │ │ ├── prime.go │ │ └── unum.go │ └── util_test.go ├── tipgodoc │ ├── Dockerfile │ ├── README │ ├── app.yaml │ └── tip.go └── vet │ ├── asmdecl.go │ ├── assign.go │ ├── atomic.go │ ├── bool.go │ ├── buildtag.go │ ├── composite.go │ ├── copylock.go │ ├── deadcode.go │ ├── doc.go │ ├── main.go │ ├── method.go │ ├── nilfunc.go │ ├── print.go │ ├── rangeloop.go │ ├── shadow.go │ ├── shift.go │ ├── structtag.go │ ├── testdata │ ├── asm.go │ ├── asm1.s │ ├── asm2.s │ ├── asm3.s │ ├── asm4.s │ ├── assign.go │ ├── atomic.go │ ├── bool.go │ ├── buildtag.go │ ├── buildtag_bad.go │ ├── composite.go │ ├── copylock_func.go │ ├── copylock_range.go │ ├── deadcode.go │ ├── method.go │ ├── nilfunc.go │ ├── print.go │ ├── rangeloop.go │ ├── shadow.go │ ├── shift.go │ ├── structtag.go │ └── unsafeptr.go │ ├── types.go │ ├── unsafeptr.go │ ├── vet_test.go │ └── whitelist │ └── whitelist.go ├── container └── intsets │ ├── sparse.go │ ├── sparse_test.go │ ├── util.go │ └── util_test.go ├── cover └── profile.go ├── go ├── ast │ └── astutil │ │ ├── enclosing.go │ │ ├── enclosing_test.go │ │ ├── imports.go │ │ ├── imports_test.go │ │ └── util.go ├── buildutil │ ├── allpackages.go │ ├── allpackages_test.go │ ├── fakecontext.go │ ├── util.go │ └── util_test.go ├── callgraph │ ├── callgraph.go │ ├── cha │ │ ├── cha.go │ │ ├── cha_test.go │ │ └── testdata │ │ │ ├── func.go │ │ │ ├── iface.go │ │ │ └── recv.go │ ├── rta │ │ ├── rta.go │ │ ├── rta_test.go │ │ └── testdata │ │ │ ├── func.go │ │ │ ├── iface.go │ │ │ └── rtype.go │ ├── static │ │ ├── static.go │ │ └── static_test.go │ └── util.go ├── exact │ ├── exact.go │ ├── exact_test.go │ ├── go13.go │ └── go14.go ├── gccgoimporter │ ├── gccgoinstallation.go │ ├── gccgoinstallation_test.go │ ├── importer.go │ ├── importer_test.go │ ├── parser.go │ ├── parser_test.go │ └── testdata │ │ ├── complexnums.go │ │ ├── complexnums.gox │ │ ├── imports.go │ │ ├── imports.gox │ │ ├── pointer.go │ │ └── pointer.gox ├── gcimporter │ ├── exportdata.go │ ├── gcimporter.go │ ├── gcimporter_test.go │ └── testdata │ │ └── exports.go ├── importer │ ├── export.go │ ├── import.go │ ├── import_test.go │ └── predefined.go ├── loader │ ├── cgo.go │ ├── loader.go │ ├── loader_test.go │ ├── source_test.go │ ├── stdlib_test.go │ ├── testdata │ │ ├── a.go │ │ ├── b.go │ │ └── badpkgdecl.go │ └── util.go ├── pointer │ ├── TODO │ ├── analysis.go │ ├── api.go │ ├── callgraph.go │ ├── constraint.go │ ├── doc.go │ ├── example_test.go │ ├── gen.go │ ├── hvn.go │ ├── intrinsics.go │ ├── labels.go │ ├── opt.go │ ├── pointer_test.go │ ├── print.go │ ├── reflect.go │ ├── solve.go │ ├── stdlib_test.go │ ├── testdata │ │ ├── a_test.go │ │ ├── another.go │ │ ├── arrayreflect.go │ │ ├── arrays.go │ │ ├── channels.go │ │ ├── chanreflect.go │ │ ├── chanreflect1.go │ │ ├── context.go │ │ ├── conv.go │ │ ├── finalizer.go │ │ ├── flow.go │ │ ├── fmtexcerpt.go │ │ ├── func.go │ │ ├── funcreflect.go │ │ ├── hello.go │ │ ├── interfaces.go │ │ ├── issue9002.go │ │ ├── mapreflect.go │ │ ├── maps.go │ │ ├── panic.go │ │ ├── recur.go │ │ ├── reflect.go │ │ ├── rtti.go │ │ ├── structreflect.go │ │ ├── structs.go │ │ └── timer.go │ └── util.go ├── ssa │ ├── blockopt.go │ ├── builder.go │ ├── builder_test.go │ ├── const.go │ ├── create.go │ ├── doc.go │ ├── dom.go │ ├── emit.go │ ├── example_test.go │ ├── func.go │ ├── interp │ │ ├── external.go │ │ ├── external_darwin.go │ │ ├── external_freebsd.go │ │ ├── external_plan9.go │ │ ├── external_unix.go │ │ ├── external_windows.go │ │ ├── interp.go │ │ ├── interp_test.go │ │ ├── map.go │ │ ├── ops.go │ │ ├── reflect.go │ │ ├── testdata │ │ │ ├── a_test.go │ │ │ ├── b_test.go │ │ │ ├── boundmeth.go │ │ │ ├── callstack.go │ │ │ ├── complit.go │ │ │ ├── coverage.go │ │ │ ├── defer.go │ │ │ ├── fieldprom.go │ │ │ ├── ifaceconv.go │ │ │ ├── ifaceprom.go │ │ │ ├── initorder.go │ │ │ ├── methprom.go │ │ │ ├── mrvchain.go │ │ │ ├── range.go │ │ │ ├── recover.go │ │ │ ├── reflect.go │ │ │ └── static.go │ │ └── value.go │ ├── lift.go │ ├── lvalue.go │ ├── methods.go │ ├── print.go │ ├── sanity.go │ ├── source.go │ ├── source_test.go │ ├── ssa.go │ ├── ssautil │ │ ├── switch.go │ │ ├── switch_test.go │ │ ├── testdata │ │ │ └── switches.go │ │ └── visit.go │ ├── stdlib_test.go │ ├── testdata │ │ ├── objlookup.go │ │ └── valueforexpr.go │ ├── testmain.go │ ├── testmain_test.go │ ├── util.go │ └── wrappers.go ├── types │ ├── api.go │ ├── api_test.go │ ├── assignments.go │ ├── builtins.go │ ├── builtins_test.go │ ├── call.go │ ├── check.go │ ├── check_test.go │ ├── conversions.go │ ├── decl.go │ ├── errors.go │ ├── eval.go │ ├── eval_test.go │ ├── expr.go │ ├── exprstring.go │ ├── exprstring_test.go │ ├── go11.go │ ├── go12.go │ ├── hilbert_test.go │ ├── initorder.go │ ├── issues_test.go │ ├── labels.go │ ├── lookup.go │ ├── methodset.go │ ├── methodsetcache.go │ ├── object.go │ ├── objset.go │ ├── operand.go │ ├── ordering.go │ ├── package.go │ ├── predicates.go │ ├── resolver.go │ ├── resolver_test.go │ ├── return.go │ ├── scope.go │ ├── selection.go │ ├── self_test.go │ ├── sizes.go │ ├── stdlib_test.go │ ├── stmt.go │ ├── testdata │ │ ├── blank.src │ │ ├── builtins.src │ │ ├── const0.src │ │ ├── const1.src │ │ ├── constdecl.src │ │ ├── conversions.src │ │ ├── cycles.src │ │ ├── cycles1.src │ │ ├── cycles2.src │ │ ├── cycles3.src │ │ ├── cycles4.src │ │ ├── decls0.src │ │ ├── decls1.src │ │ ├── decls2a.src │ │ ├── decls2b.src │ │ ├── decls3.src │ │ ├── errors.src │ │ ├── expr0.src │ │ ├── expr1.src │ │ ├── expr2.src │ │ ├── expr3.src │ │ ├── gotos.src │ │ ├── importdecl0a.src │ │ ├── importdecl0b.src │ │ ├── importdecl1a.src │ │ ├── importdecl1b.src │ │ ├── init0.src │ │ ├── init1.src │ │ ├── init2.src │ │ ├── issues.src │ │ ├── labels.src │ │ ├── methodsets.src │ │ ├── shifts.src │ │ ├── stmt0.src │ │ ├── stmt1.src │ │ └── vardecl.src │ ├── token_test.go │ ├── type.go │ ├── typestring.go │ ├── typestring_test.go │ ├── typeutil │ │ ├── example_test.go │ │ ├── imports.go │ │ ├── imports_test.go │ │ ├── map.go │ │ ├── map_test.go │ │ └── ui.go │ ├── typexpr.go │ └── universe.go └── vcs │ ├── discovery.go │ ├── env.go │ ├── http.go │ ├── vcs.go │ └── vcs_test.go ├── godoc ├── analysis │ ├── README │ ├── analysis.go │ ├── callgraph.go │ ├── implements.go │ ├── json.go │ ├── peers.go │ └── typeinfo.go ├── cmdline.go ├── cmdline_test.go ├── corpus.go ├── dirtrees.go ├── format.go ├── godoc.go ├── godoc_test.go ├── index.go ├── index_test.go ├── linkify.go ├── meta.go ├── page.go ├── parser.go ├── pres.go ├── redirect │ ├── hash.go │ └── redirect.go ├── search.go ├── server.go ├── server_test.go ├── snippet.go ├── spec.go ├── spot.go ├── static │ ├── analysis │ │ ├── call-eg.png │ │ ├── call3.png │ │ ├── callers1.png │ │ ├── callers2.png │ │ ├── chan1.png │ │ ├── chan2a.png │ │ ├── chan2b.png │ │ ├── error1.png │ │ ├── help.html │ │ ├── ident-def.png │ │ ├── ident-field.png │ │ ├── ident-func.png │ │ ├── ipcg-func.png │ │ ├── ipcg-pkg.png │ │ ├── typeinfo-pkg.png │ │ └── typeinfo-src.png │ ├── callgraph.html │ ├── codewalk.html │ ├── codewalkdir.html │ ├── dirlist.html │ ├── doc.go │ ├── error.html │ ├── example.html │ ├── gen.go │ ├── godoc.html │ ├── godocs.js │ ├── images │ │ ├── minus.gif │ │ ├── plus.gif │ │ ├── treeview-black-line.gif │ │ ├── treeview-black.gif │ │ ├── treeview-default-line.gif │ │ ├── treeview-default.gif │ │ ├── treeview-gray-line.gif │ │ └── treeview-gray.gif │ ├── implements.html │ ├── jquery.js │ ├── jquery.treeview.css │ ├── jquery.treeview.edit.js │ ├── jquery.treeview.js │ ├── makestatic.go │ ├── methodset.html │ ├── opensearch.xml │ ├── package.html │ ├── package.txt │ ├── play.js │ ├── playground.js │ ├── search.html │ ├── search.txt │ ├── searchcode.html │ ├── searchdoc.html │ ├── searchtxt.html │ ├── static.go │ └── style.css ├── tab.go ├── template.go ├── util │ ├── throttle.go │ └── util.go └── vfs │ ├── gatefs │ └── gatefs.go │ ├── httpfs │ └── httpfs.go │ ├── mapfs │ ├── mapfs.go │ └── mapfs_test.go │ ├── namespace.go │ ├── os.go │ ├── vfs.go │ └── zipfs │ └── zipfs.go ├── imports ├── fix.go ├── fix_test.go ├── imports.go ├── mkindex.go ├── mkstdlib.go ├── sortimports.go ├── sortimports_compat.go └── zstdlib.go ├── oracle ├── TODO ├── callees.go ├── callers.go ├── callgraph.go ├── callstack.go ├── definition.go ├── describe.go ├── freevars.go ├── implements.go ├── oracle.go ├── oracle_test.go ├── peers.go ├── pointsto.go ├── pos.go ├── referrers.go ├── serial │ └── serial.go ├── testdata │ └── src │ │ ├── lib │ │ └── lib.go │ │ └── main │ │ ├── callgraph-json.go │ │ ├── callgraph-json.golden │ │ ├── callgraph.go │ │ ├── callgraph.golden │ │ ├── callgraph2.go │ │ ├── callgraph2.golden │ │ ├── calls-json.go │ │ ├── calls-json.golden │ │ ├── calls.go │ │ ├── calls.golden │ │ ├── describe-json.go │ │ ├── describe-json.golden │ │ ├── describe.go │ │ ├── describe.golden │ │ ├── freevars.go │ │ ├── freevars.golden │ │ ├── implements-json.go │ │ ├── implements-json.golden │ │ ├── implements.go │ │ ├── implements.golden │ │ ├── imports.go │ │ ├── imports.golden │ │ ├── multi.go │ │ ├── peers-json.go │ │ ├── peers-json.golden │ │ ├── peers.go │ │ ├── peers.golden │ │ ├── pointsto-json.go │ │ ├── pointsto-json.golden │ │ ├── pointsto.go │ │ ├── pointsto.golden │ │ ├── referrers-json.go │ │ ├── referrers-json.golden │ │ ├── reflection.go │ │ ├── reflection.golden │ │ ├── what-json.go │ │ ├── what-json.golden │ │ ├── what.go │ │ ├── what.golden │ │ ├── whicherrs.go │ │ └── whicherrs.golden ├── what.go └── whicherrs.go ├── playground ├── appengine.go ├── common.go ├── local.go └── socket │ └── socket.go ├── present ├── args.go ├── caption.go ├── code.go ├── doc.go ├── html.go ├── iframe.go ├── image.go ├── link.go ├── link_test.go ├── parse.go ├── style.go └── style_test.go └── refactor ├── README ├── eg ├── eg.go ├── eg_test.go ├── match.go ├── rewrite.go └── testdata │ ├── A.template │ ├── A1.go │ ├── A1.golden │ ├── A2.go │ ├── A2.golden │ ├── B.template │ ├── B1.go │ ├── B1.golden │ ├── C.template │ ├── C1.go │ ├── C1.golden │ ├── D.template │ ├── D1.go │ ├── D1.golden │ ├── E.template │ ├── E1.go │ ├── E1.golden │ ├── F.template │ ├── F1.go │ ├── F1.golden │ ├── bad_type.template │ ├── expr_type_mismatch.template │ ├── no_after_return.template │ ├── no_before.template │ └── type_mismatch.template ├── importgraph ├── graph.go └── graph_test.go ├── lexical ├── lexical.go └── lexical_test.go ├── rename ├── check.go ├── mvpkg.go ├── mvpkg_test.go ├── rename.el ├── rename.go ├── rename_test.go ├── spec.go └── util.go └── satisfy └── find.go /.gitignore: -------------------------------------------------------------------------------- 1 | nut 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Jingwen Owen Ou 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Nut.toml: -------------------------------------------------------------------------------- 1 | [application] 2 | 3 | name = "nut" 4 | version = "0.0.1" 5 | authors = ["Jingwen Owen Ou "] 6 | 7 | [dependencies] 8 | 9 | "github.com/codegangsta/cli" = "" 10 | "github.com/BurntSushi/toml" = "" 11 | "golang.org/x/tools/go/vcs" = "" 12 | -------------------------------------------------------------------------------- /download.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | ) 8 | 9 | func downloadPkgs(deps ManifestDeps) error { 10 | srcPath := getSrcPath(setting.WorkDir()) 11 | for importPath, rev := range deps { 12 | showRev := rev 13 | if showRev == "" { 14 | showRev = "latest" 15 | } 16 | 17 | fmt.Printf("Downloading %s@%s\n", importPath, showRev) 18 | err := downloadPkg(srcPath, importPath, rev) 19 | if err != nil { 20 | return err 21 | } 22 | } 23 | 24 | return nil 25 | } 26 | 27 | // downloadPkg downloads package and checkouts revision to dir 28 | func downloadPkg(dir, importPath, rev string) error { 29 | root, vcs, err := VCSForImportPath(importPath) 30 | if err != nil { 31 | return err 32 | } 33 | 34 | pkgRoot := filepath.Join(dir, filepath.FromSlash(root.Root)) 35 | err = os.MkdirAll(filepath.Dir(pkgRoot), os.ModePerm) 36 | if err != nil { 37 | return err 38 | } 39 | 40 | if rev == "" { 41 | err = vcs.Create(pkgRoot, root.Repo) 42 | } else { 43 | err = vcs.CreateAtRev(pkgRoot, root.Repo, rev) 44 | } 45 | 46 | return nil 47 | } 48 | 49 | func getSrcPath(path string) string { 50 | return path + "/src" 51 | } 52 | -------------------------------------------------------------------------------- /go.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "os/exec" 6 | "strings" 7 | ) 8 | 9 | func goGet(dir string, importPath ...string) error { 10 | if len(importPath) == 0 { 11 | return nil 12 | } 13 | 14 | cmd := []string{"get", "-d", "-t"} 15 | cmd = append(cmd, importPath...) 16 | 17 | c := newGoCmd(cmd...) 18 | c.Dir = dir 19 | 20 | return c.Run() 21 | } 22 | 23 | func runGoCmd(args ...string) error { 24 | c := newGoCmd(args...) 25 | 26 | return c.Run() 27 | } 28 | 29 | func newGoCmd(args ...string) *exec.Cmd { 30 | c := exec.Command("go", args...) 31 | c.Env = goCmdEnv() 32 | c.Stdin = os.Stdin 33 | c.Stdout = os.Stdout 34 | c.Stderr = os.Stderr 35 | 36 | return c 37 | } 38 | 39 | func goCmdEnv() []string { 40 | return append(envNoGopath(), "GOPATH="+setting.WorkDir()) 41 | } 42 | 43 | func envNoGopath() (a []string) { 44 | for _, s := range os.Environ() { 45 | if !strings.HasPrefix(s, "GOPATH=") { 46 | a = append(a, s) 47 | } 48 | } 49 | return a 50 | } 51 | -------------------------------------------------------------------------------- /list.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "runtime" 6 | 7 | "github.com/jingweno/nut/vendor/_nuts/github.com/codegangsta/cli" 8 | "github.com/jingweno/nut/vendor/_nuts/golang.org/x/tools/go/vcs" 9 | ) 10 | 11 | var listCmd = cli.Command{ 12 | Name: "list", 13 | Usage: "list vendored dependencies", 14 | Action: runList, 15 | } 16 | 17 | func runList(c *cli.Context) { 18 | p, err := NewProject() 19 | check(err) 20 | 21 | r, err := vcs.RepoRootForImportPath("github.com/codegangsta/cli", false) 22 | check(err) 23 | 24 | err = r.VCS.Create("../test", r.Repo) 25 | check(err) 26 | 27 | fmt.Println(p.ImportPath) 28 | fmt.Println(r) 29 | fmt.Println(runtime.Version()) 30 | } 31 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/jingweno/nut/vendor/_nuts/github.com/codegangsta/cli" 8 | ) 9 | 10 | func main() { 11 | app := cli.NewApp() 12 | app.Name = "nut" 13 | app.Usage = "Vendor Go dependencies" 14 | app.Version = "0.0.1" 15 | app.Author = "" 16 | app.Email = "" 17 | 18 | app.Commands = []cli.Command{ 19 | installCmd, 20 | newCmd, 21 | } 22 | 23 | app.Run(os.Args) 24 | } 25 | 26 | func check(err error) { 27 | if err != nil { 28 | fmt.Fprintln(os.Stderr, err) 29 | os.Exit(1) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /manifest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/jingweno/nut/vendor/_nuts/github.com/BurntSushi/toml" 4 | 5 | type Manifest struct { 6 | App ManifestApp `toml:"application"` 7 | Deps ManifestDeps `toml:"dependencies"` 8 | } 9 | 10 | type ManifestApp struct { 11 | Name string 12 | Version string 13 | Authors []string 14 | } 15 | 16 | type ManifestDeps map[string]string 17 | 18 | func loadManifest() (*Manifest, error) { 19 | var m Manifest 20 | _, err := toml.DecodeFile(setting.ConfigFile, &m) 21 | if err != nil { 22 | return nil, err 23 | } 24 | 25 | return &m, nil 26 | } 27 | -------------------------------------------------------------------------------- /project.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | type Project struct { 9 | ImportPath string 10 | Deps []*Dep 11 | } 12 | 13 | type Dep struct { 14 | ImportPath string 15 | Rev string 16 | Deps []*Dep 17 | } 18 | 19 | func NewProject() (*Project, error) { 20 | l := pkgLister{ 21 | Env: os.Environ(), 22 | } 23 | 24 | pkgs, err := l.List(".") 25 | if err != nil { 26 | return nil, err 27 | } 28 | 29 | if len(pkgs) == 0 { 30 | return nil, fmt.Errorf("Error loading project info") 31 | } 32 | 33 | p := &Project{ImportPath: pkgs[0].ImportPath} 34 | 35 | //for n, _ := range setting.Config().Deps { 36 | //} 37 | 38 | return p, nil 39 | } 40 | -------------------------------------------------------------------------------- /rewrite_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "go/parser" 5 | "go/token" 6 | "io/ioutil" 7 | "os" 8 | "strconv" 9 | "testing" 10 | ) 11 | 12 | func Test_rewriteGoFile(t *testing.T) { 13 | f, _ := ioutil.TempFile("", "rewriteGoFile.go") 14 | f.Close() 15 | 16 | c := `package main 17 | 18 | import( 19 | "github.com/octokit/go-octokit" 20 | ) 21 | 22 | func main() { 23 | fmt.Println("hi") 24 | } 25 | 26 | ` 27 | ioutil.WriteFile(f.Name(), []byte(c), os.ModePerm) 28 | 29 | err := rewriteGoFile(f.Name(), "github.com/gophergala/nut", []string{"github.com/octokit/go-octokit"}) 30 | if err != nil { 31 | t.Fatal("err isn't nil for rewriteGoFile") 32 | } 33 | 34 | fset := token.NewFileSet() 35 | ff, _ := parser.ParseFile(fset, f.Name(), nil, parser.ParseComments) 36 | 37 | if len(ff.Imports) != 1 { 38 | t.Fatal("there should be only one import") 39 | } 40 | 41 | i, _ := strconv.Unquote(ff.Imports[0].Path.Value) 42 | if i != "github.com/gophergala/nut/vendor/_nuts/github.com/octokit/go-octokit" { 43 | t.Fatalf("import is wrong: %s", i) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /set.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func newSet() set { 4 | return make(set) 5 | } 6 | 7 | type set map[interface{}]struct{} 8 | 9 | func (set *set) Add(i interface{}) bool { 10 | _, found := (*set)[i] 11 | (*set)[i] = struct{}{} 12 | return !found 13 | } 14 | 15 | func (set *set) Contains(i ...interface{}) bool { 16 | for _, val := range i { 17 | if _, ok := (*set)[val]; !ok { 18 | return false 19 | } 20 | } 21 | 22 | return true 23 | } 24 | 25 | func (set *set) Iter() <-chan interface{} { 26 | ch := make(chan interface{}) 27 | go func() { 28 | for elem := range *set { 29 | ch <- elem 30 | } 31 | close(ch) 32 | }() 33 | 34 | return ch 35 | } 36 | 37 | func (set *set) Size() int { 38 | return len(*set) 39 | } 40 | 41 | func (set *set) ToSliceString() []string { 42 | keys := make([]string, 0, set.Size()) 43 | for elem := range *set { 44 | keys = append(keys, elem.(string)) 45 | } 46 | 47 | return keys 48 | } 49 | -------------------------------------------------------------------------------- /setting.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "path/filepath" 7 | ) 8 | 9 | var setting *Setting 10 | 11 | func init() { 12 | pwd, err := os.Getwd() 13 | check(err) 14 | 15 | setting = &Setting{ 16 | ProjectDir: pwd, 17 | ConfigFile: filepath.Join(pwd, "Nut.toml"), 18 | ConfigLockFile: filepath.Join(pwd, "Nut.lock"), 19 | } 20 | } 21 | 22 | type Setting struct { 23 | ProjectDir string 24 | ConfigFile string 25 | ConfigLockFile string 26 | goPath string 27 | manifest *Manifest 28 | } 29 | 30 | func (s *Setting) WorkDir() string { 31 | if s.goPath == "" { 32 | temp, err := ioutil.TempDir("", "nut") 33 | check(err) 34 | 35 | s.goPath = temp 36 | } 37 | 38 | return s.goPath 39 | } 40 | 41 | func (s *Setting) VendorDir() string { 42 | return filepath.Join(setting.ProjectDir, "vendor", "_nuts") 43 | } 44 | 45 | func (s *Setting) Manifest() *Manifest { 46 | if s.manifest == nil { 47 | var err error 48 | s.manifest, err = loadManifest() 49 | check(err) 50 | } 51 | 52 | return s.manifest 53 | } 54 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/.gitignore: -------------------------------------------------------------------------------- 1 | TAGS 2 | tags 3 | .*.swp 4 | tomlcheck/tomlcheck 5 | toml.test 6 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.1 4 | - 1.2 5 | - tip 6 | install: 7 | - go install ./... 8 | - go get github.com/BurntSushi/toml-test 9 | script: 10 | - export PATH="$PATH:$HOME/gopath/bin" 11 | - make test 12 | 13 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/COMPATIBLE: -------------------------------------------------------------------------------- 1 | Compatible with TOML version 2 | [v0.2.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) 3 | 4 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/Makefile: -------------------------------------------------------------------------------- 1 | install: 2 | go install ./... 3 | 4 | test: install 5 | go test -v 6 | toml-test toml-test-decoder 7 | toml-test -encoder toml-test-encoder 8 | 9 | fmt: 10 | gofmt -w *.go */*.go 11 | colcheck *.go */*.go 12 | 13 | tags: 14 | find ./ -name '*.go' -print0 | xargs -0 gotags > TAGS 15 | 16 | push: 17 | git push origin master 18 | git push github master 19 | 20 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/cmd/toml-test-decoder/COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/cmd/toml-test-decoder/README.md: -------------------------------------------------------------------------------- 1 | # Implements the TOML test suite interface 2 | 3 | This is an implementation of the interface expected by 4 | [toml-test](https://github.com/BurntSushi/toml-test) for my 5 | [toml parser written in Go](https://github.com/BurntSushi/toml). 6 | In particular, it maps TOML data on `stdin` to a JSON format on `stdout`. 7 | 8 | 9 | Compatible with TOML version 10 | [v0.2.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) 11 | 12 | Compatible with `toml-test` version 13 | [v0.2.0](https://github.com/BurntSushi/toml-test/tree/v0.2.0) 14 | 15 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/cmd/toml-test-encoder/COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/cmd/toml-test-encoder/README.md: -------------------------------------------------------------------------------- 1 | # Implements the TOML test suite interface for TOML encoders 2 | 3 | This is an implementation of the interface expected by 4 | [toml-test](https://github.com/BurntSushi/toml-test) for the 5 | [TOML encoder](https://github.com/BurntSushi/toml). 6 | In particular, it maps JSON data on `stdin` to a TOML format on `stdout`. 7 | 8 | 9 | Compatible with TOML version 10 | [v0.2.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) 11 | 12 | Compatible with `toml-test` version 13 | [v0.2.0](https://github.com/BurntSushi/toml-test/tree/v0.2.0) 14 | 15 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/cmd/tomlv/COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/cmd/tomlv/README.md: -------------------------------------------------------------------------------- 1 | # TOML Validator 2 | 3 | If Go is installed, it's simple to try it out: 4 | 5 | ```bash 6 | go get github.com/BurntSushi/toml/cmd/tomlv 7 | tomlv some-toml-file.toml 8 | ``` 9 | 10 | You can see the types of every key in a TOML file with: 11 | 12 | ```bash 13 | tomlv -types some-toml-file.toml 14 | ``` 15 | 16 | At the moment, only one error message is reported at a time. Error messages 17 | include line numbers. No output means that the files given are valid TOML, or 18 | there is a bug in `tomlv`. 19 | 20 | Compatible with TOML version 21 | [v0.1.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.1.0.md) 22 | 23 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/cmd/tomlv/main.go: -------------------------------------------------------------------------------- 1 | // Command tomlv validates TOML documents and prints each key's type. 2 | package main 3 | 4 | import ( 5 | "flag" 6 | "fmt" 7 | "log" 8 | "os" 9 | "path" 10 | "strings" 11 | "text/tabwriter" 12 | 13 | "github.com/BurntSushi/toml" 14 | ) 15 | 16 | var ( 17 | flagTypes = false 18 | ) 19 | 20 | func init() { 21 | log.SetFlags(0) 22 | 23 | flag.BoolVar(&flagTypes, "types", flagTypes, 24 | "When set, the types of every defined key will be shown.") 25 | 26 | flag.Usage = usage 27 | flag.Parse() 28 | } 29 | 30 | func usage() { 31 | log.Printf("Usage: %s toml-file [ toml-file ... ]\n", 32 | path.Base(os.Args[0])) 33 | flag.PrintDefaults() 34 | 35 | os.Exit(1) 36 | } 37 | 38 | func main() { 39 | if flag.NArg() < 1 { 40 | flag.Usage() 41 | } 42 | for _, f := range flag.Args() { 43 | var tmp interface{} 44 | md, err := toml.DecodeFile(f, &tmp) 45 | if err != nil { 46 | log.Fatalf("Error in '%s': %s", f, err) 47 | } 48 | if flagTypes { 49 | printTypes(md) 50 | } 51 | } 52 | } 53 | 54 | func printTypes(md toml.MetaData) { 55 | tabw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) 56 | for _, key := range md.Keys() { 57 | fmt.Fprintf(tabw, "%s%s\t%s\n", 58 | strings.Repeat(" ", len(key)-1), key, md.Type(key...)) 59 | } 60 | tabw.Flush() 61 | } 62 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package toml provides facilities for decoding and encoding TOML configuration 3 | files via reflection. There is also support for delaying decoding with 4 | the Primitive type, and querying the set of keys in a TOML document with the 5 | MetaData type. 6 | 7 | The specification implemented: https://github.com/mojombo/toml 8 | 9 | The sub-command github.com/BurntSushi/toml/cmd/tomlv can be used to verify 10 | whether a file is a valid TOML document. It can also be used to print the 11 | type of each key in a TOML document. 12 | 13 | Testing 14 | 15 | There are two important types of tests used for this package. The first is 16 | contained inside '*_test.go' files and uses the standard Go unit testing 17 | framework. These tests are primarily devoted to holistically testing the 18 | decoder and encoder. 19 | 20 | The second type of testing is used to verify the implementation's adherence 21 | to the TOML specification. These tests have been factored into their own 22 | project: https://github.com/BurntSushi/toml-test 23 | 24 | The reason the tests are in a separate project is so that they can be used by 25 | any implementation of TOML. Namely, it is language agnostic. 26 | */ 27 | package toml 28 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/encoding_types.go: -------------------------------------------------------------------------------- 1 | // +build go1.2 2 | 3 | package toml 4 | 5 | // In order to support Go 1.1, we define our own TextMarshaler and 6 | // TextUnmarshaler types. For Go 1.2+, we just alias them with the 7 | // standard library interfaces. 8 | 9 | import ( 10 | "encoding" 11 | ) 12 | 13 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 14 | // so that Go 1.1 can be supported. 15 | type TextMarshaler encoding.TextMarshaler 16 | 17 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 18 | // here so that Go 1.1 can be supported. 19 | type TextUnmarshaler encoding.TextUnmarshaler 20 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/encoding_types_1.1.go: -------------------------------------------------------------------------------- 1 | // +build !go1.2 2 | 3 | package toml 4 | 5 | // These interfaces were introduced in Go 1.2, so we add them manually when 6 | // compiling for Go 1.1. 7 | 8 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 9 | // so that Go 1.1 can be supported. 10 | type TextMarshaler interface { 11 | MarshalText() (text []byte, err error) 12 | } 13 | 14 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 15 | // here so that Go 1.1 can be supported. 16 | type TextUnmarshaler interface { 17 | UnmarshalText(text []byte) error 18 | } 19 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/BurntSushi/toml/session.vim: -------------------------------------------------------------------------------- 1 | au BufWritePost *.go silent!make tags > /dev/null 2>&1 2 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/codegangsta/cli/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 1.1 3 | 4 | script: 5 | - go vet ./... 6 | - go test -v ./... 7 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/codegangsta/cli/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 Jeremy Saenz 2 | All Rights Reserved. 3 | 4 | MIT LICENSE 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to 9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | the Software, and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/codegangsta/cli/autocomplete/bash_autocomplete: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | _cli_bash_autocomplete() { 4 | local cur prev opts base 5 | COMPREPLY=() 6 | cur="${COMP_WORDS[COMP_CWORD]}" 7 | prev="${COMP_WORDS[COMP_CWORD-1]}" 8 | opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) 9 | COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) 10 | return 0 11 | } 12 | 13 | complete -F _cli_bash_autocomplete $PROG -------------------------------------------------------------------------------- /vendor/_nuts/github.com/codegangsta/cli/autocomplete/zsh_autocomplete: -------------------------------------------------------------------------------- 1 | autoload -U compinit && compinit 2 | autoload -U bashcompinit && bashcompinit 3 | 4 | script_dir=$(dirname $0) 5 | source ${script_dir}/bash_autocomplete 6 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/codegangsta/cli/cli.go: -------------------------------------------------------------------------------- 1 | // Package cli provides a minimal framework for creating and organizing command line 2 | // Go applications. cli is designed to be easy to understand and write, the most simple 3 | // cli application can be written as follows: 4 | // func main() { 5 | // cli.NewApp().Run(os.Args) 6 | // } 7 | // 8 | // Of course this application does not do much, so let's make this an actual application: 9 | // func main() { 10 | // app := cli.NewApp() 11 | // app.Name = "greet" 12 | // app.Usage = "say a greeting" 13 | // app.Action = func(c *cli.Context) { 14 | // println("Greetings") 15 | // } 16 | // 17 | // app.Run(os.Args) 18 | // } 19 | package cli 20 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/codegangsta/cli/command_test.go: -------------------------------------------------------------------------------- 1 | package cli_test 2 | 3 | import ( 4 | "flag" 5 | "testing" 6 | 7 | "github.com/jingweno/nut/vendor/_nuts/github.com/codegangsta/cli" 8 | ) 9 | 10 | func TestCommandDoNotIgnoreFlags(t *testing.T) { 11 | app := cli.NewApp() 12 | set := flag.NewFlagSet("test", 0) 13 | test := []string{"blah", "blah", "-break"} 14 | set.Parse(test) 15 | 16 | c := cli.NewContext(app, set, set) 17 | 18 | command := cli.Command{ 19 | Name: "test-cmd", 20 | ShortName: "tc", 21 | Usage: "this is for testing", 22 | Description: "testing", 23 | Action: func(_ *cli.Context) {}, 24 | } 25 | err := command.Run(c) 26 | 27 | expect(t, err.Error(), "flag provided but not defined: -break") 28 | } 29 | 30 | func TestCommandIgnoreFlags(t *testing.T) { 31 | app := cli.NewApp() 32 | set := flag.NewFlagSet("test", 0) 33 | test := []string{"blah", "blah"} 34 | set.Parse(test) 35 | 36 | c := cli.NewContext(app, set, set) 37 | 38 | command := cli.Command{ 39 | Name: "test-cmd", 40 | ShortName: "tc", 41 | Usage: "this is for testing", 42 | Description: "testing", 43 | Action: func(_ *cli.Context) {}, 44 | SkipFlagParsing: true, 45 | } 46 | err := command.Run(c) 47 | 48 | expect(t, err, nil) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/_nuts/github.com/codegangsta/cli/helpers_test.go: -------------------------------------------------------------------------------- 1 | package cli_test 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | /* Test Helpers */ 9 | func expect(t *testing.T, a interface{}, b interface{}) { 10 | if a != b { 11 | t.Errorf("Expected %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) 12 | } 13 | } 14 | 15 | func refute(t *testing.T, a interface{}, b interface{}) { 16 | if a == b { 17 | t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/.gitattributes: -------------------------------------------------------------------------------- 1 | # Treat all files in this repo as binary, with no git magic updating 2 | # line endings. Windows users contributing to Go will need to use a 3 | # modern version of git and editors capable of LF line endings. 4 | # 5 | # We'll prevent accidental CRLF line endings from entering the repo 6 | # via the git-review gofmt checks. 7 | # 8 | # See golang.org/issue/9281 9 | 10 | * -text 11 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/.gitignore: -------------------------------------------------------------------------------- 1 | # Add no patterns to .gitignore except for files generated by the build. 2 | last-change 3 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/README: -------------------------------------------------------------------------------- 1 | This subrepository holds the source for various packages and tools that support 2 | the Go programming language. 3 | 4 | Some of the tools, godoc and vet for example, are included in binary Go distributions. 5 | Others, including the Go oracle and the test coverage tool, can be fetched with "go get". 6 | 7 | Packages include a type-checker for Go and an implementation of the 8 | Static Single Assignment form (SSA) representation for Go programs. 9 | 10 | To submit changes to this repository, see http://golang.org/doc/contribute.html. 11 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/blog/atom/atom.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Adapted from encoding/xml/read_test.go. 6 | 7 | // Package atom defines XML data structures for an Atom feed. 8 | package atom 9 | 10 | import ( 11 | "encoding/xml" 12 | "time" 13 | ) 14 | 15 | type Feed struct { 16 | XMLName xml.Name `xml:"http://www.w3.org/2005/Atom feed"` 17 | Title string `xml:"title"` 18 | ID string `xml:"id"` 19 | Link []Link `xml:"link"` 20 | Updated TimeStr `xml:"updated"` 21 | Author *Person `xml:"author"` 22 | Entry []*Entry `xml:"entry"` 23 | } 24 | 25 | type Entry struct { 26 | Title string `xml:"title"` 27 | ID string `xml:"id"` 28 | Link []Link `xml:"link"` 29 | Published TimeStr `xml:"published"` 30 | Updated TimeStr `xml:"updated"` 31 | Author *Person `xml:"author"` 32 | Summary *Text `xml:"summary"` 33 | Content *Text `xml:"content"` 34 | } 35 | 36 | type Link struct { 37 | Rel string `xml:"rel,attr"` 38 | Href string `xml:"href,attr"` 39 | } 40 | 41 | type Person struct { 42 | Name string `xml:"name"` 43 | URI string `xml:"uri,omitempty"` 44 | Email string `xml:"email,omitempty"` 45 | InnerXML string `xml:",innerxml"` 46 | } 47 | 48 | type Text struct { 49 | Type string `xml:"type,attr"` 50 | Body string `xml:",chardata"` 51 | } 52 | 53 | type TimeStr string 54 | 55 | func Time(t time.Time) TimeStr { 56 | return TimeStr(t.Format("2006-01-02T15:04:05-07:00")) 57 | } 58 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/benchcmp/benchcmp_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | 7 | "golang.org/x/tools/benchmark/parse" 8 | ) 9 | 10 | func TestSelectBest(t *testing.T) { 11 | have := parse.Set{ 12 | "Benchmark1": []*parse.Benchmark{ 13 | { 14 | Name: "Benchmark1", 15 | N: 10, NsPerOp: 100, Measured: parse.NsPerOp, 16 | Ord: 0, 17 | }, 18 | { 19 | Name: "Benchmark1", 20 | N: 10, NsPerOp: 50, Measured: parse.NsPerOp, 21 | Ord: 3, 22 | }, 23 | }, 24 | "Benchmark2": []*parse.Benchmark{ 25 | { 26 | Name: "Benchmark2", 27 | N: 10, NsPerOp: 60, Measured: parse.NsPerOp, 28 | Ord: 1, 29 | }, 30 | { 31 | Name: "Benchmark2", 32 | N: 10, NsPerOp: 500, Measured: parse.NsPerOp, 33 | Ord: 2, 34 | }, 35 | }, 36 | } 37 | 38 | want := parse.Set{ 39 | "Benchmark1": []*parse.Benchmark{ 40 | { 41 | Name: "Benchmark1", 42 | N: 10, NsPerOp: 50, Measured: parse.NsPerOp, 43 | Ord: 0, 44 | }, 45 | }, 46 | "Benchmark2": []*parse.Benchmark{ 47 | { 48 | Name: "Benchmark2", 49 | N: 10, NsPerOp: 60, Measured: parse.NsPerOp, 50 | Ord: 1, 51 | }, 52 | }, 53 | } 54 | 55 | selectBest(have) 56 | if !reflect.DeepEqual(want, have) { 57 | t.Errorf("filtered bench set incorrectly, want %v have %v", want, have) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/benchcmp/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | 7 | The benchcmp command displays performance changes between benchmarks. 8 | 9 | Benchcmp parses the output of two 'go test' benchmark runs, 10 | correlates the results per benchmark, and displays the deltas. 11 | 12 | To measure the performance impact of a change, use 'go test' 13 | to run benchmarks before and after the change: 14 | 15 | go test -run=NONE -bench=. ./... > old.txt 16 | # make changes 17 | go test -run=NONE -bench=. ./... > new.txt 18 | 19 | Then feed the benchmark results to benchcmp: 20 | 21 | benchcmp old.txt new.txt 22 | 23 | Benchcmp will summarize and display the performance changes, 24 | in a format like this: 25 | 26 | $ benchcmp old.txt new.txt 27 | benchmark old ns/op new ns/op delta 28 | BenchmarkConcat 523 68.6 -86.88% 29 | 30 | benchmark old allocs new allocs delta 31 | BenchmarkConcat 3 1 -66.67% 32 | 33 | benchmark old bytes new bytes delta 34 | BenchmarkConcat 80 48 -40.00% 35 | 36 | */ 37 | package main 38 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/callgraph/testdata/src/pkg/pkg.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type I interface { 4 | f() 5 | } 6 | 7 | type C int 8 | 9 | func (C) f() {} 10 | 11 | type D int 12 | 13 | func (D) f() {} 14 | 15 | func main() { 16 | var i I = C(0) 17 | i.f() // dynamic call 18 | 19 | main2() 20 | } 21 | 22 | func main2() { 23 | var i I = D(0) 24 | i.f() // dynamic call 25 | } 26 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/callgraph/testdata/src/pkg/pkg_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Don't import "testing", it adds a lot of callgraph edges. 4 | 5 | func Example() { 6 | C(0).f() 7 | } 8 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/cover/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Cover is a program for analyzing the coverage profiles generated by 7 | 'go test -coverprofile=cover.out'. 8 | 9 | Cover is also used by 'go test -cover' to rewrite the source code with 10 | annotations to track which parts of each function are executed. 11 | It operates on one Go source file at a time, computing approximate 12 | basic block information by studying the source. It is thus more portable 13 | than binary-rewriting coverage tools, but also a little less capable. 14 | For instance, it does not probe inside && and || expressions, and can 15 | be mildly confused by single statements with multiple function literals. 16 | 17 | For usage information, please see: 18 | go help testflag 19 | go tool cover -help 20 | */ 21 | package main 22 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/godex/gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file implements access to gc-generated export data. 6 | 7 | package main 8 | 9 | import ( 10 | "golang.org/x/tools/go/gcimporter" 11 | ) 12 | 13 | func init() { 14 | register("gc", gcimporter.Import) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/godex/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file implements access to gccgo-generated export data. 6 | 7 | package main 8 | 9 | import ( 10 | "golang.org/x/tools/go/gccgoimporter" 11 | "golang.org/x/tools/go/types" 12 | ) 13 | 14 | var ( 15 | initmap = make(map[*types.Package]gccgoimporter.InitData) 16 | ) 17 | 18 | func init() { 19 | incpaths := []string{"/"} 20 | 21 | // importer for default gccgo 22 | var inst gccgoimporter.GccgoInstallation 23 | inst.InitFromDriver("gccgo") 24 | register("gccgo", inst.GetImporter(incpaths, initmap)) 25 | } 26 | 27 | // Print the extra gccgo compiler data for this package, if it exists. 28 | func (p *printer) printGccgoExtra(pkg *types.Package) { 29 | if initdata, ok := initmap[pkg]; ok { 30 | p.printf("/*\npriority %d\n", initdata.Priority) 31 | 32 | p.printDecl("init", len(initdata.Inits), func() { 33 | for _, init := range initdata.Inits { 34 | p.printf("%s %s %d\n", init.Name, init.InitFunc, init.Priority) 35 | } 36 | }) 37 | 38 | p.print("*/\n") 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/godex/source.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file implements access to export data from source. 6 | 7 | package main 8 | 9 | import ( 10 | "golang.org/x/tools/go/types" 11 | ) 12 | 13 | func init() { 14 | register("source", sourceImporter) 15 | } 16 | 17 | func sourceImporter(packages map[string]*types.Package, path string) (*types.Package, error) { 18 | panic("unimplemented") 19 | } 20 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/godoc/README.godoc-app: -------------------------------------------------------------------------------- 1 | godoc on appengine 2 | ------------------ 3 | 4 | Prerequisites 5 | ------------- 6 | 7 | * Go appengine SDK 8 | https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Go 9 | 10 | * Go sources at tip under $GOROOT 11 | 12 | * Godoc sources at tip inside $GOPATH 13 | (go get -d golang.org/x/tools/cmd/godoc) 14 | 15 | 16 | Directory structure 17 | ------------------- 18 | 19 | * Let $APPDIR be the directory containing the app engine files. 20 | (e.g., $APPDIR=$HOME/godoc-app) 21 | 22 | * $APPDIR contains the following entries (this may change depending on 23 | app-engine release and version of godoc): 24 | 25 | app.yaml 26 | golang.org/x/tools/cmd/godoc 27 | godoc.zip 28 | index.split.* 29 | 30 | * The app.yaml file is set up per app engine documentation. 31 | For instance: 32 | 33 | application: godoc-app 34 | version: 1 35 | runtime: go 36 | api_version: go1 37 | 38 | handlers: 39 | - url: /.* 40 | script: _go_app 41 | 42 | 43 | Configuring and running godoc 44 | ----------------------------- 45 | 46 | To configure godoc, run 47 | 48 | bash setup-godoc-app.bash 49 | 50 | to prepare an $APPDIR as described above. See the script for details on usage. 51 | 52 | To run godoc locally, using the App Engine development server, run 53 | 54 | /dev_appserver.py $APPDIR 55 | 56 | godoc should come up at http://localhost:8080 . 57 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/godoc/dl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import "net/http" 8 | 9 | // Register a redirect handler for /dl/ to the golang.org download page. 10 | // This file will not be included when deploying godoc to golang.org. 11 | 12 | func init() { 13 | http.Handle("/dl/", http.RedirectHandler("http://golang.org/dl/", http.StatusFound)) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/godoc/play.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "encoding/json" 9 | "fmt" 10 | "go/format" 11 | "net/http" 12 | 13 | // This package registers "/compile" and "/share" handlers 14 | // that redirect to the golang.org playground. 15 | _ "golang.org/x/tools/playground" 16 | ) 17 | 18 | func init() { 19 | http.HandleFunc("/fmt", fmtHandler) 20 | } 21 | 22 | type fmtResponse struct { 23 | Body string 24 | Error string 25 | } 26 | 27 | // fmtHandler takes a Go program in its "body" form value, formats it with 28 | // standard gofmt formatting, and writes a fmtResponse as a JSON object. 29 | func fmtHandler(w http.ResponseWriter, r *http.Request) { 30 | resp := new(fmtResponse) 31 | body, err := format.Source([]byte(r.FormValue("body"))) 32 | if err != nil { 33 | resp.Error = err.Error() 34 | } else { 35 | resp.Body = string(body) 36 | } 37 | json.NewEncoder(w).Encode(resp) 38 | } 39 | 40 | // disabledHandler serves a 501 "Not Implemented" response. 41 | func disabledHandler(w http.ResponseWriter, r *http.Request) { 42 | w.WriteHeader(http.StatusNotImplemented) 43 | fmt.Fprint(w, "This functionality is not available via local godoc.") 44 | } 45 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/goimports/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Command goimports updates your Go import lines, 4 | adding missing ones and removing unreferenced ones. 5 | 6 | $ go get golang.org/x/tools/cmd/goimports 7 | 8 | It's a drop-in replacement for your editor's gofmt-on-save hook. 9 | It has the same command-line interface as gofmt and formats 10 | your code in the same way. 11 | 12 | For emacs, make sure you have the latest go-mode.el: 13 | https://github.com/dominikh/go-mode.el 14 | Then in your .emacs file: 15 | (setq gofmt-command "goimports") 16 | (add-to-list 'load-path "/home/you/somewhere/emacs/") 17 | (require 'go-mode-load) 18 | (add-hook 'before-save-hook 'gofmt-before-save) 19 | 20 | For vim, set "gofmt_command" to "goimports": 21 | https://golang.org/change/39c724dd7f252 22 | https://golang.org/wiki/IDEsAndTextEditorPlugins 23 | etc 24 | 25 | For GoSublime, follow the steps described here: 26 | http://michaelwhatcott.com/gosublime-goimports/ 27 | 28 | For other editors, you probably know what to do. 29 | 30 | Happy hacking! 31 | 32 | */ 33 | package main 34 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/present/appengine.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build appengine 6 | 7 | package main 8 | 9 | import ( 10 | "mime" 11 | 12 | "golang.org/x/tools/present" 13 | 14 | _ "golang.org/x/tools/playground" 15 | ) 16 | 17 | var basePath = "./present/" 18 | 19 | func init() { 20 | initTemplates(basePath) 21 | playScript(basePath, "HTTPTransport") 22 | present.PlayEnabled = true 23 | 24 | // App Engine has no /etc/mime.types 25 | mime.AddExtensionType(".svg", "image/svg+xml") 26 | } 27 | 28 | func playable(c present.Code) bool { 29 | return present.PlayEnabled && c.Play && c.Ext == ".go" 30 | } 31 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/present/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Present displays slide presentations and articles. It runs a web server that 7 | presents slide and article files from the current directory. 8 | 9 | It may be run as a stand-alone command or an App Engine app. 10 | Instructions for deployment to App Engine are in the README of the 11 | golang.org/x/tools repository. 12 | 13 | Usage of present: 14 | -base="": base path for slide template and static resources 15 | -http="127.0.0.1:3999": HTTP service address (e.g., '127.0.0.1:3999') 16 | -nacl=false: use Native Client environment playground (prevents non-Go code execution) 17 | -orighost="": host component of web origin URL (e.g., 'localhost') 18 | -play=true: enable playground (permit execution of arbitrary user code) 19 | 20 | The setup of the Go version of NaCl is documented at: 21 | https://golang.org/wiki/NativeClient 22 | 23 | Input files are named foo.extension, where "extension" defines the format of 24 | the generated output. The supported formats are: 25 | .slide // HTML5 slide presentation 26 | .article // article format, such as a blog post 27 | 28 | The present file format is documented by the present package: 29 | http://godoc.org/golang.org/x/tools/present 30 | */ 31 | package main 32 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/present/play.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "bytes" 9 | "fmt" 10 | "io/ioutil" 11 | "net/http" 12 | "path/filepath" 13 | "time" 14 | 15 | "golang.org/x/tools/godoc/static" 16 | ) 17 | 18 | var scripts = []string{"jquery.js", "jquery-ui.js", "playground.js", "play.js"} 19 | 20 | // playScript registers an HTTP handler at /play.js that serves all the 21 | // scripts specified by the variable above, and appends a line that 22 | // initializes the playground with the specified transport. 23 | func playScript(root, transport string) { 24 | modTime := time.Now() 25 | var buf bytes.Buffer 26 | for _, p := range scripts { 27 | if s, ok := static.Files[p]; ok { 28 | buf.WriteString(s) 29 | continue 30 | } 31 | b, err := ioutil.ReadFile(filepath.Join(root, "static", p)) 32 | if err != nil { 33 | panic(err) 34 | } 35 | buf.Write(b) 36 | } 37 | fmt.Fprintf(&buf, "\ninitPlayground(new %v());\n", transport) 38 | b := buf.Bytes() 39 | http.HandleFunc("/play.js", func(w http.ResponseWriter, r *http.Request) { 40 | w.Header().Set("Content-type", "application/javascript") 41 | http.ServeContent(w, r, "", modTime, bytes.NewReader(b)) 42 | }) 43 | } 44 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/present/static/dir.js: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // copied from $GOROOT/doc/godocs.js 6 | 7 | function bindEvent(el, e, fn) { 8 | if (el.addEventListener){ 9 | el.addEventListener(e, fn, false); 10 | } else if (el.attachEvent){ 11 | el.attachEvent('on'+e, fn); 12 | } 13 | } 14 | 15 | function godocs_bindSearchEvents() { 16 | var search = document.getElementById('search'); 17 | if (!search) { 18 | // no search box (index disabled) 19 | return; 20 | } 21 | function clearInactive() { 22 | if (search.className == "inactive") { 23 | search.value = ""; 24 | search.className = ""; 25 | } 26 | } 27 | function restoreInactive() { 28 | if (search.value !== "") { 29 | return; 30 | } 31 | if (search.type != "search") { 32 | search.value = search.getAttribute("placeholder"); 33 | } 34 | search.className = "inactive"; 35 | } 36 | restoreInactive(); 37 | bindEvent(search, 'focus', clearInactive); 38 | bindEvent(search, 'blur', restoreInactive); 39 | } 40 | 41 | bindEvent(window, 'load', godocs_bindSearchEvents); 42 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/present/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/cmd/present/static/favicon.ico -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/present/static/print.css: -------------------------------------------------------------------------------- 1 | /* set page layout */ 2 | @page { 3 | size: A4 landscape; 4 | } 5 | 6 | body { 7 | display: block !important; 8 | } 9 | 10 | .slides { 11 | left: 0; 12 | top: 0; 13 | } 14 | 15 | .slides > article { 16 | position: relative; 17 | 18 | left: 0; 19 | top: 0; 20 | 21 | margin: 0 !important; 22 | page-break-inside: avoid; 23 | 24 | text-shadow: none; /* disable shadow */ 25 | 26 | display: block !important; 27 | transform: translate(0) !important; 28 | -o-transform: translate(0) !important; 29 | -moz-transform: translate(0) !important; 30 | -webkit-transform: translate3d(0, 0, 0) !important; 31 | } 32 | 33 | div.code { 34 | background: rgb(240, 240, 240); 35 | } 36 | 37 | /* hide click areas */ 38 | .slide-area, #prev-slide-area, #next-slide-area { 39 | display: none; 40 | } 41 | 42 | /* add explicit links */ 43 | a:link:after, a:visited:after { 44 | content: " (" attr(href) ") "; 45 | font-size: 50%; 46 | } 47 | 48 | /* white background */ 49 | body { 50 | background: rgb(255,255,255) !important; 51 | } 52 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/present/templates/action.tmpl: -------------------------------------------------------------------------------- 1 | {/* 2 | This is the action template. 3 | It determines how the formatting actions are rendered. 4 | */} 5 | 6 | {{define "section"}} 7 | {{.FormattedNumber}} {{.Title}} 8 | {{range .Elem}}{{elem $.Template .}}{{end}} 9 | {{end}} 10 | 11 | {{define "list"}} 12 |
    13 | {{range .Bullet}} 14 |
  • {{style .}}
  • 15 | {{end}} 16 |
17 | {{end}} 18 | 19 | {{define "text"}} 20 | {{if .Pre}} 21 |
{{range .Lines}}{{.}}{{end}}
22 | {{else}} 23 |

24 | {{range $i, $l := .Lines}}{{if $i}}{{template "newline"}} 25 | {{end}}{{style $l}}{{end}} 26 |

27 | {{end}} 28 | {{end}} 29 | 30 | {{define "code"}} 31 |
{{.Text}}
32 | {{end}} 33 | 34 | {{define "image"}} 35 |
36 | 37 |
38 | {{end}} 39 | 40 | {{define "iframe"}} 41 | 42 | {{end}} 43 | 44 | {{define "link"}}{{end}} 45 | 46 | {{define "html"}}{{.HTML}}{{end}} 47 | 48 | {{define "caption"}}
{{style .Text}}
{{end}} -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/present/templates/article.tmpl: -------------------------------------------------------------------------------- 1 | {/* This is the article template. It defines how articles are formatted. */} 2 | 3 | {{define "root"}} 4 | 5 | 6 | 7 | {{.Title}} 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 |
{{.Title}} 16 | {{with .Subtitle}}{{.}}{{end}} 17 |
18 |
19 |
20 |
21 |
22 | {{with .Sections}} 23 |
24 | {{template "TOC" .}} 25 |
26 | {{end}} 27 | 28 | {{range .Sections}} 29 | {{elem $.Template .}} 30 | {{end}}{{/* of Section block */}} 31 | 32 | {{if .Authors}} 33 |

Authors

34 | {{range .Authors}} 35 |
36 | {{range .Elem}}{{elem $.Template .}}{{end}} 37 |
38 | {{end}} 39 | {{end}} 40 |
41 |
42 | 43 | 44 | 45 | {{end}} 46 | 47 | {{define "TOC"}} 48 |
    49 | {{range .}} 50 |
  • {{.Title}}
  • 51 | {{with .Sections}}{{template "TOC" .}}{{end}} 52 | {{end}} 53 |
54 | {{end}} 55 | 56 | {{define "newline"}} 57 | {{/* No automatic line break. Paragraphs are free-form. */}} 58 | {{end}} 59 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/present/templates/slides.tmpl: -------------------------------------------------------------------------------- 1 | {/* This is the slide template. It defines how presentations are formatted. */} 2 | 3 | {{define "root"}} 4 | 5 | 6 | 7 | {{.Title}} 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 |
17 |

{{.Title}}

18 | {{with .Subtitle}}

{{.}}

{{end}} 19 | {{if not .Time.IsZero}}

{{.Time.Format "2 January 2006"}}

{{end}} 20 | {{range .Authors}} 21 |
22 | {{range .TextElem}}{{elem $.Template .}}{{end}} 23 |
24 | {{end}} 25 |
26 | 27 | {{range $i, $s := .Sections}} 28 | 29 |
30 | {{if $s.Elem}} 31 |

{{$s.Title}}

32 | {{range $s.Elem}}{{elem $.Template .}}{{end}} 33 | {{else}} 34 |

{{$s.Title}}

35 | {{end}} 36 |
37 | 38 | {{end}}{{/* of Slide block */}} 39 | 40 |
41 |

Thank you

42 | {{range .Authors}} 43 |
44 | {{range .Elem}}{{elem $.Template .}}{{end}} 45 |
46 | {{end}} 47 |
48 | 49 |
50 | 51 | 52 | {{if .PlayEnabled}} 53 | 54 | {{end}} 55 | 56 | {{end}} 57 | 58 | {{define "newline"}} 59 |
60 | {{end}} 61 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/cgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Import "C" shouldn't be imported. 6 | 7 | package main 8 | 9 | /* 10 | #define HELLO 1 11 | */ 12 | import "C" 13 | 14 | import "fmt" 15 | 16 | type Cgo uint32 17 | 18 | const ( 19 | // MustScanSubDirs indicates that events were coalesced hierarchically. 20 | MustScanSubDirs Cgo = 1 << iota 21 | ) 22 | 23 | func main() { 24 | _ = C.HELLO 25 | ck(MustScanSubDirs, "MustScanSubDirs") 26 | } 27 | 28 | func ck(day Cgo, str string) { 29 | if fmt.Sprint(day) != str { 30 | panic("cgo.go: " + str) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/day.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Simple test: enumeration of type int starting at 0. 6 | 7 | package main 8 | 9 | import "fmt" 10 | 11 | type Day int 12 | 13 | const ( 14 | Monday Day = iota 15 | Tuesday 16 | Wednesday 17 | Thursday 18 | Friday 19 | Saturday 20 | Sunday 21 | ) 22 | 23 | func main() { 24 | ck(Monday, "Monday") 25 | ck(Tuesday, "Tuesday") 26 | ck(Wednesday, "Wednesday") 27 | ck(Thursday, "Thursday") 28 | ck(Friday, "Friday") 29 | ck(Saturday, "Saturday") 30 | ck(Sunday, "Sunday") 31 | ck(-127, "Day(-127)") 32 | ck(127, "Day(127)") 33 | } 34 | 35 | func ck(day Day, str string) { 36 | if fmt.Sprint(day) != str { 37 | panic("day.go: " + str) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/gap.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Gaps and an offset. 6 | 7 | package main 8 | 9 | import "fmt" 10 | 11 | type Gap int 12 | 13 | const ( 14 | Two Gap = 2 15 | Three Gap = 3 16 | Five Gap = 5 17 | Six Gap = 6 18 | Seven Gap = 7 19 | Eight Gap = 8 20 | Nine Gap = 9 21 | Eleven Gap = 11 22 | ) 23 | 24 | func main() { 25 | ck(0, "Gap(0)") 26 | ck(1, "Gap(1)") 27 | ck(Two, "Two") 28 | ck(Three, "Three") 29 | ck(4, "Gap(4)") 30 | ck(Five, "Five") 31 | ck(Six, "Six") 32 | ck(Seven, "Seven") 33 | ck(Eight, "Eight") 34 | ck(Nine, "Nine") 35 | ck(10, "Gap(10)") 36 | ck(Eleven, "Eleven") 37 | ck(12, "Gap(12)") 38 | } 39 | 40 | func ck(gap Gap, str string) { 41 | if fmt.Sprint(gap) != str { 42 | panic("gap.go: " + str) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/num.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Signed integers spanning zero. 6 | 7 | package main 8 | 9 | import "fmt" 10 | 11 | type Num int 12 | 13 | const ( 14 | m_2 Num = -2 + iota 15 | m_1 16 | m0 17 | m1 18 | m2 19 | ) 20 | 21 | func main() { 22 | ck(-3, "Num(-3)") 23 | ck(m_2, "m_2") 24 | ck(m_1, "m_1") 25 | ck(m0, "m0") 26 | ck(m1, "m1") 27 | ck(m2, "m2") 28 | ck(3, "Num(3)") 29 | } 30 | 31 | func ck(num Num, str string) { 32 | if fmt.Sprint(num) != str { 33 | panic("num.go: " + str) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/number.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Enumeration with an offset. 6 | // Also includes a duplicate. 7 | 8 | package main 9 | 10 | import "fmt" 11 | 12 | type Number int 13 | 14 | const ( 15 | _ Number = iota 16 | One 17 | Two 18 | Three 19 | AnotherOne = One // Duplicate; note that AnotherOne doesn't appear below. 20 | ) 21 | 22 | func main() { 23 | ck(One, "One") 24 | ck(Two, "Two") 25 | ck(Three, "Three") 26 | ck(AnotherOne, "One") 27 | ck(127, "Number(127)") 28 | } 29 | 30 | func ck(num Number, str string) { 31 | if fmt.Sprint(num) != str { 32 | panic("number.go: " + str) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/prime.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Enough gaps to trigger a map implementation of the method. 6 | // Also includes a duplicate to test that it doesn't cause problems 7 | 8 | package main 9 | 10 | import "fmt" 11 | 12 | type Prime int 13 | 14 | const ( 15 | p2 Prime = 2 16 | p3 Prime = 3 17 | p5 Prime = 5 18 | p7 Prime = 7 19 | p77 Prime = 7 // Duplicate; note that p77 doesn't appear below. 20 | p11 Prime = 11 21 | p13 Prime = 13 22 | p17 Prime = 17 23 | p19 Prime = 19 24 | p23 Prime = 23 25 | p29 Prime = 29 26 | p37 Prime = 31 27 | p41 Prime = 41 28 | p43 Prime = 43 29 | ) 30 | 31 | func main() { 32 | ck(0, "Prime(0)") 33 | ck(1, "Prime(1)") 34 | ck(p2, "p2") 35 | ck(p3, "p3") 36 | ck(4, "Prime(4)") 37 | ck(p5, "p5") 38 | ck(p7, "p7") 39 | ck(p77, "p7") 40 | ck(p11, "p11") 41 | ck(p13, "p13") 42 | ck(p17, "p17") 43 | ck(p19, "p19") 44 | ck(p23, "p23") 45 | ck(p29, "p29") 46 | ck(p37, "p37") 47 | ck(p41, "p41") 48 | ck(p43, "p43") 49 | ck(44, "Prime(44)") 50 | } 51 | 52 | func ck(prime Prime, str string) { 53 | if fmt.Sprint(prime) != str { 54 | panic("prime.go: " + str) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/unum.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Unsigned integers spanning zero. 6 | 7 | package main 8 | 9 | import "fmt" 10 | 11 | type Unum uint8 12 | 13 | const ( 14 | m_2 Unum = iota + 253 15 | m_1 16 | ) 17 | 18 | const ( 19 | m0 Unum = iota 20 | m1 21 | m2 22 | ) 23 | 24 | func main() { 25 | ck(^Unum(0)-3, "Unum(252)") 26 | ck(m_2, "m_2") 27 | ck(m_1, "m_1") 28 | ck(m0, "m0") 29 | ck(m1, "m1") 30 | ck(m2, "m2") 31 | ck(3, "Unum(3)") 32 | } 33 | 34 | func ck(unum Unum, str string) { 35 | if fmt.Sprint(unum) != str { 36 | panic("unum.go: " + str) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/tipgodoc/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.4.1 2 | 3 | RUN apt-get update && apt-get install --no-install-recommends -y -q build-essential git 4 | 5 | # golang puts its go install here (weird but true) 6 | ENV GOROOT_BOOTSTRAP /usr/src/go 7 | 8 | # golang sets GOPATH=/go 9 | ADD . /go/src/tipgodoc 10 | RUN go install tipgodoc 11 | ENTRYPOINT ["/go/bin/tipgodoc"] 12 | # Kubernetes expects us to listen on port 8080 13 | EXPOSE 8080 14 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/tipgodoc/README: -------------------------------------------------------------------------------- 1 | To deploy as an App Engine Manged VM, use gcloud: 2 | 3 | $ gcloud --project golang-org preview app deploy . 4 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/tipgodoc/app.yaml: -------------------------------------------------------------------------------- 1 | application: golang-org 2 | version: tip 3 | runtime: custom 4 | api_version: go1 5 | vm: true 6 | 7 | manual_scaling: 8 | instances: 1 9 | 10 | handlers: 11 | - url: /.* 12 | script: _go_app 13 | 14 | health_check: 15 | enable_health_check: False 16 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/vet/assign.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | This file contains the code to check for useless assignments. 7 | */ 8 | 9 | package main 10 | 11 | import ( 12 | "go/ast" 13 | "go/token" 14 | "reflect" 15 | ) 16 | 17 | func init() { 18 | register("assign", 19 | "check for useless assignments", 20 | checkAssignStmt, 21 | assignStmt) 22 | } 23 | 24 | // TODO: should also check for assignments to struct fields inside methods 25 | // that are on T instead of *T. 26 | 27 | // checkAssignStmt checks for assignments of the form " = ". 28 | // These are almost always useless, and even when they aren't they are usually a mistake. 29 | func checkAssignStmt(f *File, node ast.Node) { 30 | stmt := node.(*ast.AssignStmt) 31 | if stmt.Tok != token.ASSIGN { 32 | return // ignore := 33 | } 34 | if len(stmt.Lhs) != len(stmt.Rhs) { 35 | // If LHS and RHS have different cardinality, they can't be the same. 36 | return 37 | } 38 | for i, lhs := range stmt.Lhs { 39 | rhs := stmt.Rhs[i] 40 | if reflect.TypeOf(lhs) != reflect.TypeOf(rhs) { 41 | continue // short-circuit the heavy-weight gofmt check 42 | } 43 | le := f.gofmt(lhs) 44 | re := f.gofmt(rhs) 45 | if le == re { 46 | f.Badf(stmt.Pos(), "self-assignment of %s to %s", re, le) 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/asm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // This file contains declarations to test the assembly in test_asm.s. 8 | 9 | package testdata 10 | 11 | func arg1(x int8, y uint8) 12 | func arg2(x int16, y uint16) 13 | func arg4(x int32, y uint32) 14 | func arg8(x int64, y uint64) 15 | func argint(x int, y uint) 16 | func argptr(x *byte, y *byte, c chan int, m map[int]int, f func()) 17 | func argstring(x, y string) 18 | func argslice(x, y []string) 19 | func argiface(x interface{}, y interface { 20 | m() 21 | }) 22 | func returnint() int 23 | func returnbyte(x int) byte 24 | func returnnamed(x byte) (r1 int, r2 int16, r3 string, r4 byte) 25 | func returnintmissing() int 26 | func leaf(x, y int) int 27 | 28 | func noprof(x int) 29 | func dupok(x int) 30 | func nosplit(x int) 31 | func rodata(x int) 32 | func noptr(x int) 33 | func wrapper(x int) 34 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/asm4.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64 6 | // +build vet_test 7 | 8 | // Test cases for symbolic NOSPLIT etc. on TEXT symbols. 9 | 10 | TEXT ·noprof(SB),NOPROF,$0-8 11 | RET 12 | 13 | TEXT ·dupok(SB),DUPOK,$0-8 14 | RET 15 | 16 | TEXT ·nosplit(SB),NOSPLIT,$0 17 | RET 18 | 19 | TEXT ·rodata(SB),RODATA,$0-8 20 | RET 21 | 22 | TEXT ·noptr(SB),NOPTR|NOSPLIT,$0 23 | RET 24 | 25 | TEXT ·wrapper(SB),WRAPPER,$0-8 26 | RET 27 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/assign.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file contains tests for the useless-assignment checker. 6 | 7 | package testdata 8 | 9 | type ST struct { 10 | x int 11 | } 12 | 13 | func (s *ST) SetX(x int) { 14 | // Accidental self-assignment; it should be "s.x = x" 15 | x = x // ERROR "self-assignment of x to x" 16 | // Another mistake 17 | s.x = s.x // ERROR "self-assignment of s.x to s.x" 18 | } 19 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/atomic.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file contains tests for the atomic checker. 6 | 7 | package testdata 8 | 9 | import ( 10 | "sync/atomic" 11 | ) 12 | 13 | type Counter uint64 14 | 15 | func AtomicTests() { 16 | x := uint64(1) 17 | x = atomic.AddUint64(&x, 1) // ERROR "direct assignment to atomic value" 18 | _, x = 10, atomic.AddUint64(&x, 1) // ERROR "direct assignment to atomic value" 19 | x, _ = atomic.AddUint64(&x, 1), 10 // ERROR "direct assignment to atomic value" 20 | 21 | y := &x 22 | *y = atomic.AddUint64(y, 1) // ERROR "direct assignment to atomic value" 23 | 24 | var su struct{ Counter uint64 } 25 | su.Counter = atomic.AddUint64(&su.Counter, 1) // ERROR "direct assignment to atomic value" 26 | z1 := atomic.AddUint64(&su.Counter, 1) 27 | _ = z1 // Avoid err "z declared and not used" 28 | 29 | var sp struct{ Counter *uint64 } 30 | *sp.Counter = atomic.AddUint64(sp.Counter, 1) // ERROR "direct assignment to atomic value" 31 | z2 := atomic.AddUint64(sp.Counter, 1) 32 | _ = z2 // Avoid err "z declared and not used" 33 | 34 | au := []uint64{10, 20} 35 | au[0] = atomic.AddUint64(&au[0], 1) // ERROR "direct assignment to atomic value" 36 | au[1] = atomic.AddUint64(&au[0], 1) 37 | 38 | ap := []*uint64{&au[0], &au[1]} 39 | *ap[0] = atomic.AddUint64(ap[0], 1) // ERROR "direct assignment to atomic value" 40 | *ap[1] = atomic.AddUint64(ap[0], 1) 41 | 42 | x = atomic.AddUint64() // Used to make vet crash; now silently ignored. 43 | } 44 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/buildtag.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file contains tests for the buildtag checker. 6 | 7 | // +builder // ERROR "possible malformed \+build comment" 8 | // +build !ignore 9 | 10 | package testdata 11 | 12 | // +build toolate // ERROR "build comment must appear before package clause and be followed by a blank line" 13 | 14 | var _ = 3 15 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/buildtag_bad.go: -------------------------------------------------------------------------------- 1 | // This file contains misplaced or malformed build constraints. 2 | // The Go tool will skip it, because the constraints are invalid. 3 | // It serves only to test the tag checker during make test. 4 | 5 | // Mention +build // ERROR "possible malformed \+build comment" 6 | 7 | // +build !!bang // ERROR "invalid double negative in build constraint" 8 | // +build @#$ // ERROR "invalid non-alphanumeric build constraint" 9 | 10 | // +build toolate // ERROR "build comment must appear before package clause and be followed by a blank line" 11 | package bad 12 | 13 | // This is package 'bad' rather than 'main' so the erroneous build 14 | // tag doesn't end up looking like a package doc for the vet command 15 | // when examined by godoc. 16 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/composite.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file contains tests for the untagged struct literal checker. 6 | 7 | // This file contains the test for untagged struct literals. 8 | 9 | package testdata 10 | 11 | import ( 12 | "flag" 13 | "go/scanner" 14 | ) 15 | 16 | var Okay1 = []string{ 17 | "Name", 18 | "Usage", 19 | "DefValue", 20 | } 21 | 22 | var Okay2 = map[string]bool{ 23 | "Name": true, 24 | "Usage": true, 25 | "DefValue": true, 26 | } 27 | 28 | var Okay3 = struct { 29 | X string 30 | Y string 31 | Z string 32 | }{ 33 | "Name", 34 | "Usage", 35 | "DefValue", 36 | } 37 | 38 | type MyStruct struct { 39 | X string 40 | Y string 41 | Z string 42 | } 43 | 44 | var Okay4 = MyStruct{ 45 | "Name", 46 | "Usage", 47 | "DefValue", 48 | } 49 | 50 | // Testing is awkward because we need to reference things from a separate package 51 | // to trigger the warnings. 52 | 53 | var BadStructLiteralUsedInTests = flag.Flag{ // ERROR "unkeyed fields" 54 | "Name", 55 | "Usage", 56 | nil, // Value 57 | "DefValue", 58 | } 59 | 60 | // Used to test the check for slices and arrays: If that test is disabled and 61 | // vet is run with --compositewhitelist=false, this line triggers an error. 62 | // Clumsy but sufficient. 63 | var scannerErrorListTest = scanner.ErrorList{nil, nil} 64 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/method.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file contains tests for the canonical method checker. 6 | 7 | // This file contains the code to check canonical methods. 8 | 9 | package testdata 10 | 11 | import ( 12 | "fmt" 13 | ) 14 | 15 | type MethodTest int 16 | 17 | func (t *MethodTest) Scan(x fmt.ScanState, c byte) { // ERROR "should have signature Scan" 18 | } 19 | 20 | type MethodTestInterface interface { 21 | ReadByte() byte // ERROR "should have signature ReadByte" 22 | } 23 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/nilfunc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package testdata 6 | 7 | func F() {} 8 | 9 | type T struct { 10 | F func() 11 | } 12 | 13 | func (T) M() {} 14 | 15 | var Fv = F 16 | 17 | func Comparison() { 18 | var t T 19 | var fn func() 20 | if fn == nil || Fv == nil || t.F == nil { 21 | // no error; these func vars or fields may be nil 22 | } 23 | if F == nil { // ERROR "comparison of function F == nil is always false" 24 | panic("can't happen") 25 | } 26 | if t.M == nil { // ERROR "comparison of function M == nil is always false" 27 | panic("can't happen") 28 | } 29 | if F != nil { // ERROR "comparison of function F != nil is always true" 30 | if t.M != nil { // ERROR "comparison of function M != nil is always true" 31 | return 32 | } 33 | } 34 | panic("can't happen") 35 | } 36 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/container/intsets/util_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package intsets 6 | 7 | import "testing" 8 | 9 | func TestNLZ(t *testing.T) { 10 | // Test the platform-specific edge case. 11 | // NB: v must be a var (not const) so that the word() conversion is dynamic. 12 | // Otherwise the compiler will report an error. 13 | v := uint64(0x0000801000000000) 14 | n := nlz(word(v)) 15 | want := 32 // (on 32-bit) 16 | if bitsPerWord == 64 { 17 | want = 16 18 | } 19 | if n != want { 20 | t.Errorf("%d-bit nlz(%d) = %d, want %d", bitsPerWord, v, n, want) 21 | } 22 | } 23 | 24 | // Backdoor for testing. 25 | func (s *Sparse) Check() error { return s.check() } 26 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ast/astutil/util.go: -------------------------------------------------------------------------------- 1 | package astutil 2 | 3 | import "go/ast" 4 | 5 | // Unparen returns e with any enclosing parentheses stripped. 6 | func Unparen(e ast.Expr) ast.Expr { 7 | for { 8 | p, ok := e.(*ast.ParenExpr) 9 | if !ok { 10 | return e 11 | } 12 | e = p.X 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/buildutil/allpackages_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package buildutil_test 6 | 7 | import ( 8 | "go/build" 9 | "testing" 10 | 11 | "golang.org/x/tools/go/buildutil" 12 | ) 13 | 14 | func TestAllPackages(t *testing.T) { 15 | all := buildutil.AllPackages(&build.Default) 16 | 17 | set := make(map[string]bool) 18 | for _, pkg := range all { 19 | set[pkg] = true 20 | } 21 | 22 | const wantAtLeast = 250 23 | if len(all) < wantAtLeast { 24 | t.Errorf("Found only %d packages, want at least %d", len(all), wantAtLeast) 25 | } 26 | 27 | for _, want := range []string{"fmt", "crypto/sha256", "golang.org/x/tools/go/buildutil"} { 28 | if !set[want] { 29 | t.Errorf("Package %q not found; got %s", want, all) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/buildutil/util_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package buildutil_test 6 | 7 | import ( 8 | "go/build" 9 | "os" 10 | "path/filepath" 11 | "runtime" 12 | "testing" 13 | 14 | "golang.org/x/tools/go/buildutil" 15 | ) 16 | 17 | func TestContainingPackage(t *testing.T) { 18 | // unvirtualized: 19 | goroot := runtime.GOROOT() 20 | gopath := filepath.SplitList(os.Getenv("GOPATH"))[0] 21 | 22 | for _, test := range [][2]string{ 23 | {goroot + "/src/fmt/print.go", "fmt"}, 24 | {goroot + "/src/encoding/json/foo.go", "encoding/json"}, 25 | {goroot + "/src/encoding/missing/foo.go", "(not found)"}, 26 | {gopath + "/src/golang.org/x/tools/go/buildutil/util_test.go", 27 | "golang.org/x/tools/go/buildutil"}, 28 | } { 29 | file, want := test[0], test[1] 30 | bp, err := buildutil.ContainingPackage(&build.Default, ".", file) 31 | got := bp.ImportPath 32 | if err != nil { 33 | got = "(not found)" 34 | } 35 | if got != want { 36 | t.Errorf("ContainingPackage(%q) = %s, want %s", file, got, want) 37 | } 38 | } 39 | 40 | // TODO(adonovan): test on virtualized GOPATH too. 41 | } 42 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/callgraph/cha/testdata/func.go: -------------------------------------------------------------------------------- 1 | //+build ignore 2 | 3 | package main 4 | 5 | // Test of dynamic function calls; no interfaces. 6 | 7 | func A(int) {} 8 | 9 | var ( 10 | B = func(int) {} 11 | C = func(int) {} 12 | ) 13 | 14 | func f() { 15 | pfn := B 16 | pfn(0) // calls A, B, C, even though A is not even address-taken 17 | } 18 | 19 | // WANT: 20 | // Dynamic calls 21 | // f --> A 22 | // f --> init$1 23 | // f --> init$2 24 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/callgraph/cha/testdata/iface.go: -------------------------------------------------------------------------------- 1 | //+build ignore 2 | 3 | package main 4 | 5 | // Test of interface calls. None of the concrete types are ever 6 | // instantiated or converted to interfaces. 7 | 8 | type I interface { 9 | f() 10 | } 11 | 12 | type J interface { 13 | f() 14 | g() 15 | } 16 | 17 | type C int // implements I 18 | 19 | func (*C) f() 20 | 21 | type D int // implements I and J 22 | 23 | func (*D) f() 24 | func (*D) g() 25 | 26 | func one(i I, j J) { 27 | i.f() // calls *C and *D 28 | } 29 | 30 | func two(i I, j J) { 31 | j.f() // calls *D (but not *C, even though it defines method f) 32 | } 33 | 34 | func three(i I, j J) { 35 | j.g() // calls *D 36 | } 37 | 38 | func four(i I, j J) { 39 | Jf := J.f 40 | if unknown { 41 | Jf = nil // suppress SSA constant propagation 42 | } 43 | Jf(nil) // calls *D 44 | } 45 | 46 | func five(i I, j J) { 47 | jf := j.f 48 | if unknown { 49 | jf = nil // suppress SSA constant propagation 50 | } 51 | jf() // calls *D 52 | } 53 | 54 | var unknown bool 55 | 56 | // WANT: 57 | // Dynamic calls 58 | // (J).f$bound --> (*D).f 59 | // (J).f$thunk --> (*D).f 60 | // five --> (J).f$bound 61 | // four --> (J).f$thunk 62 | // one --> (*C).f 63 | // one --> (*D).f 64 | // three --> (*D).g 65 | // two --> (*D).f 66 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/callgraph/cha/testdata/recv.go: -------------------------------------------------------------------------------- 1 | //+build ignore 2 | 3 | package main 4 | 5 | type I interface { 6 | f() 7 | } 8 | 9 | type J interface { 10 | g() 11 | } 12 | 13 | type C int // C and *C implement I; *C implements J 14 | 15 | func (C) f() 16 | func (*C) g() 17 | 18 | type D int // *D implements I and J 19 | 20 | func (*D) f() 21 | func (*D) g() 22 | 23 | func f(i I) { 24 | i.f() // calls C, *C, *D 25 | } 26 | 27 | func g(j J) { 28 | j.g() // calls *C, *D 29 | } 30 | 31 | // WANT: 32 | // Dynamic calls 33 | // f --> (*C).f 34 | // f --> (*D).f 35 | // f --> (C).f 36 | // g --> (*C).g 37 | // g --> (*D).g 38 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/callgraph/rta/testdata/func.go: -------------------------------------------------------------------------------- 1 | //+build ignore 2 | 3 | package main 4 | 5 | // Test of dynamic function calls. 6 | // No interfaces, so no runtime/reflect types. 7 | 8 | func A1() { 9 | A2(0) 10 | } 11 | 12 | func A2(int) {} // not address-taken 13 | 14 | func B() {} // unreachable 15 | 16 | var ( 17 | C = func(int) {} 18 | D = func(int) {} 19 | ) 20 | 21 | func main() { 22 | A1() 23 | 24 | pfn := C 25 | pfn(0) // calls C and D but not A2 (same sig but not address-taken) 26 | } 27 | 28 | // WANT: 29 | // Dynamic calls 30 | // main --> init$1 31 | // main --> init$2 32 | // Reachable functions 33 | // A1 34 | // A2 35 | // init$1 36 | // init$2 37 | // Reflect types 38 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/callgraph/rta/testdata/iface.go: -------------------------------------------------------------------------------- 1 | //+build ignore 2 | 3 | package main 4 | 5 | // Test of interface calls. 6 | 7 | func use(interface{}) 8 | 9 | type A byte // instantiated but not a reflect type 10 | 11 | func (A) f() {} // called directly 12 | func (A) F() {} // unreachable 13 | 14 | type B int // a reflect type 15 | 16 | func (*B) f() {} // reachable via interface invoke 17 | func (*B) F() {} // reachable: exported method of reflect type 18 | 19 | type B2 int // a reflect type, and *B2 also 20 | 21 | func (B2) f() {} // reachable via interface invoke 22 | func (B2) g() {} // reachable: exported method of reflect type 23 | 24 | type C string // not instantiated 25 | 26 | func (C) f() {} // unreachable 27 | func (C) F() {} // unreachable 28 | 29 | type D uint // instantiated only in dead code 30 | 31 | func (D) f() {} // unreachable 32 | func (D) F() {} // unreachable 33 | 34 | func main() { 35 | A(0).f() 36 | 37 | use(new(B)) 38 | use(B2(0)) 39 | 40 | var i interface { 41 | f() 42 | } 43 | i.f() // calls (*B).f, (*B2).f and (B2.f) 44 | 45 | live() 46 | } 47 | 48 | func live() { 49 | var j interface { 50 | f() 51 | g() 52 | } 53 | j.f() // calls (B2).f and (*B2).f but not (*B).f (no g method). 54 | } 55 | 56 | func dead() { 57 | use(D(0)) 58 | } 59 | 60 | // WANT: 61 | // Dynamic calls 62 | // live --> (*B2).f 63 | // live --> (B2).f 64 | // main --> (*B).f 65 | // main --> (*B2).f 66 | // main --> (B2).f 67 | // Reachable functions 68 | // (*B).F 69 | // (*B).f 70 | // (*B2).f 71 | // (A).f 72 | // (B2).f 73 | // live 74 | // use 75 | // Reflect types 76 | // *B 77 | // *B2 78 | // B 79 | // B2 80 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/callgraph/rta/testdata/rtype.go: -------------------------------------------------------------------------------- 1 | //+build ignore 2 | 3 | package main 4 | 5 | // Test of runtime types (types for which descriptors are needed). 6 | 7 | func use(interface{}) 8 | 9 | type A byte // neither A nor byte are runtime types 10 | 11 | type B struct{ x uint } // B and uint are runtime types, but not the struct 12 | 13 | func main() { 14 | var x int // not a runtime type 15 | print(x) 16 | 17 | var y string // runtime type due to interface conversion 18 | use(y) 19 | 20 | use(struct{ uint64 }{}) // struct is a runtime type 21 | 22 | use(new(B)) // *B is a runtime type 23 | } 24 | 25 | // WANT: 26 | // Dynamic calls 27 | // Reachable functions 28 | // use 29 | // Reflect types 30 | // *B 31 | // B 32 | // string 33 | // struct{uint64} 34 | // uint 35 | // uint64 36 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/callgraph/static/static.go: -------------------------------------------------------------------------------- 1 | // Package static computes the call graph of a Go program containing 2 | // only static call edges. 3 | package static 4 | 5 | import ( 6 | "golang.org/x/tools/go/callgraph" 7 | "golang.org/x/tools/go/ssa" 8 | "golang.org/x/tools/go/ssa/ssautil" 9 | ) 10 | 11 | // CallGraph computes the call graph of the specified program 12 | // considering only static calls. 13 | // 14 | func CallGraph(prog *ssa.Program) *callgraph.Graph { 15 | cg := callgraph.New(nil) // TODO(adonovan) eliminate concept of rooted callgraph 16 | 17 | // TODO(adonovan): opt: use only a single pass over the ssa.Program. 18 | for f := range ssautil.AllFunctions(prog) { 19 | fnode := cg.CreateNode(f) 20 | for _, b := range f.Blocks { 21 | for _, instr := range b.Instrs { 22 | if site, ok := instr.(ssa.CallInstruction); ok { 23 | if g := site.Common().StaticCallee(); g != nil { 24 | gnode := cg.CreateNode(g) 25 | callgraph.AddEdge(fnode, site, gnode) 26 | } 27 | } 28 | } 29 | } 30 | } 31 | 32 | return cg 33 | } 34 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/exact/go13.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.4 6 | 7 | package exact 8 | 9 | import ( 10 | "math" 11 | "math/big" 12 | ) 13 | 14 | func ratToFloat32(x *big.Rat) (float32, bool) { 15 | // Before 1.4, there's no Rat.Float32. 16 | // Emulate it, albeit at the cost of 17 | // imprecision in corner cases. 18 | x64, exact := x.Float64() 19 | x32 := float32(x64) 20 | if math.IsInf(float64(x32), 0) { 21 | exact = false 22 | } 23 | return x32, exact 24 | } 25 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/exact/go14.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package exact 8 | 9 | import "math/big" 10 | 11 | func ratToFloat32(x *big.Rat) (float32, bool) { 12 | return x.Float32() 13 | } 14 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/gccgoimporter/testdata/complexnums.go: -------------------------------------------------------------------------------- 1 | package complexnums 2 | 3 | const NN = -1 - 1i 4 | const NP = -1 + 1i 5 | const PN = 1 - 1i 6 | const PP = 1 + 1i 7 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/gccgoimporter/testdata/complexnums.gox: -------------------------------------------------------------------------------- 1 | v1; 2 | package complexnums; 3 | pkgpath complexnums; 4 | priority 1; 5 | const NN = -0.1E1-0.1E1i ; 6 | const NP = -0.1E1+0.1E1i ; 7 | const PN = 0.1E1-0.1E1i ; 8 | const PP = 0.1E1+0.1E1i ; 9 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/gccgoimporter/testdata/imports.go: -------------------------------------------------------------------------------- 1 | package imports 2 | 3 | import "fmt" 4 | 5 | var Hello = fmt.Sprintf("Hello, world") 6 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/gccgoimporter/testdata/imports.gox: -------------------------------------------------------------------------------- 1 | v1; 2 | package imports; 3 | pkgpath imports; 4 | priority 7; 5 | import fmt fmt "fmt"; 6 | init imports imports..import 7 math math..import 1 runtime runtime..import 1 strconv strconv..import 2 io io..import 3 reflect reflect..import 3 syscall syscall..import 3 time time..import 4 os os..import 5 fmt fmt..import 6; 7 | var Hello ; 8 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/gccgoimporter/testdata/pointer.go: -------------------------------------------------------------------------------- 1 | package pointer 2 | 3 | type Int8Ptr *int8 4 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/gccgoimporter/testdata/pointer.gox: -------------------------------------------------------------------------------- 1 | v1; 2 | package pointer; 3 | pkgpath pointer; 4 | type >>; 5 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/loader/testdata/a.go: -------------------------------------------------------------------------------- 1 | package P 2 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/loader/testdata/b.go: -------------------------------------------------------------------------------- 1 | package P 2 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/loader/testdata/badpkgdecl.go: -------------------------------------------------------------------------------- 1 | // this file has no package decl 2 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/TODO: -------------------------------------------------------------------------------- 1 | -*- text -*- 2 | 3 | Pointer analysis to-do list 4 | =========================== 5 | 6 | CONSTRAINT GENERATION: 7 | - support reflection: 8 | - a couple of operators are missing 9 | - reflect.Values may contain lvalues (CanAddr) 10 | - implement native intrinsics. These vary by platform. 11 | - add to pts(a.panic) a label representing all runtime panics, e.g. 12 | runtime.{TypeAssertionError,errorString,errorCString}. 13 | 14 | OPTIMISATIONS 15 | - pre-solver: 16 | pointer equivalence: extend HVN to HRU 17 | location equivalence 18 | - solver: HCD, LCD. 19 | - experiment with map+slice worklist in lieu of bitset. 20 | It may have faster insert. 21 | 22 | MISC: 23 | - Test on all platforms. 24 | Currently we assume these go/build tags: linux, amd64, !cgo. 25 | 26 | MAINTAINABILITY 27 | - Think about ways to make debugging this code easier. PTA logs 28 | routinely exceed a million lines and require training to read. 29 | 30 | BUGS: 31 | - There's a crash bug in stdlib_test + reflection, rVCallConstraint. 32 | 33 | 34 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/print.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package pointer 6 | 7 | import "fmt" 8 | 9 | func (c *addrConstraint) String() string { 10 | return fmt.Sprintf("addr n%d <- {&n%d}", c.dst, c.src) 11 | } 12 | 13 | func (c *copyConstraint) String() string { 14 | return fmt.Sprintf("copy n%d <- n%d", c.dst, c.src) 15 | } 16 | 17 | func (c *loadConstraint) String() string { 18 | return fmt.Sprintf("load n%d <- n%d[%d]", c.dst, c.src, c.offset) 19 | } 20 | 21 | func (c *storeConstraint) String() string { 22 | return fmt.Sprintf("store n%d[%d] <- n%d", c.dst, c.offset, c.src) 23 | } 24 | 25 | func (c *offsetAddrConstraint) String() string { 26 | return fmt.Sprintf("offsetAddr n%d <- n%d.#%d", c.dst, c.src, c.offset) 27 | } 28 | 29 | func (c *typeFilterConstraint) String() string { 30 | return fmt.Sprintf("typeFilter n%d <- n%d.(%s)", c.dst, c.src, c.typ) 31 | } 32 | 33 | func (c *untagConstraint) String() string { 34 | return fmt.Sprintf("untag n%d <- n%d.(%s)", c.dst, c.src, c.typ) 35 | } 36 | 37 | func (c *invokeConstraint) String() string { 38 | return fmt.Sprintf("invoke n%d.%s(n%d ...)", c.iface, c.method.Name(), c.params) 39 | } 40 | 41 | func (n nodeid) String() string { 42 | return fmt.Sprintf("n%d", n) 43 | } 44 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/a_test.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package a 4 | 5 | // This test exercises the synthesis of testmain packages for tests. 6 | // The test framework doesn't directly let us perform negative 7 | // assertions (i.e. that TestingQuux isn't called, or that its 8 | // parameter's PTS is empty) so this test is rather roundabout. 9 | 10 | import "testing" 11 | 12 | func log(f func(*testing.T)) { 13 | // The PTS of f is the set of called tests. TestingQuux is not present. 14 | print(f) // @pointsto main.Test | main.TestFoo 15 | } 16 | 17 | func Test(t *testing.T) { 18 | // Don't assert @pointsto(t) since its label contains a fragile line number. 19 | log(Test) 20 | } 21 | 22 | func TestFoo(t *testing.T) { 23 | // Don't assert @pointsto(t) since its label contains a fragile line number. 24 | log(TestFoo) 25 | } 26 | 27 | func TestingQuux(t *testing.T) { 28 | // We can't assert @pointsto(t) since this is dead code. 29 | log(TestingQuux) 30 | } 31 | 32 | func BenchmarkFoo(b *testing.B) { 33 | } 34 | 35 | func ExampleBar() { 36 | } 37 | 38 | // Excludes TestingQuux. 39 | // @calls testing.tRunner -> main.Test 40 | // @calls testing.tRunner -> main.TestFoo 41 | // @calls testing.runExample -> main.ExampleBar 42 | // @calls (*testing.B).runN -> main.BenchmarkFoo 43 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/another.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | var unknown bool 6 | 7 | type S string 8 | 9 | func incr(x int) int { return x + 1 } 10 | 11 | func main() { 12 | var i interface{} 13 | i = 1 14 | if unknown { 15 | i = S("foo") 16 | } 17 | if unknown { 18 | i = (func(int, int))(nil) // NB type compares equal to that below. 19 | } 20 | // Look, the test harness can handle equal-but-not-String-equal 21 | // types because we parse types and using a typemap. 22 | if unknown { 23 | i = (func(x int, y int))(nil) 24 | } 25 | if unknown { 26 | i = incr 27 | } 28 | print(i) // @types int | S | func(int, int) | func(int) int 29 | 30 | // NB, an interface may never directly alias any global 31 | // labels, even though it may contain pointers that do. 32 | print(i) // @pointsto makeinterface:func(x int) int | makeinterface:func(x int, y int) | makeinterface:func(int, int) | makeinterface:int | makeinterface:main.S 33 | print(i.(func(int) int)) // @pointsto main.incr 34 | 35 | print() // regression test for crash 36 | } 37 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/chanreflect1.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import "reflect" 6 | 7 | // 8 | // This test is very sensitive to line-number perturbations! 9 | 10 | // Test of channels with reflection. 11 | 12 | var a, b int 13 | 14 | func chanreflect1() { 15 | ch := make(chan *int, 0) 16 | crv := reflect.ValueOf(ch) 17 | crv.Send(reflect.ValueOf(&a)) 18 | print(crv.Interface()) // @types chan *int 19 | print(crv.Interface().(chan *int)) // @pointsto makechan@testdata/chanreflect.go:15:12 20 | print(<-ch) // @pointsto main.a 21 | } 22 | 23 | func chanreflect2() { 24 | ch := make(chan *int, 0) 25 | ch <- &b 26 | crv := reflect.ValueOf(ch) 27 | r, _ := crv.Recv() 28 | print(r.Interface()) // @types *int 29 | print(r.Interface().(*int)) // @pointsto main.b 30 | } 31 | 32 | func main() { 33 | chanreflect1() 34 | chanreflect2() 35 | } 36 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/context.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | // Test of context-sensitive treatment of certain function calls, 6 | // e.g. static calls to simple accessor methods. 7 | 8 | var a, b int 9 | 10 | type T struct{ x *int } 11 | 12 | func (t *T) SetX(x *int) { t.x = x } 13 | func (t *T) GetX() *int { return t.x } 14 | 15 | func context1() { 16 | var t1, t2 T 17 | t1.SetX(&a) 18 | t2.SetX(&b) 19 | print(t1.GetX()) // @pointsto main.a 20 | print(t2.GetX()) // @pointsto main.b 21 | } 22 | 23 | func context2() { 24 | id := func(x *int) *int { 25 | print(x) // @pointsto main.a | main.b 26 | return x 27 | } 28 | print(id(&a)) // @pointsto main.a 29 | print(id(&b)) // @pointsto main.b 30 | 31 | // Same again, but anon func has free vars. 32 | var c int // @line context2c 33 | id2 := func(x *int) (*int, *int) { 34 | print(x) // @pointsto main.a | main.b 35 | return x, &c 36 | } 37 | p, q := id2(&a) 38 | print(p) // @pointsto main.a 39 | print(q) // @pointsto c@context2c:6 40 | r, s := id2(&b) 41 | print(r) // @pointsto main.b 42 | print(s) // @pointsto c@context2c:6 43 | } 44 | 45 | func main() { 46 | context1() 47 | context2() 48 | } 49 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/conv.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import "unsafe" 6 | 7 | var a int 8 | 9 | func conv1() { 10 | // Conversions of channel direction. 11 | ch := make(chan int) // @line c1make 12 | print((<-chan int)(ch)) // @pointsto makechan@c1make:12 13 | print((chan<- int)(ch)) // @pointsto makechan@c1make:12 14 | } 15 | 16 | func conv2() { 17 | // string -> []byte/[]rune conversion 18 | s := "foo" 19 | ba := []byte(s) // @line c2ba 20 | ra := []rune(s) // @line c2ra 21 | print(ba) // @pointsto convert@c2ba:14 22 | print(ra) // @pointsto convert@c2ra:14 23 | } 24 | 25 | func conv3() { 26 | // Conversion of same underlying types. 27 | type PI *int 28 | pi := PI(&a) 29 | print(pi) // @pointsto main.a 30 | 31 | pint := (*int)(pi) 32 | print(pint) // @pointsto main.a 33 | 34 | // Conversions between pointers to identical base types. 35 | var y *PI = &pi 36 | var x **int = (**int)(y) 37 | print(*x) // @pointsto main.a 38 | print(*y) // @pointsto main.a 39 | y = (*PI)(x) 40 | print(*y) // @pointsto main.a 41 | } 42 | 43 | func conv4() { 44 | // Handling of unsafe.Pointer conversion is unsound: 45 | // we lose the alias to main.a and get something like new(int) instead. 46 | p := (*int)(unsafe.Pointer(&a)) // @line c2p 47 | print(p) // @pointsto convert@c2p:13 48 | } 49 | 50 | // Regression test for b/8231. 51 | func conv5() { 52 | type P unsafe.Pointer 53 | var i *struct{} 54 | _ = P(i) 55 | } 56 | 57 | func main() { 58 | conv1() 59 | conv2() 60 | conv3() 61 | conv4() 62 | conv5() 63 | } 64 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/flow.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | // Demonstration of directionality of flow edges. 6 | 7 | func f1() {} 8 | func f2() {} 9 | 10 | var somepred bool 11 | 12 | // Tracking functions. 13 | func flow1() { 14 | s := f1 15 | p := f2 16 | q := p 17 | r := q 18 | if somepred { 19 | r = s 20 | } 21 | print(s) // @pointsto main.f1 22 | print(p) // @pointsto main.f2 23 | print(q) // @pointsto main.f2 24 | print(r) // @pointsto main.f1 | main.f2 25 | } 26 | 27 | // Tracking concrete types in interfaces. 28 | func flow2() { 29 | var s interface{} = 1 30 | var p interface{} = "foo" 31 | q := p 32 | r := q 33 | if somepred { 34 | r = s 35 | } 36 | print(s) // @types int 37 | print(p) // @types string 38 | print(q) // @types string 39 | print(r) // @types int | string 40 | } 41 | 42 | var g1, g2 int 43 | 44 | // Tracking addresses of globals. 45 | func flow3() { 46 | s := &g1 47 | p := &g2 48 | q := p 49 | r := q 50 | if somepred { 51 | r = s 52 | } 53 | print(s) // @pointsto main.g1 54 | print(p) // @pointsto main.g2 55 | print(q) // @pointsto main.g2 56 | print(r) // @pointsto main.g2 | main.g1 57 | } 58 | 59 | func main() { 60 | flow1() 61 | flow2() 62 | flow3() 63 | } 64 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/fmtexcerpt.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | // This is a slice of the fmt package. 4 | 5 | package main 6 | 7 | type pp struct { 8 | field interface{} 9 | } 10 | 11 | func newPrinter() *pp { 12 | return new(pp) 13 | } 14 | 15 | func Fprintln(a ...interface{}) { 16 | p := newPrinter() 17 | p.doPrint(a, true, true) 18 | } 19 | 20 | func Println(a ...interface{}) { 21 | Fprintln(a...) 22 | } 23 | 24 | func (p *pp) doPrint(a []interface{}, addspace, addnewline bool) { 25 | print(a[0]) // @types S | string 26 | stringer := a[0].(interface { 27 | String() string 28 | }) 29 | 30 | stringer.String() 31 | print(stringer) // @types S 32 | } 33 | 34 | type S int 35 | 36 | func (S) String() string { return "" } 37 | 38 | func main() { 39 | Println("Hello, World!", S(0)) 40 | } 41 | 42 | // @calls (*main.pp).doPrint -> (main.S).String 43 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/hello.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | "os" 8 | ) 9 | 10 | type S int 11 | 12 | var theS S 13 | 14 | func (s *S) String() string { 15 | print(s) // @pointsto main.theS 16 | return "" 17 | } 18 | 19 | func main() { 20 | // os.Args is considered intrinsically allocated, 21 | // but may also be set explicitly (e.g. on Windows), hence '...'. 22 | print(os.Args) // @pointsto | ... 23 | fmt.Println("Hello, World!", &theS) 24 | } 25 | 26 | // @calls main.main -> fmt.Println 27 | // @calls (*fmt.pp).handleMethods -> (*main.S).String 28 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/issue9002.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // Regression test for golang issue 9002. 5 | // 6 | // The two-result "value,ok" receive operation generated a 7 | // too-wide constraint loading (value int, ok bool), not bool, 8 | // from the channel. 9 | // 10 | // This bug manifested itself in an out-of-bounds array access 11 | // when the makechan object was the highest-numbered node, as in 12 | // this program. 13 | // 14 | // In more realistic programs it silently resulted in bogus 15 | // constraints. 16 | _, _ = <-make(chan int) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/maps.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | // Test of maps. 6 | 7 | var a, b, c int 8 | 9 | func maps1() { 10 | m1 := map[*int]*int{&a: &b} // @line m1m1 11 | m2 := make(map[*int]*int) // @line m1m2 12 | m2[&b] = &a 13 | 14 | print(m1[nil]) // @pointsto main.b | main.c 15 | print(m2[nil]) // @pointsto main.a 16 | 17 | print(m1) // @pointsto makemap@m1m1:21 18 | print(m2) // @pointsto makemap@m1m2:12 19 | 20 | m1[&b] = &c 21 | 22 | for k, v := range m1 { 23 | print(k) // @pointsto main.a | main.b 24 | print(v) // @pointsto main.b | main.c 25 | } 26 | 27 | for k, v := range m2 { 28 | print(k) // @pointsto main.b 29 | print(v) // @pointsto main.a 30 | } 31 | 32 | // Lookup doesn't create any aliases. 33 | print(m2[&c]) // @pointsto main.a 34 | if _, ok := m2[&a]; ok { 35 | print(m2[&c]) // @pointsto main.a 36 | } 37 | } 38 | 39 | func maps2() { 40 | m1 := map[*int]*int{&a: &b} 41 | m2 := map[*int]*int{&b: &c} 42 | _ = []map[*int]*int{m1, m2} // (no spurious merging of m1, m2) 43 | 44 | print(m1[nil]) // @pointsto main.b 45 | print(m2[nil]) // @pointsto main.c 46 | } 47 | 48 | func main() { 49 | maps1() 50 | maps2() 51 | } 52 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/panic.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | // Test of value flow from panic() to recover(). 6 | // We model them as stores/loads of a global location. 7 | // We ignore concrete panic types originating from the runtime. 8 | 9 | var someval int 10 | 11 | type myPanic struct{} 12 | 13 | func f(int) {} 14 | 15 | func g() string { return "" } 16 | 17 | func deadcode() { 18 | panic(123) // not reached 19 | } 20 | 21 | func main() { 22 | switch someval { 23 | case 0: 24 | panic("oops") 25 | case 1: 26 | panic(myPanic{}) 27 | case 2: 28 | panic(f) 29 | case 3: 30 | panic(g) 31 | } 32 | ex := recover() 33 | print(ex) // @types myPanic | string | func(int) | func() string 34 | print(ex.(func(int))) // @pointsto main.f 35 | print(ex.(func() string)) // @pointsto main.g 36 | } 37 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/recur.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | // Analysis abstraction of recursive calls is finite. 6 | 7 | func main() { 8 | main() 9 | } 10 | 11 | // @calls main.main -> main.main 12 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/rtti.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Regression test for oracle crash 4 | // https://code.google.com/p/go/issues/detail?id=6605 5 | // 6 | // Using reflection, methods may be called on types that are not the 7 | // operand of any ssa.MakeInterface instruction. In this example, 8 | // (Y).F is called by deriving the type Y from *Y. Prior to the fix, 9 | // no RTTI (or method set) for type Y was included in the program, so 10 | // the F() call would crash. 11 | 12 | import "reflect" 13 | 14 | var a int 15 | 16 | type X struct{} 17 | 18 | func (X) F() *int { 19 | return &a 20 | } 21 | 22 | type I interface { 23 | F() *int 24 | } 25 | 26 | func main() { 27 | type Y struct{ X } 28 | print(reflect.Indirect(reflect.ValueOf(new(Y))).Interface().(I).F()) // @pointsto main.a 29 | } 30 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/structreflect.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import "reflect" 6 | 7 | type A struct { 8 | f *int 9 | g interface{} 10 | h bool 11 | } 12 | 13 | var dyn string 14 | 15 | func reflectTypeFieldByName() { 16 | f, _ := reflect.TypeOf(A{}).FieldByName("f") 17 | print(f.Type) // @pointsto *int 18 | 19 | g, _ := reflect.TypeOf(A{}).FieldByName("g") 20 | print(g.Type) // @pointsto interface{} 21 | print(reflect.Zero(g.Type)) // @pointsto 22 | print(reflect.Zero(g.Type)) // @types interface{} 23 | 24 | print(reflect.Zero(g.Type).Interface()) // @pointsto 25 | print(reflect.Zero(g.Type).Interface()) // @types 26 | 27 | h, _ := reflect.TypeOf(A{}).FieldByName("h") 28 | print(h.Type) // @pointsto bool 29 | 30 | missing, _ := reflect.TypeOf(A{}).FieldByName("missing") 31 | print(missing.Type) // @pointsto 32 | 33 | dyn, _ := reflect.TypeOf(A{}).FieldByName(dyn) 34 | print(dyn.Type) // @pointsto *int | bool | interface{} 35 | } 36 | 37 | func reflectTypeField() { 38 | fld := reflect.TypeOf(A{}).Field(0) 39 | print(fld.Type) // @pointsto *int | bool | interface{} 40 | } 41 | 42 | func main() { 43 | reflectTypeFieldByName() 44 | reflectTypeField() 45 | } 46 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/pointer/testdata/timer.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import "time" 6 | 7 | func after() {} 8 | 9 | func main() { 10 | // @calls time.startTimer -> time.sendTime 11 | ticker := time.NewTicker(1) 12 | <-ticker.C 13 | 14 | // @calls time.startTimer -> time.sendTime 15 | timer := time.NewTimer(time.Second) 16 | <-timer.C 17 | 18 | // @calls time.startTimer -> time.goFunc 19 | // @calls time.goFunc -> main.after 20 | timer = time.AfterFunc(time.Second, after) 21 | <-timer.C 22 | } 23 | 24 | // @calls time.sendTime -> time.Now 25 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/external_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin 6 | 7 | package interp 8 | 9 | import "syscall" 10 | 11 | func init() { 12 | externals["syscall.Sysctl"] = ext۰syscall۰Sysctl 13 | } 14 | 15 | func ext۰syscall۰Sysctl(fr *frame, args []value) value { 16 | r, err := syscall.Sysctl(args[0].(string)) 17 | return tuple{r, wrapError(err)} 18 | } 19 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/external_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build freebsd 6 | 7 | package interp 8 | 9 | import "syscall" 10 | 11 | func init() { 12 | externals["syscall.Sysctl"] = ext۰syscall۰Sysctl 13 | externals["syscall.SysctlUint32"] = ext۰syscall۰SysctlUint32 14 | } 15 | 16 | func ext۰syscall۰Sysctl(fr *frame, args []value) value { 17 | r, err := syscall.Sysctl(args[0].(string)) 18 | return tuple{r, wrapError(err)} 19 | } 20 | 21 | func ext۰syscall۰SysctlUint32(fr *frame, args []value) value { 22 | r, err := syscall.SysctlUint32(args[0].(string)) 23 | return tuple{r, wrapError(err)} 24 | } 25 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/external_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package interp 6 | 7 | import "syscall" 8 | 9 | func ext۰syscall۰Close(fr *frame, args []value) value { 10 | panic("syscall.Close not yet implemented") 11 | } 12 | func ext۰syscall۰Fstat(fr *frame, args []value) value { 13 | panic("syscall.Fstat not yet implemented") 14 | } 15 | func ext۰syscall۰Kill(fr *frame, args []value) value { 16 | panic("syscall.Kill not yet implemented") 17 | } 18 | func ext۰syscall۰Lstat(fr *frame, args []value) value { 19 | panic("syscall.Lstat not yet implemented") 20 | } 21 | func ext۰syscall۰Open(fr *frame, args []value) value { 22 | panic("syscall.Open not yet implemented") 23 | } 24 | func ext۰syscall۰ParseDirent(fr *frame, args []value) value { 25 | panic("syscall.ParseDirent not yet implemented") 26 | } 27 | func ext۰syscall۰Read(fr *frame, args []value) value { 28 | panic("syscall.Read not yet implemented") 29 | } 30 | func ext۰syscall۰ReadDirent(fr *frame, args []value) value { 31 | panic("syscall.ReadDirent not yet implemented") 32 | } 33 | func ext۰syscall۰Stat(fr *frame, args []value) value { 34 | panic("syscall.Stat not yet implemented") 35 | } 36 | func ext۰syscall۰Write(fr *frame, args []value) value { 37 | panic("syscall.Write not yet implemented") 38 | } 39 | func ext۰syscall۰RawSyscall(fr *frame, args []value) value { 40 | return tuple{uintptr(0), uintptr(0), uintptr(syscall.ENOSYS)} 41 | } 42 | func syswrite(fd int, b []byte) (int, error) { 43 | panic("syswrite not yet implemented") 44 | } 45 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/a_test.go: -------------------------------------------------------------------------------- 1 | package a 2 | 3 | import "testing" 4 | 5 | func TestFoo(t *testing.T) { 6 | t.Error("foo") 7 | } 8 | 9 | func TestBar(t *testing.T) { 10 | t.Error("bar") 11 | } 12 | 13 | func BenchmarkWiz(b *testing.B) { 14 | b.Error("wiz") 15 | } 16 | 17 | // Don't test Examples since that testing package needs pipe(2) for that. 18 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/b_test.go: -------------------------------------------------------------------------------- 1 | package b 2 | 3 | import "testing" 4 | 5 | func NotATest(t *testing.T) { 6 | t.Error("foo") 7 | } 8 | 9 | func NotABenchmark(b *testing.B) { 10 | b.Error("wiz") 11 | } 12 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/callstack.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "path" 6 | "runtime" 7 | "strings" 8 | ) 9 | 10 | var stack string 11 | 12 | func f() { 13 | pc := make([]uintptr, 6) 14 | pc = pc[:runtime.Callers(1, pc)] 15 | for _, f := range pc { 16 | Func := runtime.FuncForPC(f) 17 | name := Func.Name() 18 | if strings.Contains(name, "$") || strings.Contains(name, ".func") { 19 | name = "func" // anon funcs vary across toolchains 20 | } 21 | file, line := Func.FileLine(0) 22 | stack += fmt.Sprintf("%s at %s:%d\n", name, path.Base(file), line) 23 | } 24 | } 25 | 26 | func g() { f() } 27 | func h() { g() } 28 | func i() { func() { h() }() } 29 | 30 | // Hack: the 'func' and the call to Caller are on the same line, 31 | // to paper over differences between toolchains. 32 | // (The interpreter's location info isn't yet complete.) 33 | func runtimeCaller0() (uintptr, string, int, bool) { return runtime.Caller(0) } 34 | 35 | func main() { 36 | i() 37 | if stack != `main.f at callstack.go:12 38 | main.g at callstack.go:26 39 | main.h at callstack.go:27 40 | func at callstack.go:28 41 | main.i at callstack.go:28 42 | main.main at callstack.go:35 43 | ` { 44 | panic("unexpected stack: " + stack) 45 | } 46 | 47 | pc, file, line, _ := runtimeCaller0() 48 | got := fmt.Sprintf("%s @ %s:%d", runtime.FuncForPC(pc).Name(), path.Base(file), line) 49 | if got != "main.runtimeCaller0 @ callstack.go:33" { 50 | panic("runtime.Caller: " + got) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/complit.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of composite literals. 4 | 5 | import "fmt" 6 | 7 | // Map literals. 8 | func init() { 9 | type M map[int]int 10 | m1 := []*M{{1: 1}, &M{2: 2}} 11 | want := "map[1:1] map[2:2]" 12 | if got := fmt.Sprint(*m1[0], *m1[1]); got != want { 13 | panic(got) 14 | } 15 | m2 := []M{{1: 1}, M{2: 2}} 16 | if got := fmt.Sprint(m2[0], m2[1]); got != want { 17 | panic(got) 18 | } 19 | } 20 | 21 | // Nonliteral keys in composite literal. 22 | func init() { 23 | const zero int = 1 24 | var v = []int{1 + zero: 42} 25 | if x := fmt.Sprint(v); x != "[0 0 42]" { 26 | panic(x) 27 | } 28 | } 29 | 30 | // Test for in-place initialization. 31 | func init() { 32 | // struct 33 | type S struct { 34 | a, b int 35 | } 36 | s := S{1, 2} 37 | s = S{b: 3} 38 | if s.a != 0 { 39 | panic("s.a != 0") 40 | } 41 | if s.b != 3 { 42 | panic("s.b != 3") 43 | } 44 | s = S{} 45 | if s.a != 0 { 46 | panic("s.a != 0") 47 | } 48 | if s.b != 0 { 49 | panic("s.b != 0") 50 | } 51 | 52 | // array 53 | type A [4]int 54 | a := A{2, 4, 6, 8} 55 | a = A{1: 6, 2: 4} 56 | if a[0] != 0 { 57 | panic("a[0] != 0") 58 | } 59 | if a[1] != 6 { 60 | panic("a[1] != 6") 61 | } 62 | if a[2] != 4 { 63 | panic("a[2] != 4") 64 | } 65 | if a[3] != 0 { 66 | panic("a[3] != 0") 67 | } 68 | a = A{} 69 | if a[0] != 0 { 70 | panic("a[0] != 0") 71 | } 72 | if a[1] != 0 { 73 | panic("a[1] != 0") 74 | } 75 | if a[2] != 0 { 76 | panic("a[2] != 0") 77 | } 78 | if a[3] != 0 { 79 | panic("a[3] != 0") 80 | } 81 | } 82 | 83 | func main() { 84 | } 85 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/defer.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of defer. (Deferred recover() belongs is recover.go.) 4 | 5 | import "fmt" 6 | 7 | func deferMutatesResults(noArgReturn bool) (a, b int) { 8 | defer func() { 9 | if a != 1 || b != 2 { 10 | panic(fmt.Sprint(a, b)) 11 | } 12 | a, b = 3, 4 13 | }() 14 | if noArgReturn { 15 | a, b = 1, 2 16 | return 17 | } 18 | return 1, 2 19 | } 20 | 21 | func init() { 22 | a, b := deferMutatesResults(true) 23 | if a != 3 || b != 4 { 24 | panic(fmt.Sprint(a, b)) 25 | } 26 | a, b = deferMutatesResults(false) 27 | if a != 3 || b != 4 { 28 | panic(fmt.Sprint(a, b)) 29 | } 30 | } 31 | 32 | // We concatenate init blocks to make a single function, but we must 33 | // run defers at the end of each block, not the combined function. 34 | var deferCount = 0 35 | 36 | func init() { 37 | deferCount = 1 38 | defer func() { 39 | deferCount++ 40 | }() 41 | // defer runs HERE 42 | } 43 | 44 | func init() { 45 | // Strictly speaking the spec says deferCount may be 0 or 2 46 | // since the relative order of init blocks is unspecified. 47 | if deferCount != 2 { 48 | panic(deferCount) // defer call has not run! 49 | } 50 | } 51 | 52 | func main() { 53 | } 54 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/ifaceprom.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Test of promotion of methods of an interface embedded within a 4 | // struct. In particular, this test exercises that the correct 5 | // method is called. 6 | 7 | type I interface { 8 | one() int 9 | two() string 10 | } 11 | 12 | type S struct { 13 | I 14 | } 15 | 16 | type impl struct{} 17 | 18 | func (impl) one() int { 19 | return 1 20 | } 21 | 22 | func (impl) two() string { 23 | return "two" 24 | } 25 | 26 | func main() { 27 | var s S 28 | s.I = impl{} 29 | if one := s.I.one(); one != 1 { 30 | panic(one) 31 | } 32 | if one := s.one(); one != 1 { 33 | panic(one) 34 | } 35 | closOne := s.I.one 36 | if one := closOne(); one != 1 { 37 | panic(one) 38 | } 39 | closOne = s.one 40 | if one := closOne(); one != 1 { 41 | panic(one) 42 | } 43 | 44 | if two := s.I.two(); two != "two" { 45 | panic(two) 46 | } 47 | if two := s.two(); two != "two" { 48 | panic(two) 49 | } 50 | closTwo := s.I.two 51 | if two := closTwo(); two != "two" { 52 | panic(two) 53 | } 54 | closTwo = s.two 55 | if two := closTwo(); two != "two" { 56 | panic(two) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/initorder.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | // Test of initialization order of package-level vars. 6 | 7 | var counter int 8 | 9 | func next() int { 10 | c := counter 11 | counter++ 12 | return c 13 | } 14 | 15 | func next2() (x int, y int) { 16 | x = next() 17 | y = next() 18 | return 19 | } 20 | 21 | func makeOrder() int { 22 | _, _, _, _ = f, b, d, e 23 | return 0 24 | } 25 | 26 | func main() { 27 | // Initialization constraints: 28 | // - {f,b,c/d,e} < order (ref graph traversal) 29 | // - order < {a} (lexical order) 30 | // - b < c/d < e < f (lexical order) 31 | // Solution: a b c/d e f 32 | abcdef := [6]int{a, b, c, d, e, f} 33 | if abcdef != [6]int{0, 1, 2, 3, 4, 5} { 34 | panic(abcdef) 35 | } 36 | } 37 | 38 | var order = makeOrder() 39 | 40 | var a, b = next(), next() 41 | var c, d = next2() 42 | var e, f = next(), next() 43 | 44 | // ------------------------------------------------------------------------ 45 | 46 | var order2 []string 47 | 48 | func create(x int, name string) int { 49 | order2 = append(order2, name) 50 | return x 51 | } 52 | 53 | var C = create(B+1, "C") 54 | var A, B = create(1, "A"), create(2, "B") 55 | 56 | // Initialization order of package-level value specs. 57 | func init() { 58 | x := fmt.Sprint(order2) 59 | // Result varies by toolchain. This is a spec bug. 60 | if x != "[B C A]" && // gc 61 | x != "[A B C]" { // go/types 62 | panic(x) 63 | } 64 | if C != 3 { 65 | panic(c) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/methprom.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of method promotion logic. 4 | 5 | type A struct{ magic int } 6 | 7 | func (a A) x() { 8 | if a.magic != 1 { 9 | panic(a.magic) 10 | } 11 | } 12 | func (a *A) y() *A { 13 | return a 14 | } 15 | 16 | type B struct{ magic int } 17 | 18 | func (b B) p() { 19 | if b.magic != 2 { 20 | panic(b.magic) 21 | } 22 | } 23 | func (b *B) q() { 24 | if b != theC.B { 25 | panic("oops") 26 | } 27 | } 28 | 29 | type I interface { 30 | f() 31 | } 32 | 33 | type impl struct{ magic int } 34 | 35 | func (i impl) f() { 36 | if i.magic != 3 { 37 | panic("oops") 38 | } 39 | } 40 | 41 | type C struct { 42 | A 43 | *B 44 | I 45 | } 46 | 47 | func assert(cond bool) { 48 | if !cond { 49 | panic("failed") 50 | } 51 | } 52 | 53 | var theC = C{ 54 | A: A{1}, 55 | B: &B{2}, 56 | I: impl{3}, 57 | } 58 | 59 | func addr() *C { 60 | return &theC 61 | } 62 | 63 | func value() C { 64 | return theC 65 | } 66 | 67 | func main() { 68 | // address 69 | addr().x() 70 | if addr().y() != &theC.A { 71 | panic("oops") 72 | } 73 | addr().p() 74 | addr().q() 75 | addr().f() 76 | 77 | // addressable value 78 | var c C = value() 79 | c.x() 80 | if c.y() != &c.A { 81 | panic("oops") 82 | } 83 | c.p() 84 | c.q() 85 | c.f() 86 | 87 | // non-addressable value 88 | value().x() 89 | // value().y() // not in method set 90 | value().p() 91 | value().q() 92 | value().f() 93 | } 94 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/mrvchain.go: -------------------------------------------------------------------------------- 1 | // Tests of call chaining f(g()) when g has multiple return values (MRVs). 2 | // See https://code.google.com/p/go/issues/detail?id=4573. 3 | 4 | package main 5 | 6 | func assert(actual, expected int) { 7 | if actual != expected { 8 | panic(actual) 9 | } 10 | } 11 | 12 | func g() (int, int) { 13 | return 5, 7 14 | } 15 | 16 | func g2() (float64, float64) { 17 | return 5, 7 18 | } 19 | 20 | func f1v(x int, v ...int) { 21 | assert(x, 5) 22 | assert(v[0], 7) 23 | } 24 | 25 | func f2(x, y int) { 26 | assert(x, 5) 27 | assert(y, 7) 28 | } 29 | 30 | func f2v(x, y int, v ...int) { 31 | assert(x, 5) 32 | assert(y, 7) 33 | assert(len(v), 0) 34 | } 35 | 36 | func complexArgs() (float64, float64) { 37 | return 5, 7 38 | } 39 | 40 | func appendArgs() ([]string, string) { 41 | return []string{"foo"}, "bar" 42 | } 43 | 44 | func h() (i interface{}, ok bool) { 45 | m := map[int]string{1: "hi"} 46 | i, ok = m[1] // string->interface{} conversion within multi-valued expression 47 | return 48 | } 49 | 50 | func h2() (i interface{}, ok bool) { 51 | ch := make(chan string, 1) 52 | ch <- "hi" 53 | i, ok = <-ch // string->interface{} conversion within multi-valued expression 54 | return 55 | } 56 | 57 | func main() { 58 | f1v(g()) 59 | f2(g()) 60 | f2v(g()) 61 | if c := complex(complexArgs()); c != 5+7i { 62 | panic(c) 63 | } 64 | if s := append(appendArgs()); len(s) != 2 || s[0] != "foo" || s[1] != "bar" { 65 | panic(s) 66 | } 67 | i, ok := h() 68 | if !ok || i.(string) != "hi" { 69 | panic(i) 70 | } 71 | i, ok = h2() 72 | if !ok || i.(string) != "hi" { 73 | panic(i) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/range.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of range loops. 4 | 5 | import "fmt" 6 | 7 | // Range over string. 8 | func init() { 9 | if x := len("Hello, 世界"); x != 13 { // bytes 10 | panic(x) 11 | } 12 | var indices []int 13 | var runes []rune 14 | for i, r := range "Hello, 世界" { 15 | runes = append(runes, r) 16 | indices = append(indices, i) 17 | } 18 | if x := fmt.Sprint(runes); x != "[72 101 108 108 111 44 32 19990 30028]" { 19 | panic(x) 20 | } 21 | if x := fmt.Sprint(indices); x != "[0 1 2 3 4 5 6 7 10]" { 22 | panic(x) 23 | } 24 | s := "" 25 | for _, r := range runes { 26 | s = fmt.Sprintf("%s%c", s, r) 27 | } 28 | if s != "Hello, 世界" { 29 | panic(s) 30 | } 31 | 32 | var x int 33 | for range "Hello, 世界" { 34 | x++ 35 | } 36 | if x != len(indices) { 37 | panic(x) 38 | } 39 | } 40 | 41 | // Regression test for range of pointer to named array type. 42 | func init() { 43 | type intarr [3]int 44 | ia := intarr{1, 2, 3} 45 | var count int 46 | for _, x := range &ia { 47 | count += x 48 | } 49 | if count != 6 { 50 | panic(count) 51 | } 52 | } 53 | 54 | func main() { 55 | } 56 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/recover.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of panic/recover. 4 | 5 | import "fmt" 6 | 7 | func fortyTwo() (r int) { 8 | r = 42 9 | // The next two statements simulate a 'return' statement. 10 | defer func() { recover() }() 11 | panic(nil) 12 | } 13 | 14 | func zero() int { 15 | defer func() { recover() }() 16 | panic(1) 17 | } 18 | 19 | func zeroEmpty() (int, string) { 20 | defer func() { recover() }() 21 | panic(1) 22 | } 23 | 24 | func main() { 25 | if r := fortyTwo(); r != 42 { 26 | panic(r) 27 | } 28 | if r := zero(); r != 0 { 29 | panic(r) 30 | } 31 | if r, s := zeroEmpty(); r != 0 || s != "" { 32 | panic(fmt.Sprint(r, s)) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/reflect.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "reflect" 4 | 5 | func main() { 6 | // Regression test for issue 9462. 7 | got := reflect.SliceOf(reflect.TypeOf(byte(0))).String() 8 | if got != "[]uint8" && got != "[]byte" { // result varies by toolchain 9 | println("BUG: " + got) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/static.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Static tests of SSA builder (via the sanity checker). 4 | // Dynamic semantics are not exercised. 5 | 6 | func init() { 7 | // Regression test for issue 6806. 8 | ch := make(chan int) 9 | select { 10 | case n, _ := <-ch: 11 | _ = n 12 | default: 13 | // The default case disables the simplification of 14 | // select to a simple receive statement. 15 | } 16 | 17 | // value,ok-form receive where TypeOf(ok) is a named boolean. 18 | type mybool bool 19 | var x int 20 | var y mybool 21 | select { 22 | case x, y = <-ch: 23 | default: 24 | // The default case disables the simplification of 25 | // select to a simple receive statement. 26 | } 27 | _ = x 28 | _ = y 29 | } 30 | 31 | var a int 32 | 33 | // Regression test for issue 7840 (covered by SSA sanity checker). 34 | func bug7840() bool { 35 | // This creates a single-predecessor block with a φ-node. 36 | return false && a == 0 && a == 0 37 | } 38 | 39 | // A blocking select (sans "default:") cannot fall through. 40 | // Regression test for issue 7022. 41 | func bug7022() int { 42 | var c1, c2 chan int 43 | select { 44 | case <-c1: 45 | return 123 46 | case <-c2: 47 | return 456 48 | } 49 | } 50 | 51 | // Parens should not prevent intrinsic treatment of built-ins. 52 | // (Regression test for a crash.) 53 | func init() { 54 | _ = (new)(int) 55 | _ = (make)([]int, 0) 56 | } 57 | 58 | func main() {} 59 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/go11.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.2 6 | 7 | package types 8 | 9 | import "go/ast" 10 | 11 | func slice3(x *ast.SliceExpr) bool { 12 | return false 13 | } 14 | 15 | func sliceMax(x *ast.SliceExpr) ast.Expr { 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/go12.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.2 6 | 7 | package types 8 | 9 | import "go/ast" 10 | 11 | func slice3(x *ast.SliceExpr) bool { 12 | return x.Slice3 13 | } 14 | 15 | func sliceMax(x *ast.SliceExpr) ast.Expr { 16 | return x.Max 17 | } 18 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/objset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file implements objsets. 6 | // 7 | // An objset is similar to a Scope but objset elements 8 | // are identified by their unique id, instead of their 9 | // object name. 10 | 11 | package types 12 | 13 | // An objset is a set of objects identified by their unique id. 14 | // The zero value for objset is a ready-to-use empty objset. 15 | type objset map[string]Object // initialized lazily 16 | 17 | // insert attempts to insert an object obj into objset s. 18 | // If s already contains an alternative object alt with 19 | // the same name, insert leaves s unchanged and returns alt. 20 | // Otherwise it inserts obj and returns nil. 21 | func (s *objset) insert(obj Object) Object { 22 | id := obj.Id() 23 | if alt := (*s)[id]; alt != nil { 24 | return alt 25 | } 26 | if *s == nil { 27 | *s = make(map[string]Object) 28 | } 29 | (*s)[id] = obj 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/testdata/blank.src: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package _ /* ERROR invalid package name */ 6 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/testdata/cycles1.src: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package p 6 | 7 | type ( 8 | A interface { 9 | a() interface { 10 | ABC1 11 | } 12 | } 13 | B interface { 14 | b() interface { 15 | ABC2 16 | } 17 | } 18 | C interface { 19 | c() interface { 20 | ABC3 21 | } 22 | } 23 | 24 | AB interface { 25 | A 26 | B 27 | } 28 | BC interface { 29 | B 30 | C 31 | } 32 | 33 | ABC1 interface { 34 | A 35 | B 36 | C 37 | } 38 | ABC2 interface { 39 | AB 40 | C 41 | } 42 | ABC3 interface { 43 | A 44 | BC 45 | } 46 | ) 47 | 48 | var ( 49 | x1 ABC1 50 | x2 ABC2 51 | x3 ABC3 52 | ) 53 | 54 | func _() { 55 | // all types have the same method set 56 | x1 = x2 57 | x2 = x1 58 | 59 | x1 = x3 60 | x3 = x1 61 | 62 | x2 = x3 63 | x3 = x2 64 | 65 | // all methods return the same type again 66 | x1 = x1.a() 67 | x1 = x1.b() 68 | x1 = x1.c() 69 | 70 | x2 = x2.a() 71 | x2 = x2.b() 72 | x2 = x2.c() 73 | 74 | x3 = x3.a() 75 | x3 = x3.b() 76 | x3 = x3.c() 77 | } 78 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/testdata/cycles3.src: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package p 6 | 7 | import "unsafe" 8 | 9 | var ( 10 | _ A = A(nil).a().b().c().d().e().f() 11 | _ A = A(nil).b().c().d().e().f() 12 | _ A = A(nil).c().d().e().f() 13 | _ A = A(nil).d().e().f() 14 | _ A = A(nil).e().f() 15 | _ A = A(nil).f() 16 | _ A = A(nil) 17 | ) 18 | 19 | type ( 20 | A interface { 21 | a() B 22 | B 23 | } 24 | 25 | B interface { 26 | b() C 27 | C 28 | } 29 | 30 | C interface { 31 | c() D 32 | D 33 | } 34 | 35 | D interface { 36 | d() E 37 | E 38 | } 39 | 40 | E interface { 41 | e() F 42 | F 43 | } 44 | 45 | F interface { 46 | f() A 47 | } 48 | ) 49 | 50 | type ( 51 | U interface { 52 | V 53 | } 54 | 55 | V interface { 56 | v() [unsafe.Sizeof(u)]int 57 | } 58 | ) 59 | 60 | var u U 61 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/testdata/expr1.src: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // binary expressions 6 | 7 | package expr1 8 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/testdata/importdecl0a.src: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package importdecl0 6 | 7 | import () 8 | 9 | import ( 10 | // we can have multiple blank imports (was bug) 11 | _ "math" 12 | _ "net/rpc" 13 | init /* ERROR "cannot declare init" */ "fmt" 14 | // reflect defines a type "flag" which shows up in the gc export data 15 | "reflect" 16 | . /* ERROR "imported but not used" */ "reflect" 17 | ) 18 | 19 | import "math" /* ERROR "imported but not used" */ 20 | import m /* ERROR "imported but not used as m" */ "math" 21 | import _ "math" 22 | 23 | import ( 24 | "math/big" /* ERROR "imported but not used" */ 25 | b /* ERROR "imported but not used" */ "math/big" 26 | _ "math/big" 27 | ) 28 | 29 | import "fmt" 30 | import f1 "fmt" 31 | import f2 "fmt" 32 | 33 | // reflect.flag must not be visible in this package 34 | type flag int 35 | type _ reflect /* ERROR "not exported" */ .flag 36 | 37 | // imported package name may conflict with local objects 38 | type reflect /* ERROR "reflect already declared" */ int 39 | 40 | // dot-imported exported objects may conflict with local objects 41 | type Value /* ERROR "Value already declared through dot-import of package reflect" */ struct{} 42 | 43 | var _ = fmt.Println // use "fmt" 44 | 45 | func _() { 46 | f1.Println() // use "fmt" 47 | } 48 | 49 | func _() { 50 | _ = func() { 51 | f2.Println() // use "fmt" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/testdata/importdecl0b.src: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package importdecl0 6 | 7 | import "math" 8 | import m "math" 9 | 10 | import . "testing" // declares T in file scope 11 | import . /* ERROR "imported but not used" */ "unsafe" 12 | import . "fmt" // declares Println in file scope 13 | 14 | import ( 15 | // TODO(gri) At the moment, 2 errors are reported because both go/parser 16 | // and the type checker report it. Eventually, this test should not be 17 | // done by the parser anymore. 18 | "" /* ERROR invalid import path */ /* ERROR invalid import path */ 19 | "a!b" /* ERROR invalid import path */ /* ERROR invalid import path */ 20 | "abc\xffdef" /* ERROR invalid import path */ /* ERROR invalid import path */ 21 | ) 22 | 23 | // using "math" in this file doesn't affect its use in other files 24 | const Pi0 = math.Pi 25 | const Pi1 = m.Pi 26 | 27 | type _ T // use "testing" 28 | 29 | func _() func() interface{} { 30 | return func() interface{} { 31 | return Println // use "fmt" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/testdata/importdecl1a.src: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Test case for issue 8969. 6 | 7 | package importdecl1 8 | 9 | import . "unsafe" 10 | 11 | var _ Pointer // use dot-imported package unsafe 12 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/testdata/importdecl1b.src: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package importdecl1 6 | 7 | import . /* ERROR "imported but not used" */ "unsafe" 8 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/token_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file checks invariants of token.Token ordering that we rely on 6 | // since package go/token doesn't provide any guarantees at the moment. 7 | 8 | package types 9 | 10 | import ( 11 | "go/token" 12 | "testing" 13 | ) 14 | 15 | var assignOps = map[token.Token]token.Token{ 16 | token.ADD_ASSIGN: token.ADD, 17 | token.SUB_ASSIGN: token.SUB, 18 | token.MUL_ASSIGN: token.MUL, 19 | token.QUO_ASSIGN: token.QUO, 20 | token.REM_ASSIGN: token.REM, 21 | token.AND_ASSIGN: token.AND, 22 | token.OR_ASSIGN: token.OR, 23 | token.XOR_ASSIGN: token.XOR, 24 | token.SHL_ASSIGN: token.SHL, 25 | token.SHR_ASSIGN: token.SHR, 26 | token.AND_NOT_ASSIGN: token.AND_NOT, 27 | } 28 | 29 | func TestZeroTok(t *testing.T) { 30 | // zero value for token.Token must be token.ILLEGAL 31 | var zero token.Token 32 | if token.ILLEGAL != zero { 33 | t.Errorf("%s == %d; want 0", token.ILLEGAL, zero) 34 | } 35 | } 36 | 37 | func TestAssignOp(t *testing.T) { 38 | // there are fewer than 256 tokens 39 | for i := 0; i < 256; i++ { 40 | tok := token.Token(i) 41 | got := assignOp(tok) 42 | want := assignOps[tok] 43 | if got != want { 44 | t.Errorf("for assignOp(%s): got %s; want %s", tok, got, want) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/typeutil/example_test.go: -------------------------------------------------------------------------------- 1 | package typeutil_test 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | 7 | "go/ast" 8 | "go/parser" 9 | "go/token" 10 | 11 | "golang.org/x/tools/go/types" 12 | "golang.org/x/tools/go/types/typeutil" 13 | ) 14 | 15 | func ExampleMap() { 16 | const source = `package P 17 | 18 | var X []string 19 | var Y []string 20 | 21 | const p, q = 1.0, 2.0 22 | 23 | func f(offset int32) (value byte, ok bool) 24 | func g(rune) (uint8, bool) 25 | ` 26 | 27 | // Parse and type-check the package. 28 | fset := token.NewFileSet() 29 | f, err := parser.ParseFile(fset, "P.go", source, 0) 30 | if err != nil { 31 | panic(err) 32 | } 33 | pkg, err := new(types.Config).Check("P", fset, []*ast.File{f}, nil) 34 | if err != nil { 35 | panic(err) 36 | } 37 | 38 | scope := pkg.Scope() 39 | 40 | // Group names of package-level objects by their type. 41 | var namesByType typeutil.Map // value is []string 42 | for _, name := range scope.Names() { 43 | T := scope.Lookup(name).Type() 44 | 45 | names, _ := namesByType.At(T).([]string) 46 | names = append(names, name) 47 | namesByType.Set(T, names) 48 | } 49 | 50 | // Format, sort, and print the map entries. 51 | var lines []string 52 | namesByType.Iterate(func(T types.Type, names interface{}) { 53 | lines = append(lines, fmt.Sprintf("%s %s", names, T)) 54 | }) 55 | sort.Strings(lines) 56 | for _, line := range lines { 57 | fmt.Println(line) 58 | } 59 | 60 | // Output: 61 | // [X Y] []string 62 | // [f g] func(offset int32) (value byte, ok bool) 63 | // [p q] untyped float 64 | } 65 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/typeutil/imports.go: -------------------------------------------------------------------------------- 1 | package typeutil 2 | 3 | import "golang.org/x/tools/go/types" 4 | 5 | // Dependencies returns all dependencies of the specified packages. 6 | // 7 | // Dependent packages appear in topological order: if package P imports 8 | // package Q, Q appears earlier than P in the result. 9 | // The algorithm follows import statements in the order they 10 | // appear in the source code, so the result is a total order. 11 | // 12 | func Dependencies(pkgs ...*types.Package) []*types.Package { 13 | var result []*types.Package 14 | seen := make(map[*types.Package]bool) 15 | var visit func(pkgs []*types.Package) 16 | visit = func(pkgs []*types.Package) { 17 | for _, p := range pkgs { 18 | if !seen[p] { 19 | seen[p] = true 20 | visit(p.Imports()) 21 | result = append(result, p) 22 | } 23 | } 24 | } 25 | visit(pkgs) 26 | return result 27 | } 28 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/types/typeutil/ui.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package typeutil 6 | 7 | // This file defines utilities for user interfaces that display types. 8 | 9 | import "golang.org/x/tools/go/types" 10 | 11 | // IntuitiveMethodSet returns the intuitive method set of a type, T. 12 | // 13 | // The result contains MethodSet(T) and additionally, if T is a 14 | // concrete type, methods belonging to *T if there is no identically 15 | // named method on T itself. This corresponds to user intuition about 16 | // method sets; this function is intended only for user interfaces. 17 | // 18 | // The order of the result is as for types.MethodSet(T). 19 | // 20 | func IntuitiveMethodSet(T types.Type, msets *types.MethodSetCache) []*types.Selection { 21 | var result []*types.Selection 22 | mset := msets.MethodSet(T) 23 | if _, ok := T.Underlying().(*types.Interface); ok { 24 | for i, n := 0, mset.Len(); i < n; i++ { 25 | result = append(result, mset.At(i)) 26 | } 27 | } else { 28 | pmset := msets.MethodSet(types.NewPointer(T)) 29 | for i, n := 0, pmset.Len(); i < n; i++ { 30 | meth := pmset.At(i) 31 | if m := mset.Lookup(meth.Obj().Pkg(), meth.Obj().Name()); m != nil { 32 | meth = m 33 | } 34 | result = append(result, meth) 35 | } 36 | } 37 | return result 38 | } 39 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/go/vcs/env.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package vcs 6 | 7 | import ( 8 | "os" 9 | "strings" 10 | ) 11 | 12 | // envForDir returns a copy of the environment 13 | // suitable for running in the given directory. 14 | // The environment is the current process's environment 15 | // but with an updated $PWD, so that an os.Getwd in the 16 | // child will be faster. 17 | func envForDir(dir string) []string { 18 | env := os.Environ() 19 | // Internally we only use rooted paths, so dir is rooted. 20 | // Even if dir is not rooted, no harm done. 21 | return mergeEnvLists([]string{"PWD=" + dir}, env) 22 | } 23 | 24 | // mergeEnvLists merges the two environment lists such that 25 | // variables with the same name in "in" replace those in "out". 26 | func mergeEnvLists(in, out []string) []string { 27 | NextVar: 28 | for _, inkv := range in { 29 | k := strings.SplitAfterN(inkv, "=", 2)[0] 30 | for i, outkv := range out { 31 | if strings.HasPrefix(outkv, k) { 32 | out[i] = inkv 33 | continue NextVar 34 | } 35 | } 36 | out = append(out, inkv) 37 | } 38 | return out 39 | } 40 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/page.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package godoc 6 | 7 | import ( 8 | "net/http" 9 | "runtime" 10 | ) 11 | 12 | // Page describes the contents of the top-level godoc webpage. 13 | type Page struct { 14 | Title string 15 | Tabtitle string 16 | Subtitle string 17 | Query string 18 | Body []byte 19 | 20 | // filled in by servePage 21 | SearchBox bool 22 | Playground bool 23 | Version string 24 | } 25 | 26 | func (p *Presentation) ServePage(w http.ResponseWriter, page Page) { 27 | if page.Tabtitle == "" { 28 | page.Tabtitle = page.Title 29 | } 30 | page.SearchBox = p.Corpus.IndexEnabled 31 | page.Playground = p.ShowPlayground 32 | page.Version = runtime.Version() 33 | applyTemplateToResponseWriter(w, p.GodocHTML, page) 34 | } 35 | 36 | func (p *Presentation) ServeError(w http.ResponseWriter, r *http.Request, relpath string, err error) { 37 | w.WriteHeader(http.StatusNotFound) 38 | p.ServePage(w, Page{ 39 | Title: "File " + relpath, 40 | Subtitle: relpath, 41 | Body: applyTemplate(p.ErrorHTML, "errorHTML", err), // err may contain an absolute path! 42 | }) 43 | } 44 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/call-eg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/call-eg.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/call3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/call3.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/callers1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/callers1.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/callers2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/callers2.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/chan1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/chan1.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/chan2a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/chan2a.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/chan2b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/chan2b.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/error1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/error1.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ident-def.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ident-def.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ident-field.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ident-field.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ident-func.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ident-func.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ipcg-func.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ipcg-func.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ipcg-pkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ipcg-pkg.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/typeinfo-pkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/typeinfo-pkg.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/analysis/typeinfo-src.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/typeinfo-src.png -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/callgraph.html: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/codewalkdir.html: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | {{range .}} 9 | 10 | {{$name_html := html .Name}} 11 | 12 | 13 | 14 | 15 | {{end}} 16 |
{{$name_html}} {{html .Title}}
17 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/dirlist.html: -------------------------------------------------------------------------------- 1 | 6 | 7 |

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | {{range .}} 20 | 21 | {{$name_html := fileInfoName . | html}} 22 | 23 | 24 | 25 | 26 | 27 | 28 | {{end}} 29 | 30 |
File Bytes Modified
..
{{$name_html}}{{html .Size}}{{fileInfoTime . | html}}
31 |

32 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package static exports a map of static file content that supports the godoc 6 | // user interface. The map should be used with the mapfs package, see 7 | // golang.org/x/tools/godoc/vfs/mapfs. 8 | package static 9 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/error.html: -------------------------------------------------------------------------------- 1 | 6 | 7 |

8 | {{html .}} 9 |

10 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/example.html: -------------------------------------------------------------------------------- 1 |
2 | 5 |
6 |

Example{{example_suffix .Name}}

7 | {{with .Doc}}

{{html .}}

{{end}} 8 | {{$output := .Output}} 9 | {{with .Play}} 10 |
11 |
12 |
{{html $output}}
13 |
14 | Run 15 | Format 16 | 17 |
18 |
19 | {{else}} 20 |

Code:

21 |
{{.Code}}
22 | {{with .Output}} 23 |

Output:

24 |
{{html .}}
25 | {{end}} 26 | {{end}} 27 |
28 |
29 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package static 6 | 7 | //go:generate go run makestatic.go 8 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/images/minus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/images/minus.gif -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/images/plus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/images/plus.gif -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/images/treeview-black-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/images/treeview-black-line.gif -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/images/treeview-black.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/images/treeview-black.gif -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/images/treeview-default-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/images/treeview-default-line.gif -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/images/treeview-default.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/images/treeview-default.gif -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/images/treeview-gray-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/images/treeview-gray-line.gif -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/images/treeview-gray.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/images/treeview-gray.gif -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/implements.html: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/methodset.html: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/opensearch.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | godoc 4 | The Go Programming Language 5 | go golang 6 | 7 | 8 | /favicon.ico 9 | UTF-8 10 | UTF-8 11 | 12 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/search.html: -------------------------------------------------------------------------------- 1 | 6 | {{with .Alert}} 7 |

8 | {{html .}} 9 |

10 | {{end}} 11 | {{with .Alt}} 12 |

13 | Did you mean: 14 | {{range .Alts}} 15 | {{html .}} 16 | {{end}} 17 |

18 | {{end}} 19 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/search.txt: -------------------------------------------------------------------------------- 1 | QUERY 2 | {{.Query}} 3 | 4 | {{with .Alert}}{{.}} 5 | {{end}}{{/* .Alert */}}{{/* 6 | 7 | --------------------------------------- 8 | 9 | */}}{{with .Alt}}DID YOU MEAN 10 | 11 | {{range .Alts}} {{.}} 12 | {{end}} 13 | {{end}}{{/* .Alt */}}{{/* 14 | 15 | --------------------------------------- 16 | 17 | */}}{{with .Pak}}PACKAGE {{$.Query}} 18 | 19 | {{range .}} {{pkgLink .Pak.Path}} 20 | {{end}} 21 | {{end}}{{/* .Pak */}}{{/* 22 | 23 | --------------------------------------- 24 | 25 | */}}{{range $key, $val := .Idents}}{{if $val}}{{$key.Name}} 26 | {{range $val.Idents}} {{.Path}}.{{.Name}} 27 | {{end}} 28 | {{end}}{{end}}{{/* .Idents */}}{{/* 29 | 30 | --------------------------------------- 31 | 32 | */}}{{with .Hit}}{{with .Decls}}PACKAGE-LEVEL DECLARATIONS 33 | 34 | {{range .}}package {{.Pak.Name}} 35 | {{range $file := .Files}}{{range .Groups}}{{range .}} {{srcLink $file.File.Path}}:{{infoLine .}}{{end}} 36 | {{end}}{{end}}{{/* .Files */}} 37 | {{end}}{{end}}{{/* .Decls */}}{{/* 38 | 39 | --------------------------------------- 40 | 41 | */}}{{with .Others}}LOCAL DECLARATIONS AND USES 42 | 43 | {{range .}}package {{.Pak.Name}} 44 | {{range $file := .Files}}{{range .Groups}}{{range .}} {{srcLink $file.File.Path}}:{{infoLine .}} 45 | {{end}}{{end}}{{end}}{{/* .Files */}} 46 | {{end}}{{end}}{{/* .Others */}}{{end}}{{/* .Hit */}}{{/* 47 | 48 | --------------------------------------- 49 | 50 | */}}{{if .Textual}}{{if .Complete}}{{.Found}} TEXTUAL OCCURRENCES{{else}}MORE THAN {{.Found}} TEXTUAL OCCURRENCES{{end}} 51 | 52 | {{range .Textual}}{{len .Lines}} {{srcLink .Filename}} 53 | {{end}}{{if not .Complete}}... ... 54 | {{end}}{{end}} 55 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/searchdoc.html: -------------------------------------------------------------------------------- 1 | 6 | {{range $key, $val := .Idents}} 7 | {{if $val}} 8 |

{{$key.Name}}

9 | {{range $val}} 10 | {{$pkg_html := pkgLink .Path | html}} 11 | {{if eq "Packages" $key.Name}} 12 | {{html .Path}} 13 | {{else}} 14 | {{$doc_html := docLink .Path .Name| html}} 15 | {{html .Package}}.{{.Name}} 16 | {{end}} 17 | {{if .Doc}} 18 |

{{comment_html .Doc}}

19 | {{else}} 20 |

No documentation available

21 | {{end}} 22 | {{end}} 23 | {{end}} 24 | {{end}} 25 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/static/searchtxt.html: -------------------------------------------------------------------------------- 1 | 6 | {{$query_url := urlquery .Query}} 7 | {{with .Textual}} 8 | {{if $.Complete}} 9 |

{{html $.Found}} textual occurrences

10 | {{else}} 11 |

More than {{html $.Found}} textual occurrences

12 |

13 | Not all files or lines containing "{{html $.Query}}" are shown. 14 |

15 | {{end}} 16 |

17 | 18 | {{range .}} 19 | {{$file := .Filename}} 20 | 21 | 24 | 25 | 26 | 27 | 35 | 36 | {{end}} 37 | {{if not $.Complete}} 38 | 39 | {{end}} 40 |
22 | {{$file}}: 23 | {{len .Lines}} 28 | {{range .Lines}} 29 | {{html .}} 30 | {{end}} 31 | {{if not $.Complete}} 32 | ... 33 | {{end}} 34 |
...
41 |

42 | {{end}} 43 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/godoc/vfs/vfs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package vfs defines types for abstract file system access and provides an 6 | // implementation accessing the file system of the underlying OS. 7 | package vfs 8 | 9 | import ( 10 | "io" 11 | "io/ioutil" 12 | "os" 13 | ) 14 | 15 | // The FileSystem interface specifies the methods godoc is using 16 | // to access the file system for which it serves documentation. 17 | type FileSystem interface { 18 | Opener 19 | Lstat(path string) (os.FileInfo, error) 20 | Stat(path string) (os.FileInfo, error) 21 | ReadDir(path string) ([]os.FileInfo, error) 22 | String() string 23 | } 24 | 25 | // Opener is a minimal virtual filesystem that can only open regular files. 26 | type Opener interface { 27 | Open(name string) (ReadSeekCloser, error) 28 | } 29 | 30 | // A ReadSeekCloser can Read, Seek, and Close. 31 | type ReadSeekCloser interface { 32 | io.Reader 33 | io.Seeker 34 | io.Closer 35 | } 36 | 37 | // ReadFile reads the file named by path from fs and returns the contents. 38 | func ReadFile(fs Opener, path string) ([]byte, error) { 39 | rc, err := fs.Open(path) 40 | if err != nil { 41 | return nil, err 42 | } 43 | defer rc.Close() 44 | return ioutil.ReadAll(rc) 45 | } 46 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/imports/sortimports_compat.go: -------------------------------------------------------------------------------- 1 | // +build !go1.2 2 | 3 | // Copyright 2013 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package imports 8 | 9 | import "go/ast" 10 | 11 | // Go 1.1 users don't get fancy package grouping. 12 | // But this is still gofmt-compliant: 13 | 14 | var sortImports = ast.SortImports 15 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/definition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package oracle 6 | 7 | import ( 8 | "fmt" 9 | "go/ast" 10 | "go/token" 11 | 12 | "golang.org/x/tools/go/types" 13 | "golang.org/x/tools/oracle/serial" 14 | ) 15 | 16 | // definition reports the location of the definition of an identifier. 17 | // 18 | // TODO(adonovan): opt: for intra-file references, the parser's 19 | // resolution might be enough; we should start with that. 20 | // 21 | func definition(o *Oracle, qpos *QueryPos) (queryResult, error) { 22 | id, _ := qpos.path[0].(*ast.Ident) 23 | if id == nil { 24 | return nil, fmt.Errorf("no identifier here") 25 | } 26 | 27 | obj := qpos.info.ObjectOf(id) 28 | if obj == nil { 29 | // Happens for y in "switch y := x.(type)", but I think that's all. 30 | return nil, fmt.Errorf("no object for identifier") 31 | } 32 | 33 | return &definitionResult{qpos, obj}, nil 34 | } 35 | 36 | type definitionResult struct { 37 | qpos *QueryPos 38 | obj types.Object // object it denotes 39 | } 40 | 41 | func (r *definitionResult) display(printf printfFunc) { 42 | printf(r.obj, "defined here as %s", r.qpos.ObjectString(r.obj)) 43 | } 44 | 45 | func (r *definitionResult) toSerial(res *serial.Result, fset *token.FileSet) { 46 | definition := &serial.Definition{ 47 | Desc: r.obj.String(), 48 | } 49 | if pos := r.obj.Pos(); pos != token.NoPos { // Package objects have no Pos() 50 | definition.ObjPos = fset.Position(pos).String() 51 | } 52 | res.Definition = definition 53 | } 54 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/lib/lib.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | type Type int 4 | 5 | func (Type) Method(x *int) *int { 6 | return x 7 | } 8 | 9 | func Func() { 10 | } 11 | 12 | const Const = 3 13 | 14 | var Var = 0 15 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/callgraph-json.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of call-graph queries, -format=json. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See callgraph-json.golden for expected query results. 6 | 7 | func A() {} 8 | 9 | func B() {} 10 | 11 | // call is not (yet) treated context-sensitively. 12 | func call(f func()) { 13 | f() 14 | } 15 | 16 | // nop *is* treated context-sensitively. 17 | func nop() {} 18 | 19 | func call2(f func()) { 20 | f() 21 | f() 22 | } 23 | 24 | func main() { 25 | call(A) 26 | call(B) 27 | 28 | nop() 29 | nop() 30 | 31 | call2(func() { 32 | // called twice from main.call2, 33 | // but call2 is not context sensitive (yet). 34 | }) 35 | 36 | print("builtin") 37 | _ = string("type conversion") 38 | call(nil) 39 | if false { 40 | main() 41 | } 42 | var nilFunc func() 43 | nilFunc() 44 | var i interface { 45 | f() 46 | } 47 | i.f() 48 | } 49 | 50 | func deadcode() { 51 | main() 52 | } 53 | 54 | // @callgraph callgraph "^" 55 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/callgraph-json.golden: -------------------------------------------------------------------------------- 1 | -------- @callgraph callgraph -------- 2 | { 3 | "mode": "callgraph", 4 | "callgraph": [ 5 | { 6 | "name": "main.main", 7 | "pos": "testdata/src/main/callgraph-json.go:24:6", 8 | "children": [ 9 | 0, 10 | 1, 11 | 2, 12 | 3 13 | ] 14 | }, 15 | { 16 | "name": "main.call", 17 | "pos": "testdata/src/main/callgraph-json.go:12:6", 18 | "children": [ 19 | 5, 20 | 6 21 | ] 22 | }, 23 | { 24 | "name": "main.nop", 25 | "pos": "testdata/src/main/callgraph-json.go:17:6" 26 | }, 27 | { 28 | "name": "main.call2", 29 | "pos": "testdata/src/main/callgraph-json.go:19:6", 30 | "children": [ 31 | 7 32 | ] 33 | }, 34 | { 35 | "name": "main.init", 36 | "pos": "-" 37 | }, 38 | { 39 | "name": "main.A", 40 | "pos": "testdata/src/main/callgraph-json.go:7:6" 41 | }, 42 | { 43 | "name": "main.B", 44 | "pos": "testdata/src/main/callgraph-json.go:9:6" 45 | }, 46 | { 47 | "name": "main.main$1", 48 | "pos": "testdata/src/main/callgraph-json.go:31:8" 49 | } 50 | ] 51 | } -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/callgraph.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of call-graph queries. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See callgraph.golden for expected query results. 6 | 7 | import "lib" 8 | 9 | func A() {} 10 | 11 | func B() {} 12 | 13 | // call is not (yet) treated context-sensitively. 14 | func call(f func()) { 15 | f() 16 | } 17 | 18 | // nop *is* treated context-sensitively. 19 | func nop() {} 20 | 21 | func call2(f func()) { 22 | f() 23 | f() 24 | } 25 | 26 | func main() { 27 | call(A) 28 | call(B) 29 | 30 | nop() 31 | nop() 32 | 33 | call2(func() { 34 | // called twice from main.call2, 35 | // but call2 is not context sensitive (yet). 36 | }) 37 | 38 | print("builtin") 39 | _ = string("type conversion") 40 | call(nil) 41 | if false { 42 | main() 43 | } 44 | var nilFunc func() 45 | nilFunc() 46 | var i interface { 47 | f() 48 | } 49 | i.f() 50 | 51 | lib.Func() 52 | } 53 | 54 | func deadcode() { 55 | main() 56 | } 57 | 58 | // @callgraph callgraph-main "^" 59 | 60 | // @callgraph callgraph-complete "nopos" 61 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/callgraph.golden: -------------------------------------------------------------------------------- 1 | -------- @callgraph callgraph-main -------- 2 | 3 | Below is a call graph of package main. 4 | The numbered nodes form a spanning tree. 5 | Non-numbered nodes indicate back- or cross-edges to the node whose 6 | number follows in parentheses. 7 | 8 | 0 init 9 | 1 main 10 | 2 call 11 | 3 A 12 | 4 B 13 | 5 call2 14 | 6 main$1 15 | main (1) 16 | 7 nop 17 | 18 | -------- @callgraph callgraph-complete -------- 19 | 20 | Below is a call graph of the entire program. 21 | The numbered nodes form a spanning tree. 22 | Non-numbered nodes indicate back- or cross-edges to the node whose 23 | number follows in parentheses. 24 | 25 | 0 26 | 1 main.init 27 | 2 lib.init 28 | 3 main.main 29 | 4 lib.Func 30 | 5 main.call 31 | 6 main.A 32 | 7 main.B 33 | 8 main.call2 34 | 9 main.main$1 35 | main.main (3) 36 | 10 main.nop 37 | 38 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/callgraph2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of call-graph queries. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See callgraph2.golden for expected query results. 6 | 7 | // (Regression test for pointer analysis: programs that use reflection 8 | // create some cgnodes before the root of the callgraph.) 9 | import _ "reflect" 10 | 11 | func f() {} 12 | func main() { 13 | f() 14 | } 15 | 16 | // @callgraph callgraph "^" 17 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/callgraph2.golden: -------------------------------------------------------------------------------- 1 | -------- @callgraph callgraph -------- 2 | 3 | Below is a call graph of package main. 4 | The numbered nodes form a spanning tree. 5 | Non-numbered nodes indicate back- or cross-edges to the node whose 6 | number follows in parentheses. 7 | 8 | 0 init 9 | 1 main 10 | 2 f 11 | 12 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/calls-json.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of call-graph queries, -format=json. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See calls-json.golden for expected query results. 6 | 7 | func call(f func()) { 8 | f() // @callees @callees-f "f" 9 | } 10 | 11 | func main() { 12 | call(func() { 13 | // @callers callers-main.anon "^" 14 | // @callstack callstack-main.anon "^" 15 | }) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/calls-json.golden: -------------------------------------------------------------------------------- 1 | -------- @callees @callees-f -------- 2 | { 3 | "mode": "callees", 4 | "callees": { 5 | "pos": "testdata/src/main/calls-json.go:8:3", 6 | "desc": "dynamic function call", 7 | "callees": [ 8 | { 9 | "name": "main.main$1", 10 | "pos": "testdata/src/main/calls-json.go:12:7" 11 | } 12 | ] 13 | } 14 | }-------- @callstack callstack-main.anon -------- 15 | { 16 | "mode": "callstack", 17 | "callstack": { 18 | "pos": "testdata/src/main/calls-json.go:12:7", 19 | "target": "main.main$1", 20 | "callers": [ 21 | { 22 | "pos": "testdata/src/main/calls-json.go:8:3", 23 | "desc": "dynamic function call", 24 | "caller": "main.call" 25 | }, 26 | { 27 | "pos": "testdata/src/main/calls-json.go:12:6", 28 | "desc": "static function call", 29 | "caller": "main.main" 30 | } 31 | ] 32 | } 33 | } -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/describe-json.go: -------------------------------------------------------------------------------- 1 | package describe // @describe pkgdecl "describe" 2 | 3 | // Tests of 'describe' query, -format=json. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See describe-json.golden for expected query results. 6 | 7 | func main() { // 8 | var s struct{ x [3]int } 9 | p := &s.x[0] // @describe desc-val-p "p" 10 | _ = p 11 | 12 | var i I = C(0) 13 | if i == nil { 14 | i = new(D) 15 | } 16 | print(i) // @describe desc-val-i "\\bi\\b" 17 | 18 | go main() // @describe desc-stmt "go" 19 | } 20 | 21 | type I interface { 22 | f() 23 | } 24 | 25 | type C int // @describe desc-type-C "C" 26 | type D struct{} 27 | 28 | func (c C) f() {} 29 | func (d *D) f() {} 30 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/freevars.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of 'freevars' query. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See freevars.golden for expected query results. 6 | 7 | // TODO(adonovan): it's hard to test this query in a single line of gofmt'd code. 8 | 9 | type T struct { 10 | a, b int 11 | } 12 | 13 | type S struct { 14 | x int 15 | t T 16 | } 17 | 18 | func f(int) {} 19 | 20 | func main() { 21 | type C int 22 | x := 1 23 | const exp = 6 24 | if y := 2; x+y+int(C(3)) != exp { // @freevars fv1 "if.*{" 25 | panic("expected 6") 26 | } 27 | 28 | var s S 29 | 30 | for x, y := range "foo" { 31 | println(s.x + s.t.a + s.t.b + x + int(y)) // @freevars fv2 "print.*y." 32 | } 33 | 34 | f(x) // @freevars fv3 "f.x." 35 | 36 | // TODO(adonovan): enable when go/types supports labels. 37 | loop: // #@freevars fv-def-label "loop:" 38 | for { 39 | break loop // #@freevars fv-ref-label "break loop" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/freevars.golden: -------------------------------------------------------------------------------- 1 | -------- @freevars fv1 -------- 2 | Free identifiers: 3 | type C 4 | const exp int 5 | var x int 6 | 7 | -------- @freevars fv2 -------- 8 | Free identifiers: 9 | var s.t.a int 10 | var s.t.b int 11 | var s.x int 12 | var x int 13 | var y rune 14 | 15 | -------- @freevars fv3 -------- 16 | Free identifiers: 17 | var x int 18 | 19 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/implements-json.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of 'implements' query, -output=json. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See implements.golden for expected query results. 6 | 7 | func main() { 8 | } 9 | 10 | type E interface{} // @implements E "E" 11 | 12 | type F interface { // @implements F "F" 13 | f() 14 | } 15 | 16 | type FG interface { // @implements FG "FG" 17 | f() 18 | g() []int // @implements slice "..int" 19 | } 20 | 21 | type C int // @implements C "C" 22 | type D struct{} 23 | 24 | func (c *C) f() {} // @implements starC ".C" 25 | func (d D) f() {} // @implements D "D" 26 | 27 | func (d *D) g() []int { return nil } // @implements starD ".D" 28 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/implements.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of 'implements' query. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See implements.golden for expected query results. 6 | 7 | import _ "lib" 8 | import _ "sort" 9 | 10 | func main() { 11 | } 12 | 13 | type E interface{} // @implements E "E" 14 | 15 | type F interface { // @implements F "F" 16 | f() 17 | } 18 | 19 | type FG interface { // @implements FG "FG" 20 | f() 21 | g() []int // @implements slice "..int" 22 | } 23 | 24 | type C int // @implements C "C" 25 | type D struct{} 26 | 27 | func (c *C) f() {} // @implements starC ".C" 28 | func (d D) f() {} // @implements D "D" 29 | 30 | func (d *D) g() []int { return nil } // @implements starD ".D" 31 | 32 | type sorter []int // @implements sorter "sorter" 33 | 34 | func (sorter) Len() int { return 0 } 35 | func (sorter) Less(i, j int) bool { return false } 36 | func (sorter) Swap(i, j int) {} 37 | 38 | type I interface { // @implements I "I" 39 | Method(*int) *int 40 | } 41 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/implements.golden: -------------------------------------------------------------------------------- 1 | -------- @implements E -------- 2 | empty interface type main.E 3 | 4 | -------- @implements F -------- 5 | interface type main.F 6 | is implemented by pointer type *main.C 7 | is implemented by struct type main.D 8 | is implemented by interface type main.FG 9 | 10 | -------- @implements FG -------- 11 | interface type main.FG 12 | is implemented by pointer type *main.D 13 | implements main.F 14 | 15 | -------- @implements slice -------- 16 | slice type []int implements only interface{} 17 | 18 | -------- @implements C -------- 19 | pointer type *main.C 20 | implements main.F 21 | 22 | -------- @implements starC -------- 23 | pointer type *main.C 24 | implements main.F 25 | 26 | -------- @implements D -------- 27 | struct type main.D 28 | implements main.F 29 | pointer type *main.D 30 | implements main.FG 31 | 32 | -------- @implements starD -------- 33 | pointer type *main.D 34 | implements main.F 35 | implements main.FG 36 | 37 | -------- @implements sorter -------- 38 | slice type main.sorter 39 | implements sort.Interface 40 | 41 | -------- @implements I -------- 42 | interface type main.I 43 | is implemented by basic type lib.Type 44 | 45 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/imports.go: -------------------------------------------------------------------------------- 1 | package imports 2 | 3 | import ( 4 | "hash/fnv" // @describe ref-pkg-import2 "fnv" 5 | "lib" // @describe ref-pkg-import "lib" 6 | ) 7 | 8 | // Tests that import another package. (To make the tests run quickly, 9 | // we avoid using imports in all the other tests. Remember, each 10 | // query causes parsing and typechecking of the whole program.) 11 | // 12 | // See go.tools/oracle/oracle_test.go for explanation. 13 | // See imports.golden for expected query results. 14 | 15 | var a int 16 | 17 | func main() { 18 | const c = lib.Const // @describe ref-const "Const" 19 | lib.Func() // @describe ref-func "Func" 20 | lib.Var++ // @describe ref-var "Var" 21 | var t lib.Type // @describe ref-type "Type" 22 | p := t.Method(&a) // @describe ref-method "Method" 23 | 24 | print(*p + 1) // @pointsto p "p " 25 | 26 | var _ lib.Type // @describe ref-pkg "lib" 27 | 28 | fnv.New32() 29 | } 30 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/imports.golden: -------------------------------------------------------------------------------- 1 | -------- @describe ref-pkg-import2 -------- 2 | import of package "hash/fnv" 3 | func New32 func() hash.Hash32 4 | func New32a func() hash.Hash32 5 | func New64 func() hash.Hash64 6 | func New64a func() hash.Hash64 7 | 8 | -------- @describe ref-pkg-import -------- 9 | import of package "lib" 10 | const Const untyped int = 3 11 | func Func func() 12 | type Type int 13 | method (Type) Method(x *int) *int 14 | var Var int 15 | 16 | -------- @describe ref-const -------- 17 | reference to const lib.Const untyped int 18 | defined here 19 | 20 | -------- @describe ref-func -------- 21 | reference to func lib.Func() 22 | defined here 23 | 24 | -------- @describe ref-var -------- 25 | reference to var lib.Var int 26 | defined here 27 | 28 | -------- @describe ref-type -------- 29 | reference to type lib.Type (size 8, align 8) 30 | defined as int 31 | Method set: 32 | method (lib.Type) Method(x *int) *int 33 | 34 | -------- @describe ref-method -------- 35 | reference to method func (lib.Type).Method(x *int) *int 36 | defined here 37 | 38 | -------- @pointsto p -------- 39 | this *int may point to these objects: 40 | imports.a 41 | 42 | -------- @describe ref-pkg -------- 43 | reference to package "lib" 44 | const Const untyped int = 3 45 | func Func func() 46 | type Type int 47 | method (Type) Method(x *int) *int 48 | var Var int 49 | 50 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/multi.go: -------------------------------------------------------------------------------- 1 | package multi 2 | 3 | func g(x int) { 4 | } 5 | 6 | func f() { 7 | x := 1 8 | g(x) // "g(x)" is the selection for multiple queries 9 | } 10 | 11 | func main() { 12 | f() 13 | } 14 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/peers-json.go: -------------------------------------------------------------------------------- 1 | package peers 2 | 3 | // Tests of channel 'peers' query, -format=json. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See peers-json.golden for expected query results. 6 | 7 | func main() { 8 | chA := make(chan *int) 9 | <-chA 10 | select { 11 | case <-chA: // @peers peer-recv-chA "<-" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/peers-json.golden: -------------------------------------------------------------------------------- 1 | -------- @peers peer-recv-chA -------- 2 | { 3 | "mode": "peers", 4 | "peers": { 5 | "pos": "testdata/src/main/peers-json.go:11:7", 6 | "type": "chan *int", 7 | "allocs": [ 8 | "testdata/src/main/peers-json.go:8:13" 9 | ], 10 | "receives": [ 11 | "testdata/src/main/peers-json.go:9:2", 12 | "testdata/src/main/peers-json.go:11:7" 13 | ] 14 | } 15 | } -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/peers.go: -------------------------------------------------------------------------------- 1 | package peers 2 | 3 | // Tests of channel 'peers' query. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See peers.golden for expected query results. 6 | 7 | var a2 int 8 | 9 | func main() { 10 | chA := make(chan *int) 11 | a1 := 1 12 | chA <- &a1 13 | 14 | chA2 := make(chan *int, 2) 15 | if a2 == 0 { 16 | chA = chA2 17 | } 18 | 19 | chB := make(chan *int) 20 | b := 3 21 | chB <- &b 22 | 23 | <-chA // @pointsto pointsto-chA "chA" 24 | <-chA2 // @pointsto pointsto-chA2 "chA2" 25 | <-chB // @pointsto pointsto-chB "chB" 26 | 27 | select { 28 | case rA := <-chA: // @peers peer-recv-chA "<-" 29 | _ = rA // @pointsto pointsto-rA "rA" 30 | case rB := <-chB: // @peers peer-recv-chB "<-" 31 | _ = rB // @pointsto pointsto-rB "rB" 32 | 33 | case <-chA: // @peers peer-recv-chA' "<-" 34 | 35 | case chA2 <- &a2: // @peers peer-send-chA' "<-" 36 | } 37 | 38 | for _ = range chA { 39 | } 40 | 41 | close(chA) // @peers peer-close-chA "chA" 42 | 43 | chC := make(chan *int) 44 | (close)(chC) // @peers peer-close-chC "chC" 45 | 46 | close := func(ch chan *int) chan *int { 47 | return ch 48 | } 49 | 50 | close(chC) <- &b // @peers peer-send-chC "chC" 51 | <-close(chC) // @peers peer-recv-chC "chC" 52 | } 53 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/pointsto-json.go: -------------------------------------------------------------------------------- 1 | package pointsto 2 | 3 | // Tests of 'pointsto' queries, -format=json. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See pointsto-json.golden for expected query results. 6 | 7 | func main() { // 8 | var s struct{ x [3]int } 9 | p := &s.x[0] // @pointsto val-p "p" 10 | _ = p 11 | 12 | var i I = C(0) 13 | if i == nil { 14 | i = new(D) 15 | } 16 | print(i) // @pointsto val-i "\\bi\\b" 17 | } 18 | 19 | type I interface { 20 | f() 21 | } 22 | 23 | type C int 24 | type D struct{} 25 | 26 | func (c C) f() {} 27 | func (d *D) f() {} 28 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/pointsto-json.golden: -------------------------------------------------------------------------------- 1 | -------- @pointsto val-p -------- 2 | { 3 | "mode": "pointsto", 4 | "pointsto": [ 5 | { 6 | "type": "*int", 7 | "labels": [ 8 | { 9 | "pos": "testdata/src/main/pointsto-json.go:8:6", 10 | "desc": "s.x[*]" 11 | } 12 | ] 13 | } 14 | ] 15 | }-------- @pointsto val-i -------- 16 | { 17 | "mode": "pointsto", 18 | "pointsto": [ 19 | { 20 | "type": "*D", 21 | "namepos": "testdata/src/main/pointsto-json.go:24:6", 22 | "labels": [ 23 | { 24 | "pos": "testdata/src/main/pointsto-json.go:14:10", 25 | "desc": "new" 26 | } 27 | ] 28 | }, 29 | { 30 | "type": "C", 31 | "namepos": "testdata/src/main/pointsto-json.go:23:6" 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/referrers-json.go: -------------------------------------------------------------------------------- 1 | package referrers 2 | 3 | // Tests of 'referrers' query. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See referrers.golden for expected query results. 6 | 7 | import "lib" 8 | 9 | type s struct { 10 | f int 11 | } 12 | 13 | func main() { 14 | var v lib.Type = lib.Const // @referrers ref-package "lib" 15 | _ = v.Method // @referrers ref-method "Method" 16 | _ = v.Method 17 | v++ //@referrers ref-local "v" 18 | v++ 19 | 20 | _ = s{}.f // @referrers ref-field "f" 21 | 22 | var s2 s 23 | s2.f = 1 24 | } 25 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/referrers-json.golden: -------------------------------------------------------------------------------- 1 | -------- @referrers ref-package -------- 2 | { 3 | "mode": "referrers", 4 | "referrers": { 5 | "pos": "testdata/src/main/referrers-json.go:14:8", 6 | "objpos": "testdata/src/main/referrers-json.go:7:8", 7 | "desc": "package lib", 8 | "refs": [ 9 | "testdata/src/main/referrers-json.go:14:8", 10 | "testdata/src/main/referrers-json.go:14:19" 11 | ] 12 | } 13 | }-------- @referrers ref-method -------- 14 | { 15 | "mode": "referrers", 16 | "referrers": { 17 | "pos": "testdata/src/main/referrers-json.go:15:8", 18 | "objpos": "testdata/src/lib/lib.go:5:13", 19 | "desc": "func (lib.Type).Method(x *int) *int", 20 | "refs": [ 21 | "testdata/src/main/referrers-json.go:15:8", 22 | "testdata/src/main/referrers-json.go:16:8" 23 | ] 24 | } 25 | }-------- @referrers ref-local -------- 26 | { 27 | "mode": "referrers", 28 | "referrers": { 29 | "pos": "testdata/src/main/referrers-json.go:17:2", 30 | "objpos": "testdata/src/main/referrers-json.go:14:6", 31 | "desc": "var v lib.Type", 32 | "refs": [ 33 | "testdata/src/main/referrers-json.go:15:6", 34 | "testdata/src/main/referrers-json.go:16:6", 35 | "testdata/src/main/referrers-json.go:17:2", 36 | "testdata/src/main/referrers-json.go:18:2" 37 | ] 38 | } 39 | }-------- @referrers ref-field -------- 40 | { 41 | "mode": "referrers", 42 | "referrers": { 43 | "pos": "testdata/src/main/referrers-json.go:20:10", 44 | "objpos": "testdata/src/main/referrers-json.go:10:2", 45 | "desc": "field f int", 46 | "refs": [ 47 | "testdata/src/main/referrers-json.go:20:10", 48 | "testdata/src/main/referrers-json.go:23:5" 49 | ] 50 | } 51 | } -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/reflection.go: -------------------------------------------------------------------------------- 1 | package reflection 2 | 3 | // This is a test of 'pointsto', but we split it into a separate file 4 | // so that pointsto.go doesn't have to import "reflect" each time. 5 | 6 | import "reflect" 7 | 8 | var a int 9 | var b bool 10 | 11 | func main() { 12 | m := make(map[*int]*bool) 13 | m[&a] = &b 14 | 15 | mrv := reflect.ValueOf(m) 16 | if a > 0 { 17 | mrv = reflect.ValueOf(&b) 18 | } 19 | if a > 0 { 20 | mrv = reflect.ValueOf(&a) 21 | } 22 | 23 | _ = mrv // @pointsto mrv "mrv" 24 | p1 := mrv.Interface() // @pointsto p1 "p1" 25 | p2 := mrv.MapKeys() // @pointsto p2 "p2" 26 | p3 := p2[0] // @pointsto p3 "p3" 27 | p4 := reflect.TypeOf(p1) // @pointsto p4 "p4" 28 | 29 | _, _, _, _ = p1, p2, p3, p4 30 | } 31 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/reflection.golden: -------------------------------------------------------------------------------- 1 | -------- @pointsto mrv -------- 2 | this reflect.Value may contain these dynamic types: 3 | *bool, may point to: 4 | reflection.b 5 | *int, may point to: 6 | reflection.a 7 | map[*int]*bool, may point to: 8 | makemap 9 | 10 | -------- @pointsto p1 -------- 11 | this interface{} may contain these dynamic types: 12 | *bool, may point to: 13 | reflection.b 14 | *int, may point to: 15 | reflection.a 16 | map[*int]*bool, may point to: 17 | makemap 18 | 19 | -------- @pointsto p2 -------- 20 | this []reflect.Value may point to these objects: 21 | 22 | 23 | -------- @pointsto p3 -------- 24 | this reflect.Value may contain these dynamic types: 25 | *int, may point to: 26 | reflection.a 27 | 28 | -------- @pointsto p4 -------- 29 | this reflect.Type may contain these dynamic types: 30 | *reflect.rtype, may point to: 31 | *bool 32 | *int 33 | map[*int]*bool 34 | 35 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/what-json.go: -------------------------------------------------------------------------------- 1 | package what 2 | 3 | // Tests of 'what' queries, -format=json. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See what-json.golden for expected query results. 6 | 7 | func main() { 8 | f() // @what call "f" 9 | } 10 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/what-json.golden: -------------------------------------------------------------------------------- 1 | -------- @what call -------- 2 | { 3 | "mode": "what", 4 | "what": { 5 | "enclosing": [ 6 | { 7 | "desc": "identifier", 8 | "start": 179, 9 | "end": 180 10 | }, 11 | { 12 | "desc": "function call (or conversion)", 13 | "start": 179, 14 | "end": 182 15 | }, 16 | { 17 | "desc": "expression statement", 18 | "start": 179, 19 | "end": 182 20 | }, 21 | { 22 | "desc": "block", 23 | "start": 176, 24 | "end": 202 25 | }, 26 | { 27 | "desc": "function declaration", 28 | "start": 164, 29 | "end": 202 30 | }, 31 | { 32 | "desc": "source file", 33 | "start": 0, 34 | "end": 202 35 | } 36 | ], 37 | "modes": [ 38 | "callees", 39 | "callers", 40 | "callgraph", 41 | "callstack", 42 | "definition", 43 | "describe", 44 | "freevars", 45 | "implements", 46 | "pointsto", 47 | "referrers" 48 | ], 49 | "srcdir": "testdata/src", 50 | "importpath": "main" 51 | } 52 | } -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/what.go: -------------------------------------------------------------------------------- 1 | package what // @what pkgdecl "what" 2 | 3 | // Tests of 'what' queries. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See what.golden for expected query results. 6 | 7 | func main() { 8 | f() // @what call "f" 9 | var ch chan int // @what var "var" 10 | <-ch // @what recv "ch" 11 | } 12 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/what.golden: -------------------------------------------------------------------------------- 1 | -------- @what pkgdecl -------- 2 | identifier 3 | source file 4 | modes: [callgraph definition describe freevars implements pointsto referrers] 5 | srcdir: testdata/src 6 | import path: main 7 | 8 | -------- @what call -------- 9 | identifier 10 | function call (or conversion) 11 | expression statement 12 | block 13 | function declaration 14 | source file 15 | modes: [callees callers callgraph callstack definition describe freevars implements pointsto referrers] 16 | srcdir: testdata/src 17 | import path: main 18 | 19 | -------- @what var -------- 20 | variable declaration 21 | variable declaration statement 22 | block 23 | function declaration 24 | source file 25 | modes: [callers callgraph callstack describe freevars pointsto] 26 | srcdir: testdata/src 27 | import path: main 28 | 29 | -------- @what recv -------- 30 | identifier 31 | unary <- operation 32 | expression statement 33 | block 34 | function declaration 35 | source file 36 | modes: [callers callgraph callstack definition describe freevars implements peers pointsto referrers] 37 | srcdir: testdata/src 38 | import path: main 39 | 40 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/whicherrs.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type errType string 4 | 5 | const constErr errType = "blah" 6 | 7 | func (et errType) Error() string { 8 | return string(et) 9 | } 10 | 11 | var errVar error = errType("foo") 12 | 13 | func genErr(i int) error { 14 | switch i { 15 | case 0: 16 | return constErr 17 | case 1: 18 | return errVar 19 | default: 20 | return nil 21 | } 22 | } 23 | 24 | func main() { 25 | err := genErr(0) // @whicherrs localerrs "err" 26 | _ = err 27 | } 28 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/oracle/testdata/src/main/whicherrs.golden: -------------------------------------------------------------------------------- 1 | -------- @whicherrs localerrs -------- 2 | this error may point to these globals: 3 | errVar 4 | this error may contain these constants: 5 | constErr 6 | this error may contain these dynamic types: 7 | errType 8 | 9 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/playground/appengine.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build appengine 6 | 7 | package playground 8 | 9 | import ( 10 | "net/http" 11 | 12 | "appengine" 13 | "appengine/urlfetch" 14 | ) 15 | 16 | func client(r *http.Request) *http.Client { 17 | return urlfetch.Client(appengine.NewContext(r)) 18 | } 19 | 20 | func report(r *http.Request, err error) { 21 | appengine.NewContext(r).Errorf("%v", err) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/playground/common.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package playground registers HTTP handlers at "/compile" and "/share" that 6 | // proxy requests to the golang.org playground service. 7 | // This package may be used unaltered on App Engine. 8 | package playground 9 | 10 | import ( 11 | "bytes" 12 | "fmt" 13 | "io" 14 | "net/http" 15 | ) 16 | 17 | const baseURL = "http://play.golang.org" 18 | 19 | func init() { 20 | http.HandleFunc("/compile", bounce) 21 | http.HandleFunc("/share", bounce) 22 | } 23 | 24 | func bounce(w http.ResponseWriter, r *http.Request) { 25 | b := new(bytes.Buffer) 26 | if err := passThru(b, r); err != nil { 27 | http.Error(w, "Server error.", http.StatusInternalServerError) 28 | report(r, err) 29 | return 30 | } 31 | io.Copy(w, b) 32 | } 33 | 34 | func passThru(w io.Writer, req *http.Request) error { 35 | defer req.Body.Close() 36 | url := baseURL + req.URL.Path 37 | r, err := client(req).Post(url, req.Header.Get("Content-type"), req.Body) 38 | if err != nil { 39 | return fmt.Errorf("making POST request: %v", err) 40 | } 41 | defer r.Body.Close() 42 | if _, err := io.Copy(w, r.Body); err != nil { 43 | return fmt.Errorf("copying response Body: %v", err) 44 | } 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/playground/local.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | 7 | package playground 8 | 9 | import ( 10 | "log" 11 | "net/http" 12 | ) 13 | 14 | func client(r *http.Request) *http.Client { 15 | return http.DefaultClient 16 | } 17 | 18 | func report(r *http.Request, err error) { 19 | log.Println(err) 20 | } 21 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/present/caption.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package present 6 | 7 | import "strings" 8 | 9 | func init() { 10 | Register("caption", parseCaption) 11 | } 12 | 13 | type Caption struct { 14 | Text string 15 | } 16 | 17 | func (c Caption) TemplateName() string { return "caption" } 18 | 19 | func parseCaption(_ *Context, _ string, _ int, text string) (Elem, error) { 20 | text = strings.TrimSpace(strings.TrimPrefix(text, ".caption")) 21 | return Caption{text}, nil 22 | } 23 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/present/html.go: -------------------------------------------------------------------------------- 1 | package present 2 | 3 | import ( 4 | "errors" 5 | "html/template" 6 | "path/filepath" 7 | "strings" 8 | ) 9 | 10 | func init() { 11 | Register("html", parseHTML) 12 | } 13 | 14 | func parseHTML(ctx *Context, fileName string, lineno int, text string) (Elem, error) { 15 | p := strings.Fields(text) 16 | if len(p) != 2 { 17 | return nil, errors.New("invalid .html args") 18 | } 19 | name := filepath.Join(filepath.Dir(fileName), p[1]) 20 | b, err := ctx.ReadFile(name) 21 | if err != nil { 22 | return nil, err 23 | } 24 | return HTML{template.HTML(b)}, nil 25 | } 26 | 27 | type HTML struct { 28 | template.HTML 29 | } 30 | 31 | func (s HTML) TemplateName() string { return "html" } 32 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/present/iframe.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package present 6 | 7 | import ( 8 | "fmt" 9 | "strings" 10 | ) 11 | 12 | func init() { 13 | Register("iframe", parseIframe) 14 | } 15 | 16 | type Iframe struct { 17 | URL string 18 | Width int 19 | Height int 20 | } 21 | 22 | func (i Iframe) TemplateName() string { return "iframe" } 23 | 24 | func parseIframe(ctx *Context, fileName string, lineno int, text string) (Elem, error) { 25 | args := strings.Fields(text) 26 | i := Iframe{URL: args[1]} 27 | a, err := parseArgs(fileName, lineno, args[2:]) 28 | if err != nil { 29 | return nil, err 30 | } 31 | switch len(a) { 32 | case 0: 33 | // no size parameters 34 | case 2: 35 | if v, ok := a[0].(int); ok { 36 | i.Height = v 37 | } 38 | if v, ok := a[1].(int); ok { 39 | i.Width = v 40 | } 41 | default: 42 | return nil, fmt.Errorf("incorrect image invocation: %q", text) 43 | } 44 | return i, nil 45 | } 46 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/present/image.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package present 6 | 7 | import ( 8 | "fmt" 9 | "strings" 10 | ) 11 | 12 | func init() { 13 | Register("image", parseImage) 14 | } 15 | 16 | type Image struct { 17 | URL string 18 | Width int 19 | Height int 20 | } 21 | 22 | func (i Image) TemplateName() string { return "image" } 23 | 24 | func parseImage(ctx *Context, fileName string, lineno int, text string) (Elem, error) { 25 | args := strings.Fields(text) 26 | img := Image{URL: args[1]} 27 | a, err := parseArgs(fileName, lineno, args[2:]) 28 | if err != nil { 29 | return nil, err 30 | } 31 | switch len(a) { 32 | case 0: 33 | // no size parameters 34 | case 2: 35 | // If a parameter is empty (underscore) or invalid 36 | // leave the field set to zero. The "image" action 37 | // template will then omit that img tag attribute and 38 | // the browser will calculate the value to preserve 39 | // the aspect ratio. 40 | if v, ok := a[0].(int); ok { 41 | img.Height = v 42 | } 43 | if v, ok := a[1].(int); ok { 44 | img.Width = v 45 | } 46 | default: 47 | return nil, fmt.Errorf("incorrect image invocation: %q", text) 48 | } 49 | return img, nil 50 | } 51 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/README: -------------------------------------------------------------------------------- 1 | golang.org/x/tools/refactor: libraries for refactoring tools. 2 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/A.template: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package template 4 | 5 | // Basic test of type-aware expression refactoring. 6 | 7 | import ( 8 | "errors" 9 | "fmt" 10 | ) 11 | 12 | func before(s string) error { return fmt.Errorf("%s", s) } 13 | func after(s string) error { return errors.New(s) } 14 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/A1.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package A1 4 | 5 | import ( 6 | . "fmt" 7 | myfmt "fmt" 8 | "os" 9 | "strings" 10 | ) 11 | 12 | func example(n int) { 13 | x := "foo" + strings.Repeat("\t", n) 14 | // Match, despite named import. 15 | myfmt.Errorf("%s", x) 16 | 17 | // Match, despite dot import. 18 | Errorf("%s", x) 19 | 20 | // Match: multiple matches in same function are possible. 21 | myfmt.Errorf("%s", x) 22 | 23 | // No match: wildcarded operand has the wrong type. 24 | myfmt.Errorf("%s", 3) 25 | 26 | // No match: function operand doesn't match. 27 | myfmt.Printf("%s", x) 28 | 29 | // No match again, dot import. 30 | Printf("%s", x) 31 | 32 | // Match. 33 | myfmt.Fprint(os.Stderr, myfmt.Errorf("%s", x+"foo")) 34 | 35 | // No match: though this literally matches the template, 36 | // fmt doesn't resolve to a package here. 37 | var fmt struct{ Errorf func(string, string) } 38 | fmt.Errorf("%s", x) 39 | 40 | // Recursive matching: 41 | 42 | // Match: both matches are well-typed, so both succeed. 43 | myfmt.Errorf("%s", myfmt.Errorf("%s", x+"foo").Error()) 44 | 45 | // Outer match succeeds, inner doesn't: 3 has wrong type. 46 | myfmt.Errorf("%s", myfmt.Errorf("%s", 3).Error()) 47 | 48 | // Inner match succeeds, outer doesn't: the inner replacement 49 | // has the wrong type (error not string). 50 | myfmt.Errorf("%s", myfmt.Errorf("%s", x+"foo")) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/A1.golden: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package A1 4 | 5 | import ( 6 | . "fmt" 7 | "errors" 8 | myfmt "fmt" 9 | "os" 10 | "strings" 11 | ) 12 | 13 | func example(n int) { 14 | x := "foo" + strings.Repeat("\t", n) 15 | // Match, despite named import. 16 | errors.New(x) 17 | 18 | // Match, despite dot import. 19 | errors.New(x) 20 | 21 | // Match: multiple matches in same function are possible. 22 | errors.New(x) 23 | 24 | // No match: wildcarded operand has the wrong type. 25 | myfmt.Errorf("%s", 3) 26 | 27 | // No match: function operand doesn't match. 28 | myfmt.Printf("%s", x) 29 | 30 | // No match again, dot import. 31 | Printf("%s", x) 32 | 33 | // Match. 34 | myfmt.Fprint(os.Stderr, errors.New(x+"foo")) 35 | 36 | // No match: though this literally matches the template, 37 | // fmt doesn't resolve to a package here. 38 | var fmt struct{ Errorf func(string, string) } 39 | fmt.Errorf("%s", x) 40 | 41 | // Recursive matching: 42 | 43 | // Match: both matches are well-typed, so both succeed. 44 | errors.New(errors.New(x + "foo").Error()) 45 | 46 | // Outer match succeeds, inner doesn't: 3 has wrong type. 47 | errors.New(myfmt.Errorf("%s", 3).Error()) 48 | 49 | // Inner match succeeds, outer doesn't: the inner replacement 50 | // has the wrong type (error not string). 51 | myfmt.Errorf("%s", errors.New(x+"foo")) 52 | } 53 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/A2.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package A2 4 | 5 | // This refactoring causes addition of "errors" import. 6 | // TODO(adonovan): fix: it should also remove "fmt". 7 | 8 | import myfmt "fmt" 9 | 10 | func example(n int) { 11 | myfmt.Errorf("%s", "") 12 | } 13 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/A2.golden: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package A2 4 | 5 | // This refactoring causes addition of "errors" import. 6 | // TODO(adonovan): fix: it should also remove "fmt". 7 | 8 | import ( 9 | myfmt "fmt" 10 | "errors" 11 | ) 12 | 13 | func example(n int) { 14 | errors.New("") 15 | } 16 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/B.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | // Basic test of expression refactoring. 4 | // (Types are not important in this case; it could be done with gofmt -r.) 5 | 6 | import "time" 7 | 8 | func before(t time.Time) time.Duration { return time.Now().Sub(t) } 9 | func after(t time.Time) time.Duration { return time.Since(t) } 10 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/B1.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package B1 4 | 5 | import "time" 6 | 7 | var startup = time.Now() 8 | 9 | func example() time.Duration { 10 | before := time.Now() 11 | time.Sleep(1) 12 | return time.Now().Sub(before) 13 | } 14 | 15 | func msSinceStartup() int64 { 16 | return int64(time.Now().Sub(startup) / time.Millisecond) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/B1.golden: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package B1 4 | 5 | import "time" 6 | 7 | var startup = time.Now() 8 | 9 | func example() time.Duration { 10 | before := time.Now() 11 | time.Sleep(1) 12 | return time.Since(before) 13 | } 14 | 15 | func msSinceStartup() int64 { 16 | return int64(time.Since(startup) / time.Millisecond) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/C.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | // Test of repeated use of wildcard in pattern. 4 | 5 | // NB: multiple patterns would be required to handle variants such as 6 | // s[:len(s)], s[x:len(s)], etc, since a wildcard can't match nothing at all. 7 | // TODO(adonovan): support multiple templates in a single pass. 8 | 9 | func before(s string) string { return s[:len(s)] } 10 | func after(s string) string { return s } 11 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/C1.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package C1 4 | 5 | import "strings" 6 | 7 | func example() { 8 | x := "foo" 9 | println(x[:len(x)]) 10 | 11 | // Match, but the transformation is not sound w.r.t. possible side effects. 12 | println(strings.Repeat("*", 3)[:len(strings.Repeat("*", 3))]) 13 | 14 | // No match, since second use of wildcard doesn't match first. 15 | println(strings.Repeat("*", 3)[:len(strings.Repeat("*", 2))]) 16 | 17 | // Recursive match demonstrating bottom-up rewrite: 18 | // only after the inner replacement occurs does the outer syntax match. 19 | println((x[:len(x)])[:len(x[:len(x)])]) 20 | // -> (x[:len(x)]) 21 | // -> x 22 | } 23 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/C1.golden: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package C1 4 | 5 | import "strings" 6 | 7 | func example() { 8 | x := "foo" 9 | println(x) 10 | 11 | // Match, but the transformation is not sound w.r.t. possible side effects. 12 | println(strings.Repeat("*", 3)) 13 | 14 | // No match, since second use of wildcard doesn't match first. 15 | println(strings.Repeat("*", 3)[:len(strings.Repeat("*", 2))]) 16 | 17 | // Recursive match demonstrating bottom-up rewrite: 18 | // only after the inner replacement occurs does the outer syntax match. 19 | println(x) 20 | // -> (x[:len(x)]) 21 | // -> x 22 | } 23 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/D.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | import "fmt" 4 | 5 | // Test of semantic (not syntactic) matching of basic literals. 6 | 7 | func before() (int, error) { return fmt.Println(123, "a") } 8 | func after() (int, error) { return fmt.Println(456, "!") } 9 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/D1.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package D1 4 | 5 | import "fmt" 6 | 7 | func example() { 8 | fmt.Println(123, "a") // match 9 | fmt.Println(0x7b, `a`) // match 10 | fmt.Println(0173, "\x61") // match 11 | fmt.Println(100+20+3, "a"+"") // no match: constant expressions, but not basic literals 12 | } 13 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/D1.golden: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package D1 4 | 5 | import "fmt" 6 | 7 | func example() { 8 | fmt.Println(456, "!") // match 9 | fmt.Println(456, "!") // match 10 | fmt.Println(456, "!") // match 11 | fmt.Println(100+20+3, "a"+"") // no match: constant expressions, but not basic literals 12 | } 13 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/E.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "os" 7 | ) 8 | 9 | // Replace call to void function by call to non-void function. 10 | 11 | func before(x interface{}) { log.Fatal(x) } 12 | func after(x interface{}) { fmt.Fprintf(os.Stderr, "warning: %v", x) } 13 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/E1.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package E1 4 | 5 | import "log" 6 | 7 | func example() { 8 | log.Fatal("oops") // match 9 | } 10 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/E1.golden: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package E1 4 | 5 | import ( 6 | "log" 7 | "os" 8 | "fmt" 9 | ) 10 | 11 | func example() { 12 | fmt.Fprintf(os.Stderr, "warning: %v", "oops") // match 13 | } 14 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/F.template: -------------------------------------------------------------------------------- 1 | package templates 2 | 3 | // Test 4 | 5 | import "sync" 6 | 7 | func before(s sync.RWMutex) { s.Lock() } 8 | func after(s sync.RWMutex) { s.RLock() } -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/F1.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package F1 4 | 5 | import "sync" 6 | 7 | func example(n int) { 8 | var x struct { 9 | mutex sync.RWMutex 10 | } 11 | 12 | var y struct { 13 | sync.RWMutex 14 | } 15 | 16 | type l struct { 17 | sync.RWMutex 18 | } 19 | 20 | var z struct { 21 | l 22 | } 23 | 24 | var a struct { 25 | *l 26 | } 27 | 28 | var b struct{ Lock func() } 29 | 30 | // Match 31 | x.mutex.Lock() 32 | 33 | // Match 34 | y.Lock() 35 | 36 | // Match indirect 37 | z.Lock() 38 | 39 | // Should be no match however currently matches due to: 40 | // https://golang.org/issue/8584 41 | // Will start failing when this is fixed then just change golden to 42 | // No match pointer indirect 43 | // a.Lock() 44 | a.Lock() 45 | 46 | // No match 47 | b.Lock() 48 | } 49 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/F1.golden: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package F1 4 | 5 | import "sync" 6 | 7 | func example(n int) { 8 | var x struct { 9 | mutex sync.RWMutex 10 | } 11 | 12 | var y struct { 13 | sync.RWMutex 14 | } 15 | 16 | type l struct { 17 | sync.RWMutex 18 | } 19 | 20 | var z struct { 21 | l 22 | } 23 | 24 | var a struct { 25 | *l 26 | } 27 | 28 | var b struct{ Lock func() } 29 | 30 | // Match 31 | x.mutex.RLock() 32 | 33 | // Match 34 | y.RLock() 35 | 36 | // Match indirect 37 | z.RLock() 38 | 39 | // Should be no match however currently matches due to: 40 | // https://golang.org/issue/8584 41 | // Will start failing when this is fixed then just change golden to 42 | // No match pointer indirect 43 | // a.Lock() 44 | a.RLock() 45 | 46 | // No match 47 | b.Lock() 48 | } 49 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/bad_type.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | // Test in which replacement has a different type. 4 | 5 | const shouldFail = "int is not a safe replacement for string" 6 | 7 | func before() interface{} { return "three" } 8 | func after() interface{} { return 3 } 9 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/expr_type_mismatch.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | import ( 4 | "crypto/x509" 5 | "fmt" 6 | ) 7 | 8 | // This test demonstrates a false negative: according to the language 9 | // rules this replacement should be ok, but types.Assignable doesn't work 10 | // in the expected way (elementwise assignability) for tuples. 11 | // Perhaps that's even a type-checker bug? 12 | const shouldFail = "(n int, err error) is not a safe replacement for (key interface{}, err error)" 13 | 14 | func before() (interface{}, error) { return x509.ParsePKCS8PrivateKey(nil) } 15 | func after() (interface{}, error) { return fmt.Print() } 16 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/no_after_return.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | const shouldFail = "after: must contain a single statement" 4 | 5 | func before() int { return 0 } 6 | func after() int { println(); return 0 } 7 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/no_before.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | const shouldFail = "no 'before' func found in template" 4 | 5 | func Before() {} 6 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/eg/testdata/type_mismatch.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | const shouldFail = "different signatures" 4 | 5 | func before() int { return 0 } 6 | func after() string { return "" } 7 | -------------------------------------------------------------------------------- /vendor/_nuts/golang.org/x/tools/refactor/lexical/lexical_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package lexical 6 | 7 | import ( 8 | "go/build" 9 | "testing" 10 | 11 | "golang.org/x/tools/go/buildutil" 12 | "golang.org/x/tools/go/loader" 13 | ) 14 | 15 | func TestStdlib(t *testing.T) { 16 | defer func(saved func(format string, args ...interface{})) { 17 | logf = saved 18 | }(logf) 19 | logf = t.Errorf 20 | 21 | ctxt := build.Default // copy 22 | 23 | // Enumerate $GOROOT packages. 24 | saved := ctxt.GOPATH 25 | ctxt.GOPATH = "" // disable GOPATH during AllPackages 26 | pkgs := buildutil.AllPackages(&ctxt) 27 | ctxt.GOPATH = saved 28 | 29 | // Throw in a number of go.tools packages too. 30 | pkgs = append(pkgs, 31 | "golang.org/x/tools/cmd/godoc", 32 | "golang.org/x/tools/refactor/lexical") 33 | 34 | // Load, parse and type-check the program. 35 | conf := loader.Config{ 36 | Build: &ctxt, 37 | SourceImports: true, 38 | } 39 | for _, path := range pkgs { 40 | conf.ImportWithTests(path) 41 | } 42 | iprog, err := conf.Load() 43 | if err != nil { 44 | t.Fatalf("Load failed: %v", err) 45 | } 46 | 47 | // This test ensures that Structure doesn't panic and that 48 | // its internal sanity-checks against go/types don't fail. 49 | for pkg, info := range iprog.AllPackages { 50 | _ = Structure(iprog.Fset, pkg, &info.Info, info.Files) 51 | } 52 | } 53 | --------------------------------------------------------------------------------