1
0
mirror of https://github.com/golang/go synced 2024-11-06 05:36:13 -07:00
Commit Graph

1748 Commits

Author SHA1 Message Date
Alan Donovan
ee8cb08bfe cmd/guru: what: report identifiers equivalent to the selected one
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>
2016-02-20 21:18:35 +00:00
Alberto Donizetti
a17fa845d7 go/gcimporter15: add missing argument to error message
Backport of Change 19641

Change-Id: Ic386cc8ecc006a2cd96c5ac3ff00f3d314873fd3
Reviewed-on: https://go-review.googlesource.com/19643
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-18 21:23:36 +00:00
Russ Cox
bf084ef758 imports: add support for vendor directories
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>
2016-02-18 16:47:46 +00:00
Russ Cox
d0c9d43af1 bundle: new docs, command-line interface
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>
2016-02-17 15:40:24 +00:00
Alan Donovan
cd3cb7be66 cmd/guru: fix build breakage due to unneeded log import
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>
2016-02-16 02:42:20 +00:00
Alan Donovan
fb3df4a89d cmd/guru: definition: try parser-based resolution first
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>
2016-02-16 00:29:23 +00:00
Alan Donovan
cadb821a95 cmd/guru: don't panic on *ast.Bad{Decl,Stmt,Expr}
These nodes are common in incomplete programs.

Change-Id: Iff9750050c78762f0cb8bebc7739584c197d661e
Reviewed-on: https://go-review.googlesource.com/19509
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-02-15 21:39:56 +00:00
Alan Donovan
d7762ee5c0 cmd/guru: emacs: report an error when the guru command fails
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>
2016-02-15 21:39:43 +00:00
Alan Donovan
19c83edf02 cmd/guru: in Emacs, change 'definition' to jump directly
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>
2016-02-15 17:57:16 +00:00
Alan Donovan
e08a7ae6bc cmd/guru: add support for loading modified files
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>
2016-02-15 15:04:13 +00:00
Dmitri Shuralyov
5a22c00969 godoc/vfs/zipfs: use an os.IsNotExist-compatible error
When a file is not found, it's common to return an error that can
be detected with os.IsNotExist helper. It's possible to use
os.PathError type to satisfy that requirement while still providing
the path information in the error.

Add a test that files that are not found return a non-nil error, and
that the error satisfies os.IsNotFound.

Change-Id: I5f1a26b18f2556af822ede73306541e8575ede28
Reviewed-on: https://go-review.googlesource.com/19503
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-02-15 04:18:10 +00:00
Alan Donovan
93ea01aea0 cmd/guru: describe: show methods and fields of an expression
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>
2016-02-15 03:46:17 +00:00
Alan Donovan
608d57b3ae cmd/guru: call{ers,stack}: avoid pointer analysis where possible
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>
2016-02-12 23:38:00 +00:00
Alan Donovan
8da9f8bbd7 cmd/guru: describe: show selectable fields when describing a type
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>
2016-02-12 23:35:49 +00:00
Alan Donovan
1d6b8698af cmd/guru: remove vestiges of -pos flag
It's a positional parameter now.

Also, update -help message to address
https://go-review.googlesource.com/#/c/19474 comments

Change-Id: Ie5947aa3c37180961e780747ca02be54f7030c21
Reviewed-on: https://go-review.googlesource.com/19493
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-12 22:00:14 +00:00
Alan Donovan
00b8b1eb95 cmd/guru: clean ups to command-line interface
-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>
2016-02-12 21:50:49 +00:00
Alan Donovan
789265387f cmd/guru: freevars: reenable test of labels (and improve output)
Change-Id: Icb7747d0856a4be2de52e143b793b52a725d297c
Reviewed-on: https://go-review.googlesource.com/19437
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-12 03:59:51 +00:00
Alan Donovan
37bb37ec1c cmd/guru: fix bad import, and run gofmt
Change-Id: Ieb5c732bad494942f7b45ac5a1b605e810436e87
Reviewed-on: https://go-review.googlesource.com/19478
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-12 03:58:01 +00:00
Alan Donovan
7347379304 cmd/guru: rename oracle to guru, copying it to a single package
See plans at:
https://docs.google.com/document/d/1UErU12vR7jTedYvKHVNRzGPmXqdMASZ6PfE7B-p6sIg/edit#heading=h.t5rbcuy7di7j

Change-Id: I369747e0ce8cd42a2975eb0f651a2e5fba47cf9e
Reviewed-on: https://go-review.googlesource.com/19475
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-12 03:38:58 +00:00
Alan Donovan
78e666a894 cmd/oracle: add pointsto, whicherrs to help message
Also, remove stale example.

Change-Id: Ifa1123b9dca49c991a16ef35eb7227847878c657
Reviewed-on: https://go-review.googlesource.com/19474
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-11 22:30:21 +00:00
Chris Broadfoot
3440805344 godoc/static: disable spellcheck on textareas
Fixes golang/go#14287.

Change-Id: I028eb6d669998b59e1bf1e3b40a337d5e28fbc57
Reviewed-on: https://go-review.googlesource.com/19430
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-10 23:35:39 +00:00
Robert Griesemer
7ed774bdc0 go/gcimporter15: interpret relative srcDir relative to cwd
This is a backport of the respective changes in golang.org/cl/19393.

For golang/go#14215.

Change-Id: I8d60dd6daa827a60597f3af925e6732914537319
Reviewed-on: https://go-review.googlesource.com/19394
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-10 17:55:37 +00:00
Andrew Gerrand
fe74a41861 godoc: don't quote search term to avoid escaping regexps
This is safe because the page title is HTML-escaped as it is displayed.

Fixes golang/go#14208

Change-Id: Ib98071a08adeaad79043b9a2eb07bc7a5e8d251d
Reviewed-on: https://go-review.googlesource.com/19242
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-05 01:57:33 +00:00
Alan Donovan
02f1928320 go/loader: ignore (*build.Package).Goroot flag when handling "unsafe"
For the default build.Context, the Package.Goroot flag indicates when a
package was loaded from the standard library.  Until now, the loader
used it to enable the typechecker's intrinsics for the "unsafe" package.
This seemed like a good check, but it is troublesome for clients that
use a nonstandard build.Context.  For example, if a client defines
nonstandard Context hooks that load all packages, whether standard or
user-defined, from a flat sstable, there is no way for those hooks to
indicate which packages should have this flag set and which not.  As a
result the contents of the "unsafe" package directory are treated as Go
source code when they are merely documentation.

Change-Id: Iea0a7cc9877507d73606391293971a28279c4e4b
Reviewed-on: https://go-review.googlesource.com/19188
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-05 00:45:20 +00:00
Larz Conwell
9a6ae37d4e cmd/godoc: accept GOOS and GOARCH URL parameters in -http mode
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>
2016-02-04 22:11:53 +00:00
Alan Donovan
a6e3cc80e8 oracle: describe: backport fix to 1.4, 1.5
(See CL 19158, bug 14160, commit 35b3d64)

Change-Id: I01ee2bb0eca072141b2c4551789793b1d5c480e3
Reviewed-on: https://go-review.googlesource.com/19189
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-02-04 17:28:22 +00:00
Alan Donovan
35b3d645bc oracle: fix panic when describing "unsafe"
Fixes issue 14160

Change-Id: Ie27d79ba135cadd2e6f5d3b40b8eca25b6a030d9
Reviewed-on: https://go-review.googlesource.com/19158
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-02-03 15:29:59 +00:00
Brad Fitzpatrick
b47dfd93e5 all: fix plan9 failures
Updates golang/go#11811

Change-Id: I6ed252eb3272354fce8084ec99f4777e41c3daa3
Reviewed-on: https://go-review.googlesource.com/18993
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2016-01-28 00:31:03 +00:00
Brad Fitzpatrick
2fd075ed02 all: skip slow tests in short mode
Updates golang/go#14113
Updates golang/go#11811

Change-Id: I61851de12ff474d3b738fc88f402742677973cae
Reviewed-on: https://go-review.googlesource.com/18992
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-01-28 00:14:01 +00:00
Mikio Hara
09dc3ef4c7 go/gcimporter15: fix build
This change prevents test code to slip into package gcimporter15 and
fixes a weird situation that the test passes but the package doesn't
exist.

For example, we can see the situation with Go 1.6 like the follwoing:

go build
./gcimporter_test16.go:20: undefined: MustHaveGoBuild
./gcimporter_test16.go:45: undefined: testPath

go test
PASS
ok  	golang.org/x/tools/go/gcimporter15	0.896s

Change-Id: I95550574ccd1b2273072c700c28a82c791c16c63
Reviewed-on: https://go-review.googlesource.com/18950
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-01-27 07:08:15 +00:00
Andrew Gerrand
95cc01bac9 godoc/static: fix dd styles
This makes /doc/install/source render correctly.

Fixes golang/go#14104

Change-Id: I58a883abd875197064a5e120a47e5ea8faad7df9
Reviewed-on: https://go-review.googlesource.com/18955
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-27 04:50:12 +00:00
Chris Broadfoot
e7cdd7bb9f cmd/tip: update deploy instructions
Change-Id: I5c26a2fc8ef7c0ad99c3d176b866f221cb39c9e2
Reviewed-on: https://go-review.googlesource.com/18980
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-01-27 02:50:12 +00:00
Mikio Hara
7421583666 go/vcs: drop support for Google Code Project Hosting
The hosting service was shut down on January 25, 2016 and a few tests
started to fail like the following:

=== RUN   TestRepoRootForImportPath
--- FAIL: TestRepoRootForImportPath (2.47s)
	vcs_test.go:129: RepoRootForImport("code.google.com/p/go"):
unable to detect version control system for code.google.com/ path
FAIL

This change drops support for code.google.com and fixes test. See
http://google-opensource.blogspot.jp/2015/03/farewell-to-google-code.html
for further information.

Fixes golang/go#14105

Change-Id: I87cb9a3d666c2a1af0f8bf39a66ba0f669c99fd5
Reviewed-on: https://go-review.googlesource.com/18951
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-27 00:23:28 +00:00
Chris Broadfoot
ce967854d3 cmd/tip: move side health check to main health check. Use 503.
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.

Fixes golang/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>
2016-01-25 21:17:16 +00:00
Alan Donovan
f3a63969dd go/gcimporter15: fix build for go1.4
Change-Id: I0b2650bbb2bf35d7895e1a808cfb45f7f0194ea9
Reviewed-on: https://go-review.googlesource.com/18822
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-01-21 22:50:50 +00:00
Robert Griesemer
d2e00652ba x/tools: fix build
Change-Id: I02b42abcc29ee04c8f54dc8ba2c6079b3e6c4153
Reviewed-on: https://go-review.googlesource.com/18816
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-01-21 22:29:25 +00:00
Scott Mansfield
abfa4875c0 cmd/gorename: Fixing panic when showing diffs
When displaying a diff the gorename command would panic because the
stdout variable was never set. These changes default stdout to
os.Stdout.

Fixes https://github.com/golang/go/issues/14009

Change-Id: I0902b2b4e2b8e1f46f8ab50e30dcfc841c925174
Reviewed-on: https://go-review.googlesource.com/18813
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-01-21 20:39:40 +00:00
Robert Griesemer
7912bef4df go/gcimporter15: only test binary export when running against Go 1.6
Also: rename setname15.go to setname.go for consistency

Change-Id: I3f7e37ef4ade716ce64674edb4d53a543a1150c5
Reviewed-on: https://go-review.googlesource.com/18772
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-01-20 21:48:19 +00:00
Robert Griesemer
e6d5370703 go/gcimporter15: implement types.Package.SetName for Go 1.5
This makes gcimporter15 build against Go 1.5.

Change-Id: I14e7ff80b28d99f996abc19a0a74b08e5e1bbd75
Reviewed-on: https://go-review.googlesource.com/18771
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-01-20 21:18:18 +00:00
Robert Griesemer
2fb4b8bc95 go/gcimporter15: use latest std/lib gcimporter code
Change-Id: Ia497e56084cf262510461b7e94296570ca8e2049
Reviewed-on: https://go-review.googlesource.com/18770
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-01-20 20:18:03 +00:00
Dmitri Shuralyov
5804fef4c0 x/tools/go/vcs: fix FromDir returning bad root on Windows
Import path is a '/'-separated path. FromDir documentation says
on return, root is the import path corresponding to the root of
the repository. On Windows and other OSes where os.PathSeparator
is not '/', that wasn't true since root would contain characters
other than '/', and therefore it wasn't a valid import path
corresponding to the root of the repository. Fix that by using
filepath.ToSlash.

Add test coverage for root value returned from FromDir, it was
previously not tested.

Additionally, remove a dubious statement from the documentation
"(thus root is a prefix of importPath)". There is no variable
importPath that is being referred to. It's also redundant and
confusing. Without it, the description of root value matches
the documentation of RepoRoot.Root struct field:

	// Root is the import path corresponding to the root of the
	// repository.
	Root string

Fixes golang/go#7723.

Change-Id: If9f5f55b5751e01a7f88b79d9b039402af3e9312
Reviewed-on: https://go-review.googlesource.com/18461
Reviewed-by: Chris Manghane <cmang@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-19 15:45:24 +00:00
Kenji Kaneda
3c782264fb go/types: fix a comment of Named.Obj
// TypeName returns ...
-> // Obj returns ...

Change-Id: I2ac6133a703ec2c4b2045d4bdf9acc70049f0e1e
Reviewed-on: https://go-review.googlesource.com/18704
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-16 17:31:34 +00:00
Daniel Morsing
ae18226edd oracle: handle implicit selections in callees
The types only optimization for callees looked at the type of the
receiver to figure out if it was a dynamic call. If the selection
involves any implicit selections, we cannot be sure that this type
is the one that will actually receive the call.

Fix by working backwards from function signature to find the true
receiver

Change-Id: If79e3de7af33480e37bcf1081abe44bb04914da4
Reviewed-on: https://go-review.googlesource.com/18563
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-01-13 18:20:05 +00:00
Alan Donovan
5a2875abe7 go/loader: reduce contention for findPackage mutex
...by making the cache non-blocking and duplicate-suppressing.

(The bottleneck was introduced while adding vendoring support.)
This reduces the 95th percentile map shard time for type-checking 120K
packages to 8min from 20min.

Also: move the I/O-limiting counting semaphore and the NoGoError check
from FindPackage to findPackage so that all implementations benefit.

Change-Id: I43527122262cf80475dd3212d78c340e1c71e36c
Reviewed-on: https://go-review.googlesource.com/18580
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-01-13 18:09:25 +00:00
Andrew Gerrand
b81ea3a5e1 godoc: hide vendored packages from /pkg/ as we do with internal packages
Such packages may be viewed by adding ?m=all to the URL.

Fixes golang/go#13929

Change-Id: Id0ac48bc2937b5bec722b95b9a690d48d065ea6b
Reviewed-on: https://go-review.googlesource.com/18554
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-13 08:57:48 +00:00
Timothy Studd
b57d82def5 x/tools/present: add video element for slides
Change-Id: I19f7c181d9bd8148f7791925f04207a34c95ac1e
Reviewed-on: https://go-review.googlesource.com/18484
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-01-13 03:34:37 +00:00
Alan Donovan
f8ecfdb6b6 cmd/stringer: fork and tag for go1.4
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>
2016-01-11 14:24:22 +00:00
Timothy Studd
4ad533583d x/tools/godoc: fixed width limit for non-paragraph text
Change-Id: I6020e03959a434622e3e999e0054849f0bfb522f
Fixes: golang/go#13602
Reviewed-on: https://go-review.googlesource.com/18361
Reviewed-by: Francesc Campoy Flores <campoy@golang.org>
2016-01-09 02:08:43 +00:00
Alan Donovan
ae186f56a2 go/loader: don't treat unsafe specially wrt vendoring
The loader treats GOROOT's "unsafe" package specially,
with no source files and a Package of types.Unsafe.

Tested on Go 1.4.1, 1.5, and ~1.6 (tip).

Fixes issue #13882

Change-Id: I86c4e394665d86a50ec3852d6d702f0e9c5d2276
Reviewed-on: https://go-review.googlesource.com/18457
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-01-08 20:29:04 +00:00
Alan Donovan
e211dfb000 refactor/rename: fix crash with "." as -from package
Cause: the absolute cwd, not ".", must be passed to build.Import.

Also: simplify the lookup logic in findFromObjects, and handle nil
gracefully.

(No unit test---not worth faking os.Getwd.)

Fixes issue #13866

Change-Id: I7e8eede55bc83d98e2ef5e42609c287e74c04501
Reviewed-on: https://go-review.googlesource.com/18453
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-01-08 19:32:44 +00:00