Previously we were sorting only JSON objects, but we must do the same
for plain output too to avoid sporadic failures.
Tested 20 times.
Change-Id: Ic60363b720c2afc91b57864bc93e298f83e85b99
Reviewed-on: https://go-review.googlesource.com/22555
Reviewed-by: Robert Griesemer <gri@golang.org>
For a 'definition' query on X in p.X, use special logic to load and
parse package p and find the declaration of package member X, without
using the type checker. Such queries now typically take under
10ms (faster than godef).
The logic assumes that import "something/p" defines the name p. If this
assumption is false, p.X could be a selection of a field or method X on
a member p of the same package, defined in another file.
So don't write code like that.
Added missing test of 'definitions'.
JSON tests now sanitize absolute $GOPATH filenames in the output.
Fixes issue #15458
Change-Id: I21e75fcc9372aaedd56851cace444aef205c7a97
Reviewed-on: https://go-review.googlesource.com/22526
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Michael Matloob <matloob@golang.org>
...as the basis of the query, instead of reporting an error.
+ test
Change-Id: Ie5defa98cd8dfc8e200e296c2aa02c88893cf9ac
Reviewed-on: https://go-review.googlesource.com/22117
Reviewed-by: Michael Matloob <matloob@golang.org>
We define a derived mode of compilation-mode, so that various
names say "guru" instead of "compilation", and use the hooks it
provides to apply our postprocessing incrementally instead of
all at the end. It's much faster, and works nicely with the
new streaming referrers query.
Compilation mode requires a shell command, not an execve array,
so go-guru--compile-command joins the arguments with spaces.
go-guru--exec has been specialized for JSON mode,
and renamed to go-guru--json.
go-guru--set-scope-if-empty is now done by each mode, to avoid
the NEED-SCOPE parameter to go-guru--exec.
Change-Id: I692b8b28449b7cc17fd6251a152588f9d8b89ebc
Reviewed-on: https://go-review.googlesource.com/21772
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Alan Donovan <adonovan@google.com>
This picks up a recent change to the playground package.
Change-Id: I9b5f0ef9981373274d707014a2c0e2786e9624c0
Reviewed-on: https://go-review.googlesource.com/22538
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
strings.Split is not your friend.
Change-Id: I829f08f113f3340b2dd865aea47f5759a427f7c4
Reviewed-on: https://go-review.googlesource.com/22116
Reviewed-by: Michael Matloob <matloob@golang.org>
Keep the leftmost element when removing duplicates, so that we report
"function call" instead of "expression statement".
Also split go-guru--enclosing into two functions.
Change-Id: Ie325613e292e36dda9558eda54bc7323fbf0bc6d
Reviewed-on: https://go-review.googlesource.com/22132
Reviewed-by: Alan Donovan <adonovan@google.com>
A recent change to the cmd/go tool made it place godoc in $GOPATH/bin
instead of the special-cased $GOROOT/bin.
Change-Id: If026ff7e3a521ee2aa9b4107585124df108d7124
Reviewed-on: https://go-review.googlesource.com/21951
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This extracts the overlay context and archive parsing from guru into
buildutil.
At least one tool (gogetdoc) has a vendored copy of this code already,
and more tools implementing the same functionality will follow.
The new code in buildutil is an almost identical copy of the code in
guru (names aside), except for the following changes:
- Instead of reading into a bytes.Buffer, we read directly into a []byte
of appropriate size
- sameFile first attempts a simple comparison of path.Clean'ed paths.
Change-Id: I97cd978ccc10722e3648e5e10625fa7f1407f202
Reviewed-on: https://go-review.googlesource.com/21805
Reviewed-by: Alan Donovan <adonovan@google.com>
The go-guru-expand-region function uses the "what" query to determine
the enclosing regions. Consecutive calls to go-guru-expand-region will
reuse a cached version of the list.
Change-Id: Ice9ac5540c1b639c6cbdc505866bbab347be1e98
Reviewed-on: https://go-review.googlesource.com/21754
Reviewed-by: Alan Donovan <adonovan@google.com>
Visible changes:
- "referrers" queries now emit a stream of results,
so they start appearing quickly even in large queries.
We no longer report the total number of matches.
- packageReferrers now also uses AfterTypeCheck hook and streaming.
- XML support has been dropped.
- The -format flag has been replaced by -json.
JSON protocol changes:
- The enclosing Result struct has been removed.
- Likewise the 'mode' field (since the caller knows it already)
- "freevars" and "referrers" now emit a stream of objects
In the case of referrers, the first object has a different from the rest.
- The "referrers" results include the text of the matching line
(parity with -json=false)
Implementation details:
- the concurrency-safe q.Output function can be called
many times, each with a queryResult to print.
- fset is no longer saved in Query (cleaner)
- queryResult methods renamed PrintPlain, JSON
Change-Id: I41a4e3f57f266fcf043ece4045bca82c6f6a356f
Reviewed-on: https://go-review.googlesource.com/21397
Reviewed-by: Michael Matloob <matloob@golang.org>
Per https://groups.google.com/forum/#!topic/golang-announce/qu_rAphYdxY
this change deletes the packages
go/exact
go/gccgoimporter
go/gcimporter
go/importer
go/types
cmd/vet
from the x/tools repo and any files depending on those packages
building against Go 1.4.
x/tools packages depending on any of these libraries must use the
respective versions from the std lib or use vendored versions if
building against 1.4.
Remaining packages may or may not build against Go 1.4 anymore
and will not be supported against 1.4.
Change-Id: I1c655fc30aee49b6c7326ebd4eb1bb0836ac97e0
Reviewed-on: https://go-review.googlesource.com/20810
Reviewed-by: Alan Donovan <adonovan@google.com>
Always serve from four instances to avoid flakiness.
Change-Id: I11684f93bb27a377f54ddbe4fb3d95894d393a48
Reviewed-on: https://go-review.googlesource.com/21528
Reviewed-by: Chris Broadfoot <cbro@golang.org>
We cannot determine the extension of buffers with no file names (not
without throwing an error, anyway.)
Change-Id: I2b10390da738d71b6f95a6f668d3b92b54db29ed
Reviewed-on: https://go-review.googlesource.com/20470
Reviewed-by: Alan Donovan <adonovan@google.com>
That way, running guru on /a/foo.go, followed by /b/bar.go won't leave
the user with a display buffer that still defaults to /a/
Change-Id: I3f9b085c6d206ac2adc269fc2009799c624c371a
Reviewed-on: https://go-review.googlesource.com/20475
Reviewed-by: Alan Donovan <adonovan@google.com>
Now that we have both interactive and non-interactive uses of the guru,
we should separate the command output buffer from the display buffer.
Change-Id: I50082fdc3847c7b12869e204509141e906df3852
Reviewed-on: https://go-review.googlesource.com/20473
Reviewed-by: Alan Donovan <adonovan@google.com>
By using guru's -modified flag and making up a file name, we can run
guru on a buffer that has no file attached to it. This feature will only
be useful for queries that operate on single files, as otherwise our made
up name could cause conflicts.
This will be useful for the "what" query and features using it.
Change-Id: I3d199bc0548245d59ba7b492f57beb9422d7f43d
Reviewed-on: https://go-review.googlesource.com/20431
Reviewed-by: Alan Donovan <adonovan@google.com>
This fixes some print calls with wrong format directives. Additionally,
struct initialisers were changed to use keyed fields, purely to reduce
the amount of noise generated by go vet.
Change-Id: Ib9f6fd8f2dff7ce84826478de0ba83dda9746270
Reviewed-on: https://go-review.googlesource.com/21180
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Implement the "what" query and use it to get all uses of an
identifier (the "sameids" attribute). The user can either manually call
go-guru-hl-identifier, which will highlight all instances of the
identifier under point, or they can enable the
go-guru-hl-identifier-mode minor mode. The minor mode sets up an idle
timer, which will highlight the current identifier after a configurable
timeout. If the user modifies the buffer, or moves point off of an
identifier, we clear the highlight.
Change-Id: Iac870f3bcd17e0002eafcba0b73f07adaa03cd76
Reviewed-on: https://go-review.googlesource.com/20433
Reviewed-by: Alan Donovan <adonovan@google.com>
To help track down some flakiness.
Change-Id: I2dd21abdc0f05c58857da580d962b0ab72cf52b3
Reviewed-on: https://go-review.googlesource.com/20728
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
In go1.5, go/constant (floating-point) numeric values are printed
as fractions. Correct output as necessary so that they always
appear as floating-point numbers to match golden files.
Change-Id: If63a14d8d87bb664bf6272b16345e38e8d638ead
Reviewed-on: https://go-review.googlesource.com/20719
Reviewed-by: Alan Donovan <adonovan@google.com>
Also fix a typo in the tool's help string.
Change-Id: I54a9ed4a5515b137b0fbf1b2391dd6fa84b2d2d8
Reviewed-on: https://go-review.googlesource.com/20474
Reviewed-by: Alan Donovan <adonovan@google.com>
If godoc didn't come up quickly enough, we would leave it running and
then try to start another one on the same port.
The new one would fail to start, being unable to bind to the address,
causing cascading failures.
Also increase the timeout to 10 minutes.
Change-Id: I7008a39f649021ea213902d557f26bf78567026d
Reviewed-on: https://go-review.googlesource.com/20420
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
The BuilderModeFlag function does not work with flag packages (such as
Google's) that define their own FlagSet. This change exposes a type
that satisifies flag.Value insted of a function. That type
is *BuilderMode; there's no need for a separate wrapper type.
Change-Id: I8095b80de499e3c52a29a5c1996d1b1fe3799358
Reviewed-on: https://go-review.googlesource.com/20330
Reviewed-by: Michael Matloob <matloob@golang.org>
Line numbers match line numbers from the included file,
not the lines in the segment selected by the
.code or .play START/STOP regexps.
Fixesgolang/go#5248
Change-Id: I374e7b665e98db5032446ae49e6fae00d9d2b975
Reviewed-on: https://go-review.googlesource.com/20311
Reviewed-by: Andrew Gerrand <adg@golang.org>
Fix by removing jQuery usage from slides.js as jquery.js is only
available when play.js is included.
Fixesgolang/go#9878
Change-Id: I5793350105b138d7b7645f11d814e1d2f573a73e
Reviewed-on: https://go-review.googlesource.com/20288
Reviewed-by: Andrew Gerrand <adg@golang.org>
Bind go-guru-whicherrs to `C-C C-o e'
Also remove go-guru-callgraph as callgraph mode is not supported
by guru.
Change-Id: Id233d178629a3cafc00e4f9640191c3d3c673cf1
Reviewed-on: https://go-review.googlesource.com/20310
Reviewed-by: Alan Donovan <adonovan@google.com>
This allows users to swap point and mark to jump between use and
definition in the same buffer, or pop-tag-mark (M-*) to jump back to the
use even between multiple buffers.
This mirrors the behaviour of godef-jump from go-mode.
Also remove an obosolete TODO and fix a typo.
Change-Id: I614090493b565acadf359ebb4c7092f4c673fd56
Reviewed-on: https://go-review.googlesource.com/20303
Reviewed-by: Alan Donovan <adonovan@google.com>
This CL makes little observable difference to the behavior but paves the
way for streaming 'referrers' and (later) 'implements' queries which
scan the entire workspace, but print each result as soon as it is found.
The go/loader package now exposes a hook, AfterTypeCheck, that lets
clients inspect each package as soon as it is type-checked, and also
modify it, for instance to release unneeded data structures.
A 'referrers' query applied to an exported object must scan the entire
workspace. It uses this hook so to gather uses of the query object in
streaming fashion. However, for now, it still accumulates the results
and prints them all at the end, though I propose to change that in a
follow-up.
Code details:
- The referrers logic had a 2-iteration loop to load first the query
package and then if necessary the enlarged program. The second
iteration has now been unrolled and split into globalReferrers.
- Queries for package names (whether in a package declaration or
a qualified identifier) have been split off into packageReferrers.
It now loads all direct importers of the query package,
which catches some references that were missing before.
(It used to inspect only the forward dependencies of the query
package.)
Also:
- Referrers.Pos (the position of query identifier) was removed from the
JSON output. It's a nuisance to compute now, and it's already
absent from the plain output.
(In a follow-up, I plan to simplify the information content of the
JSON output exactly what is currently printed in the plain output.)
Change-Id: Ia5677636dc7b0fe4461a5d393107665757fb9a97
Reviewed-on: https://go-review.googlesource.com/19794
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
This fixes a bug in guru describe.
Also, add a test of IntuitiveMethodSet.
Change-Id: Ied3780807afd88e664fdb186619499670529fe33
Reviewed-on: https://go-review.googlesource.com/20166
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
This fixes a bug in which guru reports a "query position beyond end of
file" error when making a query from an unsaved editor buffer at an
offset greater than the length of the file on disk.
Change-Id: I908c024d8dd14baa657b4227e3231fa760443732
Reviewed-on: https://go-review.googlesource.com/20167
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
Make go-guru compatible with package.el prior to uploading this pacakge to
MELPA.
Also add ;;;###autoload magic comments, so that the go-guru-xxx commands can
be used without need to explicitly (require 'go-guru) first.
Change-Id: I21c7f5f354fb7b39877a05c2a9ffecd02ab022f6
Reviewed-on: https://go-review.googlesource.com/19789
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Alan Donovan <adonovan@google.com>
A consequence of CL 19747 was that ad hoc packages of a single filename
are no longer valid -scope arguments, which broke most of the tests.
This CL fixes the tests by extracting the import path from the filename.
The test output now includes the import path, not the package
name, of each of these packages, so the output was updated too.
Also, the -scope argument caused the main package to be imported twice,
once as main.go and once under its import path, causing duplicate
'implements' results.
I'm not sure how I failed to notice this.
Change-Id: I6fb3ae3e1497f0eb8cf88f453660b9e2fd9718d8
Reviewed-on: https://go-review.googlesource.com/19886
Reviewed-by: Michael Matloob <matloob@golang.org>
This fixes the following usability issues:
- when go-guru is called twice in a row and the output from the second invocation
is bigger then this output is not fully visible
- output window could be re-used by other packages (such as helm) that are not
usable with the shrank window
Change-Id: I86d522006d29e945a71b96c9d13a1a39572bdb3b
Reviewed-on: https://go-review.googlesource.com/19780
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Alan Donovan <adonovan@google.com>
Major modes should use the C-c prefix followed by C-something. We'll
stick with C-o (oracle) since C-g is taken by go-jump-xxx (and in any
case C-g should be reserved for keyboard-quit.)
Change-Id: I18f41d7cbd5bf83aa53909554501e7f76543f033
Reviewed-on: https://go-review.googlesource.com/19510
Reviewed-by: Michael Matloob <matloob@golang.org>
This information is useful for editor UIs that highlight all
uses of the local variable under the cursor.
Change-Id: I718d648d407468509e6d12f932ae6cdef368830a
Reviewed-on: https://go-review.googlesource.com/19512
Reviewed-by: Michael Matloob <matloob@golang.org>
Editor modes that invoke the goimports command on temporary copies
of actual source files will need to invoke goimports -srcdir now to say
where the real source directory is. Otherwise goimports will not consider
vendored or internal packages when looking for new imports.
In lieu of a test for cmd/goimports (because it has no tests),
a command transcript:
$ cd /tmp
$ cat x.go
package p
var _ = hpack.HuffmanDecode
$
$ GOPATH= goimports < x.go
package p
var _ = hpack.HuffmanDecode
$ GOPATH= goimports x.go
package p
var _ = hpack.HuffmanDecode
$
But with the new flag:
$ GOPATH= goimports -srcdir $GOROOT/src/math < x.go
package p
import "golang.org/x/net/http2/hpack"
var _ = hpack.HuffmanDecode
$ GOPATH= goimports -srcdir $GOROOT/src/math x.go
package p
import "golang.org/x/net/http2/hpack"
var _ = hpack.HuffmanDecode
$
The tests in this CL and the above transcript assume that
$GOROOT/src/vendor/golang.org/x/net/http2/hpack exists.
It did in 40a26c9, but it does not today.
It will again soon (once Go 1.7 opens).
For golang/go#12278 (original request).
Change-Id: I27b136041f54edcde4bf474215b48ebb0417f34d
Reviewed-on: https://go-review.googlesource.com/17728
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
Before, "bundle -help" printed only one not particularly useful line:
Usage of bundle:
and "bundle" printed a bit more but not a standard usage message:
bundle: Usage: bundle package dest prefix
Arguments:
package is the import path of the package to concatenate.
dest is the import path of the package in which the resulting file will reside.
prefix is the string to attach to all renamed identifiers.
And most of that output belonged in (but was missing from) the doc comment,
which leaned heavily on the reader inferring usage from one example.
While fixing all this, I ended up dropping "dest" and "prefix" as required
arguments: perfectly good defaults can be inferred in the common case
where the bundle is intended for the current directory. The defaults can be
overridden with the new -dst and -prefix option.
I corrected a TODO about not assuming the package name could be
derived from the destination import path. Like -dst and -prefix, the
default package name can be inferred from the current directory,
but there is also a new -pkg option to override the default if needed.
I added a -o option to specify the destination output file (standard output
is still the default output). One benefit of -o is that it makes the bundle
commands self-contained in the sense of not needing a shell.
That in turn makes them suitable for use with "go generate", so when -o
is specified the bundle output now includes a "//go:generate" comment
for updating the bundle mechanically.
To keep bundle working for net/http's use case, I added a -importmap
option to specify additional import rewrites (net/http needs the http2
import of golang.org/x/net/http2/hpack rewritten to begin with internal/golang.org).
The net effect of all of this is that the first two lines at the top of
net/http/h2_bundle.go will change from:
// Code generated by golang.org/x/tools/cmd/bundle command:
// $ bundle golang.org/x/net/http2 net/http http2
to
// Code generated by golang.org/x/tools/cmd/bundle.
//go:generate bundle -o h2_bundle.go -prefix http2 -import golang.org/x/net/http2/hpack=internal/golang.org/x/net/http2/hpack golang.org/x/net/http2
and net/http's copy of http2 can now be updated by "go generate"
instead of by copying and pasting commands from source code to shell.
For an experiment I am doing with cmd/dist bundling archive/zip,
the header is even shorter and makes a better demonstration of the
power of the defaults:
// Code generated by golang.org/x/tools/cmd/bundle.
//go:generate bundle -o zip.go archive/zip
New usage message, printed by "bundle -help" and "bundle":
Usage: bundle [options] <src>
-dst path
set destination import path (default taken from current directory)
-import map
rewrite import using map, of form old=new (can be repeated)
-o file
write output to file (default standard output)
-pkg name
set destination package name (default taken from current directory)
-prefix p
set bundled identifier prefix to p (default source package name + "_")
See CL for new doc comment.
Following this CL I will send a CL updating the two-line header in net/http/h2_bundle.go
to match the new usage of the bundle, whatever that ends up being.
Change-Id: I83a65b6a500897854027cefdefb8f62f1d4448b4
Reviewed-on: https://go-review.googlesource.com/19428
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
I think this resulted from git automerging.
Change-Id: Icc285601846bd0a2a2bb2316ae4575395744c44b
Reviewed-on: https://go-review.googlesource.com/19511
Reviewed-by: Alan Donovan <adonovan@google.com>
The parser does intra-file resolution. It's only a best-effort but
it's extremely fast, so we try it first and fall back to the loader-based
implementation if it fails.
Also:
- factor definitionResult so it doesn't depend on either go/types.Object
or go/ast.Object.
- guessImportPath: make importPath=="" result an error,
since you can't import the empty string. Simplify importQueryPackage.
- Make fastQueryPos continue in face of minor parse errors.
- describe: eliminate old TODO; suppress log statement.
Change-Id: I30a32487e9fd9d5308b1580ec12220cad2c16299
Reviewed-on: https://go-review.googlesource.com/19507
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
Don't just display the output buffer or, worse, parse it as JSON.
Change-Id: I1125ff235a5073b07f45f587ef8844b8a12f05ac
Reviewed-on: https://go-review.googlesource.com/19508
Reviewed-by: Michael Matloob <matloob@golang.org>
go-guru--run has been split up to separate running the tool
from turning its output into compilation-mode form.
The definition command uses only the first part,
and parses its output in JSON form.
Added test, factoring the test script.
Change-Id: I4c3e4a51a1346551a3703a5e3137c878d7b2d95f
Reviewed-on: https://go-review.googlesource.com/19499
Reviewed-by: Michael Matloob <matloob@golang.org>
The -modified flag causes guru to read a simple archive file from stdin.
This archive specifies alternative contents for one or more file names.
The build.Context checks this table before delegating to the usual
behavior.
This will not work for files that import "C" since cgo accesses the
file system directly.
Added end-to-end test via Emacs.
Simplify findQueryPos (now: fileOffsetToPos)
Credit: Daniel Morsing, for the prototype of this feature.
Change-Id: I5ae818ed5e8bb81001781893dded2d085e9cf8d6
Reviewed-on: https://go-review.googlesource.com/19498
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
Previously you had to describe a type to get this information,
which required two queries, and the need for this query is
extremely common.
Change-Id: I1d1d5b45fead60ca8719ddc302eee47d9f10a375
Reviewed-on: https://go-review.googlesource.com/19501
Reviewed-by: Michael Matloob <matloob@golang.org>
As an optimization, the callers and callstack queries now avoid the
relatively costly pointer analysis in some common cases:
The callers of a function that is never address-taken can be enumerated
directly from the SSA representation.
Similarly, the callstack can be computed initially by ignoring dynamic
call edges; we run the pointer analysis only if no path is found in this
partial callgraph. As a bonus, this also causes the tool to
preferentially report all-static callpaths.
A callers query on fmt.Errorf now completes in 3 seconds instead of 8,
and a callstack query completes in 2 seconds instead of 8.
The new code is covered by the existing tests.
Change-Id: I777ea07a1cdb6cadcc2a94952f553b6b036e7382
Reviewed-on: https://go-review.googlesource.com/19496
Reviewed-by: Michael Matloob <matloob@golang.org>
Also, qualify field and method types relative to the defining package,
not the query package.
Change-Id: If65d2a4c2fd60e51d0d34e44000954e95106972e
Reviewed-on: https://go-review.googlesource.com/19495
Reviewed-by: Michael Matloob <matloob@golang.org>
-pos is now a positional argument; -scope is now a flag.
Tidy up usage message.
Update Vim and Emacs scripts and test
Remove call to GOMAXPROCS.
Use log.{SetPrefix,SetFlags} and Fatalf
Change-Id: I3786ed83aecb17d622b29d2a538a374f813f0adc
Reviewed-on: https://go-review.googlesource.com/19438
Reviewed-by: Michael Matloob <matloob@golang.org>
This allows users to change the GOOS/GOARCH without running their own
godoc server (or restarting with appropriate env vars).
Change-Id: I0b54ef1b2dd93cf2c965ca584d8df74119ed1be6
Reviewed-on: https://go-review.googlesource.com/1371
Reviewed-by: Andrew Gerrand <adg@golang.org>
500 is considered to be healthy. Use 503 instead, so the instance is
considered unhealthy while the side is coming up.
Add some extra log statements that help debug instances from
application logs.
Fixesgolang/go#13682.
Change-Id: I713c8c2fa75de4e275f632b999edc98cedd257bd
Reviewed-on: https://go-review.googlesource.com/18547
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
The previous change updated the import of golang.org/x/tools/go/types
to the standard go/types package, causing 1.4 builds to fail.
Fixes#13874.
Change-Id: Idf0b4ac5e4e01dd5cd7cc9b89d017fbffb7a29df
Reviewed-on: https://go-review.googlesource.com/18430
Reviewed-by: Robert Griesemer <gri@golang.org>
(from importing golang.org/x/tools/go/types to std lib go/types)
The cmd/vet package should never have been included in this change.
Tested with 1.4.1, 1.5 and ~1.6 (tip).
Change-Id: I6d915619cbfa0297dbb9aa9ba033c1320a08c367
Reviewed-on: https://go-review.googlesource.com/18385
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
A few files have been forked and tagged "go1.5,!go1.6" to work around
minor API changes between the two types packages:
- constant.Value.String() in oracle/describe.go and its tests;
- constant.ToInt must now be called before constant.Int64Val.
- types.Config{Importer: importer.Default()} in a number of places
- go/types/typeutil/import_test.go uses lowercase names to avoid 'import "C"'.
Files in go/types/typesutil, missing from my previous CL, have been
tagged !go1.5; these files will be deleted in February.
All affected packages were tested using 1.4.1, 1.5, and ~1.6 (tip).
Change-Id: Iec7fd370e1434508149b378438fb37f65b8d2ba8
Reviewed-on: https://go-review.googlesource.com/18207
Reviewed-by: Robert Griesemer <gri@golang.org>
This change will ensure that the tree continues to work with go1.4.1.
All files continue to depend on golang.org/x/tools/go/types, but in a
follow-up change, I will switch the primary files to depend on the
standard go/types package. Another (smaller) set of files will be
forked and tagged, this time !1.6, due to API differences between the
two packages.
All tests pass using 1.4.1, 1.5, and ~1.6 (tip).
Change-Id: Ifd75a6330e120957d646be91693daaba1ce0e8c9
Reviewed-on: https://go-review.googlesource.com/18333
Reviewed-by: Robert Griesemer <gri@golang.org>
The user may specify the diff tool using the -diffcmd flag.
+ test.
Also:
- eliminate redundant DryRun flag
- simplify Verbose messages using log.SetPrefix
Fixes issue #13355
Change-Id: I917edc73e31ddf0f5d5b9b30c43f826465529da1
Reviewed-on: https://go-review.googlesource.com/18208
Reviewed-by: Michael Matloob <matloob@golang.org>
so that the bundled package doesn't clobber the package declaration
of the host package.
Also: minor comment tweaks.
Change-Id: I28ab3aca2b02213edc95c6b12c0d1a2514453cfe
Reviewed-on: https://go-review.googlesource.com/18040
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Since this tool is a handy way to run the pointer analysis during debugging.
Change-Id: If9a62f71dd8651ad6c782ead85bb84f09c703cba
Reviewed-on: https://go-review.googlesource.com/17382
Reviewed-by: Robert Griesemer <gri@golang.org>
There is no need to add play.js in article page when
playground is disabled.
Signed-off-by: Tw <tw19881113@gmail.com>
Change-Id: If40d256c89d7bd37efff9e08bb176bd3ea2d6f88
Reviewed-on: https://go-review.googlesource.com/16415
Reviewed-by: Andrew Gerrand <adg@golang.org>
The command's documentation mistakingly said that the instructions for
testing and deployment to App Engine were contained in the top-level
README for the tools repository. As best as I can tell, the top-level
README never contained this information.
This commit adds a configuration fragment and provides sample
instructions for the App Engine workflow.
Change-Id: If89c099e254ef91ca224742aebd81f7d1206d9b8
Reviewed-on: https://go-review.googlesource.com/15685
Reviewed-by: Andrew Gerrand <adg@golang.org>
- copied all affected xxx.go files to a respective xxx14.go file
- added build tags
- no other source changes
Change-Id: Ic150a097e537ee29a0e0616ab8e1e74b21e3066d
Reviewed-on: https://go-review.googlesource.com/15702
Reviewed-by: Alan Donovan <adonovan@google.com>
Unlike in BSD, in GNU/Linux find option for -depth is without an
argument. To make the command compatible in both system, use
-mindepth and -maxdepth arguments.
Change-Id: Ie82736fd2c28b6fe0f64dbfc7272f0e0f0d8e8df
Reviewed-on: https://go-review.googlesource.com/15014
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
These were built inside Google but have been in production for years.
Move them into the public tools repository so that they can be more
easily maintained.
This is step one to moving the entire golang.org deployment process out
of Google's internal source repository.
Change-Id: I72f875c5020b3f58f1c0cea1d19268e0f991833f
Reviewed-on: https://go-review.googlesource.com/14842
Reviewed-by: Chris Broadfoot <cbro@golang.org>
The documentation for the testing package states only that "The suffix
must start with a lower-case letter."
Fixesgolang/go#12663
Change-Id: I9b079b105a7c9680325fed442c42adcf3b75055e
Reviewed-on: https://go-review.googlesource.com/14760
Reviewed-by: Andrew Gerrand <adg@golang.org>
Also make health check test the backup process.
Change-Id: I9d2ed2780c07bb08683d231fccad4674c2ac22a1
Reviewed-on: https://go-review.googlesource.com/14668
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This was formerly inserted by some deployment scripts. Putting it in
the code here simplifies deployment at little cost to other users.
Change-Id: Ic092bb560c4c90e0e5bc6f9f33426b35214d613d
Reviewed-on: https://go-review.googlesource.com/14741
Reviewed-by: Andrew Gerrand <adg@golang.org>
This was preventing the playground /compile and /share handlers
from being registered under Managed VMs.
Change-Id: I690bd50abc2f42b30956e734903d09487f712d4a
Reviewed-on: https://go-review.googlesource.com/14665
Reviewed-by: Andrew Gerrand <adg@golang.org>
This will allow us to serve blog.golang.org and talks.golang.org from
the latest sources without re-deploying.
Change-Id: I2399a8a7eb60a0c6648916052f5f129cb826d546
Reviewed-on: https://go-review.googlesource.com/14662
Reviewed-by: Andrew Gerrand <adg@golang.org>
The existing list of checks in doc.go has become somewhat unwieldy.
This commit is purely cosmetic and sorts the list alphabetically keyed
by the flag name.
Change-Id: Ibb56357f9d4667d199acc6637dc28f6e17903046
Reviewed-on: https://go-review.googlesource.com/14558
Reviewed-by: Rob Pike <r@golang.org>
This commit fixes a few defects from a25a8d567b:
(1.) Making the top-level vars in main consistent w.r.t. documentation
formatting, and the-like.
(2.) Removing of one-use top-level is-test predicate.
(3.) Including documentation of what the validation does and when.
Change-Id: I19b34d25836bb2af865219d18600e1add78c3fd7
Reviewed-on: https://go-review.googlesource.com/14557
Reviewed-by: Rob Pike <r@golang.org>
In spite of https://blog.golang.org/examples and
http://golang.org/pkg/testing/#pkg-examples, a number of internal Go
authors have found writing documentation examples to be problematic in
the sense that the syntax is error-prone due to loose coupling with
identifiers found in the source corpus.
This commit introduces a suite of validations for documentation
examples:
Overall:
- Correct suffices, if present
- Niladic function argument and return signatures
func Example() {}
func ExampleF() {}
- F exists
func ExampleT() {}
- T exists
func ExampleT_M() {}
- T exists
- M exists within T
Further, if the example is in `package foo_test`, vet attempts to
resolve the respective lookups in `package foo`, if `package foo`
exists (cf., `package stringutil_test`).
Change-Id: Ifa13906363541ebf28325681b749b14b7f8b103d
Reviewed-on: https://go-review.googlesource.com/11982
Reviewed-by: Andrew Gerrand <adg@golang.org>
It takes too long for the builders.
Also remove GOPATH from the environment when indexing.
Change-Id: I9a3f2628f248bdbf9dce97119c2fbb7cbd63f3fe
Reviewed-on: https://go-review.googlesource.com/12917
Reviewed-by: Andrew Gerrand <adg@golang.org>
This adds a flag for specifying a regular expression for failures that
should be ignored. This is useful for filtering out known issues and
provides a logical mirror to the existing -failure flag.
Change-Id: Ibbacdd2125aa23fe819896e5a17664b703c4ee35
Reviewed-on: https://go-review.googlesource.com/12676
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
In preparation for removal of types.New.
Change-Id: Ieff0c41cf03351124cea32e9b96075a4801c051f
Reviewed-on: https://go-review.googlesource.com/10775
Reviewed-by: Rob Pike <r@golang.org>
It cleans the string and removes the initial ./, which will cause the
test to fail if . is not in $PATH
Change-Id: Icc216f7ab4887c39ccda93d1c4093ccd03de44bc
Reviewed-on: https://go-review.googlesource.com/10696
Reviewed-by: Robert Griesemer <gri@golang.org>
This is needed to control which files to test in the usual manner.
A followup CL on the main repo will add the flag to the go vet command.
Updates golang/go#10228
Change-Id: I820d3c74657b58de5e92276627368dedf4e2096c
Reviewed-on: https://go-review.googlesource.com/10692
Reviewed-by: Andrew Gerrand <adg@golang.org>
When String() was called on the maximum value of an integer type (eg
255 for uint8) this would cause an integer overflow, which would cause
an index error later in the code.
Fixed by re-arranging the code slightly.
Fixesgolang/go#10563
Change-Id: I9fd016afc5eea22adbc3843f6081091fd50deccf
Reviewed-on: https://go-review.googlesource.com/9255
Reviewed-by: Rob Pike <r@golang.org>
The variable was assigned but not used, as caught by a tool
written by gorden.klaus@gmail.com.
Change-Id: I84ca3d00896287a35561bd122a0cf64212854a86
Reviewed-on: https://go-review.googlesource.com/10610
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
And add a TODO.
Change-Id: I51c63b32e9ac4309cdfb8228348a5d528f36a919
Reviewed-on: https://go-review.googlesource.com/10489
Reviewed-by: Robert Griesemer <gri@golang.org>
Currently at the end of a long stress run you may not know from the
end of the output whether there were any failures. Add a failure count
to the periodic status message to make this obvious.
Change-Id: I5ad19b9e6f462369fb32be6efbfb6f21568e98e4
Reviewed-on: https://go-review.googlesource.com/10187
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
fiximports enumerates the set of packages identified by the
command-line arguments, using "go list" notation. Within each
package, it replaces all imports of non-canonical packages by their
canonical name, introducing an import renaming if (heuristically)
necessary.
If a package comes from one of the -baddomains, and it has no import
comment, fiximports reports an error. The error message includes the
list of packages that import the errant package, directly or
indirectly. This flag is used to indicate "sinking ship" package
hosting domains like code.google.com.
Caveat: this process is not trivially reversible. Consider a package A
to which we add an import comment "B", and run the tool. Package C,
which imported A, now imports B. ('go get -u' would fetch package B).
But changing the import comment in directory A and re-running the tool
will not cause C to be changed because it no longer imports A; it
imports B.
+ Tests.
Change-Id: I3d3d9663d3c084356fffc7e55407709ebc6d9a39
Reviewed-on: https://go-review.googlesource.com/8562
Reviewed-by: Andrew Gerrand <adg@golang.org>
Also, in Emacs, make 'referrers' query not prompt for a scope.
Change-Id: I5c0f034d4fa8b653311f1b7d8ff58b699d168b79
Reviewed-on: https://go-review.googlesource.com/9927
Reviewed-by: Andrew Gerrand <adg@golang.org>
in that order, so that "go get golang.org/x/tools/cmd/oracle" installs
it and no copy is needed. We keep the old location for compatibility.
Why is if/else control flow so hard in basic Lisp? Sometimes you just need 'return'.
Change-Id: Iae231a761d707daaa1316161cfad0365111eff0e
Reviewed-on: https://go-review.googlesource.com/9547
Reviewed-by: David Chase <drchase@google.com>
The stress utility is intended for catching of episodic failures.
It runs a given process in parallel in a loop and collects any failures.
Usage:
$ stress ./fmt.test -test.run=TestSometing -test.cpu=10
You can also specify a number of parallel processes with -p flag;
instruct the utility to not kill hanged processes for gdb attach;
or specify the failure output you are looking for (if you want to
ignore some other episodic failures).
Do you find it useful?
I use it for several years for all kinds of episodic failures (not just Go btw).
Change-Id: I06553345b76768a819412acb45f9bdfb3bababf7
Reviewed-on: https://go-review.googlesource.com/9373
Reviewed-by: Keith Randall <khr@golang.org>
The loader package now loads, parses, and type-checks a whole program
from source, and that is all.
Also:
- simplified loader logic
- ssa.Create is gone; use ssautil.CreateProgram.
- ssautil.LoadPackage renamed to BuildPackage.
It is now independent of go/types' Import hook and the Packages map.
- ssadump: -importbin flag removed.
The value of this flag was that it caused the tool to print IR
for only a single package; this is now the normal behaviour.
Fixes#9955
Change-Id: I4571118258ab1a46dccece3241b7dc51401a3acc
Reviewed-on: https://go-review.googlesource.com/8953
Reviewed-by: Robert Griesemer <gri@golang.org>
Missed this in a prior change.
Change-Id: I7358c17b73a1221cb8f9dff6b808fdea8b13ec06
Reviewed-on: https://go-review.googlesource.com/8916
Reviewed-by: Rob Pike <r@golang.org>
Depends on https://golang.org/cl/8767/.
With this change, cmd/vet does not depend on x/tools anymore
and could be moved into the std repo if so desired.
Change-Id: Ia205c6e1a6a63eebb27776064e5c24491043b683
Reviewed-on: https://go-review.googlesource.com/8791
Reviewed-by: Rob Pike <r@golang.org>
This package was only imported for the trivial Unparen function.
Change-Id: I0ead916a7fdb469a26b4fe99c6964a8ed1438c49
Reviewed-on: https://go-review.googlesource.com/8566
Reviewed-by: Rob Pike <r@golang.org>
Currently, if for some reason http.ListenAndServe fails, any running
running godoc processes don't get killed. I don't think this would ever
actually happen because, with godoc being set up in a separate go
routine, http.ListenAndServe would always(?) fail before the godoc
server started.
This change ensures that, if a Proxy has a cmd, it is closed when
http.ListenAndServe fails.
Change-Id: I0d3bfae0c16bc583248c2052a4d7a84c95127e76
Reviewed-on: https://go-review.googlesource.com/8570
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This peculiar case arose in range statements but there are other contexts
and one turned up in the auto-generated translation of the compiler.
Take care of it always.
for i := 0; i < 0; func() {i++; q=q.Link}() { ... }
That code has been given the obvious rewrite but we should still handle it.
Odd but easy to fix (tricky to test).
Fixes#10269.
Change-Id: I66e1404eb24da15a24be7f67403e19ed66fba0a7
Reviewed-on: https://go-review.googlesource.com/8284
Reviewed-by: Robert Griesemer <gri@golang.org>
The check for len(argv)==0 now only applies to these modes.
Also, more consistent variable naming.
Change-Id: I9adb6bebc819eb43d54ddf63c42d952671ce9236
Reviewed-on: https://go-review.googlesource.com/8244
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Features:
More robust: silently ignore type errors in modes that don't need
SSA form: describe, referrers, implements, freevars, description.
This makes the tool much more robust for everyday queries.
Less configuration: don't require a scope argument for all queries.
Only queries that do pointer analysis need it.
For the rest, the initial position is enough for
importQueryPackage to deduce the scope.
It now works for queries in GoFiles, TestGoFiles, or XTestGoFiles.
(It no longer works for ad-hoc main packages like
$GOROOT/src/net/http/triv.go)
More complete: "referrers" computes the scope automatically by
scanning the import graph of the entire workspace, using gorename's
refactor/importgraph package. This requires two passes at loading.
Faster: simplified start-up logic avoids unnecessary package loading
and SSA construction (a consequence of bad abstraction) in many
cases.
"callgraph": remove it. Unlike all the other commands it isn't
related to the current selection, and we have
golang.org/x/tools/cmdcallgraph now.
Internals:
Drop support for long-running clients (i.e., Pythia), since
godoc -analysis supports all the same features except "pointsto",
and precomputes all the results so latency is much lower.
Get rid of various unhelpful abstractions introduced to support
long-running clients. Expand out the set-up logic for each
subcommand. This is simpler, easier to read, and gives us more
control, at a small cost in duplication---the familiar story of
abstractions.
Discard PTA warnings. We weren't showing them (nor should we).
Split tests into separate directories (so that importgraph works).
Change-Id: I55d46b3ab33cdf7ac22436fcc2148fe04c901237
Reviewed-on: https://go-review.googlesource.com/8243
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Emacs integration:
- eliminate oracle minor mode
- in go-mode, bind F5, F6 to "describe", "referrers".
This reverts a previous policy decision but convenience matters too.
- don't insist on an analysis scope for modes that don't do PTA.
- don't hide the filename as "▶"; show the last 20 chars.
(Especially useful for "referrers" mode.)
- output postprocessing: don't get stuck in a loop if the output
is not as expected (e.g. when it includes a panic log).
referrers:
- show the matching lines (like grep does).
We do the I/O in parallel.
Change-Id: I86b18c1d3a4d9fa4242984cba62b314796669d8e
Reviewed-on: https://go-review.googlesource.com/8120
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Cover deleted all comments because they can break the simple way that
counters are injected into the rewritten source. But //go: comments have
semantic value, and for instance go test -cover runtime fails during
compilation because of their absence from the annotated source.
We can keep the //go: comments because they are at the beginning of
the line and are not affected by our counter injection.
Fixes#10270.
After this CL, go test -cover runtime works.
A testing strategy that does not involve a golden file would be welcome
but I can't think of one.
Change-Id: I73f7b7a36383a8efed8e33fa2414cd0eac7d015a
Reviewed-on: https://go-review.googlesource.com/8173
Reviewed-by: Robert Griesemer <gri@golang.org>
Given
x()
panic(1)
y()
the y should not show as covered.
Fixes#10185
Change-Id: Iec61f1b096a888e6727be5f4526508654f5d3c91
Reviewed-on: https://go-review.googlesource.com/8140
Reviewed-by: Robert Griesemer <gri@golang.org>
Silly test added yesterday requires that some code in a goroutine executes.
Make sure it does.
Change-Id: I7e852454736e300151473986cc437a70b41dc9b7
Reviewed-on: https://go-review.googlesource.com/7691
Reviewed-by: Russ Cox <rsc@golang.org>
eg with no arguments prints its usage, including a hand-written flag summary.
eg -help shows the detailed help message.
Change-Id: I615d8de3985ced1e86e9d7cafa9ef679079b249c
Reviewed-on: https://go-review.googlesource.com/6951
Reviewed-by: Robert Griesemer <gri@golang.org>
It used to do packages only when run by the go tool, but it was
fixed a while back to handle packages properly when doing a
directory walk. Remove the incorrect information from the
documentation.
Change-Id: I961340bb84e48474c94ee03bf88f9136492c0226
Reviewed-on: https://go-review.googlesource.com/7642
Reviewed-by: Andrew Gerrand <adg@golang.org>
Just missed a case (ha!) in the tree walk. Dup the code for an empty switch, add test.
Fixes#10163.
Change-Id: I3d50ab6cb450ca21e87213291eaab8cbe924fac5
Reviewed-on: https://go-review.googlesource.com/7641
Reviewed-by: Andrew Gerrand <adg@golang.org>
Skip tests on arm platforms.
The godoc tests require large amounts of memory, in excess of 700mb in -index mode which none of the arm builders have spare.
Because of their requirements the tests can be killed by the test runner leaving stray godoc processes spinning in swap trying to -index.
Change-Id: I1544d56e9d9aabbbaac21adeebfb9e2690bd2da5
Reviewed-on: https://go-review.googlesource.com/7540
Reviewed-by: Andrew Gerrand <adg@golang.org>
On tip, search included redundant source results from /pkg/bootstrap
(with broken links as godoc doesn't support source files under /pkg).
This change excludes all directories under /pkg from indexing.
Fixesgolang/go#10024.
Change-Id: I0c69d22ff08d131f9c37c91a7711db6a4ec53fd4
Reviewed-on: https://go-review.googlesource.com/7267
Reviewed-by: Andrew Gerrand <adg@golang.org>
Also use a more reliable implementation.
Change-Id: I9e6858c7e9bdb60f1fb4e060e6d4d1b3762b83bc
Reviewed-on: https://go-review.googlesource.com/7260
Reviewed-by: Minux Ma <minux@golang.org>
Run godoc indexing just once on startup. Wait for indexing to complete
before switching to new side. Increase startup timeout to accommodate for
indexing.
Updates golang/go#9996.
Change-Id: I1e746a68b7d787e6d7f180c2617ea75f0d3291f8
Reviewed-on: https://go-review.googlesource.com/7120
Reviewed-by: Andrew Gerrand <adg@golang.org>
The caller of Usage should call os.Exit -- Usage shouldn't call it.
Change-Id: I3decf662883fb2a6b19b7035138ee8a06a02de08
Reviewed-on: https://go-review.googlesource.com/7110
Reviewed-by: Andrew Gerrand <adg@golang.org>
...since the zero value is more useful by far.
This is a breaking API change, obviously. (One or two tests in this
CL have intentional been left using the zero value, i.e., they now
load source.)
Change-Id: I42287bfcdb1afef8ee84e5eac12534dd0a1fd5d2
Reviewed-on: https://go-review.googlesource.com/5653
Reviewed-by: Robert Griesemer <gri@golang.org>
Due to copy/paste from Google-internal branch.
I can't explain why I didn't test this; sorry.
Change-Id: I7b5f083a124c7cfb0fa6cb0506465a36bd79e983
Reviewed-on: https://go-review.googlesource.com/5654
Reviewed-by: Alan Donovan <adonovan@google.com>
While we're here, silence a print about failure to import fmt.
When it prints, it looks like a problem, and in fact the result
is never used in vet.
Change-Id: I76121b335026a2b09637608b997517be94fd167c
Reviewed-on: https://go-review.googlesource.com/5573
Reviewed-by: Rob Pike <r@golang.org>
I moved print.css into styles.css - to make it obvious that it needs to be
considered when modifying the styles.css. I use @media screen for all the
framwork related css, this means the @media print doesn't have to start
overriding each property - also there's less chance of a problem when
something isn't overridden.
Change-Id: Ic58e8c80df3339b55f67140a47866a232e0d30a3
Reviewed-on: https://go-review.googlesource.com/5526
Reviewed-by: Andrew Gerrand <adg@golang.org>
ssadump's -build=G option is now spelled -import; it was never related to ssa.
Change-Id: Ic21cd8b6990c0ffd25651c17a842a63bfa5019cf
Reviewed-on: https://go-review.googlesource.com/5172
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Argument indexes in a format string are one-based, however vet would not
warn when using a zero-index unless the type of the argument referenced
was not a string. That warning was misleading as it would say the type
was not a string. Vet will now print a correct warning when using a zero
index.
Included are tests for both cases.
Fixes#9752
Change-Id: I285e99990a86a653b4668b0c279d5f5f1c34f7aa
Reviewed-on: https://go-review.googlesource.com/3692
Reviewed-by: Rob Pike <r@golang.org>
Before this change, many kinds of error would cause the loader to stop.
making it brittle when analyzing large codebases, as in "godoc -analysis".
This change moves operations that used to occur during
configuration---(*build.Context).Import, loading, and parsing of
initial packages---into the Load call, and ensures that all failures
during Loading are reported at the end so that the maximum amount of
progress is made.
Also: redesign the tests and add many new cases.
Change-Id: Ia8cd99416af7c5d4a5fe133908adfa83676d401f
Reviewed-on: https://go-review.googlesource.com/3626
Reviewed-by: Robert Griesemer <gri@golang.org>
...to avoid namespace conflicts.
Also make its name "main", since it defines func main().
And fix 2 typos.
Change-Id: I7cf7894d6bed134907b3d2742255e5a82426071b
Reviewed-on: https://go-review.googlesource.com/3150
Reviewed-by: Robert Griesemer <gri@golang.org>
Most of the names have been brought in line with the names used in
testing/BenchmarkResult. For example, NsOp becomes NsPerOp.
Additionally, "Bench" becomes "Benchmark" and "BenchSet" becomes "Set".
Change-Id: I7dfca68a804e285a87ab9692b5bb99ccb676da7f
Reviewed-on: https://go-review.googlesource.com/2610
Reviewed-by: Rob Pike <r@golang.org>
This change adds a command mvpkg that will move a given package and
update all its imports. It uses similar logic to gorename to update
the imports.
Change-Id: Iebbd0b4c93c2302b0a71c3b99c68f6778106012a
Reviewed-on: https://go-review.googlesource.com/1973
Reviewed-by: Alan Donovan <adonovan@google.com>
This allows godoc.org to link to the source code. I chose to link to
github.com instead of googlesource.com because their file browser is
better.
Details here:
864b1c0aba
Change-Id: I962b3fadc822e753245f52240937be5c7e158dc7
Reviewed-on: https://go-review.googlesource.com/2719
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This lets go vet produce useful results for syscall on darwin/amd64,
otherwise it gets caught on asm.s.
Change-Id: I3daa49cf61eeada52eb9d4e94e40c4d21d1d5b2d
Reviewed-on: https://go-review.googlesource.com/2741
Reviewed-by: Rob Pike <r@golang.org>
Actually parse the strings to check them more accurately.
The particular problem it missed was that it didn't check
for control characters in the key. The only valid separator
is a space.
More tests.
Fixes#9500
Change-Id: Ib547e11c7e8d47d81eb8b1e8f1ab9c26174933df
Reviewed-on: https://go-review.googlesource.com/2685
Reviewed-by: Russ Cox <rsc@golang.org>
Godoc documentation did not mention the feature for showing example code
runnable by the testing package. Add a link to the testing package.
Update golang/go#9471
Change-Id: Ic15794c59732e9b0b42c5b16c60be0a47c41afa5
Reviewed-on: https://go-review.googlesource.com/2490
Reviewed-by: Andrew Gerrand <adg@golang.org>
Move the parser for benchmark output from cmd/benchcmp into its own
package, benchmark/parse.
The majority of the change is just moving code around. Instead of
implementing the '-best' flag in ParseBenchSet, it is now implemented in
its own function 'selectBest' in cmd/benchcmp.
Bench.Ord (the ordinal position of a Bench within a BenchSet) has been
exported.
Change-Id: Id27032a220f9ff2596117b58b86243998695a804
Reviewed-on: https://go-review.googlesource.com/2102
Reviewed-by: Rob Pike <r@golang.org>
Fixes various problems reported by go vet.
Change-Id: I12a6fdba8f911b21805d8e42903f8f6a5033790a
Reviewed-on: https://go-review.googlesource.com/2163
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This will match the default behavior when running locally.
In fact, our http://blog.golang.org/godoc-documenting-go-code explicitly
documents this feature (see also golang.org/cl/1953).
Change-Id: I581b17b60229ce70900cb51d548d1e2a34df41ba
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/2116
Reviewed-by: Andrew Gerrand <adg@golang.org>
Close the `<h3>` header tag with a closing `</h3>` tag to fix the HTML
syntax.
Change-Id: Ic86c5f31ec5550d6875aa085eed8da6a75881405
Reviewed-on: https://go-review.googlesource.com/2104
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Suggestion by dsymonds: Save code not data.
Add an extra element to the index array and an if can be eliminated.
Old generated code:
const _Day_name = "MondayTuesdayWednesdayThursdayFridaySaturdaySunday"
var _Day_index = [...]uint8{6, 13, 22, 30, 36, 44, 50}
func (i Day) String() string {
if i < 0 || i >= Day(len(_Day_index)) {
return fmt.Sprintf("Day(%d)", i)
}
hi := _Day_index[i]
lo := uint8(0)
if i > 0 {
lo = _Day_index[i-1]
}
return _Day_name[lo:hi]
}
New generated code:
const _Day_name = "MondayTuesdayWednesdayThursdayFridaySaturdaySunday"
var _Day_index = [...]uint8{0, 6, 13, 22, 30, 36, 44, 50}
func (i Day) String() string {
if i < 0 || i+1 >= Day(len(_Day_index)) {
return fmt.Sprintf("Day(%d)", i)
}
return _Day_name[_Day_index[i]:_Day_index[i+1]]
}
Change-Id: I6f46a4892d5813a12ec1ad01738c6a21c7e45172
Reviewed-on: https://go-review.googlesource.com/1990
Reviewed-by: David Symonds <dsymonds@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
At least in theory. We don't totally have it working yet. It does
run locally in the dev environment, though, which should be the same
as production, since it builds the Docker container locally.
But we're getting problems when pushing it to production.
Also some minor tweaks to the code with Andrew.
Change-Id: Id192669dbc8d3f86d9c8dad79764abd66e983895
Reviewed-on: https://go-review.googlesource.com/1761
Reviewed-by: Andrew Gerrand <adg@golang.org>
Rough work in progress. Don't hate.
Change-Id: I9d8247005724a21bdb5d4760cc6135bceb49f2d4
Reviewed-on: https://go-review.googlesource.com/1704
Reviewed-by: Andrew Gerrand <adg@golang.org>
The whicherrs query mode takes the position of an error and returns the set of constants, globals and types visible from within the scope of the error being queried.
It is meant to be used as a shortcut to find out which errors should be handled for a given functions call.
LGTM=adonovan
R=golang-codereviews, dominik.honnef, adonovan
CC=golang-codereviews
https://golang.org/cl/167420043
Previously, gorename rejected all method renamings if it would
change the assignability relation.
Now, so long as the renaming was initiated at an abstract
method, the renaming proceeds, changing concrete methods (and
possibly other abstract methods) as needed. The user
intention is clear.
The intention of a renaming initiated at a concrete method is
less clear, so we still reject it if it would change the
assignability relation. The diagnostic advises the user to
rename the abstract method if that was the intention.
Additional safety checks are required: for each
satisfy.Constraint that couples a concrete type C and an
interface type I, we must treat it just like a set of implicit
selections C.f, one per abstract method f of I, and ensure the
selections' meanings are unchanged.
The satisfy package no longer canonicalizes types, since this
substitutes one interface for another (equivalent) one, which
is sound, but makes the type names random and the error
messages confusing.
Also, fixed a bug in 'satisfy' relating to map keys.
+ Lots more tests.
LGTM=sameer
R=sameer
CC=golang-codereviews
https://golang.org/cl/173430043
Avoid error "could not import C (can't find import: C)"
Fixesgolang/go#9169.
LGTM=adonovan, r
R=golang-codereviews, adonovan, r
CC=golang-codereviews
https://golang.org/cl/184730043
"static" ignores dynamic calls altogether.
"cha" uses Class Hierarchy Analysis, which assumes that a
dynamic call may dispatch to any func or method that satisfies
the type.
Both these algorithms can work on partial programs,
e.g. libraries without a main function or tests.
(This feature was requested after my talk last night.)
+ Tests.
LGTM=sameer
R=sameer, minux
CC=golang-codereviews, gri
https://golang.org/cl/176780043
- print "oracle:" not "Error:" in error messages; remove period.
- allocate token.FileSet correctly.
- remove stale TODO (multiple test packages)
- fix typo and omission ('what') in usage message.
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/178860043
Such messages are more informative when the error occurs deep within a script.
Also: add tool name to digraph's usage messages.
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/173380043
(This functionality is provided by the oracle, but its output
format is inflexible, and the functionality is better suited
to a shell utility. I may remove the oracle 'callgraph' feature.)
See Usage for details.
+ Test.
LGTM=sameer
R=sameer
CC=golang-codereviews, gri
https://golang.org/cl/164460044
Rewrite performed with this command:
sed -i '' 's_code.google.com/p/go\._golang.org/x/_g' \
$(grep -lr 'code.google.com/p/go.' *)
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/170920043