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

2052 Commits

Author SHA1 Message Date
Syohei YOSHIDA
5e567c6dff cmd/guru: emacs: Use cl-lib.el instead of cl.el
This package requires cl-lib.el in package header but it is not loaded
and cl.el functions are used instead of cl-lib functions. Using cl.el
functions causes byte-compile warnings.

Change-Id: I6d9400f9ced6a5cc0592d83da2ab1c1cf34e20b8
Reviewed-on: https://go-review.googlesource.com/27031
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-10-12 14:21:26 +00:00
Francesc Campoy
8453f27cc7 present: make code in slides editable only with -edit
Also added a suite of tests and fixed a minor bug that
caused a panic when the .code command specified HL with
no text after.

Fixes golang/go#17379.

Change-Id: I3c246523c3d4010bf76a467ee648475255090e1b
Reviewed-on: https://go-review.googlesource.com/30691
Reviewed-by: Rob Pike <r@golang.org>
2016-10-07 20:29:58 +00:00
Tamir Duberstein
4c4edc0bec cmd/goyacc: remove hardcoded NTYPES
Updates #16144.

Change-Id: I196dd4e871c88792ea95c02b31c54f269fdc505f
Reviewed-on: https://go-review.googlesource.com/27350
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-10-07 17:45:45 +00:00
Robert Griesemer
b5358b5fee go/gcimporter15: update exportdata.go to match latest version from std lib
For golang/go#17281.

Change-Id: I7bed233368939719672eb331cca1d6aef01e807d
Reviewed-on: https://go-review.googlesource.com/30591
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-10-06 19:19:18 +00:00
Alan Donovan
03663480fa go/buildutil: ExpandPatterns: ignore a trailing slash in a pattern
Previously, a trailing slash would cause "foo/" to be treated as the
name of a package, with comical results.

Fixed golang/go#14584

Change-Id: I660f8a079bbd63d3645812e516a9264c8e080e61
Reviewed-on: https://go-review.googlesource.com/30452
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-05 19:34:25 +00:00
Alan Donovan
27f88d9b7a cmd/guru: if query file is not beneath GOPATH, treat it as a package
This allows type-based guru queries to work on arbitrary files at the
root or even outside of a GOPATH workspace (as "go run foo.go" does).

Fixes golang/go#15797

Change-Id: I2be28f7259448e6398aae84d6ae7e71d8649967a
Reviewed-on: https://go-review.googlesource.com/30451
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-05 18:29:27 +00:00
Mohit Agarwal
73d2e795b8 cmd/godoc: fix command for creating the zip file
The `-r` option (to recurse into directories) need to be specified
else the created file consists only of the specified directory and
nothing else.

Change-Id: I624184fc2e88998a3119c12f8c328603588c123c
Reviewed-on: https://go-review.googlesource.com/17283
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-04 20:51:58 +00:00
Francesc Campoy
471a6e15ec godoc: drop outdated comment
Change-Id: I2a4d0c112575cad70180ba0f8984a271a7658775
Reviewed-on: https://go-review.googlesource.com/29686
Reviewed-by: Sameer Ajmani <sameer@golang.org>
2016-10-04 17:46:36 +00:00
Alan Donovan
fc2b74b64e refactor/rename: don't stop because of "soft" errors
Because go/types is slightly more strict than gc about certain "soft"
errors (ones that aren't necessary to interpret a Go program), gorename
rejects programs that compile under gc.  This change relaxes gorename's
error checks so that they are weaker than gc's.

This is a workaround for issue golang/go#14596 in gorename,
whose underlying problem is issue golang/go#8560 in gc.

Fixes golang/go#14596

Change-Id: Ica5006c2376c0564a575224269093c1497348ee6
Reviewed-on: https://go-review.googlesource.com/29853
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-27 16:36:09 +00:00
Rhys Hiltner
c2ef61f450 go/ast/astutil: fix loop logic in AddNamedImport
When merging import declarations into a single block, AddNamedImport
modifies the list of declarations in the provided file while
iterating over the list. Take care to adjust the index into the list
so as to not skip entries or fall off the end.

Fixes golang/go#17213

Change-Id: I807246f762c965ea1fc51eb57759f6088336db86
Reviewed-on: https://go-review.googlesource.com/29681
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-24 00:48:36 +00:00
Francesc Campoy
3f4088edb4 godoc: avoid exposing absolute paths on 404
Exposing the full paths to files is considered possible
source of vulnerabilities.

Change-Id: Ie9ae3791e51fcff5f1df711f84db9879d7e6ce37
Reviewed-on: https://go-review.googlesource.com/29445
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-21 00:04:58 +00:00
Brad Fitzpatrick
f1a397bba5 cmd/bundle: add flag to rewrite golang.org/ to golang_org/ in imports
I've been doing this by hand since Go 1.7rc2.

Updates golang/go#16333

Change-Id: Ib12c013b14210123d48d6ad78922caf1286c20cc
Reviewed-on: https://go-review.googlesource.com/29086
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-09-13 16:37:30 +00:00
Dominik Honnef
5ffc3249d3 present: dont crash if address searched backwards
For /start/,/end/, the /end/ address can wrap around and match somewhere
before /start/. Handle this case without crashing.

Fixes golang/go#7163.

Change-Id: I6fc3b5048e88728c9403a1d1e284ea8ada567a1e
Reviewed-on: https://go-review.googlesource.com/21182
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-09-13 12:21:10 +00:00
Alan Donovan
86ad1193da go/ssa/interp: turn {strings,bytes}.init into no-ops
...to avoid executing the supportAVX2 assembly function.

Also, combine all no-op intrinsics into a single function.

Change-Id: Ic65a80d3a6df52c3850c34406f034781057a0991
Reviewed-on: https://go-review.googlesource.com/28711
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-09-07 20:36:55 +00:00
Robert Griesemer
9deed8c6c1 go/gcimporter15: update to recognize export format version 2
Port of https://go-review.googlesource.com/#/c/27999/.

Change-Id: I71c4553e925fcf943ecafdef307591f63136d432
Reviewed-on: https://go-review.googlesource.com/28001
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-08-29 18:38:39 +00:00
Robert Griesemer
a832035fe5 go/gcimporter15: update to match latest changes to cmd/compiler exporter
Backport of https://go-review.googlesource.com/27814 changes to
bexport.go.

With this, the gcimporter15 is again up-to-date and in sync with both
the compiler's export code, and the compiler's and std lib gcimporter's
import code.

Change-Id: I8e229660eb78ddc1506b7b96a89c81ff083e0412
Reviewed-on: https://go-review.googlesource.com/27914
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-26 22:16:59 +00:00
Robert Griesemer
e545a4ce60 go/gcimporter15: update to match latest changes to std lib gcimporter
Mostly a backport of https://go-review.googlesource.com/27816.
Includes an update to TestIssue13898 to match the std lib gcimporter
test.

Change-Id: I790123a49deb2d52f19e51c84bbc7ee74c99156e
Reviewed-on: https://go-review.googlesource.com/27913
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-26 22:16:48 +00:00
Dmitri Shuralyov
5cb1c80a83 cmd/bundle: Support renaming imports.
Document a risk of generating invalid code due to shadowing between
identifiers in code files and the imported package names.

This risk was present before for any package with more than 1 .go file,
but it's increased when some files have renamed imports (since they're
typically used to resolve shadowing conflicts).

Resolves TODO(adonovan): support renaming imports.

Change-Id: Ie0e702345790fd2059c229623fb99fe645d688a4
Reviewed-on: https://go-review.googlesource.com/23785
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-08-24 17:03:01 +00:00
David R. Jenni
6e2a0ce36e cmd/guru: show correct definition for embedded type.
Fixes golang/go#16263.

Change-Id: I081a12306ac5415d2223e3509a29a1b47700e1ff
Reviewed-on: https://go-review.googlesource.com/27001
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-08-24 12:03:13 +00:00
Robert Griesemer
b2560d12f6 go/gcimporter15: backport compiler exporter fix for golang/go#15514
Code from https://go-review.googlesource.com/#/c/27639/ .

Remain backward-compatible with possibly installed packages
that remain in Go1.6 format.

Change-Id: If424e7a881c81bbfcacf38c0946542793c406abd
Reviewed-on: https://go-review.googlesource.com/27640
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-23 23:43:11 +00:00
Robert Griesemer
2bbdb4568e go/gcimporter15: update to match std lib gcimporter (fix build)
TBR=adonovan

Change-Id: Ib2464def48932e0d0fc24f67c76a10e8918acb9d
Reviewed-on: https://go-review.googlesource.com/27235
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-23 00:37:51 +00:00
Konstantin Shaposhnikov
8ea9d46069 refactor/rename: do not allow a new name to be a keyword
Fixes golang/go#16535

Change-Id: I46f9b9530e25bb286557712a7969715f8dde99b9
Reviewed-on: https://go-review.googlesource.com/25343
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-08-20 16:15:16 +00:00
Tamir Duberstein
df703d6484 cmd/goyacc: remove unused constants
Change-Id: I48002d39de6d32ee9410fd4271f623b5661f0081
Reviewed-on: https://go-review.googlesource.com/27328
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-18 16:45:58 +00:00
Brad Fitzpatrick
f1ba7e38e5 cmd/goyacc: move go tool yacc from the go repo
This moves the 'go tool yacc' command from the main Go repo
to x/tools.

Copied from go rev 795ad07b3 + doc changes from "go tool yacc" to "goyacc".

Updates golang/go#11229

Change-Id: I6d17911a3bf64724c090c4fe4903238e3bce3b8c
Reviewed-on: https://go-review.googlesource.com/27324
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-18 15:37:45 +00:00
Robert Griesemer
1cf0a337cd go/gcimporter15: don't run 1.7-specific test under 1.8 (fix build)
TBR=adonovan

Change-Id: I310ff6e51d681b2e5c8288e73870ce7d68e45518
Reviewed-on: https://go-review.googlesource.com/27208
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-17 05:10:56 +00:00
David R. Jenni
491cbb1158 go/ast/astutil: add tests for UsesImport.
Change-Id: I05e9897b2ac858e1c3cc0d54f9da74e34f72f9e2
Reviewed-on: https://go-review.googlesource.com/27002
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 21:44:40 +00:00
Michael Matloob
08b1e0510c x/tools/cmd/heapview: add a sidebar to hold navigation
This change also puts more structure into the viewer.
Adds an enum for events that we'll issue and a few more elements
to organize things.

Change-Id: I39c7c53422779348ca05f051c6b0b07d22ad6a00
Reviewed-on: https://go-review.googlesource.com/26656
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-08-16 17:33:40 +00:00
Brad Fitzpatrick
3fe2afc9e6 imports: update zstdlib to Go 1.7
Change-Id: I936c6f03e8c3dc14832c8493937fdb64e6d1a853
Reviewed-on: https://go-review.googlesource.com/27079
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2016-08-15 22:30:11 +00:00
Chris Broadfoot
c66da98c4f imports: don't use fastpath on appengine (syscall not available)
Change-Id: I02fbdf1a08894b35a19a3638357c0d42e64d42cc
Reviewed-on: https://go-review.googlesource.com/27078
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-15 22:01:42 +00:00
Tamir Duberstein
0e9f43fcb6 cmd/goimports: work around lack of runtime/trace in gccgo
Moves runtime/trace support (including its command line flag) behind
a "gc" build tag to allow goimports to build under gccgo, which does
not support runtime/trace.

Updates golang/go#15544.

Change-Id: I017a44089c0a4f3d3ba98815d57a141e25b3fe56
Reviewed-on: https://go-review.googlesource.com/26998
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-13 05:07:58 +00:00
Michael Matloob
68cf18548e x/tools/cmd/heapview/internal/core: stub mmapfile for !darwin,!linux
mmapfile.go uses symbols in the syscall package that are not defined
on windows and some other operating systems. Temporarily
buildtag-restrict mmapfile to darwin and linux (the platforms easiest
for me to test) to fix the build.

Change-Id: Ib056608a655b6d32170cd86deac785811e7bc0d1
Reviewed-on: https://go-review.googlesource.com/26830
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-11 13:58:04 +00:00
Brian Kennedy
62f0028207 imports: properly handle global variables when creating imports
Fixes golang/go#7463

Change-Id: Ib8b511a34c562a2b3cdce6bb143caa7cf453bd00
Reviewed-on: https://go-review.googlesource.com/23444
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-11 06:06:14 +00:00
Michael Matloob
855bbc50ad cmd/heapview: add an internal core package for reading cores
This is based on github.com/tombergan/goheapdump/heapdump.

This CL mostly just copies over the 'raw' data structures based
on the profiler records' data structures. Many of them may need
to be changed, but I think it will be good to have these definitions
here to provide a base.

Change-Id: I609202b6b87d980b0835c8087b3d78e11bd6dfe3
Reviewed-on: https://go-review.googlesource.com/25584
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2016-08-09 19:00:08 +00:00
Michael Matloob
29462195f2 x/tools/cmd/goimports: define verbose flag in parseFlags
This will allow users to use a different flag name.

Change-Id: I252871b8efb6867e61ca507f59a9663cb7140b7d
Reviewed-on: https://go-review.googlesource.com/26632
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-09 18:14:46 +00:00
Michael Matloob
72064bd647 cmd/heapview: dowgrade to customelements v0
I've had too many issues with customelements v1. The interface for v0
isn't as nice, and v0 will eventually be deprecated. But v1's polyfill
library is better supported, and it will be easy to upgrade later.

Change-Id: I87b376376b750167a0464c6c249930edecbd59db
Reviewed-on: https://go-review.googlesource.com/25545
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2016-08-05 20:49:36 +00:00
Michael Matloob
337c0124d7 x/tools/cmd/heapview: add a heading to the page
This CL's purpose is to introduce the dependency on the HTML Custom
Elements polyfill. Like we've done so far, I'm trying to keep
dependencies light by using current or polyfilling future webcomponents
standards.

Change-Id: I11d14db367b697cdd527fb66b9d7d160ac244b78
Reviewed-on: https://go-review.googlesource.com/25494
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-05 01:00:25 +00:00
Michael Matloob
7ef02fdb22 cmd/heapview: add karma+jasmine TS unit testing config
Add a configuration that allows unit testing of client Typescript
code using Karma and Jasmine. Add a basic test to exercise this.

Change-Id: I88af82b68547423efeaafb0fab8214ed39573ee9
Reviewed-on: https://go-review.googlesource.com/25411
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Evan Martin <evanm@google.com>
2016-08-03 18:16:31 +00:00
Miroslav Genov
bf0c35b6b6 tip/doc: update doc to match latest gcloud syntax
gcloud command no longer requires preview for deployment and is showing
warning when command is executed:

```
WARNING: The `gcloud preview app` command group is deprecated; please
use the `gcloud app` commands instead.
```

This change is removing "preview" text from README to make deploy
command up to date with gcloud.

Change-Id: I64d390ab4891f82fe608c64be20fae01a80d00fc
Reviewed-on: https://go-review.googlesource.com/25430
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-03 14:42:34 +00:00
Michael Matloob
9e7459099f x/tools/cmd/heapview: break out init code
This change breaks out the code that adds handler funcs and
starts the HTTP server into separate functions, so that they
can be overridden in other environments, such as Google's.

For instance, listenAndServe can be overridden in an init method
in a different file to use a HTTP2 server.

Updates golang/go#16410

Change-Id: I074242af10486c60c374e9ac7ebe9d0e61a8fa22
Reviewed-on: https://go-review.googlesource.com/25273
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2016-07-27 17:11:33 +00:00
Michael Matloob
053ddb97bf x/tools/cmd/heapview: add basic client serving
This change primarily exists to import Typescript and the
ES6 module loader polyfill as dependencies for this project.
Both dependencies are relatively lightweight and can be easily
removed if we decide we don't need them.

The module loader polyfill implements support for an upcoming
browser feature in ES6 (the next version of JavaScript). This
feature helps modularize Javascript code and conveniently split it
into multiple files. It should be supported by the stable versions
of the four major browsers (Chrome, Firefox, Safari and Edge)
by the end of the year. Once that happens, we can remove the polyfill.

The Typescript compiler provides two things: First, it compiles
new, but not-yet-supported ES6 Javascript features into ES5. It
also provides a typechecker similar to what Closure does, but types
are indicated in syntax rather than JSDoc comments. If we decide
we don't want this dependency, we can compile the Typescript code
into human-readable JavaScript code. (The compiler basically
strips out types and replaces ES6 language features with more
well-supported JavaScript equivalents). The Typescript compiler
is not required for development. typescript.js and a feature in
the module loader will be used to compile Typescript into JavaScript
at serving time. (We might want to do something different for the
production version, but we can get to that later).

The change also adds code to serve the HTML and Javascript files.

Updates golang/go#16410

Change-Id: I42c669d1de636d8b221fc03ed22aa7ac60554610
Reviewed-on: https://go-review.googlesource.com/25240
Reviewed-by: Austin Clements <austin@google.com>
2016-07-26 20:51:39 +00:00
Brad Fitzpatrick
1c6f639aae imports: don't ignore GOPATH if GOROOT is a prefix of GOPATH
Fixes golang/go#16458

Change-Id: I1aaec5d115dd703dd702101f6bec37bf8b02a73d
Reviewed-on: https://go-review.googlesource.com/25192
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-07-26 13:45:23 +00:00
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
Alex Brainman
682b241254 imports: make filepath.Rel work on windows
filepath.Rel will always fail if one parameter starts with
drive letter and the other does not. Make both filepath.Rel
parameters absolute paths, to give it chance to succeed.

Fixes broken tools build on windows.

Change-Id: Ibefcfe283f28977503323f01bc3a698478227f84
Reviewed-on: https://go-review.googlesource.com/25120
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-07-21 14:33:34 +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
Tim Henderson
1634796cc3 go/ssa: fix stale docs for CreateProgram and Build
Both functions had documentation referring to BuildAll when the
function is now called Build.

Change-Id: I59cce397a0a72bf7fa36f9798e2b07bb6b1da726
Reviewed-on: https://go-review.googlesource.com/25084
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-20 18:52:54 +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
d4a8e583a1 imports: skip "node_modules" directories
Updates golang/go#16417

Change-Id: Ia4a5f997036274d09cca2ff10e500e403c1725ba
Reviewed-on: https://go-review.googlesource.com/25044
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-07-19 16:05:27 +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