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

1993 Commits

Author SHA1 Message Date
Andrew Gerrand
d8da78068e cmd/tip: add context to error values and log prints
To help track down some flakiness.

Change-Id: I2dd21abdc0f05c58857da580d962b0ab72cf52b3
Reviewed-on: https://go-review.googlesource.com/20728
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-16 04:48:27 +00:00
Robert Griesemer
1431634c56 cmd/guru: fix for prior submission (fix build)
Accidentally submitted wrong file version in
https://go-review.googlesource.com/20719.

TBR: adonovan

Change-Id: I362ded51cf9cef8cb22faf6a2334ce01678d9f4e
Reviewed-on: https://go-review.googlesource.com/20742
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-15 22:17:46 +00:00
Robert Griesemer
ce9c53141f cmd/guru: adjust test output for go1.5 (fix build)
In go1.5, go/constant (floating-point) numeric values are printed
as fractions. Correct output as necessary so that they always
appear as floating-point numbers to match golden files.

Change-Id: If63a14d8d87bb664bf6272b16345e38e8d638ead
Reviewed-on: https://go-review.googlesource.com/20719
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-15 21:51:11 +00:00
Robert Griesemer
f42ec616d3 go/gcimporter15: require go1.6 for binary import/export (fix build)
The binary import/export functionality depends on go/constant from
go1.6 - make it only available if we build against go1.6. Eventually
this packet will be replaced by std lib go/importer functionality.

Change-Id: If96cf2e889daf1250152d7719afa64ad1ba8fb0e
Reviewed-on: https://go-review.googlesource.com/20716
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-15 20:04:44 +00:00
Robert Griesemer
95e5e62424 imports: fix TestFindImportVendor for 1.5 (fix build)
TBR=adonovan

Change-Id: I7edeb180bdf09648e7539b9371db0d14272b9030
Reviewed-on: https://go-review.googlesource.com/20697
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-15 04:38:51 +00:00
Robert Griesemer
8852e49d27 imports: adjust tests to fix build
These changes will need to be reverted once we use
vendoring in the stdlib again, but it's trivial to
do so when the time comes.

TBR=adonovan

Fixes #14823.

Change-Id: I2173c48d5466874492affc679332f6484bf96592
Reviewed-on: https://go-review.googlesource.com/20695
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-15 04:38:37 +00:00
Robert Griesemer
cac5711748 go/gcimporter15: update build tag for binary import (fix build for 1.6)
Also: renamed file to match 1.7 tag.

Fixes golang/go#14824.

Change-Id: Iea92292d93c1140e3396678bc37f50f0348e616a
Reviewed-on: https://go-review.googlesource.com/20694
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-15 01:10:22 +00:00
Robert Griesemer
48737e9c89 go/gcimporter15: update import/export to match std lib at tip
This change copies the respective changes from https://golang.org/cl/20605.

There is a format conflict here - we are going to track tip, not 1.6.
This change should fix the issue when testing against tip.

Fixes golang/go#14824.

Change-Id: I58e79cc65748e7a3e5c8486c6cee339884110a07
Reviewed-on: https://go-review.googlesource.com/20693
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-15 00:34:34 +00:00
Brad Fitzpatrick
093d7650ab Revert: godoc: Implement Unordered Output.
Revert https://go-review.googlesource.com/#/c/20458/3 (git rev 3d2dab63)

It doesn't compile.

Change-Id: I62fb10fe611e9ba0f599f037b03a91600b024d30
Reviewed-on: https://go-review.googlesource.com/20492
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-09 22:01:01 +00:00
Brady Catherman
3d2dab63d9 godoc: Implement Unordered Output.
When an Example's output is listed as being Unordered this will make
godoc display "Unordered output:" rather than the normal "Output:".

For an example of where this is useful, see the recently added example
for math.rand.Perm().

Change-Id: I737c901102dca46434f46a48300445bb43ce34e0
Reviewed-on: https://go-review.googlesource.com/20458
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-09 21:21:03 +00:00
Dominik Honnef
c5b51756ce cmd/guru: emacs: add go-guru-debug variable
Don't print debug messages unless go-guru-debug is set.

Change-Id: I1332a0b10eba1d1107ef987734b2b787ae28d9c2
Reviewed-on: https://go-review.googlesource.com/20432
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-09 20:00:51 +00:00
Dominik Honnef
b023cf6107 cmd/guru: emacs: update scope documentation
Also fix a typo in the tool's help string.

Change-Id: I54a9ed4a5515b137b0fbf1b2391dd6fa84b2d2d8
Reviewed-on: https://go-review.googlesource.com/20474
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-09 15:55:45 +00:00
Andrew Gerrand
498e5ca207 cmd/tip: kill godoc when it fails to be ready on time
If godoc didn't come up quickly enough, we would leave it running and
then try to start another one on the same port.
The new one would fail to start, being unable to bind to the address,
causing cascading failures.

Also increase the timeout to 10 minutes.

Change-Id: I7008a39f649021ea213902d557f26bf78567026d
Reviewed-on: https://go-review.googlesource.com/20420
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-08 22:55:24 +00:00
David Brophy
e740c56c6b cover: fixed broken error message
The error message is attempting to display the line of text, but was
incorrectly using m (which is always nil) instead of line.

Change-Id: Id09f488b3b7b0e8c3c2cb6e8f0a8d635861c77ac
Reviewed-on: https://go-review.googlesource.com/19330
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-08 18:20:19 +00:00
Alan Donovan
3d26f6847a go/ssa: make *BuilderMode satisfy flag.Value
The BuilderModeFlag function does not work with flag packages (such as
Google's) that define their own FlagSet.  This change exposes a type
that satisifies flag.Value insted of a function.  That type
is *BuilderMode; there's no need for a separate wrapper type.

Change-Id: I8095b80de499e3c52a29a5c1996d1b1fe3799358
Reviewed-on: https://go-review.googlesource.com/20330
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-03-07 22:18:09 +00:00
Konstantin Shaposhnikov
53f5cdeed1 cmd/present: fix displaying line numbers for .code and .play
Line numbers match line numbers from the included file,
not the lines in the segment selected by the
.code or .play START/STOP regexps.

Fixes golang/go#5248

Change-Id: I374e7b665e98db5032446ae49e6fae00d9d2b975
Reviewed-on: https://go-review.googlesource.com/20311
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-07 22:14:29 +00:00
Konstantin Shaposhnikov
1074774aec cmd/present: fix slides movement when -play=false
Fix by removing jQuery usage from slides.js as jquery.js is only
available when play.js is included.

Fixes golang/go#9878

Change-Id: I5793350105b138d7b7645f11d814e1d2f573a73e
Reviewed-on: https://go-review.googlesource.com/20288
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-07 22:13:35 +00:00
Konstantin Shaposhnikov
7a73fe1b6c cmd/guru: emacs: add default key binding for whicherrs
Bind go-guru-whicherrs to `C-C C-o e'

Also remove go-guru-callgraph as callgraph mode is not supported
by guru.

Change-Id: Id233d178629a3cafc00e4f9640191c3d3c673cf1
Reviewed-on: https://go-review.googlesource.com/20310
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-07 15:54:09 +00:00
Alan Donovan
d2abdd5413 cmd/guru: fix nil deref when position is not in Go source
+ test

Fixes issue golang/go#14684

Change-Id: I56023bf36c307d02c71b4ddf08aee9c229fc66c1
Reviewed-on: https://go-review.googlesource.com/20247
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
2016-03-07 15:53:42 +00:00
Konstantin Shaposhnikov
b15543bacc cmd/gorename: emacs: do not auto shrink error window
Change-Id: Iffa740a15658993cd905a34333f89145952524ca
Reviewed-on: https://go-review.googlesource.com/20289
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-07 15:44:52 +00:00
Dominik Honnef
adda3a6894 cmd/guru: emacs: push mark in go-guru-definition
This allows users to swap point and mark to jump between use and
definition in the same buffer, or pop-tag-mark (M-*) to jump back to the
use even between multiple buffers.

This mirrors the behaviour of godef-jump from go-mode.

Also remove an obosolete TODO and fix a typo.

Change-Id: I614090493b565acadf359ebb4c7092f4c673fd56
Reviewed-on: https://go-review.googlesource.com/20303
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-07 15:33:11 +00:00
Dominik Honnef
459f0c0f73 cmd/guru: emacs: allow passing tags to guru
Change-Id: I2e49d050add1f764a0e41300b2cca8da699f418a
Reviewed-on: https://go-review.googlesource.com/20302
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-07 02:38:31 +00:00
Alan Donovan
2336c53cf0 cmd/guru: compute referrers as packages are type checked
This CL makes little observable difference to the behavior but paves the
way for streaming 'referrers' and (later) 'implements' queries which
scan the entire workspace, but print each result as soon as it is found.

The go/loader package now exposes a hook, AfterTypeCheck, that lets
clients inspect each package as soon as it is type-checked, and also
modify it, for instance to release unneeded data structures.

A 'referrers' query applied to an exported object must scan the entire
workspace.  It uses this hook so to gather uses of the query object in
streaming fashion.  However, for now, it still accumulates the results
and prints them all at the end, though I propose to change that in a
follow-up.

Code details:
- The referrers logic had a 2-iteration loop to load first the query
  package and then if necessary the enlarged program.  The second
  iteration has now been unrolled and split into globalReferrers.
- Queries for package names (whether in a package declaration or
  a qualified identifier) have been split off into packageReferrers.
  It now loads all direct importers of the query package,
  which catches some references that were missing before.
  (It used to inspect only the forward dependencies of the query
  package.)

Also:
- Referrers.Pos (the position of query identifier) was removed from the
  JSON output.  It's a nuisance to compute now, and it's already
  absent from the plain output.
  (In a follow-up, I plan to simplify the information content of the
  JSON output exactly what is currently printed in the plain output.)

Change-Id: Ia5677636dc7b0fe4461a5d393107665757fb9a97
Reviewed-on: https://go-review.googlesource.com/19794
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
2016-03-04 21:13:08 +00:00
Alan Donovan
ac02106e04 refactor/importgraph: document that graphs are cyclic
Change-Id: I195656b523488433945b3215558c3442cf45b2bd
Reviewed-on: https://go-review.googlesource.com/19831
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-03 22:47:59 +00:00
Hyang-Ah (Hana) Kim
51464e57af godoc/analysis: use build.Default.GOROOT instead of runtime.GOROOT
Change-Id: Ic34744557c3fbddd27590303794d384e28ff1ae3
Reviewed-on: https://go-review.googlesource.com/19781
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-03 20:16:49 +00:00
Alan Donovan
3dafbd1ba4 go/types/typeutil: make IntuitiveMethodSet(*C) nonempty for concrete types C
This fixes a bug in guru describe.

Also, add a test of IntuitiveMethodSet.

Change-Id: Ied3780807afd88e664fdb186619499670529fe33
Reviewed-on: https://go-review.googlesource.com/20166
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
2016-03-03 19:43:35 +00:00
Alan Donovan
6c84e9e3e0 cmd/guru: make fastQueryPos indirect through the -modified map
This fixes a bug in which guru reports a "query position beyond end of
file" error when making a query from an unsaved editor buffer at an
offset greater than the length of the file on disk.

Change-Id: I908c024d8dd14baa657b4227e3231fa760443732
Reviewed-on: https://go-review.googlesource.com/20167
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
2016-03-03 19:00:43 +00:00
Alan Donovan
2f1d035a8a go/gcimporter15: BExportData: inverse of BImportData
+ test

Change-Id: I8db03e19ebb4cf3888f259457aaa3c931da23f24
Reviewed-on: https://go-review.googlesource.com/20109
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-02 22:33:32 +00:00
Alan Donovan
6f233b96df cmd/guru: fix nil dereference in describe
+ test

Fixes issue golang/go#14579

Change-Id: I6fd56f10c170027f06917935ccbc28490d413d8a
Reviewed-on: https://go-review.googlesource.com/20100
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-03-01 22:59:02 +00:00
Andrew Gerrand
8b178a93c1 playground/socket: fix message buffering
Use time.After to avoid the finnicky antics of
correctly resetting a time.Timer.

Fixes golang/go#13749

Change-Id: I3f1ed17a31d981996e2bb7a8155c3ba0ec723c7d
Reviewed-on: https://go-review.googlesource.com/19942
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-02-29 11:33:26 +00:00
David R. Jenni
e852fdd89f go/ast/astutil: add function DeleteNamedImport.
DeleteNamedImport deletes the import with a given
name and path from a parsed file, if present.

imports uses this function to delete named imports.

Fixes golang/go#8149.

Change-Id: I84539d5627191c45f06db2d008507aee4d3b1eb2
Reviewed-on: https://go-review.googlesource.com/19951
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26 17:37:10 +00:00
Konstantin Shaposhnikov
a917fb9d7b cmd/guru: emacs: package.el compatibility changes
Make go-guru compatible with package.el prior to uploading this pacakge to
MELPA.

Also add ;;;###autoload magic comments, so that the go-guru-xxx commands can
be used without need to explicitly (require 'go-guru) first.

Change-Id: I21c7f5f354fb7b39877a05c2a9ffecd02ab022f6
Reviewed-on: https://go-review.googlesource.com/19789
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-26 04:34:18 +00:00
Robert Griesemer
06f9f0dd88 go/gcimporter15: backport latest changes to binary export format (fix build)
This is the gcimporter/bimport.go part of:

https://go-review.googlesource.com/19627

Also, fixed a type that was fixed in gcimporter/bimport.go before.

TBR=adonovan

Change-Id: I0be8549f6ea8c199842623284091499abf698322
Reviewed-on: https://go-review.googlesource.com/19926
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-26 01:18:04 +00:00
Alan Donovan
2327a65811 cmd/guru: fix tests
A consequence of CL 19747 was that ad hoc packages of a single filename
are no longer valid -scope arguments, which broke most of the tests.

This CL fixes the tests by extracting the import path from the filename.
The test output now includes the import path, not the package
name, of each of these packages, so the output was updated too.

Also, the -scope argument caused the main package to be imported twice,
once as main.go and once under its import path, causing duplicate
'implements' results.

I'm not sure how I failed to notice this.

Change-Id: I6fb3ae3e1497f0eb8cf88f453660b9e2fd9718d8
Reviewed-on: https://go-review.googlesource.com/19886
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-02-25 22:51:33 +00:00
David R. Jenni
108746816d go/ast/astutil: keep comment position for existing imports.
Fixes golang/go#10337.

Change-Id: Ia21547bb57790c077ca01a2ad656086da3f2ba8a
Reviewed-on: https://go-review.googlesource.com/19822
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-23 17:36:30 +00:00
Alan Donovan
f7268ab39b cmd/bundle: fix broken test
Change-Id: I95bd6cd1b63a1d1b5bd255546fbf571010a67266
Reviewed-on: https://go-review.googlesource.com/19745
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-22 20:47:44 +00:00
Alan Donovan
9aae8f06b5 go/loader: update comment
CL 18580 (Jan 12) made the loader cache non-blocking.

Change-Id: I8f280dbd405bd9b19a201191a4a987f13d862300
Reviewed-on: https://go-review.googlesource.com/19830
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-22 20:28:10 +00:00
Alan Donovan
3f95c66345 cmd/guru: allow foo/... and -foo patterns in scope argument
Also, document -scope argument.

Depends on CL 19746 (buildutil.ExpandPatterns)

Change-Id: I3c9000e94d87cca5c2c49fe8de12a77fc43f7257
Reviewed-on: https://go-review.googlesource.com/19747
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-02-22 20:17:58 +00:00
Alan Donovan
a69e659f44 cmd/guru: fix mode map, again
Change-Id: Ic1fef2e237205ed392912601324415af625417b0
Reviewed-on: https://go-review.googlesource.com/19749
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-22 20:17:02 +00:00
Alan Donovan
ba766134cc go/buildutil: add ExpandPatterns utility
This will be used by the guru command's -scope argument.

+ test

Change-Id: I5bf38b544809e4518e2c22a73ec3349a5d2c09fc
Reviewed-on: https://go-review.googlesource.com/19746
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-02-22 20:15:22 +00:00
Konstantin Shaposhnikov
54fa7477e2 cmd/guru: emacs: do not shrink results window
This fixes the following usability issues:

- when go-guru is called twice in a row and the output from the second invocation
  is bigger then this output is not fully visible
- output window could be re-used by other packages (such as helm) that are not
  usable with the shrank window

Change-Id: I86d522006d29e945a71b96c9d13a1a39572bdb3b
Reviewed-on: https://go-review.googlesource.com/19780
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-22 15:47:11 +00:00
Alan Donovan
86372b3255 cmd/guru: use byte (not rune) count in -modified archive
Change-Id: I7fc575c8ec7a8170e64719419079d6742f47b119
Reviewed-on: https://go-review.googlesource.com/19744
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-02-21 19:51:54 +00:00
Alan Donovan
b0452eeec4 cmd/guru: fix bug in mode map caused by bad merge
Change-Id: I2c4ff577f744e168a7914d15269636092ceef5a9
Reviewed-on: https://go-review.googlesource.com/19748
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-02-21 01:08:56 +00:00
Alan Donovan
ee6079c0ac go/buildutil: add (*TagsFlag).Get method to satisfy Getter interface
Change-Id: I8a52a1cc006608ff87d1436d14c836b6e9c7d6d4
Reviewed-on: https://go-review.googlesource.com/16810
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-21 00:49:10 +00:00
Alan Donovan
4828f5cb61 cmd/guru: emacs: minor changes to keybindings
Major modes should use the C-c prefix followed by C-something.  We'll
stick with C-o (oracle) since C-g is taken by go-jump-xxx (and in any
case C-g should be reserved for keyboard-quit.)

Change-Id: I18f41d7cbd5bf83aa53909554501e7f76543f033
Reviewed-on: https://go-review.googlesource.com/19510
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-02-21 00:47:43 +00:00
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