1
0
mirror of https://github.com/golang/go synced 2024-09-30 16:28:32 -06:00
Commit Graph

565 Commits

Author SHA1 Message Date
Keith Rarick
ed69e84b15 cmd/goimports, imports: add -local flag
This allows the caller to indicate they want certain
import paths to sort into another group after 3rd-party
imports when added by goimports. For example, running
'goimports -local example.com/' might produce

    import (
        "database/sql"
        "io"
        "strconv"

        "golang.org/x/net/context"

        "example.com/foo/bar"
        "example.com/foo/baz"
    )

Resolves golang/go#12420

Change-Id: If6d88599f6cca2f102313bce95ba6ac46ffec1fe
Reviewed-on: https://go-review.googlesource.com/25145
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-07-23 01:23:54 +00:00
Brad Fitzpatrick
f3284303b6 cmd/goimports: permit complete filename for -srcdir
Updates dominikh/go-mode.el#146
Updates golang/go#7463 (for https://golang.org/cl/23444)

Change-Id: Ieb769329531050b803528acce0c50d02786533b6
Reviewed-on: https://go-review.googlesource.com/25140
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-07-21 20:15:52 +00:00
Dmitri Shuralyov
5b59ce8b5f cmd/bundle: More idiomatic flag.Usage.
The responsibility of flag.Usage is to print usage to stderr:

> Usage prints to standard error a usage message documenting all
> defined command-line flags.

Calling os.Exit(2) is outside of its scope, flag package does that.

Change-Id: I3eef2b796e5ddedff6d5927dbcdbfff3a6082270
Reviewed-on: https://go-review.googlesource.com/23788
Reviewed-by: Joseph Holsten <joseph@josephholsten.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-07-21 15:33:57 +00:00
Michael Matloob
55296b3beb x/tools/cmd/heapview: rename heapdump to heapview
Updates golang/go#16410

Change-Id: I0133971f9a1149da6d88180fc2e378003f189cc8
Reviewed-on: https://go-review.googlesource.com/25101
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-20 19:02:34 +00:00
Michael Matloob
5dbb806c12 x/tools/cmd/heapdump: add empty heapdump command
This change creates a place where we can start building
the 'heapdump' heap viewer and analyzer

Updates golang/go#16410

Change-Id: I216e13f1ceb6790bf492cfc8cbcc4f19f12b0b9e
Reviewed-on: https://go-review.googlesource.com/25085
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-20 16:50:05 +00:00
Brad Fitzpatrick
edf8e6fef8 cmd/goimports, imports: optimize directory scanning and other things
This brings goimports from 160ms to 100ms on my laptop, and under 50ms
on my Linux machine.

Using cmd/trace, I noticed that filepath.Walk is inherently slow.
See https://golang.org/issue/16399 for details.

Instead, this CL introduces a new (private) filepath.Walk
implementation, optimized for speed and avoiding unnecessary work.

In addition to avoid an Lstat per file, it also reads directories
concurrently. The old goimports code did that too, but now that logic
is removed from goimports and the code is simplified.

This also adds some profiling command line flags to goimports that I
found useful.

Updates golang/go#16367 (goimports is slow)
Updates golang/go#16399 (filepath.Walk is slow)

Change-Id: I708d570cbaad3fa9ad75a12054f5a932ee159b84
Reviewed-on: https://go-review.googlesource.com/25001
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-07-19 03:21:45 +00:00
Alan Donovan
b825d2868c cmd/oracle: announce planned deletion in 2.5 months
Change-Id: Id3e1dd598707c04be883b168add0a7049dc45874
Reviewed-on: https://go-review.googlesource.com/25031
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-07-18 23:21:13 +00:00
Alan Donovan
f2932db7c0 cmd/guru: suppress failing test on plan9
The test expectation includes the text of a UNIX ENOENT message.

Also, make the same change for (deprecated) oracle tool.

Fixes golang/go#16397

Change-Id: I8c3c6a300ff2366bfeb97cf41d34097c41aab680
Reviewed-on: https://go-review.googlesource.com/24968
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-07-18 14:28:24 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
53006ac4c2 cmd/tip: redirect from HTTP to HTTPS; update to Go 1.6
Change-Id: I7b219a991df4f71d068b62a22f69acb123ac31f0
Reviewed-on: https://go-review.googlesource.com/22367
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-27 01:13:02 +00:00
Alan Donovan
5e468032ea cmd/guru: avoid bug when -scope=""
strings.Split is not your friend.

Change-Id: I829f08f113f3340b2dd865aea47f5759a427f7c4
Reviewed-on: https://go-review.googlesource.com/22116
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-04-18 16:46:08 +00:00
Dominik Honnef
3114265539 cmd/guru: emacs: interpret byte offsets correctly
Change-Id: Id506c6c0b3f3c585781bfc38df1b665d507a7c33
Reviewed-on: https://go-review.googlesource.com/22019
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-04-17 18:15:17 +00:00
Dominik Honnef
837ce23ea3 cmd/guru: emacs: report most specific element in expand-region
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>
2016-04-17 13:26:57 +00:00
Hironao OTSUBO
321c6fd171 cmd/stringer: fixed usage line typo
Change-Id: I5852d03c0326d82c13d9e1078f9648ecc695fbbf
Reviewed-on: https://go-review.googlesource.com/22150
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-17 02:19:27 +00:00
Andrew Gerrand
c3291436fa cmd/tip: look for godoc binary under $GOPATH/bin instead of $GOROOT/bin
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>
2016-04-13 03:37:58 +00:00
Dominik Honnef
446a18e709 go/buildutil, cmd/guru: extract overlay context into buildutil
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>
2016-04-13 01:11:48 +00:00
Dominik Honnef
fb9c7fc43c cmd/guru: emacs: add function for expandiong region
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>
2016-04-13 01:08:39 +00:00
Alan Donovan
2da0720e4f cmd/guru: support streaming plain and -json output
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>
2016-04-11 19:51:55 +00:00
Audrey Lim
b75b3f5cd5 x/tools/present: add command line flag to enable presenter notes
Change-Id: I9d4414ce8bafcb13f53361b45774f379bacd886b
Reviewed-on: https://go-review.googlesource.com/21486
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-07 00:38:29 +00:00
Robert Griesemer
adaaa07486 x/tools: delete x/tools/go/types and dependent packages/client files
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>
2016-04-06 21:52:49 +00:00
Andrew Gerrand
e77df0732c cmd/tip: use manual scaling for tip.golang.org
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>
2016-04-06 00:03:48 +00:00
Andrew Gerrand
f2e4f834ec cmd/present/static: remove unused function
Change-Id: I2d5db20ffb2ae59818b69d33d91256bc829ee6d8
Reviewed-on: https://go-review.googlesource.com/21445
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-04 05:09:31 +00:00
Dominik Honnef
74b98c2c7a cmd/guru: emacs: only check modified buffers with file names
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>
2016-03-28 14:50:23 +00:00
Dominik Honnef
fc3ceb1825 cmd/guru: emacs: update default-directory
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>
2016-03-28 14:50:15 +00:00
Dominik Honnef
999f507100 cmd/guru: emacs: store output in separate buffer
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>
2016-03-28 14:50:08 +00:00
Dominik Honnef
5c5d833208 cmd/guru: emacs: support running on nameless buffers
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>
2016-03-28 14:50:02 +00:00
Alan Donovan
35cacb533e cmd/guru: change "Method set:" to less formal "Methods:"
Change-Id: I7a43f3e9ed7e88f4f8f09d4d112c81aa037b7d8d
Reviewed-on: https://go-review.googlesource.com/21111
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-03-28 14:29:15 +00:00
Dominik Honnef
361bcb2be3 all: address vet issues, fix print calls
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>
2016-03-27 20:36:34 +00:00