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

2413 Commits

Author SHA1 Message Date
Rob Pike
ffe8890671 cmd/stringer: revert CL 40403
Revert "cmd/stringer: use source importer when available"

This reverts CL 40403.

The idea is to avoid type-checking and use just parsing, which should be
enough for stringer.

Separately reopening golang/go#10249 because the original change closed that issue,
but the change is itself causing other problems as described in the discussion
at golang/go#25650.

This reversion restores the old behavior of stringer and will be followed
with other fixes if they can be worked out.

Change-Id: I8404d78da08043ede1a36b0e135a3fc7fdf6728d
Reviewed-on: https://go-review.googlesource.com/121884
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-03 00:36:02 +00:00
LE Manh Cuong
b23eb6252f imports: fixup comments on import lines correctly
The current implementation uses the added import specs EndPos to fixup
the comments position after import specs is sorted. If two or more
import specs have the same EndPos, a comment associated with one of them
is always added to the last import spec.

This commit uses the current import spec position to compute new
position for next import spec. So there is never two or more specs have
the same EndPos.

Fixes golang/go#23709

Change-Id: I60ace9431d871e94a2b3d90892aa80d0671aeea0
Reviewed-on: https://go-review.googlesource.com/121878
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-02 20:27:37 +00:00
Brad Fitzpatrick
1c99e1239a godoc: default to GOOS/GOARCH js/wasm when rendering syscall/js docs
Otherwise it was just blank. With this CL, this URL should start rendering docs:

   https://tip.golang.org/pkg/syscall/js/

Tested locally.

Change-Id: I2d9b7286f374e9372be372987bb5d12ce5044ce9
Reviewed-on: https://go-review.googlesource.com/121315
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-28 16:39:57 +00:00
Alan Donovan
16699b2d33 go/gcexportdata: add -package flag to diagnostic tool
...to show information about indirectly mentioned packages.

Change-Id: Ib74b56493861bf41d9720760e76ace186efae2ea
Reviewed-on: https://go-review.googlesource.com/121195
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-27 17:17:06 +00:00
Robert Griesemer
56e9b8e653 go/internal/gcimporter,gccgoimporter: use types.NewInterfaceType
https://go-review.googlesource.com/c/go/+/120875 changed the name
of types.NewInterface2 to NewInterfaceType. Adjust x/tools code to
match new API.

For golang/go#25301.

Change-Id: I21e13566f7c88591a16ce461cb4cce8901980b05
Reviewed-on: https://go-review.googlesource.com/120895
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-26 17:42:40 +00:00
Agniva De Sarker
3c1bb8b785 godoc: accept scanner.RawString too during EBNF parsing
Commit c8915a0696 changed the text/scanner
package to return a scanner.RawString (rather than a scanner.String) token
for raw string literals. This broke the EBNF parser which didn't look
for scanner.RawString.

Updated the EBNF parser code to reflect that change.

Fixes golang/go#25986

Change-Id: Ib9c133a7c357dd750a4038d2ed39be86a245995c
Reviewed-on: https://go-review.googlesource.com/120659
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-25 04:25:21 +00:00
Austin Clements
25b95b4822 go/ssa: fix some incorrect comments
Change-Id: I8aa4780e0fa4a182678f1d34b247ab203e906144
Reviewed-on: https://go-review.googlesource.com/119915
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-06-20 14:00:53 +00:00
David Symonds
fcb3cb6c24 go/vcs: match go-import package prefixes by slash
This is related to golang/go#15947.

This ports https://golang.org/cl/23732 (June 2016)
from cmd/go to this repository.

Change-Id: I9960556bd19775b433d4eecc0ecca3f09ce1368b
Reviewed-on: https://go-review.googlesource.com/119935
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-20 03:09:55 +00:00
Alan Donovan
53440098a4 godoc/static: resolve merge conflict, committed in error
Change-Id: Ica50edbae03eb1c6efad702841b926ffaf1c98ec
Reviewed-on: https://go-review.googlesource.com/119476
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-06-18 17:10:13 +00:00
Alan Donovan
e10d6c9a84 godoc/static: use a stable quote function
Printf(%q) aka strconv.AppendQuote depends on the Unicode tables du
jour, which means gen_test breaks after a Go release in which Unicode
evolves. This change uses a very dumb quotation function that emits
only ASCII and is independent of the Go release.

Perhaps an even better fix would have been to parse the generated file.

Change-Id: I197942f1c36a8b53d6a37be4bb2b1e63a208f7e2
Reviewed-on: https://go-review.googlesource.com/119157
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-18 16:36:09 +00:00
Russ Cox
c06a8d8ed1 imports: skip $GOPATH/src/v and $GOPATH/src/mod
These are both vgo module cache locations (originally v, soon to be mod).
Vgo dumps a lot of code into these directories.
If goimports walks in there, it takes forever.

Change-Id: I667b0a4979bf6a6b71c3651d25ec29777ff15301
Reviewed-on: https://go-review.googlesource.com/119337
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-17 21:38:49 +00:00
Agniva De Sarker
465e6f3992 godoc: add link to expand/close all examples
Fixes golang/go#3081

Change-Id: I096b22691a08d72b88dbe925e17893d24ba3c992
Reviewed-on: https://go-review.googlesource.com/118935
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-15 19:57:36 +00:00
Paul Jolly
c6269430a5 refactor/rename: allow Force to make edits within autogenerated files.
Currently, as documented, gorename fails if it would cause an edit to an
autogenerated file:

- detect and reject edits to autogenerated files (cgo, protobufs)

There are times when refactoring code where such an edit is necessary.
This CL enables such edits if Force is set (which corresponds to
gorename -force).

Change-Id: If21249ae50d61fb5b59ee6e1ecf7157aaae0260a
Reviewed-on: https://go-review.googlesource.com/118975
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-06-14 20:28:06 +00:00
Alan Donovan
903a227b9b godoc/static: mimic the pre-1.10 behavior of strconv.Quote
Thanks to iant for identifying the root cause.

Tested with go1.9 and go1.10.

Fixes golang/go#25880

Change-Id: Ibc3a2aadd92c1e512cf6c537134ee085398e8e6c
Reviewed-on: https://go-review.googlesource.com/118955
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-14 19:21:16 +00:00
Alan Donovan
49ce10d933 godoc/static: suppress gen_test on go1.9
Either string quotation or Go formatting has since changed.
Will investigate later, but this fixes the dashboard for now.

Change-Id: Ieab3800fc2c24ba86026d25dea12853131c04948
Reviewed-on: https://go-review.googlesource.com/118715
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-14 18:36:27 +00:00
Robert Griesemer
c995a08888 go/internal/gcimporter: move 1.11 specific tests out of non-1.11 builds (fix build)
TBR=adonovan

The tests TestImportedTypes and TestIssue25301 are dependent on many
1.11-specific bug fixes that went into go/types. Just move them out
of non-1.11 builds.

While doing so, also extended the set of test cases run by
TestImportedTypes (now matching the corresponding tests cases
in the std lib).

This also makes it again unnecessary to factor out the embeddedType
function into build-specific versions. Removed again.

For https://github.com/golang/lint/issues/402.

Change-Id: I45eb8c3d1dcca7b392f14a7660bc1599a44a0d41
Reviewed-on: https://go-review.googlesource.com/118567
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-13 19:12:07 +00:00
Robert Griesemer
e580e344d4 go/internal/gcimporter: don't use Interface.EmbeddedType for builds before go1.11
For https://github.com/golang/lint/issues/402.

Change-Id: I3f4eab123e52460980e76f5ffaca3a77a3af7374
Reviewed-on: https://go-review.googlesource.com/118565
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-06-13 18:37:28 +00:00
Robert Griesemer
6f857df7d4 go/internal/gccgoimporter: use types.NewInterface (not NewInterface2) for builds before Go 1.11
For https://github.com/golang/lint/issues/402.

Change-Id: I06d944aaa168fb595ff96eb27a7d6e7da344ebd6
Reviewed-on: https://go-review.googlesource.com/118564
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-06-13 18:13:43 +00:00
Robert Griesemer
9d855108b0 go/internal/gcimporter: missed a NewInterface2 call in prior CL
For https://github.com/golang/lint/issues/402.

Change-Id: Ideaac18b4f0be1674bb07010840b3d10e6ebe9d6
Reviewed-on: https://go-review.googlesource.com/118639
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-06-13 18:12:16 +00:00
Robert Griesemer
58c6d92c35 go/internal/gcimporter: use types.NewInterface (not NewInterface2) for builds before Go 1.11
For https://github.com/golang/lint/issues/402.

Change-Id: If8802c93679af57bcb50c43f386f37458813d910
Reviewed-on: https://go-review.googlesource.com/118563
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-13 17:48:59 +00:00
Andy Lindeman
e1f909067f godoc: correct abspath when looking for cmds
godoc is erroneously detecting paths like syscall and unsafe as possible
commands.

A previous attempt at a fix adjusted the parameters of pkgHandler in
pres.go, but that change had unexpected ripple effects that broke links
and other features of godoc. This change is scoped only to the godoc
command line tool.

cmdline_test.go is updated to match the parameters used in the real
pkgHandler in pres.go.

Fixes golang/go#14447

Change-Id: I8f740c6847e46523b8443722b16942192bdf9cb8
GitHub-Last-Rev: cfc24f2d4c3519c4c87628b2021f65a4725cda6b
GitHub-Pull-Request: golang/tools#27
Reviewed-on: https://go-review.googlesource.com/96515
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-13 15:42:59 +00:00
Robert Griesemer
9a70f1fcbf go/internal/gcimporter, gccgoimporter: updated to match latest version in std lib
This CL brings over the changes from:

https://go-review.googlesource.com/118496 (better error message when importer is out of date)
https://go-review.googlesource.com/114317 (permit embedding of non-defined interfaces via alias type names)
https://go-review.googlesource.com/85318  (use named receiver types for methods of named interfaces)
https://go-review.googlesource.com/42870  (report import path if package is not found)
https://go-review.googlesource.com/41710  (version tests for 1.8, v4 and v5)

Also updated go/gcexportdata to select between binary and new indexed export format.

For golang/go#25856.
For golang/go#25301.
For golang/go#20230.
For golang/go#13829.

Change-Id: Ibf77c50f86e767cef411bd1d3809e12397678958
Reviewed-on: https://go-review.googlesource.com/118555
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-06-13 15:25:57 +00:00
Robert Griesemer
02fcd6aaf1 godoc: fix test failure
Adjust code to satisfy vet.

Change-Id: I532b4d988eb29b413520de60b8520d9e100b42c9
Reviewed-on: https://go-review.googlesource.com/118557
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-13 15:25:43 +00:00
Brad Fitzpatrick
8c39fb57ad cmd/godoc: use same GOROOT discovery as Go 1.10's cmd/go
Fixes golang/go#23445

Change-Id: I4c707107e636558b49ea9a1a8690723b06dda235
Reviewed-on: https://go-review.googlesource.com/118075
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-12 01:24:34 +00:00
Ian Lance Taylor
2475cf16d3 cmd/guru: if built with gccgo, switch to gc mode if GOROOT is valid
The gccgo compiler does not provide a gc-style GOROOT with standard
library sources. The effect is that guru may not fully work when using
gccgo. However, it can fully work if the GOROOT environment variable
points to valid gc-style GOROOT. In that case, make it work by telling
the go/build package to use gc mode.

Change-Id: Iadff8be61be8cc9a7ff2ca0a067b116b62895451
Reviewed-on: https://go-review.googlesource.com/117997
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-06-11 19:19:27 +00:00
Ian Lance Taylor
f96157268c imports: fix test to work with gccgo
Change-Id: I382905b7b7bd8189c169048ba05080ee96e1da5b
Reviewed-on: https://go-review.googlesource.com/117995
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-11 19:17:03 +00:00
Ian Lance Taylor
c65208ee29 go/...: make most tests pass with gccgo
There is one non-test change: have FakeContext change the compiler to
"gc", as callers expect to be accessing a gc-style GOROOT.

The go/pointer, go/ssa, and go/ssa/interp tests still fail with gccgo.

Change-Id: I850c9618401f6b9e63d7ca7196f91931b03f1524
Reviewed-on: https://go-review.googlesource.com/117395
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-08 16:58:49 +00:00
Filippo Valsorda
4e38c85762 godoc/dl: add valsorda to users allowed to upload
Change-Id: Iac4a80b030be9c275323a27d2dfba4f83942cbf9
Reviewed-on: https://go-review.googlesource.com/117195
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-07 18:59:51 +00:00
Yury Smolsky
a5b4c53f6e playground.js: display vet errors when program has no output
When program has no output and vet errors are encountered,
initialize data.Events as an empty array.

Fixes golang/go#25455.

Change-Id: Icedd77685b784505da3bb6383629cdfa8b8b22e9
Reviewed-on: https://go-review.googlesource.com/113875
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-05-25 02:41:13 +00:00
Sebastien Binet
1937f90a1b cmd/gomvpkg: add missing closing double-quote to documentation
This CL adds a missing closing double-quote to the documentation string
of gomvpkg.

Change-Id: I000fe33fb9ddc5342bbf51c36595a884d6aa4eab
Reviewed-on: https://go-review.googlesource.com/114115
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-22 18:16:25 +00:00
Andrew Gerrand
28aef64757 go/internal/gcimporter: return error from BExportData
This change adds an error return value to BExportData and replaces the
various calls to log.Fatal within that library with panics that
propagate the internal error up the call stack to BExportData which
recovers and returns the error.

Fixes golang/go#25431

Change-Id: Id628c63a04145bb469bd6fbc7fbab1b0fa291b2c
Reviewed-on: https://go-review.googlesource.com/113457
Reviewed-by: David Symonds <dsymonds@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-17 02:09:35 +00:00
Yury Smolsky
48418e5732 godoc: display "go vet" errors before the output of a program
This change adds an option to run "go vet" for the playground program
and display errors before any output. To enable this, the playground
function has to be supplied with opts.enableVet set to true.
Vet check is performed only for succesfully run programs,
meaning that the "/compile" endpoint returned no errors.

This change highlights lines printed to stderr as errors (in red).

There is a corresponding change for the Playground: CL 100776.

Updates golang/go#7597
Updates golang/go#24576

Change-Id: I8c0f8c1189c461338b5bce57777b12aecab268fb
Reviewed-on: https://go-review.googlesource.com/107455
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-05-08 19:22:17 +00:00
jimmyfrasche
76f5b51ce4 x/tools/godoc: make front page video respond to layout changes (2/2)
This part of a multi-repo change. See CL 108677 for details.

Note: this change also requires a CL to golang/go to complete the fix,
though either CL without the other is harmless.

Updates golang/go#24997.

Change-Id: I99ca9a4e6df16347b8706f24cef9689b3345854a
Reviewed-on: https://go-review.googlesource.com/108678
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-05-08 19:21:29 +00:00
Brad Fitzpatrick
8772326260 cmd/guru: skip the slow tests in short mode
Change-Id: I85c2de03087ae8bb8989763f255b362eeee5b397
Reviewed-on: https://go-review.googlesource.com/109556
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-05-04 17:47:05 +00:00
Agniva De Sarker
ae8027637c godoc/static: add test for static.go file generation
Moved the code which generates static.go to remain in the static package.
This makes the code testable.

Additionally, it is very easy for developers to forget to run "go generate"
to update static.go. Because while development, the templates directory
can be directly passed as a flag to read the files from it.

This test catches that.

Change-Id: I314907b98907bb14e4eabfd3c532ba2d84ce7c5f
Reviewed-on: https://go-review.googlesource.com/110158
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-03 19:34:25 +00:00
Jeevanandam M
f4ce24f1d8 godoc/static: cleanup unused lines in makestatic.go
Change-Id: I9b930efb5efd4b32c41c40d2399e04bacd75b470
GitHub-Last-Rev: 53db7899927e5ae255310c6a765526a10552649f
GitHub-Pull-Request: golang/tools#36
Reviewed-on: https://go-review.googlesource.com/111155
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 05:28:33 +00:00
Andrew Bonventre
8026fb003c cmd/guru: fix vet error in referrers.go
Fixes golang/go#25227

Change-Id: If121154f95681367874332dac30bfe69d1755182
Reviewed-on: https://go-review.googlesource.com/111035
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-02 21:01:57 +00:00
Agniva De Sarker
a25dedfa53 godoc: set the GOROOT path properly in cmdline mode
- Setting the GOROOT build path to the value passed from the command line.

- Clarified the return values to named parameters for extra clarity.

- And while here, added some missed out error handling. Just logging the error
to preserve original behavior.

Fixes golang/go#13296

Change-Id: I91427eee790928a3cfb51ae207747e9a17bd5496
Reviewed-on: https://go-review.googlesource.com/110275
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-05-02 17:46:13 +00:00
Josh Bleecher Snyder
5c8013c561 cmd/guru: re-use buffer for reading files
I felt guilty about leaving 2% on the table in CL 108878,
so I thought I'd get it a different way.

Teach readFile to accept a re-usable bytes.Buffer to read into,
to reduce the amount of garbage created.

To limit the possible memory impact of giant files,
only re-use the buffer for the duration of a single package.
Even that is enough to help.

name       old time/op       new time/op       delta
Referrers        4.67s ± 3%        4.58s ± 2%  -1.96%  (p=0.029 n=10+10)

name       old user-time/op  new user-time/op  delta
Referrers        16.5s ± 3%        15.8s ± 1%  -4.39%  (p=0.000 n=10+8)

name       old sys-time/op   new sys-time/op   delta
Referrers        16.1s ± 3%        15.9s ± 3%    ~     (p=0.218 n=10+10)

This work supported by Sourcegraph.

Change-Id: I594ef25c0fd5ccb766ff5b98dbbd1a75a7a4f957
Reviewed-on: https://go-review.googlesource.com/108935
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-05-01 18:53:35 +00:00
Josh Bleecher Snyder
c1f4e2c6dc cmd/guru: emit initial referrers result earlier
This simplifies and unifies the code.
It also improves the output:
Now the initial result is referred to from the perspective of
the query site, rather than from the perspective of the package
containing the query object, which seems more natural.

This work supported by Sourcegraph.

Change-Id: Ie7a77d39dd6568334e72d894dc66d35494ed4ac4
Reviewed-on: https://go-review.googlesource.com/108936
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-05-01 18:28:20 +00:00
Josh Bleecher Snyder
d4c6246f3e cmd/guru: parallelize loop in globalReferrersPkgLevel
This change parallelizes the outer loop in globalReferrersPkgLevel,
which loops over packages to inspect.

There is also an easily parallelizable inner loop.
However, parallelizing it adds complication
(deffiles needs a mutex, inQueryPackage requires a wait group)
and offers only a 2% speed-up.

Benchmarks for this change, looking for encoding/json.MarshalIndent:

name       old time/op       new time/op       delta
Referrers        5.31s ± 2%        4.67s ± 3%  -11.95%  (p=0.000 n=10+10)

name       old user-time/op  new user-time/op  delta
Referrers        15.9s ± 2%        16.5s ± 3%   +3.71%  (p=0.000 n=10+10)

name       old sys-time/op   new sys-time/op   delta
Referrers        15.7s ± 3%        16.1s ± 3%   +2.73%  (p=0.011 n=10+10)


Fixes golang/go#24272
Updates golang/go#25017


This work supported by Sourcegraph.

Change-Id: I5dcda9017103cdff59d0ffdf5e87d2c2c955a33a
Reviewed-on: https://go-review.googlesource.com/108878
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-05-01 18:27:15 +00:00
Josh Bleecher Snyder
1e1ec013b9 cmd/guru: optimize global pkglevel referrer queries
Global, package-level queries can be done without typechecking.
This makes it significantly cheaper.

Instead of typechecking, consider all packages that directly
import the query package. In each of those packages, filter out:

* files that don't contain the query name
* files that don't import the query package

Fully parse the remaining files and look for selector expressions
matching the query package and name.

There are a few twists (dot imports, the query package, xtests).
They are described, along with how they are handled,
in the large comment at the beginning of globalReferrersPkgLevel.

On my machine and GOPATH, this reduces typical time
needed to find referrers to encoding/json.MarshalIndent
from (roughly)

real	0m39.946s
user	2m27.844s
sys	0m54.774s

to (roughly)

real	0m5.687s
user	0m15.793s
sys	0m16.001s

The processing of packages could be parallelized;
that is left for a future change, to ease reviewing.

Benefits from that will be limited;
building the reverse import graph accounts for 73%
of the runtime, and that is dominated by syscalls.

Optimization idea from Alan Donovan.

This work supported by Sourcegraph.

Change-Id: Ib19e25fcdcb27673fb03d7300dba2a53198901ad
Reviewed-on: https://go-review.googlesource.com/97800
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-01 18:10:48 +00:00
Andrew Bonventre
c47212f6f0 godoc: don't exclude version field from File struct
When uploading a new release, it deserializes the payload into
a File struct for processing. It needs the Version field to
determine which release it's in.

Change-Id: I171f416dbb1b1b6c354948ea9a31b9c8694f892e
Reviewed-on: https://go-review.googlesource.com/110627
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-05-01 16:35:01 +00:00
Nikhil Benesch
836e0f611e cmd/goyacc: fix an off-by-one error in lineno tracking
Previously, goyacc's line number tracking would run off by one whenever
a multiline comment was used inside of an action, like so:

    expr:
        TOKEN
        {
            /* Hello. */
        }

This is because the character after the multi-line comment close marker
(i.e., the character immediately after `*/`) was blindly printed out
instead of properly accounted for. A newline character after a
multi-line comment would fail to increment lineno, for example, and any
error messages generated after that point would refer to the wrong line.
Similarly, a variable reference after a multi-line comment, like

    $$.val = &someStruct{Value: /* oops */$1}

would copy the $ literally into the resulting Go code. (This was not a
problem in practice because multi-line comments are typically followed
by whitespace.)

Adjust the control flow so the character after the multi-line comment
close marker character gets run through the relevant switch statement
and accounted for.

Change-Id: I276b6ffdb7626101f76811b7ee4804bacc6ef740
Reviewed-on: https://go-review.googlesource.com/110495
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-01 01:19:15 +00:00
Bryan C. Mills
165bdd618e imports: fix races in findImportGoPath
Before this change, findImportGoPath used a field within the
(otherwise read-only) structs in the dirScan map to cache the distance
from the importing package to the candidate package to be imported. As
a result, the top-level imports.Process function was not safe to call
concurrently: one goroutine could overwrite the distances while
another was attempting to sort by them. Furthermore, there were some
internal write-after-write races (writing the same cached distance to
the same address) that otherwise violate the Go memory model.

This change fixes those races, simplifies the concurrency patterns,
and clarifies goroutine lifetimes. The functions in the imports
package now wait for the goroutines they spawn to finish before
returning, eliminating the need for an awkward test-only mutex that
could otherwise mask real races in the production code paths.

See also:
https://golang.org/wiki/CodeReviewComments#goroutine-lifetimes
https://golang.org/wiki/CodeReviewComments#synchronous-functions

Fixes golang/go#25030.

Change-Id: I8fec735e0d4ff7abab406dea9d0c11d1bd93d775
Reviewed-on: https://go-review.googlesource.com/109156
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2018-04-30 20:17:55 +00:00
Agniva De Sarker
8e070db38e godoc: remove vendor prefixes for border-radius
All major browsers support the border-radius directive
without any vendor prefix. Hence, removing them.

https://caniuse.com/#search=border-radius

Change-Id: I2da5f109296df3c7f191df95876bd6849f51d9ae
Reviewed-on: https://go-review.googlesource.com/110155
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-28 22:29:17 +00:00
Agniva De Sarker
0b5ca0b040 godoc: use relative css unit
To scale the website elements independently of the default font size,
we use the css rem unit. This scales the elements proportionally if the
user has set a different font size than the default.

We make all calculations assuming that 1rem=16px, which is the
default font size for browsers.

Tested manually on FF 59 and Chrome 65 with permutations of different
resolutions and different default font-sizes upto 36px.

Fixes golang/go#6150

Change-Id: I7ded227ee2c55178271667009ab98ee0b4e7e8b3
Reviewed-on: https://go-review.googlesource.com/94935
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-04-27 00:46:46 +00:00
Rebecca Stambler
6e0e2181b9 go/internal/gcimporter: support indexed export data
Support indexed export data in the x/tools gcimporter. Fixes tests with
tip.

This is just a copy of the bimport.go and iimport.go files in the
standard library gcimporter package, including some minor fixes to the
existing bimport.go. The iexport logic in x/tools still needs to be
updated.

Fixes golang/go#25052

Change-Id: I2858e5c0853735c904f32b7b27c1c288a9e62e88
Reviewed-on: https://go-review.googlesource.com/109595
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-04-26 19:07:32 +00:00
Josh Bleecher Snyder
c1def519f0 imports: improve VendorlessPath docs
Eliminate Latin, lest someone complain
"it's Greek to me".

This work supported by Sourcegraph,
though perhaps not the commit message.

Change-Id: Ia44eaf5bc5adb6624b590c9cfdfe8083d1414a2c
Reviewed-on: https://go-review.googlesource.com/108937
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-23 20:32:37 +00:00
Josh Bleecher Snyder
81527693ec imports: export VendorlessPath
Rename to avoid imports/import stutter and export.
It will be used soon by guru's referrers command.

This work supported by Sourcegraph.

Change-Id: Ibfc39d061d6269a336a59d9b6979188a94537d94
Reviewed-on: https://go-review.googlesource.com/108877
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-04-23 20:00:20 +00:00