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.
Fixesgolang/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>
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>
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>
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>
Thanks to iant for identifying the root cause.
Tested with go1.9 and go1.10.
Fixesgolang/go#25880
Change-Id: Ibc3a2aadd92c1e512cf6c537134ee085398e8e6c
Reviewed-on: https://go-review.googlesource.com/118955
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
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>
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>
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.
Fixesgolang/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>
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>
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>
When program has no output and vet errors are encountered,
initialize data.Events as an empty array.
Fixesgolang/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>
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>
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.
Fixesgolang/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>
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>
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>
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>
- 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.
Fixesgolang/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>
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>
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>
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)
Fixesgolang/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>
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>
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>
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>
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-lifetimeshttps://golang.org/wiki/CodeReviewComments#synchronous-functionsFixesgolang/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>
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>
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.
Fixesgolang/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>
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.
Fixesgolang/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>
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>
If test files are not included here,
then results in those files will be missing
for queries within a single package.
This work supported by Sourcegraph.
Change-Id: I8136ea250ba980179228d9b408d9e7409c49a873
Reviewed-on: https://go-review.googlesource.com/97799
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
This make it possible to easily run individual guru tests.
It also slightly speeds up the overall test run,
from 23s to 18s on my machine;
the TestGuru/calls is now the limiting factor,
by a significant margin.
This work supported by Sourcegraph.
Change-Id: If61ebf1cc60441a65274f3fddd31f69c7ca23b48
Reviewed-on: https://go-review.googlesource.com/108876
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
It is going to be used by a new tool.
Moved to an internal package so it does not become a publicly supported
api.
Modified the tests so they don't depend on the fix_test infrastructure.
Change-Id: Ib8ebef24dc23e180960af04aa3d06b5f41a7c02b
Reviewed-on: https://go-review.googlesource.com/99678
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
CL 107155 introduced this bug due to oversight. There can be
a scenario where a folder has no source .go or .c files,
but has an ignored .go file. In that case, both the if conditions
to check the length of pkgfiles slice will evaluate to true.
Added a test case for it to prevent this happening in future.
Change-Id: I7181699bbf7580888a6f7923c5aeb842356941a8
Reviewed-on: https://go-review.googlesource.com/107195
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
I'd like to propose changes to the directory scanner implementation,
and it would be good to be able to measure how changes compare in
terms of allocations and time taken.
Change-Id: I4ff4bbd38b5e3522f50d31473f2ac607bb0de802
Reviewed-on: https://go-review.googlesource.com/94904
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>