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

1994 Commits

Author SHA1 Message Date
Andrew Gerrand
477d3b98e5 godoc: recognize examples with unordered output
A pared down verison of https://golang.org/cl/20458
that is compatible with Go 1.5.

Fixes golang/go#10149

Change-Id: I550b097dc1cd65d0711bdea943f2b0678cfbc5fd
Reviewed-on: https://go-review.googlesource.com/22032
Reviewed-by: Caleb Spare <cespare@gmail.com>
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>
2016-04-22 02:03:42 +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
Andrew Gerrand
0c4d9b3099 godoc/dl: remove broken link to old releases
Fxies golang/go#15284

Change-Id: I64db7db801eb8ab89765aeb6ab3f3facad4f21be
Reviewed-on: https://go-review.googlesource.com/22165
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-18 04:04:19 +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
Robert Griesemer
764c4ccf44 go/gcimporter15: match https://golang.org/cl/22096/
Read and write position info.

Change-Id: Ibe4a914ff51911bbda656b08f1397132e495ab8a
Reviewed-on: https://go-review.googlesource.com/22098
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-04-15 16:49:27 +00:00
Simon Jefford
4b9c8b56b8 cmd/godoc: fix multi-paragraph marker rendering
Fixes golang/go#15231

Change-Id: Ia0e00f1eca41dfdd85158feb3fa300df40cfa185
Reviewed-on: https://go-review.googlesource.com/21972
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-14 23:55:41 +00:00
Andrew Gerrand
3868f57059 godoc/static: replace version strings with actual versions
This will allow the source installation instructions to
always show the current version, but only when that version
is a release version.

Fixes golang/go#14371

Change-Id: Ibfad8054f3c75d9320ca94ba5149ab9bf052157e
Reviewed-on: https://go-review.googlesource.com/22056
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-14 23:46:28 +00:00
Robert Griesemer
5da1e91fb2 go/gcimporter15: match https://golang.org/cl/21939/
Plus cleanups from https://golang.org/cl/21963/.

Change-Id: Ifb216081581950f38d73bcb5f22e2ca7acd64f01
Reviewed-on: https://go-review.googlesource.com/21965
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-04-13 17:25:25 +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
Robert Griesemer
b9ac36caf8 go/gcimporter15: match https://golang.org/cl/21896/
Change-Id: I1cd7a77617658c057c863bd311470f1f22062aee
Reviewed-on: https://go-review.googlesource.com/21900
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-04-12 19:34:05 +00:00
Alan Donovan
51487f711d x/tools: remove remaining files tagged for Go 1.4
(accidentally omitted from https://go-review.googlesource.com/20810)

Change-Id: Ib6ee4b2e43b6f32c5c0c031910087cc39d5c5d14
Reviewed-on: https://go-review.googlesource.com/21862
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-04-12 18:58:24 +00:00
Dmitri Shuralyov
d601baae9c go/vcs: apply test style improvements from cmd/go
Apply style improvements to TestFromDir from golang/go@b6cd6d7d32,
in order to keep them in sync.

Check for error when creating a directory, its successful existence is a
precondition for the test to run.

Helps golang/go#11490.

Change-Id: I87054114c84aead96977f603ca3bd9eccfcfbd5e
Reviewed-on: https://go-review.googlesource.com/21795
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2016-04-12 07:00:54 +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
Dmitri Shuralyov
13c24a6d6a go/vcs: report correct directory for 'no version control'
Apply golang/go@b99fdb2a11.

Updates golang/go#6175.
Helps golang/go#11490.

Change-Id: I897bac1bac94b53e950cb5cf5e572d25a7c5996b
Reviewed-on: https://go-review.googlesource.com/21342
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-08 03:23:12 +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
Audrey Lim
52d9c872e3 x/tools/present: parse presenter notes and record them in Section struct
This is the first of a series of changes that add support for
speaker notes to the Go present tool. This is done by displaying
slides with speaker notes on a second window, and synchronizing
both windows.

Updates golang/go#14654

Change-Id: Ic7b158d1e40f9e7e58d01791c88909f5619ce87f
Reviewed-on: https://go-review.googlesource.com/21485
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-07 00:13:27 +00:00
Robert Griesemer
83f918d66b go/gcimporter15: update gcexporter to match gc export format
Change-Id: Icd84cbef6463ba584a2a29f01b23c7e4542d0101
Reviewed-on: https://go-review.googlesource.com/21618
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-04-06 22:12:38 +00:00
Alan Donovan
f07cde3d91 refactor/eg: fix build after deletion of x/tools/go/types
Change-Id: Ic8d9c37230b3359a3caa7514c89eae9595f2fb80
Reviewed-on: https://go-review.googlesource.com/21584
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-04-06 22:02:45 +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
fe1488f8ab present: fix misspelled TODO
Change-Id: Id984c4e5c7cde4a5ecf3ae783441fc866d86d404
Reviewed-on: https://go-review.googlesource.com/21527
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2016-04-06 00:42:05 +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
Robert Griesemer
44f369b779 gco/gcimporter15: update importer to match new gc binary export format
This is simply a copy of std lib's go/internal/gcimporter/bimport.go
with updated header comment and build tag. No semantic changes.

This will fix part of the x/tools build break at tip. The other part
is to adjust bexport.go (next CL).

Change-Id: Ibc37fae7e0d0447fdea9e3a733aa38589735c59a
Reviewed-on: https://go-review.googlesource.com/21543
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-04-05 20:22:26 +00:00
Brad Fitzpatrick
02e8ee6893 imports: add Options.FormatOnly
Fixes golang/go#14500

Change-Id: Ied9d772e5f606ce6716193faa2c1a285f0ab00b9
Reviewed-on: https://go-review.googlesource.com/21532
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-04-05 16:34:54 +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
Alan Donovan
6361b5799a go/pointer: clarify a comment
Change-Id: Ia434ca4e7259cdb9a6f50d51432977fd31be27db
Reviewed-on: https://go-review.googlesource.com/21391
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-04-01 17:12:30 +00:00
Alan Donovan
84e7bc0dd3 go/loader: don't pass ldflags to cgo
Although these flags are harmless on linux, they
cause clang on darwin to issue an error about
unused flags (-lpthread).  We only care about compilation
so we don't need them.

Change-Id: I0fc756e2f4d7a829d43b5aa912c4e4b24a802a1c
Reviewed-on: https://go-review.googlesource.com/21283
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-29 18:37:41 +00:00
Alan Donovan
0ed9f242ee go/loader: update stdlib test after changes to stdlib
The os/user.lookup function no longer exists so instead we use
os/user.current.  (This function also existed in go1.5.)

Change-Id: Ic66d80acc186289331f1023e0145370feab6a001
Reviewed-on: https://go-review.googlesource.com/21281
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-29 16:31:44 +00:00
Alan Donovan
0d7417cc02 go/pointer: disable analysis of runtime package
It has few interesting effects on aliasing and it contains a lot of
unsafe code that we can't analyze.

Change-Id: I66d3592ea7797802c6be36eb30fd17e2ee307e50
Reviewed-on: https://go-review.googlesource.com/21260
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-29 16:14:39 +00:00
Akihiro Suda
681404b4b2 go/loader: support pkg-config
Fix golang/go#13526

Signed-off-by: Akihiro Suda <suda.kyoto@gmail.com>

Change-Id: I015a3777c345ec06455ebf275c6acc246e8be73d
Reviewed-on: https://go-review.googlesource.com/21121
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-29 01:50:51 +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
David R. Jenni
c6be41b91f go/ast/astutil: add merging pass to AddImport and AddNamedImport.
After inserting an import, merge all import declarations.

Fixes golang/go#14075.

Change-Id: I17fceb60f490deced2ee8eadf78091720580ffa1
Reviewed-on: https://go-review.googlesource.com/19828
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-27 21:31:10 +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
Idora Shinatose
3b9441cce4 go/importer: fix doc typo
Fix the following issue detected by golint:

	import.go:9:1: package comment should be of the form "Package importer ..."

It makes the package comment more consistent with other packages.

Change-Id: I1415066c136ce249af19d70848a38203caf7c9c7
Reviewed-on: https://go-review.googlesource.com/21177
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-26 09:02:56 +00:00
Robert Griesemer
5a2fc32f44 imports: adjust vendored packages test to keep working against 1.6
The prior commit fixed this test for tip (1.7) but broke it for 1.6.

Change-Id: Ic39d215ac8bc60dba4b66201f1f16713b2e02d9c
Reviewed-on: https://go-review.googlesource.com/21144
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-25 17:41:17 +00:00
Robert Griesemer
35f54f0ea0 imports: adjust tests to check vendored packages again (fix build)
Change-Id: I616dccc07c255bb7ca1146ad0d37d05999eeb772
Reviewed-on: https://go-review.googlesource.com/21142
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-25 17:11:48 +00:00
Dominik Honnef
47218d24f2 cmd/guru: whicherrs: don't crash on dead code
Change-Id: I5e80613ec27a4edb45516ff1ff3a88d5f9cb3a67
Reviewed-on: https://go-review.googlesource.com/21130
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-25 16:35:34 +00:00
Dominik Honnef
824b504fc7 cmd/guru: emacs: highlight all instances of an identifier
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>
2016-03-25 02:11:11 +00:00
David R. Jenni
21cc49bd03 cmd/guru: fix assignment to entry in nil map.
Fixes golang/go#14746.

Change-Id: Id79c43c7d3700b98c010aa7dc0aac2463164be09
Reviewed-on: https://go-review.googlesource.com/20988
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-21 19:52:00 +00:00
Hariharan Srinath
936084890a x/tools/godoc/vfs: adds NewNameSpace() and emptyVFS for better behavior
The existing implementation of NameSpace implicitly assumes that a
FileSystem with a directory at the top will be mounted at the root
mount point "/" of the NameSpace. If this is not the case, then
Stat("/") will fail even if ReadDir("/") succeedes. This is unexpected
behavior which breaks directory traversal routines (eg. http.FileServer).

This CL adds an unexported implementation of FileSystem called emptyVFS
that emulates an empty directory and adds a NewNameSpace() function that
binds emptyVFS to "/" so that unexpected behavior does not arise even if
the use does not mount anything explicitly at "/".

Latest patch set causes the FileInfo of the empty top level emulated
directory to return "/" for Name() and Zero Time for ModTime() and
removes the related struct state fields being used in the previous
implementation.

Fixes golang/go#14190

Change-Id: Idce2fc3c9b81206847a33840d76b660059d53d18
Reviewed-on: https://go-review.googlesource.com/19445
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-21 00:49:05 +00:00
Ahmy Yulrizka
6e94e8a89f imports: cleanup test due to assignment copies of sync.Once
go vet detected that the value of pkgIndexOnce
is copied through assignments in the test.
This patch fixes that by converting it to *sync.Once instead.

Change-Id: I90b2252942625b2f8a93eb5da24d16c6a8a56e4e
Reviewed-on: https://go-review.googlesource.com/20910
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-20 22:53:05 +00:00
Alan Donovan
fcde77432e go/gcimporter15: create dummy "anyType" to fix breakage
The previous CL added a duplicate InvalidType to the predecl table so
that it tracked the one used by gc, but this caused it to fail an
assertion of uniqueness, and I ran the wrong tests.

Change-Id: I56342046cea328e503d917127f5b12205df7999a
Reviewed-on: https://go-review.googlesource.com/20870
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-18 17:20:55 +00:00
Alan Donovan
8a9be374d7 go/gcimporter15: support invalid types and constants in binary export data
Although invalid types and unknown constant values should never appear
in .a files (since gc will stop with an error before writing export
data), they can now be faithfully encoded and decoded.  This makes the
protocol robust for IDE-like applications that must deal with incomplete
or incorrect programs.

(Corresponding std lib CL: https://go-review.googlesource.com/20828)

Change-Id: I539ffd951b90f01705a7f23ec778c623c729d9a0
Reviewed-on: https://go-review.googlesource.com/20827
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-18 16:35:36 +00:00