1
0
mirror of https://github.com/golang/go synced 2024-10-01 03:38:32 -06:00
Commit Graph

2047 Commits

Author SHA1 Message Date
Josh Bleecher Snyder
6d32be89d5 imports: minor fixes
These are mostly comments for CL 24941 that didn't
get sent quickly enough.

strings.Trim(`\"`) works, but by accident.
It trims all leading and trailing "s and \s,
but there are never leading or trailing \s.

Semantic line breaks and punctuation cleanup.

The reflow of comments in the pkgName == "main" if
block is to silence this spurious vet failure:

fix.go:247: +build comment must appear before package clause and be followed by a blank line

Plain sync.Once values are enough.

Change-Id: I241f3025031b6f21605da78ea52066713a203327
Reviewed-on: https://go-review.googlesource.com/24983
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-16 22:16:59 +00:00
Robert Griesemer
c550f66b0b go/gcimporter15: backport of https://golang.org/cl/23606/
Change-Id: I24a6a844e179dd1b69c90c5834d7998cb963c543
Reviewed-on: https://go-review.googlesource.com/24974
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-07-15 21:35:32 +00:00
Robert Griesemer
3f933d433a go/gcimporter15: backport of https://golang.org/cl/23012/
Fixes golang/go#16365.

Change-Id: I8e33fbd9f1bf1b4b5d85a5c972ad43414cea57cb
Reviewed-on: https://go-review.googlesource.com/24973
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-07-15 21:35:22 +00:00
Brad Fitzpatrick
ffe4e61c64 imports: add configuration mechanism to exclude directories
Each $GOPATH entry may have a file $GOPATH/src/.goimportsignore which
may contain blank lines, #comment lines, or lines naming a directory
relative to the configuration file to ignore when scanning.  No
globbing or regex patterns are allowed.

Updates golang/go#16367 (goimports speed)
Fixes golang/go#16386 (add mechanism to ignore directories)

Change-Id: I8f1a88ae6c4d0ed3075444d70aec3e2228c5ce6a
Reviewed-on: https://go-review.googlesource.com/24971
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-07-15 19:48:34 +00:00
Brad Fitzpatrick
7c26c99973 imports: do less I/O finding the package name of an import
When goimports was run on a file like:

    package main

    import (
        "example.net/foo"
        "example.net/bar"
    )

    var _, _ = foo.Foo, bar.Bar

... even though there looks to be no work to do, it still needs to
verify that "example.net/foo" is really package "foo" (even though it
looks like it) and "example.net/bar" is really package
"bar". (Packages in the standard library are hard-coded since the
previous commit and not verified for consistency since they're always consistent)

To do that verification for non-std packages, go/build.Import was
being used before, but Import reads all files in the directory to make
sure they're consistent. That's unnecessary. Instead, stop after the
first file. If example.net/foo has foo.go with "package foo" and
just_kidding.go with "package other", we never read that far to find
the inconsistency. Oh well. Prefer speed.

Updates golang/go#16367

Change-Id: I9fc3fefbee0e8a6bc287bf2a565257fb9523fd5c
Reviewed-on: https://go-review.googlesource.com/24948
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-07-15 19:34:14 +00:00
Alan Donovan
ef6b6ebf3b cmd/guru: what: include imported package names in sameids
+ Test.

Change-Id: Ib7ef99786f5b60bb3e56ced9588d2ba5725576e1
Reviewed-on: https://go-review.googlesource.com/24949
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-07-15 18:55:24 +00:00
Alan Donovan
92480e4760 cmd/guru: update Emacs installation documentation
I was going to add a hook to enable go-guru-hl-identifier-mode
as a side effect of go-mode, but a person I consulted said that
was bad form; instead I merely documented it.

Change-Id: I48b00b71c7ba485b3d632211923509a74281acbe
Reviewed-on: https://go-review.googlesource.com/24834
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-15 15:54:54 +00:00
Alan Donovan
9c3986db53 refactor/rename: fix two bugs related to MS Windows' path separator
In the package, the added import declarations used backslashes.
In the test, filenames in warning messages used backslashes.
Now both use forward slash.

Fixes golang/go#16384

Change-Id: I43116aab0b3209305f23ed9def7c4adf3259941e
Reviewed-on: https://go-review.googlesource.com/24943
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-07-15 14:58:04 +00:00
Brad Fitzpatrick
e047ae774b cmd/goimports, imports: make goimports great again
I felt the burn of my laptop on my legs, spinning away while processing
goimports, and felt that it was time to make goimports great again.

Over the past few years goimports fell into a slow state of disrepair
with too many feature additions and no attention to the performance
death by a thousand cuts. This was particularly terrible on OS X with
its lackluster filesystem buffering.

This CL makes goimports stronger, together with various optimizations
and more visibility into what goimports is doing.

* adds more internal documentation

* avoids scanning $GOPATH for answers when running goimports on a file
  under $GOROOT (for Go core hackers)

* don't read all $GOROOT & $GOPATH directories' Go code looking for
  their package names until much later. Require the package name of
  missing imports to be present in the last two directory path
  components.  Then only try importing them in order from best to
  worst (shortest to longest, as before), so we can stop early.

* when adding imports, add names to imports when the imported package name
  doesn't match the baes of its import path. For example:
        import foo "example.net/foo/v1"

* don't read all *.go files in a package directory once the first file
  in a directory has revealed itself to be a package we're not looking
  for. For example, if we're looking for the right "client" for "client.Foo",
  we used to consider a directory "bar/client" as a candidate and read
  all 50 of its *.go files instead of stopping after its first *.go
  file had a "package main" line.

* add some fast paths to remove allocations

* add some fast paths to remove disk I/O when looking up the base
  package name of a standard library import (of existing imports in a
  file, which are very common)

* adds a special case for import "C", to avoid some disk I/O.

* add a -verbose flag to goimports for debugging

On my Mac laptop with a huge $GOPATH, with a test file like:

	package foo
	import (
	       "fmt"
	       "net/http"
	)

	/*

	*/
	import "C"

	var _ = cloudbilling.New
	var _ = http.NewRequest
	var _ = client.New

... this took like 10 seconds before, and now 1.3 seconds. (Still
slow; disk-based caching can come later)

Updates golang/go#16367 (goimports is slow)
Updates golang/go#16384 (refactor TestRename is broken on Windows)

Change-Id: I97e85d3016afc9f2ad5501f97babad30c7989183
Reviewed-on: https://go-review.googlesource.com/24941
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-07-15 05:29:07 +00:00
Alan Donovan
b3887f7a17 refactor/rename: fix spurious conflict report when renaming x/foo to y/foo
There is no need to check for import conflicts when the package name
doesn't change.  Add test.

Also, when reporting a (non-spurious) import conflict, make clear that
the error is just a warning.  Add a test for same.

Change-Id: Idde0483b502cd041fd893230fec06b8533f54f3c
Reviewed-on: https://go-review.googlesource.com/24917
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-07-14 18:43:43 +00:00
Brad Fitzpatrick
0835c73534 imports: special case rand.Read, prevent math/rand by chance
In Go 1.7, math/rand.Read was added. Previously, the only package
containing "rand.Read" was "crypto/rand".

goimports was updated to know that, and zstdlib.go contains a note
that it's ambiguous:

        "rand.Perm":        "math/rand",
        "rand.Prime":       "crypto/rand",
        "rand.Rand":        "math/rand",
        // "rand.Read" is ambiguous
        "rand.Reader":                   "crypto/rand",
        "rand.Seed":                     "math/rand",
        "rand.Source":                   "math/rand",

The intention originally was that such ambiguous things would
never be resolved, even randomly.

But a later change added support for build.Default.SrcDirs, which
meant GOROOT was also searched for ambiguous things. Or maybe I forget
the history.

In any case, when goimports tried to resolve "rand.Read", the
findImportStdlib check was returning nothing, which lead to the
$GOROOT being searched, where math/rand was picked by chance. That's a
dangerous default when the intentional might've been crypto/rand.

Special case it and prefer crypto/rand if there's no more specific
clue either way.

Change-Id: Ib5f8f297f72fa309d5ca9b15a37493df2e17567c
Reviewed-on: https://go-review.googlesource.com/24847
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-07-14 05:39:27 +00:00
Alan Donovan
cda5280914 cmd/guru: fix quoting bug in Emacs binding
combine-and-quote-strings is buggy.  The value of this expression:
 (split-string-and-unquote (combine-and-quote-strings '("a" "" "b")))
is ("a" "b").  Consequently, if go-guru-scope is "", the following
"-tags" flag is interpreted as the scope.

Change-Id: I2955ffa2b95914e01d44b52690e810f816076d5c
Reviewed-on: https://go-review.googlesource.com/24746
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-07-12 13:22:42 +00:00
Parker Moore
130914b004 tip: update package doc to refer to stable code
This comment was written and has not been changed since this package was
created: https://www.youtube.com/watch?v=1rZ-JorHJEY

It is no longer called 'tipgodoc', and it is no longer all that 'new'. This
change request updates that text to reflect the current state of the 'tip'
command.

Change-Id: I4ce56fb9a3bd617cf92f8d53df5a2d4726085a9a
Reviewed-on: https://go-review.googlesource.com/24860
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-11 22:47:40 +00:00
Alan Donovan
35c6e68a1a cmd/guru: update link to documentation
Change-Id: Ia50c7878b0ba3c6576acf56b033beda122812c76
Reviewed-on: https://go-review.googlesource.com/24835
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-07-08 22:10:47 +00:00
Alan Donovan
2b3249681b cmd/guru: add menu to Emacs
Change-Id: Ife18d22f8f9b81a0e898a2b5da202feb1df23852
Reviewed-on: https://go-review.googlesource.com/24832
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-08 18:46:17 +00:00
glorieux
527b253f58 x/tools/cmd/present: Fix present not working on Safari
As described on https://github.com/golang/go/issues/16216 present is not
currently working on Safari because of the use of ES6 JavaScript let
statements.
The solution is to use var statements instead of let.

Fixes golang/go#16216

Change-Id: I44c84f920aa41dfc8de5997ab50a440de6d57093
Reviewed-on: https://go-review.googlesource.com/24721
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-07-03 04:58:21 +00:00
Robert Griesemer
6c3528d5c1 go/gcimporter15: backport https://golang.org/cl/24648/
Change-Id: Id85050b236f5da2c705c45163c90fef1a396e8f8
Reviewed-on: https://go-review.googlesource.com/24700
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-07-01 19:20:20 +00:00
Alan Donovan
0d2bde8553 go/ast/astutil: describe fewer CallExprs as "conversions"
Only unary CallExprs with no ellipsis, f(x), are ambiguous.

Change-Id: If4f17445ab0725dee916992db133eac5536133a7
Reviewed-on: https://go-review.googlesource.com/24552
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-06-30 18:40:56 +00:00
Josh Bleecher Snyder
1727758746 imports: add unsafe symbols to zstdlib
Change-Id: Ia5856e2197925671ebaa5e673af3e97fad1cdaee
Reviewed-on: https://go-review.googlesource.com/24463
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-06-24 22:29:30 +00:00
kortschak
8b3828f1c8 cmd/present: add request address to logged errors
Change-Id: I504d29d7196b8c61cff5e92bb4244a34c9c41fa8
Reviewed-on: https://go-review.googlesource.com/24331
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-06-22 22:42:38 +00:00
Andrew Gerrand
a2a552218a godoc: rate limit file parsing on startup, improve diagnostics
When building the corpus of local packages, a "too many open files"
error would cause some directories inside GOPATH to be skipped.
Further, the error would not be reported because it was masked by a
"file not found" error from the GOROOT VFS layer.

This change adds a rate limit around parsing files when buildling
the directory tree, error reporting when godoc is run with -v, and
fixes the masked error issue in the vfs package.

It's possible that the rate limiting could be put into the
godoc/vfs/gatefs package, but I tried making the gate account for
open files (not just individual open/close/read/write operations)
but then godoc just hard locks (it wasn't designed to only open 20
files at once).

Change-Id: I925d120b53d9a86430b6977cb90eb143785ecc48
Reviewed-on: https://go-review.googlesource.com/24060
Reviewed-by: Dave Day <djd@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-06-14 05:10:12 +00:00
Audrey Lim
3d35e41306 x/tools/present: fix null notes value on initial slide
Change-Id: I370fdf2ef7de33976028f8cd872402a08d8f103c
Reviewed-on: https://go-review.googlesource.com/24050
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-06-14 00:56:51 +00:00
Filippo Valsorda
95963e031d imports: support symlinks in GOPATH
The go tool will import a package with a import path that traverses
symlinks with no problems, but goimports would remove that import
because it would fail to recognize the package as existent.

Fixes golang/go#14845

Note: if the file you are currently processing also has a name inside
the symlink, you might have to use the "long" path for vendoring to
work, as it wouldn't be recognized as "deeper" than the vendor folder
otherwise. For example in this tree:

.
├── myfile.go
└── x
    ├── vendor
    │   └── mypkg
    │       └── foo.go
    └── y -> ..

If myfile.go imports mypkg, you will have to process it as
./x/y/myfile.go, not ./myfile.go.

Change-Id: Ic8f41baed3f28d4e9b813160d91aef09ece1fc9f
Reviewed-on: https://go-review.googlesource.com/23803
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-06-09 03:45:06 +00:00
Audrey Lim
b41cbfc0fa x/tools/present: add presenter notes documentation
Fixes golang/go#14654

Fixes golang/go#12355

Change-Id: I0c05db624170f7bef5883192b47b618ca343a830
Reviewed-on: https://go-review.googlesource.com/21489
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-06-01 21:14:44 +00:00
Audrey Lim
19c2ab042a x/tools/present: display presenter notes and synchronize browser windows
Change-Id: If7d5cc52f7594c141060d40e8393ac69cb7ba9ad
Reviewed-on: https://go-review.googlesource.com/21488
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-06-01 05:16:27 +00:00
Konstantin Shaposhnikov
6eef0b4fad cmd/godoc: fix anchor links for constructors
Fixes golang/go#15866

Change-Id: I67f41026c64046ca581251fb0851d337d2651560
Reviewed-on: https://go-review.googlesource.com/23531
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-28 22:14:14 +00:00
Konstantin Shaposhnikov
3560419ce9 godoc/static: makestatic.go: gofmt generated code
Change-Id: Ibe0948fa283af94b1213e9ef344ef9eda6e59c05
Reviewed-on: https://go-review.googlesource.com/23532
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-28 22:13:57 +00:00
Yasuhiro Matsumoto
ba484b064f cmd/bundle: move down imports of external package
imports should be ordered like

    import (
    	"fmt"

    	"golang.org/x/text"
    )

Change-Id: I000374833de370463d772c2596c7ac6ee5e9725c
Reviewed-on: https://go-review.googlesource.com/23026
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-05-26 02:53:53 +00:00
Monty Taylor
6d483ee832 vcs: Add support for git.openstack.org
Go is being proposed as an officially supported language for elements of
OpenStack:

  https://review.openstack.org/#/c/312267/

As such, repos that exist in OpenStack's git infrastructure
are likely to become places from which people might want to go get
things. Allow optional .git suffixes to allow writing code that
depends on git.openstack.org repos that will work with older go versions
while we wait for this support to roll out.

Change-Id: I1f7be6b7aae63f9c554dbcdbfa46855bcff321df
Reviewed-on: https://go-review.googlesource.com/23362
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-24 15:53:25 +00:00
Andrew Gerrand
9ae4729fba godoc/proxy: use HTTPS when bouncing through to the playground
Fixes golang/go#15692

Change-Id: I0d0731b249de9399b972c8ee9cf9e0f355d4fcc0
Reviewed-on: https://go-review.googlesource.com/23241
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-19 07:11:34 +00:00
Cezar Sa Espinola
c86fe5956d imports: try importing pkg path from vendor when looking for pkg name
Since CL 17728 goimports was using the file path to try finding packages
inside its /vendor directory. This CL builds upon this previous work to
also consider packages inside /vendor when converting an import path to
a package name.

Change-Id: I173472ac51e3f681d758ec52add60ffc04c62c1a
Reviewed-on: https://go-review.googlesource.com/22020
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-10 17:11:45 +00:00
Robert Griesemer
fbb6674a74 go/gcimporter15: match recent changes to export format
This is a copy&paste fix of the changes in golang.org/cl/22839.

Fixes https://github.com/golang/lint/issues/207 .

Change-Id: I2c4850395c8aa330ea27ad629b21ac21b973ef75
Reviewed-on: https://go-review.googlesource.com/22963
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-05-10 02:37:36 +00:00
Alan Donovan
3f1f7eeff1 go/gcimporter15: set Pos attribute of decoded types.Objects
BImportData now requires a token.FileSet.
Column numbers are not exported, and are always reported as 1.
Line numbers greater than the limit (currently 64K) are reported as 1.

+ Test that file/line info is correctly preserved for the entire
  standard library.

Change-Id: I80cf370685320240dfb262d36fafd6cdf8569bfb
Reviewed-on: https://go-review.googlesource.com/22788
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-05-09 13:28:09 +00:00
nwidger
2c200eec40 cmd/godoc: Add anchor links to functions, types and methods
Added anchor link beside each function, type and method definition in
godoc's generated HTML.  Anchor links are only shown when the mouse is
hovering over the definition.  The link body is the Unicode PILCROW SIGN
character (&#xb6; HTML entity).

Fixes: golang/go#13748

Change-Id: I645269f6c229f76b2882899e1a7483577877ac30
Reviewed-on: https://go-review.googlesource.com/20246
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-05 16:36:38 +00:00
Francesc Campoy
0b2f4dcf4d tools: fix 'Split called after Scan'
Change-Id: I2dae23440d33fa830107575987805e858e4bf4a7
Reviewed-on: https://go-review.googlesource.com/22749
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-04 16:29:22 +00:00
Robert Griesemer
8dab6f1129 go/gcimporter15: adopt changes from golang.org/cl/22714
Fixes x/tools build.

Change-Id: Ifd958ff1293ec2c4fd971813ae7b199b5d8244fe
Reviewed-on: https://go-review.googlesource.com/22721
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-05-03 16:15:14 +00:00
Andrew Gerrand
c9a2436076 cmd/godoc: set Strict-Transport-Security header in production
This coerces browsers into enforcing HTTPS-only for golang.org.

Change-Id: I91a4cc64b10b9836ef5623314a3cf22a54033dc2
Reviewed-on: https://go-review.googlesource.com/22673
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-02 17:22:30 +00:00
Andrew Gerrand
0238d429c7 cmd/tip: set Strict-Transport-Security header in production
Change-Id: I33db74025785c802a634f324ad110a4ec5381c1f
Reviewed-on: https://go-review.googlesource.com/22674
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-02 17:21:26 +00:00
Andrew Gerrand
f3109af80d playground: fix share URL
The baseURL is used to construct the target URLs for both /compile
and /share. When I changed it recently, I forgot about the latter case.

Change-Id: Icde617b1cc3d31d98ca4b62e313b9d886253f1cc
Reviewed-on: https://go-review.googlesource.com/22689
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-02 16:10:21 +00:00
Konstantin Shaposhnikov
d4437bf597 imports: add go:generate directive for generating zstdlib.go
Change-Id: I8c54e01799f690819cda746ad5fb7c4d87e769c4
Reviewed-on: https://go-review.googlesource.com/22541
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-29 02:56:15 +00:00
Alan Donovan
686d0ad5b8 go/ssa: reduce set of expected indirect imports
...now that gc's export data records fewer dependencies.

Change-Id: Ie0f68f1f7b0825f6d2c100dfe189be017383db60
Reviewed-on: https://go-review.googlesource.com/22584
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-04-28 21:42:55 +00:00
Robert Griesemer
c5c16cf68a go/gcimporter: update importer to match latest gc export data changes
Adjustments taken from https://golang.org/cl/22580.

Change-Id: Ic88137b410767bd17e3d6142cec2b5a112df56be
Reviewed-on: https://go-review.googlesource.com/22582
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-04-28 21:04:03 +00:00
Alan Donovan
14480f21a0 cmd/guru: for determinism, sort referrers output in test
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>
2016-04-28 19:07:35 +00:00
Alan Donovan
56005b4126 go/ssa/interp: add intrinsic for runtime.NumGoroutine
...which is used by $GOROOT/test/goprint.go.

Change-Id: I4626b8fae3f87d9c8dd8cdcd8c05036955a36262
Reviewed-on: https://go-review.googlesource.com/22560
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-04-28 18:16:55 +00:00
Alan Donovan
50ff896a1c cmd/guru: definition: opt: avoid type checker for qualified identifiers
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>
2016-04-28 17:00:30 +00:00
Konstantin Shaposhnikov
e48e17a0b5 imports: update static stdlib index to go1.6
Change-Id: Ie19594472ec0fa2455a3f1aeac681e74eb3a6b0b
Reviewed-on: https://go-review.googlesource.com/22539
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-28 14:59:03 +00:00
Alan Donovan
0f5f9fcf9a cmd/guru: implements: if selected expr is a value, use its type
...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>
2016-04-28 14:33:14 +00:00
Alan Donovan
9ae7e1769c cmd/guru: Emacs: run guru asynchronously using compilation-mode
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>
2016-04-28 14:21:22 +00:00
Andrew Gerrand
94f857c7cf cmd/tip: bump verison serving tip.golang.org to HEAD
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>
2016-04-28 01:23:19 +00:00
Andrew Gerrand
1f1b3322f6 playground: hit golang.org/compile endpoint instead of play.golang.org
Not sure why this was originally going via the playground. It needn't.

Change-Id: I40b5886a56ba4b941ff74f4bc325625412d7eaff
Reviewed-on: https://go-review.googlesource.com/22497
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-27 05:26:01 +00:00