1
0
mirror of https://github.com/golang/go synced 2024-09-30 16:18:35 -06:00
Commit Graph

892 Commits

Author SHA1 Message Date
Chris Broadfoot
bdd8ae38fd cmd/godoc: improve deployment scripts, add buildinfo
* Build Go from a given version (make.bash)
* Add a /buildinfo file that describes the inputs of the
  build/deployment.
* Use Makefile/environment variables to override Go version and
  Docker tag.

Updates golang/go#27205.

Change-Id: Ia7a88b75f9d5b2319d2381e56bc963eb53e889c7
Reviewed-on: https://go-review.googlesource.com/c/138978
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-02 23:13:01 +00:00
Chris Broadfoot
ee6b03148c godoc: migrate to App Engine flexible
See bug for more details on exactly what was migrated.

Notably:
* No more Google-internal deployment scripts; see README.godoc-app and
  the Makefile for details.
* Build tag "golangorg" is used for the godoc configuration used for
  golang.org.
* Use of App Engine libraries replaced with GCP client libraries.
* Redis is used to replace App Engine memcache.
* Google analytics is controlled by an environment variable.
* Regression tests have been migrated from Google-internal.
* hg -> git hash map is moved from Google-internal.

Updates golang/go#27205.

Change-Id: Ia0a983f239c50eda8be2363494c8b784f60c2c6d
Reviewed-on: https://go-review.googlesource.com/133355
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-02 04:34:10 +00:00
Chris Broadfoot
e9ca907325 cmd/godoc: simplify dev and prod environment for App Engine
Remove all of the code generation and the concept of "APPDIR" - just
generate godoc.zip and index files in the app directory.

Simplify generation of the zip - use a symlink so that every file in
godoc.zip is under the "goroot" directory, regardless of the
environment. Previously, the prefix would be dependent on the location
of the user's GOROOT.

Running the setup script is now optional - it's now possible to run
dev_appserver.py on a regular checkout of cmd/godoc without godoc.zip
and search index files. Use environment variables to switch whether the
zip file is used vs reading GOROOT from the filesystem.

Change-Id: I1ce95c891717fe2da975f979778fd775b23f18c8
Reviewed-on: https://go-review.googlesource.com/46725
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-09-28 11:54:07 +00:00
Rebecca Stambler
d457fc8054 cmd/golsp: support formatting in golsp
This commit adds support for some basic commands necessary for
integration with VSCode. It also adds support for the
"textDocument/format" method.

Change-Id: I8fd0e33ca544ab65d3233efe2fef9716446ad4ff
Reviewed-on: https://go-review.googlesource.com/138135
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-09-27 17:02:42 +00:00
Ian Cottrell
ef04bbebd8 cmd/golsp: An empty shell of an lsp server for the go language
Change-Id: I51ef556048c2d10537ad90fa5284939e09bc31fd
Reviewed-on: https://go-review.googlesource.com/137097
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-09-27 15:24:00 +00:00
Jamie Wilkinson
9eb9690e39 cmd/goyacc: put //line annotations on the first column.
This appears to have broken since go1.11, and "go doc compile" and
https://golang.org/issue/24183 documents this new convention (point
2)

Change-Id: I6a4bc0fc51a18c17ac9a72a67d9a8eb4c879e0f9
Reviewed-on: https://go-review.googlesource.com/137515
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-09-26 03:27:08 +00:00
Michael Matloob
0aa4b8830f go/packages: remove the Config.Error hook
Errors relating to a particular package (as opposed to the Load
operation as a whole) are now only recorded in the Errors
field of the corresponding Package.
Clients are responsible for printing or otherwise handling errors.
This is a breaking API change.

The PrintErrors function prints all accumulated errors,
dependencies first, and is provided for convenience.

PrintErrors is based on Visit, another helper function, which
visits each Package in an import graph.

Also:
- add an Example documenting typical use.
- update clients to handle errors explicitly.

Depends on https://go-review.googlesource.com/c/tools/+/130576

Change-Id: I39407ab7f46dae2f0dd0fdde21080e172e1258aa
Reviewed-on: https://go-review.googlesource.com/131015
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-09-04 20:52:37 +00:00
Andrew Bonventre
6cd1fcedba cmd/godoc: remove workaround for 1.8 behavior
1.8 is no longer supported. Remove code that placates it.
Also removes a superfluous newline in appinit.go.

Change-Id: I9c89b5bddf4c001d0854404114fb354209ad6024
Reviewed-on: https://go-review.googlesource.com/131715
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-28 01:58:42 +00:00
Agniva De Sarker
ba93f9405e godoc: update to use new goroot finding logic
The logic to determine whether a filesystem root was in GOROOT or GOPATH
still relied on runtime.GOROOT(), whereas cmd/godoc was updated to copy
the goroot finding logic from standard library.

Hence, godoc is unable to determine if a filesystem is in GOROOT or not
when the binary is outside runtime.GOROOT(). So we expose a new variable
and set that from cmd/godoc to avoid copying the logic again for the 3rd time.

Fixes golang/go#27162

Change-Id: I160dcdbdd262e671f09f7bf01c329be5eac280ad
Reviewed-on: https://go-review.googlesource.com/130796
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-23 15:26:32 +00:00
Brad Fitzpatrick
ef27ca3af5 cmd/godoc: redirect to https instead of http for blog.golang.org
And update some comments.

Change-Id: I4e0b7062fa0d12982ad0f9ee150635cf11ed247c
Reviewed-on: https://go-review.googlesource.com/130555
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-08-22 02:22:54 +00:00
Dominik Honnef
44ec670fe7 cmd/digraph: print usage on -h
Also switch usage printing to using stderr always, as is common for Go
tools.

Change-Id: I240da4344fe6b51a418c0d4b0b7d7e7d5614c1d7
Reviewed-on: https://go-review.googlesource.com/129776
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-20 20:10:23 +00:00
Alan Donovan
9de1900191 go/packages: opt: ignore function bodies in non-initial packages
This saves 35% of wall time in a command such as

 $ gopackages -mode=syntax golang.org/x/tools/go/packages/gopackages fmt

that would otherwise typecheck every function in each package that
depends on fmt. It also applies in -mode=types when source was loaded
as a fall back for missing export data due to an error in a lower package.

Also, remove Config.TypeChecker field now that not a single of its
subfields is passed through go/packages to the type checker.
(The Sizes function is logically a result, not an input, of loading,
though we have yet to implement it properly.)

Change-Id: I472d21b34fc5e2832f7353e82992a67a06e4e4cc
Reviewed-on: https://go-review.googlesource.com/129497
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-08-16 00:26:32 +00:00
Alan Donovan
87c7dcbd5d cmd/callgraph: temporarily disable failing tests on go1.10
go1.10 and earlier versions of go list do not report test main packages.
Furthermore, go/packages has errors in its Imports under go1.10.

The long-term fix is for go/packages to synthesize test main packages
when working with older versions of the go command, but in the
meantime we will disable the tests.

Updates golang/go#11811

Change-Id: Ifd5e37d5b68a01134e911fda90e30a39fc25b88d
Reviewed-on: https://go-review.googlesource.com/129175
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-13 17:53:22 +00:00
Rebecca Stambler
e10408200f cmd/guru: fix tests for line directives in Go 1.11
Go 1.11 changed the behavior of line directives, so reflect that in the
golden files for tests.

Change-Id: I7df282dfbeb3bfc5d75481c345acf724bb0b25bf
Reviewed-on: https://go-review.googlesource.com/128999
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-08-13 16:50:33 +00:00
Alan Donovan
27709f6afe cmd/ssadump: use go/packages
Unlike go/loader's FromArgs, go/packages doesn't return the
non-package arguments, so we add a new repeated flag -arg=x -arg=y to
specify them.

Because we cannot add packages to a packages.Load query, we emit an
error if -run is specified and "runtime" is not among the
dependencies.

There is no easy way to distinguish synthetic test main packages
from regular main packages, so we no longer try.
This makes -test and -run orthogonal.

Change-Id: Ibd69b993c05de62df01dde52218a9e266cd63a71
Reviewed-on: https://go-review.googlesource.com/128837
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-08-10 20:16:25 +00:00
Kazuhiro Sera
4354ead92e all: fix typos in comments
This pull request fixes several typos in comments. I believe that they're safe enough.

Change-Id: Ic7c594bdb89dcd04f8775f225abbc0f966f3728e
GitHub-Last-Rev: 2394feb263714c83b419f45eccb3c6c9fdff7fed
GitHub-Pull-Request: golang/tools#45
Reviewed-on: https://go-review.googlesource.com/128956
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-10 18:15:57 +00:00
Alan Donovan
e96c4e2476 x/tools: remove old renaming imports of go/constant as exact
Fixes golang/go#26522

Change-Id: Ie8184a358f11bc7ad855e0eeb964c29848d2263e
Reviewed-on: https://go-review.googlesource.com/128998
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-10 17:04:37 +00:00
Russ Cox
4432cd1c27 cmd/compilebench: fix GOROOT inconsistencies
If GOROOT is unset (as is common now),
then the output of "go env GOROOT" may
differ from the GOROOT inferred by alternate
compilers being executed and also from the
value of runtime.GOROOT() inside compilebench,
used by go/build. Harmonize all of these by
setting GOROOT explicitly (will fix subcommands)
and by invoking the go command to learn about
packages instead of assuming go/build has any
idea what it's doing.

Change-Id: If97aa76cc2afec11a8404975f39329db7eb452e0
Reviewed-on: https://go-review.googlesource.com/109516
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-08-10 00:27:41 +00:00
Alan Donovan
1bd72987c2 cmd/callgraph: use go/packages
Because go/packages presents each synthesized test main package
as a first-class package, the tests now analyze all of the dependencies
of "testing", which they previously avoided.  This makes the tests
slower and the resulting call graph much larger,
so they now look for a subset match, not an exact match,
on the set of graph edges.

Change-Id: I9d7acf420e41cbffc03ca8423f5afb3ef671d775
Reviewed-on: https://go-review.googlesource.com/128695
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-08-09 16:04:36 +00:00
Agniva De Sarker
4d8a0ac9f6 cmd/godoc: fix TestWeb for versions < 1.11
The test was looking for strings found in specific Go versions
without checking for the actual Go version running the test.

Used ReleaseTags to check whether the current go version should
execute a test or not.

P.S. The version info is inferred from the binary running the test.
But the test builds godoc using the "go" binary in $PATH. In case
one is testing different go versions, please ensure to run tests
by changing the $PATH variable to point to different go versions,
rather than using a custom go binary in a different path.

Fixes golang/go#26531

Change-Id: I16dda81518021e865e79c9c29fc2d9e8a83e7057
Reviewed-on: https://go-review.googlesource.com/125755
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-25 15:26:38 +00:00
Jim Minter
4735f53fb3 cmd/goyacc: append trailing newline to text "Code generated by goyacc"
Fixes golang/go#26478

Change-Id: Ieaf7dcaf639b277555580964acfff034393284e2
GitHub-Last-Rev: f2a6ab2a513d4938cda62f46de7f5314714b5325
GitHub-Pull-Request: golang/tools#39
Reviewed-on: https://go-review.googlesource.com/124995
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-19 18:26:00 +00:00
Brad Fitzpatrick
32950ab3be godoc: add version info for struct fields
Follow-up to CL 85396, which only did types, funcs, and methods.

This adds version info to struct fields (in the form of small
comments) if the struct field's version is different from the struct
itself, to minimize how often this fires.

Updates golang/go#5778

Change-Id: I34d60326cbef88c108d5c4ca487eeb98b039b16e
Reviewed-on: https://go-review.googlesource.com/124495
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Devon O'Dell <dhobsd@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-17 23:22:00 +00:00
Devon H. O'Dell
57f659e14d godoc: show version information for stdlib
This change reads $GOROOT/api/go1.*.txt when godoc starts and caches
information about which versions of Go introduce functions, types, and
methods. This information is displayed currently only in HTML output.
Functions, types, and methods introduced as part of Go 1 are not
annotated, as their presence at that version is implied.

This change does not address constants or variables, and completely
ignores the syscall package. The former are future work, the latter is
likely an exercise in futility. In all cases, this is because the story
around displaying the version information is not well developed.

Fixes golang/go#5778

Change-Id: Ieb3cc0da7b18e195bc9c443f14fd8a82e8b2bbf8
Reviewed-on: https://go-review.googlesource.com/85396
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Devon O'Dell <dhobsd@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-17 18:09:30 +00:00
Rob Pike
18f0b668f1 cmd/stringer: add a -tags flag that supports build tags
This is reapplying CL121995 after rolling back the change to the importing
methods. There is still a need for a flag to control tags.
The original CL decription:

The feature has been requested but, like build tags in general,
only works in a directory, not when files are specified explicitly.
Unlike the build tools, report when the feature is misused like this
to avoid confusion.

Fixes golang/go#9449

Change-Id: I732627d5f2e6323367e3bdd5de746923868890a9
Reviewed-on: https://go-review.googlesource.com/122537
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-10 05:22:40 +00:00
Rob Pike
e2be0f7276 cmd/goyacc: include arguments in DO NOT EDIT marker
A follow-on to CL122095, which normalized the marker but
did not include the arguments.

Output now looks like this:

	// Code generated by goyacc -o expr.go -p expr expr.y. DO NOT EDIT.

Change-Id: I20577ea90943516f45478d778353b5bd2f485dfa
Reviewed-on: https://go-review.googlesource.com/122540
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-09 04:37:16 +00:00
Rob Pike
827133af57 cmd/stringer: revert back to source importer
Roll back my two recent changes. Stringer is now very slow again,
but works in most use cases.

My git foo is insufficient to do this as a revert, but it is a by-hand
reversion of CLs

	https://go-review.googlesource.com/121884
	https://go-review.googlesource.com/121995

See the issue for a long conversation about the general problem.

Update golang/go#10249
Update golang/go#25650

Change-Id: I7b6ce352a4c7ebf0977883509e9d7189aaac1251
Reviewed-on: https://go-review.googlesource.com/122535
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-07 07:48:14 +00:00
Agniva De Sarker
435878328f cmd/godoc,cmd/tip: enable HSTS preload
Add the includeSubDomains directive to meet the requirements
for being added to the preload list described at https://hstspreload.org/.

Updates golang/go#26162

Change-Id: I415775aa523bcef3a52f1853de033f343b914e83
Reviewed-on: https://go-review.googlesource.com/122175
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-06 16:21:24 +00:00
Jonathan Pentecost
16f8f9bb72 cmd/goyacc: add header to generated go output file
Add "// Code generated by goyacc. DO NOT EDIT." to the top of the
generated go output file.

Fixes golang/go#26158

Change-Id: I5dd66af9cd8ccccd27440886c55cd604686472e3
Reviewed-on: https://go-review.googlesource.com/122095
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2018-07-05 09:00:07 +00:00
Rob Pike
75d2ffb453 stringer: add a -tags flag that supports build tags
The feature has been requested but, like build tags in general,
only works in a directory, not when files are specified explicitly.
Unlike the build tools, report when the feature is misused like this
to avoid confusion.

Fixes golang/go#9449

Change-Id: I079d363c5eeb5bc647fd2f0f3d88d28d630644d8
Reviewed-on: https://go-review.googlesource.com/121995
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-04 00:06:24 +00:00
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
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
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
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
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
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
Josh Bleecher Snyder
71f44073ef cmd/guru: always import tests in initial referrers import
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>
2018-04-23 20:00:06 +00:00
Josh Bleecher Snyder
7e5e8df4df cmd/guru: make tests granular and parallel
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>
2018-04-23 19:59:51 +00:00
Agniva De Sarker
d11f6ec946 blog: serve relative links when run locally
Currently, links inside blog articles are absolute links to golang.org.
But when a godoc server is run locally, the blog package should
serve local links pointing to the local godoc server. It is not possible
to simply change the links inside the blog templates to relative urls
because the blog articles are independant pages on their own.
And moreover, they are served from blog.golang.org.

Rather, the blog package consumes and serves blog articles.
So, a flag was added in the Config struct to denote whether
to convert the links or not. This flag is then set from the
call site in godoc package where the blog server is initialized from.

This was required because "golang.org/x/tools/blog" is a package
which can be used by other code to serve blog pages and not just godoc.
This preserves existing functionality for all working code which
imports "golang.org/x/tools/blog" and changes the functionality only
when a godoc server is run locally.

And while here, replace relevant bytes.Buffer occurences
with strings.Builder.

Fixes golang/go#22681

Change-Id: I7dbf9c5f2f93fd0b7e17915238de1c084fcd1431
Reviewed-on: https://go-review.googlesource.com/105835
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-13 18:10:15 +00:00
David Url
5e86cd2985 cmd/present: display slide numbers
Fixes golang/go#5331

Change-Id: Iddd45452959823b2e8e3f9b4236a9a9a3968d35f
Reviewed-on: https://go-review.googlesource.com/97058
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-04-13 16:54:21 +00:00
Brad Fitzpatrick
dc06d3e643 cmd/godoc: support http-01 ACME challenge in optional autocert support
Using same structure & naming as CL 91518.

Fixes golang/go#23627

Change-Id: Ifb73c77d2c39f9f669d425650f9c5bc31bace196
Reviewed-on: https://go-review.googlesource.com/106455
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-04-11 21:25:11 +00:00
Brad Fitzpatrick
368a7e18b5 cmd/guru: skip broken test for old Go versions for now
Updates golang/go#24421

Change-Id: Iedcb629135802f78e8f149b377f34e49c8019fe9
Reviewed-on: https://go-review.googlesource.com/106435
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-04-11 19:25:09 +00:00
Agniva De Sarker
faed997d2c godoc: cleanup package templates
Separate the templates of package root directory and other
directories. This removes several if-else conditions and
makes the template code much cleaner.

To be merged after CL 95835.

For golang/go#3305

Change-Id: I435441dbe214e4c89271483173df7c30a42ee28f
Reviewed-on: https://go-review.googlesource.com/101295
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-04-10 16:42:09 +00:00
Dmitri Shuralyov
370143dbca godoc/static: add perf, review, sync subrepos
They exist and are considered to be worth listing based on the decision
made in golang/go#24432. They weren't listed previously. This change
fixes that.

Document the remaining subrepos that are not meant to be listed (per
decision in golang/go#24432), so it's clear that it's intentional for
them to not be visible at https://golang.org/pkg/#subrepo.

Closes golang/go#24432.
Updates golang/go#14304.

Change-Id: Icc50ebfcdbc490c32519d92a1a838eb3f54c823d
Reviewed-on: https://go-review.googlesource.com/103075
Reviewed-by: Austin Clements <austin@google.com>
2018-03-30 16:45:20 +00:00
Yury Smolsky
77106db15f cmd/godoc: fix TestWebIndex test
The godoc in the test was indexing sources in the default GOPATH.
If the default GOPATH pointed to local workspace, test would timeout.
The fix is to supply GOPATH set to non-existing path.

Fixes golang/go#24504

Change-Id: Iedf044cdec78d5c5642105650ad8ec17aa10a5ba
Reviewed-on: https://go-review.googlesource.com/102295
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-03-24 18:54:18 +00:00
Yury Smolsky
39919aea04 cmd/godoc: provide -all flag to output unexported identifiers
This flag includes unexported identifiers in command-line mode.
It is equivalent to ?m=all in web mode.

Fixes golang/go#8093

Change-Id: I1e5a69626929d3430638d900f3e975b272a98c90
Reviewed-on: https://go-review.googlesource.com/99435
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-03-16 16:52:36 +00:00
Robert Griesemer
c4b4e4b0fa cmd/guru: fix .golden file (fix build)
This regression is due to https://go-review.googlesource.com/c/go/+/100235
which made the go/scanner behavior match the compiler's scanner by
not modifying filenames in line directives in any form. Specifically,
relative filenames now remain relative. This makes it easier to reason
about the behavior of the scanner but may require clients to adjust
those filenames.

If removing the longer path in the .golden file is not satisfactory,
the (scanner) client may have to massage positions returned via line
directives; or better, the line directives are created with extended
path information.

R=adonovan

Change-Id: I836571a6dafef5e6d81e4c7add203c994e107055
Reviewed-on: https://go-review.googlesource.com/101015
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-03-16 01:01:07 +00:00
Nishanth Shanmugham
059bec968c cmd/goimports: support multiple comma-separated imports in -local flag
In cmd/goimports, allow for the -local flag to accept a comma-separated
list of import path prefixes. Also, update the imports package
accordingly to support this.

Fixes golang/go#19188

Change-Id: I083d584df8c3a77532f0f66e9c5d970960180e0d
Reviewed-on: https://go-review.googlesource.com/85397
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-03-05 19:26:41 +00:00
Andrew Bonventre
733d489786 cmd/godoc: add x/lint and x/vgo redirects
Change-Id: I6e21f167091338600c2a0a37411b0a565d27ce36
Reviewed-on: https://go-review.googlesource.com/96196
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-02-22 03:57:22 +00:00
Andrew Bonventre
5e776fee60 cmd/tip: update talks hash to pull in e00c182
Updates golang/go#21643

Change-Id: Ic662ac6ca152d8cf702b02651f55936a29a2e234
Reviewed-on: https://go-review.googlesource.com/95675
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-20 22:33:34 +00:00
Daniel Martí
90b807ada4 all: fix a few issues found by unparam
In cmd/present, a mode was being passed to the function parse, but it
wasn't actually being used. Use it.

In go/ssa, checkFinalInstr received an idx integer but it doesn't
actually need it. Get rid of it.

Lastly, in imports, findImportStdlib always returned rename==false. Get
rid of that result parameter.

Change-Id: I719006b69ee80a3ef4b0ea24c1c206016a7e304b
Reviewed-on: https://go-review.googlesource.com/93596
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-02-13 22:52:51 +00:00
Agniva De Sarker
006ac430a0 godoc: init corpus in a separate goroutine in http mode
Currently, in http mode the server blocks until the corpus
has been initialized. This can cause considerable delay
if the user workspace is significantly large and the files
are not present in the buffer cache.

This CL spawns off the initialization in a separate goroutine
if httpMode is set and turns on a flag when it's done.
The http handler checks the flag and returns an error response
if it has not been set.

The check is only performed for the path prefixes handled by the
handlerServer struct. Other paths do not call the GetPageInfo() function
and hence can return immediately. This preserves maximum responsiveness
of the server.

Also adds an additional print statement in verbose mode

Note: This is a re-do of a previous CL golang.org/cl/88695 which was
incorrect committed without running tests. This CL fixes that test.

Fixes golang/go#13278

Change-Id: I80c801f32af007312090d3783a2ea2c6f92cad66
Reviewed-on: https://go-review.googlesource.com/93215
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-13 20:23:58 +00:00
Andrew Bonventre
70252dea49 Revert "godoc: init corpus in a separate goroutine in http mode"
This reverts commit f86b507a7e.

Reason for revert: broke tests in tools repo

Change-Id: Id7e5d8e050896b6f5fedaee705be8a5f9adf4bf3
Reviewed-on: https://go-review.googlesource.com/93115
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-02-09 17:03:34 +00:00
Brad Fitzpatrick
66487607e2 cmd/tip: enable HTTP ACME challenges
Updates golang/go#23627

Change-Id: I9dff655b531dc3491419ee1883c570c0bc5d8955
Reviewed-on: https://go-review.googlesource.com/91518
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-02-02 16:21:31 +00:00
Andrew Bonventre
25101aadb9 godoc,cmd/getgo: update download links to dl.google.com
Change-Id: Idd003c76edbf9d3ecf3354036e734386c55ed1f2
Reviewed-on: https://go-review.googlesource.com/89695
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-01-25 02:56:30 +00:00
Agniva De Sarker
f86b507a7e godoc: init corpus in a separate goroutine in http mode
Currently, in http mode the server blocks until the corpus
has been initialized. This can cause considerable delay
if the user workspace is significantly large and the files
are not present in the buffer cache.

This CL spawns off the initialization in a separate goroutine
if httpMode is set and turns on a flag when it's done.
The http handler checks the flag and returns an error response
if it has not been set.

The check is only performed for the path prefixes handled by the
handlerServer struct. Other paths do not call the GetPageInfo() function
and hence can return immediately. This preserves maximum responsiveness
of the server.

Also adds an additional print statement in verbose mode

Fixes golang/go#13278

Change-Id: I0505acc1c190423d09fb199b11ca86e0400e84d4
Reviewed-on: https://go-review.googlesource.com/88695
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-01-23 16:04:43 +00:00
Andrew Bonventre
99037e3760 cmd/godoc: allow golang.google.cn as a valid host
Change-Id: I8a585ad64f389f57800afe99824ae249c9f80340
Reviewed-on: https://go-review.googlesource.com/88677
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-01-20 03:13:38 +00:00
Andrew Bonventre
951512dfed godoc: proxy /compile requests to play.golang.org
Now that play.golang.org and sandbox[-flex].golang.org have been
merged, proxy requests to the former.

Change-Id: I7d18d0494fd54c2357dc53952fa458ceb1380aca
Reviewed-on: https://go-review.googlesource.com/86253
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-01-04 23:58:58 +00:00
Daniel Martí
ae8cc59455 cmd/stringer: add flag to use line comment as str
This can be very helpful if you lay out each value's string
representation like this:

	and    // &
	andAnd // &&
	or     // |
	orOr   // ||

Without the use of comments, it's impossible to use stringer with these
names as the characters & and | cannot form valid identifiers in a Go
program.

Fixes #20483.

Change-Id: I4d36c74059dd48ae3a5e09b70a429a75853ef179
Reviewed-on: https://go-review.googlesource.com/44076
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Rob Pike <r@golang.org>
2017-12-19 23:05:15 +00:00
HENRY-PC\Henry
71657689f0 stringer: don't emit unnecessary variables
Fixes golang/go#23014

Change-Id: I159f83bae0ed632b0b3c00f8ab02f5701acbc4cc
Reviewed-on: https://go-review.googlesource.com/82215
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2017-12-07 08:59:40 +00:00
Brad Fitzpatrick
36c7af3342 all: fix plan9 build
getgo doesn't work on plan9. Skip it entirely.

And skip the massive slow godoc start-up test. Not worth it.

Change-Id: If062b7c4c8c7c5084e607ed22085657054c10ba9
Reviewed-on: https://go-review.googlesource.com/80737
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-29 20:22:11 +00:00
Alan Donovan
2c687adedb go/ssa/interp: drop interpretation of "testing" package
The "testing" package depends on low-level details that change too often.

Change-Id: I59101e16588296cb40c851d4a34ddf199f4d176c
Reviewed-on: https://go-review.googlesource.com/80376
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-11-28 21:57:06 +00:00
Daniel Martí
bd4635fd25 cmd/stringer: use strconv instead of fmt
In the generated code, we want to pull in as few dependencies as
possible. fmt is heavier than strconv, and the latter can be used with a
bit of extra code for the same results.

More importantly, this will allow stringer to be used in some std
packages that cannot import fmt, such as regexp/syntax. While strconv
lies in L2 in deps_test.go, fmt lies in L4.

This means that many other packages will also be able to use stringer
where it could be useful, such as path/filepath, os/exec, or io/ioutil.

Since some of these types may be 64-bit integers, use FormatInt instead
of Itoa to avoid overflows with int on 32-bit.

Also double-checked that the generated code is still formatted properly.

Change-Id: Iffb3bd2df5c94407705689719240aca0c7474a89
Reviewed-on: https://go-review.googlesource.com/77473
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-11-14 15:22:39 +00:00
Daniel Martí
bce7a99f8a cmd/stringer: add -trimprefix option
To trim a string prefix from the names when generating their final
strings. Add a simple test too.

There is no automatic detection of prefixes for now. That can be added
later, building on top of this first simple implementation.

Fixes #16539.

Change-Id: Ica37273ac74bb0a6cbd43e61823786963d86a492
Reviewed-on: https://go-review.googlesource.com/76650
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2017-11-09 22:55:28 +00:00
Ian Lance Taylor
05e91d0638 cmd/stringer: fix typo in test log message ("no" -> "not")
Fixes golang/go#22623

Change-Id: I62ab82a04f34f379f715f0902a69caa9c74c50d2
Reviewed-on: https://go-review.googlesource.com/76397
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Kevin Burke <kev@inburke.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-11-07 22:55:16 +00:00
David R. Jenni
9adcb2aa41 cmd/getgo: fix vet failure caused by missing argument to Errorf call.
Change-Id: I2812e2c655a0e463203f5c2ede08182c40556953
Reviewed-on: https://go-review.googlesource.com/75975
Reviewed-by: Gabriel Aszalos <gabriel.aszalos@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Gabriel Aszalos <gabriel.aszalos@gmail.com>
2017-11-06 15:28:13 +00:00
David R. Jenni
9e72de2cfb cmd/gorename: fix test failure formatting.
Change-Id: Idbfb356225f4650446bffa80a43cec4679bcd507
Reviewed-on: https://go-review.googlesource.com/75976
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-11-06 14:18:16 +00:00
griesemer
032dfd515a cmd/toolstash: don't try comparing "asm -V=full" output.
Added link as well, since they are all symmetric.

Follow-up on https://go-review.googlesource.com/c/tools/+/75670.

For golang/go#22552.

Change-Id: I12d951b800cd5fc7abc6d09e6a8a986e3f9f6936
Reviewed-on: https://go-review.googlesource.com/75672
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-11-02 22:54:56 +00:00
Matthew Dempsky
d620ba0fbb cmd/toolstash: don't try comparing "compile -V=full" output
Fixes golang/go#22552.

Change-Id: I2a31cf4fe85f33068502102031ed62f06abb6d6e
Reviewed-on: https://go-review.googlesource.com/75670
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-11-02 22:39:47 +00:00
Cherry Zhang
e4b401d06e cmd/toolstash: pass -c=1 in the second compilation
When toolstash -cmp found diff, it does a second compilation
with extra flags -v -m=2, which are imcompatible with the
concurrent backend. Pass -c=1 in the second compilation.

Change-Id: I3c77069936da1829b68375a4a6c7f9bbe364247c
Reviewed-on: https://go-review.googlesource.com/60390
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-10-10 17:47:39 +00:00
Carl Johnson
e00c182679 present: Scale down slides on smaller displays
On mobile and tablets, it was very difficult to view slides because the
slides were not designed to be smaller than 1250x750.

This adds a function to the JS that uses CSS scaling to make the slides
fit on smaller displays.

Fixes golang/go#21643

Change-Id: I68e9e2c1274aaf6396bf01d19ca023cddf76e2ec
Reviewed-on: https://go-review.googlesource.com/60270
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Francesc Campoy Flores <campoy@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Francesc Campoy Flores <campoy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-31 21:56:44 +00:00
Dmitri Shuralyov
5831d16d18 cmd/callgraph: fix "import path of the enclosing package" example in usage
Caller is *ssa.Function. Its Pkg field is *ssa.Package. But ssa.Package
struct doesn't contain either field or method named Object.

So one gets the following error:

	$ callgraph -format '{{.Caller.Pkg.Object.Path}} -> {{.Callee.Pkg.Object.Path}}' \
	    $(go env GOROOT)/src/net/http/triv.go | sort | uniq
	callgraph: template: -format:1:9: executing "-format" at <.Caller.Pkg.Object.P...>: can't evaluate field Object in type *ssa.Package

ssa.Package contains Pkg field:

	Pkg     *types.Package    // the corresponding go/types.Package

types.Package contains Path() method that returns the package path.

That appears to be the right way to get the "import path of the
enclosing package" with the current x/tools/go/ssa API.

Fixes golang/go#20459.

Change-Id: I3cb7b61b767148f5c771d57f8f5e7e6ab20aea87
Reviewed-on: https://go-review.googlesource.com/43812
Reviewed-by: Avelino <t@avelino.xxx>
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-08-08 14:46:45 +00:00
Jaana Burcu Dogan
fcc44a6330 cmd/getgo: add a user-agent to download requests
Change-Id: Ic8fa61e53e2d06a02b06b685bd1082423df00825
Reviewed-on: https://go-review.googlesource.com/52530
Run-TryBot: Jaana Burcu Dogan <jbd@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2017-08-01 21:43:54 +00:00
Brad Fitzpatrick
3fd990c6be cmd/tip: fix the build
https://golang.org/cl/52390 was submitted too early with failing trybots.

This fixes it, hiding the cloud.google.com stuff behind a build tag,
used by the Dockerfile but not the Go build system.

Change-Id: I66c6b40d4b06bf6c763f3ab221c7997856bfc910
Reviewed-on: https://go-review.googlesource.com/52470
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jessie Frazelle <me@jessfraz.com>
2017-08-01 18:51:51 +00:00
Brad Fitzpatrick
d07a458d9a cmd/tip: add a cert cache, clean up Kubernetes config, use update-deps
Fixes expired cert issue too, either by virtue of newer autocert, or
that we're no longer hitting some LetsEncrypt rate limit.

But we have a cache now at least, so we should be nicer to LetsEncrypt
when the process dies. I did see some process crashes (old?) in the
logs. So maybe we were crashing and re-hitting LE often.

Verified that the cert now expires:
    Sunday, October 29, 2017 at 9:57:00 PM Pacific
and that it's cached in GCS.

Fixes golang/go#21251

Change-Id: I3def551ae8eef5df0ec7c51927c4d4bb52cd7a6a
Reviewed-on: https://go-review.googlesource.com/52390
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Reviewed-by: Jessie Frazelle <me@jessfraz.com>
Run-TryBot: Jessie Frazelle <me@jessfraz.com>
2017-08-01 15:37:25 +00:00
Jaana Burcu Dogan
9badcbe49b cmd/getgo: prompt warning if an earlier installation exists
There is nothing else we can do other than just showing a
message that user need to remove it from their PATH not
to conflict with the current installation.

Fixes #21217.

Change-Id: Ie65385f4d536d5bb789387ba0229f54f2ee793f0
Reviewed-on: https://go-review.googlesource.com/51930
Run-TryBot: Jaana Burcu Dogan <jbd@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Kevin Burke <kev@inburke.com>
2017-07-31 22:15:19 +00:00
Chris Broadfoot
f2b3bb0049 cmd/getgo: fix builds
A couple fixes:

* Disable integration tests in short mode.
* Remove import of "google.golang.org/appengine" package. App Engine has
two ways to create an app: as a main package and calling
appengine.Main(), and as any regular Go package with handlers registered
in init().

Change-Id: Ib416111786c1c86cf428d91c60dc406c251d3ca1
Reviewed-on: https://go-review.googlesource.com/52211
Run-TryBot: Chris Broadfoot <cbro@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jaana Burcu Dogan <jbd@google.com>
2017-07-31 18:28:23 +00:00
Jaana Burcu Dogan
001b4ec819 cmd/getgo: have consistent messages
Currently, we output:

The latest go version is go1.8.3, install that? Y/n [Y]: Y
Download go version go1.8.3 to /Users/jbd/.go? Y/n [Y]: Y

Change-Id: I4fa72f2066259b75d3349487dae5bdced9fdd8a2
Reviewed-on: https://go-review.googlesource.com/51910
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2017-07-31 17:12:47 +00:00
Jaana Burcu Dogan
29518d98f4 cmd/getgo: display that -i stands for interactive mode
Change-Id: Ia6d8b0e9b2a355d2c4b41634fd51de51187be833
Reviewed-on: https://go-review.googlesource.com/51931
Reviewed-by: Kevin Burke <kev@inburke.com>
2017-07-31 17:04:26 +00:00
Chris Broadfoot
ac1e4b1998 cmd/getgo: initial commit
Initial commit of getgo, a "one-line installer".

Example use from bash:

  curl -LO https://get.golang.org/$(uname)/go_installer && chmod +x go_installer && ./go_installer && rm go_installer

It's comprised of two parts:

cmd/getgo/server: an App Engine application that redirects users to an
appropriate installer based on the request path, which identifies the
user's operating system. It's deployed to get.golang.org.

cmd/getgo: a cross-compiled binary that does the heavy lifting of
downloading and installing the latest Go version (including setting up
the environment) to the user's system. The installers are served from
the golang GCS bucket.

Currently supported systems:
  linux, darwin, windows / amd64, 386

Authored by Jess Frazelle, Steve Francia, Chris Broadfoot.

Change-Id: I615de86e198d3bd93e418fa23055d00ddbdd99fb
Reviewed-on: https://go-review.googlesource.com/51115
Reviewed-by: Jaana Burcu Dogan <jbd@google.com>
2017-07-28 18:26:31 +00:00
Matthew Dempsky
3da34b1b52 cmd/gorename: disable TestGeneratedFiles for !cgo builds
Fixes golang/go#21055.

Change-Id: I126cef4496c15424048e39b2af111c95580b90fb
Reviewed-on: https://go-review.googlesource.com/49390
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-07-17 21:59:59 +00:00
Tim Heckman
807424b52b cmd/go-contrib-init: exit with an error if package install fails
During the first run of `go-contrib-init` it tries to install the
golang.org/x/review/git-codereview package using `go get`. If this command were
to fail, we would check for the error and log that the command failed to
succeed. However, when failure occurred we would only log the error and not
interrupt the flow of the program. This would cause the program to continue with
the assumption that git-codereview had been installed correctly.

This change enhances the `go-contrib-init` command to exit with a bad status
code, after logging the failure, if installing git-codereview fails.

Fixes golang/go#21040

Change-Id: Ie01d78557d54285001db61faafbb409888b2893c
Reviewed-on: https://go-review.googlesource.com/49151
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-17 03:20:55 +00:00
Edward Muller
41b76ca51c present: Set the background using CSS
This allowed me to better match the background image to the size of
the slides.

Change-Id: Ieaae93cd78582a3059ed6c3e64e740dea9088af5
Reviewed-on: https://go-review.googlesource.com/47130
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-07-17 00:28:30 +00:00
Austin Clements
7a4327eb7a cmd/go-contrib-init: don't crash from src/golang.org/x
If go-contrib-init is executed from the src/golang.org/x directory (as
opposed to a sub-directory), it crashes with an index out-of-bounds.

Fix this by including the trailing slash in the inspected path prefix
so we never slice more than what we know is in the string.

Change-Id: Ibbb74759c2ba839972de34a8ffb28b6cfb6825e2
Reviewed-on: https://go-review.googlesource.com/48690
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-15 16:38:41 +00:00
Kevin Burke
6f1996fdfe cmd/go-contrib-init: better GOPATH checkout error message
Modify the error message to provide more context if the user is in the
wrong directory. (The default Terminal.app does not do a great job of
showing what directory you are currently in).

Change-Id: Iafcbbd2070ca968863120fb8c4bc15609475cda2
Reviewed-on: https://go-review.googlesource.com/48232
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-13 05:25:58 +00:00
Leo Rudberg
7a94893dc3 cmd/eg: Gofmt eg's dry-run output.
The content of the dry-run and the actual (file-editing) run should now
be the same.

Change-Id: If89f85838f7f53f14ffa4e2b6a425507835dda62
Reviewed-on: https://go-review.googlesource.com/48210
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-13 04:09:46 +00:00
Kevin Burke
76622760f0 cmd/go-contrib-init: match subdomain-less .gitcookies file
My `.gitcookies` file starts with ".googlesource.com", which
errored because it did not match "go.googlesource.com" or
"go-review.googlesource.com". Fix this by optionally matching on
"go.googlesource.com" or ".googlesource.com".

Fixes golang/go#20992.

Change-Id: I29d3c0b1e958382495a90502f280bdb52868c2c7
Reviewed-on: https://go-review.googlesource.com/48230
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-13 03:45:07 +00:00
Hiroshi Ioka
bce9606b3f cmd/bundle: include non-associated comments
https://golang.org/cl/45117 doesn't handle comments which don't
belong to any declarations. This CL addresses it.

Fixes golang/go#20627

Change-Id: I81c7cdc070efc6cb9e9f38101d7b2b8909916ba6
Reviewed-on: https://go-review.googlesource.com/45190
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-07-07 17:27:36 +00:00
suzmue
9dc2b714a0 cmd/gorename: add tests that run successfully
Set the env variable to only include the correct gopath in the test.

Fixes golang/go#20805

Change-Id: I496ed5c60278e508016f915cf53a115cc3c222ae
Reviewed-on: https://go-review.googlesource.com/47410
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-07-07 17:24:26 +00:00
Brad Fitzpatrick
6e57528ade imports: fix reading from stdin on Windows
Don't panic when reading from stdin on Windows. This is a regression
from https://golang.org/cl/43454

Also fix some weird behavior with stdin processing I noticed during
reviewing the code: don't allow the -w (write) flag, and adust the
filename shown with the -d (diff) flag.

Fixes golang/go#20941

Change-Id: I73d0a1dc74c919238a3bb72823585bbf1b7daba1
Reviewed-on: https://go-review.googlesource.com/47810
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Jones <rbjones@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-07 17:20:05 +00:00
Alan Donovan
da9759ca30 cmd/bundle: fix nil dereference panic
In the loader API, (*Config).Import, like go/build, accepts relative
paths such as ".", but (*Program).Package requires the exact path of a
loaded package.  So, to find the package identified by "." we must
look at the set of packages actually loaded, which in this scenario is
guaranteed to be a singleton.

(This is a definite weakness of the loader API.  In the more general
case where two or more packages are imported, it's tricky to correlate
the calls to Import with the package(s) each call actually loads.)

Fixes golang/go#20751

Change-Id: I925e969c9b4f4d6b6344c16f156b47857436d70a
Reviewed-on: https://go-review.googlesource.com/46414
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-06-23 02:24:18 +00:00
Suzy Mueller
1ab5277e83 refactor/rename: fail cleanly when attempting to rename cgo files
Previous implementation will overwrite files the import "C" with the
cgo preprocessing and renaming. Rename will now emit an error when
rename must edit files that import "C". Will also emit more useful
error when using -offset in a "C" importing file.

Fixes golang/go#17839

Change-Id: I072100b22197ec145b56d727feca58be7529e359
Reviewed-on: https://go-review.googlesource.com/45930
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-06-23 01:23:57 +00:00
Yasuhiro Matsumoto
545ce0dcdd tools: handle paths like ~/ or $HOME/.
tilde should be located at the beginning of line.

Change-Id: I271ba5220da3c483838d1741d908755aee8e081e
Reviewed-on: https://go-review.googlesource.com/46430
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-22 02:08:34 +00:00
Koichi Shiraishi
cd6e398dae cmd/git-contrib-init: support http.cookiefile config for gitcookies
Change-Id: I097905122e1cb7298c31c330731f0fc3c6fc9b59
Reviewed-on: https://go-review.googlesource.com/46235
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-21 15:43:17 +00:00
Koichi Shiraishi
601a54bfa3 cmd/go-contrib-init: fix get GOPATH env logic
Go runtime now uses user homedir+go (i.e. $HOME/go) if GOPATH
environment variable is not set.

Change-Id: I26d90e07976a5311ea19de8a6e2c63830b802882
Reviewed-on: https://go-review.googlesource.com/46234
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-21 05:03:32 +00:00
Brad Fitzpatrick
f2cd9d3b51 cmd/go-contrib-init: fix in-GOPATH check
It's okay to have GOROOT=$HOME/go, GOPATH=$HOME.

That's what I have.

It's just not okay to hack in Go under $GOPATH/src.

Change-Id: I6ae69aceb43970bbdc9631ab090689a153954087
Reviewed-on: https://go-review.googlesource.com/45651
Reviewed-by: Steve Francia <spf@golang.org>
2017-06-14 16:55:02 +00:00
Chris Broadfoot
b4e0c5ecfb cmd/tip: manually scale talks to 1 instance
Disable health checker - it only causes trouble if we're running on one
instance. We'd rather see "starting up" than to have nothing served and
the instance killed when it doesn't come up ready in time.

Change-Id: I3396c626f840d606e0fb4a5ec4c0493195fd015f
Reviewed-on: https://go-review.googlesource.com/45654
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-13 23:21:29 +00:00
Chris Broadfoot
aca8b28035 cmd/tip: log error when fetching metadata
This error was previously ignored. This caused a silent failure when the
meta URL wasn't accessible.

Change-Id: I4020897ac15fec7b60a46277d81a99a6b6447a7d
Reviewed-on: https://go-review.googlesource.com/45655
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-13 23:21:17 +00:00
Brad Fitzpatrick
7d47e840ac cmd/goimports: update docs to not imply goimports is superset of gofmt
Change-Id: I098fa50c274d8206b6e2534d647cfae18d6b2703
Reviewed-on: https://go-review.googlesource.com/45390
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-13 20:38:26 +00:00
Kevin Burke
011098bb92 cmd/stress: flush out Usage doc
Provide more context when you run `stress -h` besides just the flags.

Change-Id: I9dbe7ba2b7178dd7a542d8c4c29bf79999a38234
Reviewed-on: https://go-review.googlesource.com/44810
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-12 21:12:06 +00:00
Hiroshi Ioka
e493388965 x/tools/cmd/bundle: include comments inside functions
Fixes golang/go#20548

Change-Id: Ieff2323b63308cbc052a2883237520620965cf86
Reviewed-on: https://go-review.googlesource.com/45117
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-09 02:56:03 +00:00
Steve Francia
2a3bccfb1b cmd/go-contrib-init: check working dir and autodectect repo
Change-Id: I730216e2954ff591a57314e82ffd7b43d1da8ed4
Reviewed-on: https://go-review.googlesource.com/45084
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-08 03:08:27 +00:00
Brad Fitzpatrick
a768197954 cmd/go-contrib-init: add git alias dry run mode, add success message
Updates golang/go#17802

Change-Id: I2b5473bc0539a760c26889497a301808deb5e5ae
Reviewed-on: https://go-review.googlesource.com/45083
Reviewed-by: Steve Francia <spf@golang.org>
2017-06-07 23:52:31 +00:00
Brad Fitzpatrick
16c483b02b cmd/go-contrib-init: don't assume user is in root directory of git checkout
Updates golang/go#17802

Change-Id: I8eeae42f395dee4eedd17114f10bb56536783089
Reviewed-on: https://go-review.googlesource.com/45082
Reviewed-by: Steve Francia <spf@golang.org>
2017-06-07 23:32:37 +00:00
Brad Fitzpatrick
154c88c09d cmd/go-contrib-init: add git-codereview bits
Updates golang/go#17802

Change-Id: Ic5278804203029926dd5a26e571f79aaafb13110
Reviewed-on: https://go-review.googlesource.com/45080
Reviewed-by: Steve Francia <spf@golang.org>
2017-06-07 23:21:04 +00:00
Brad Fitzpatrick
fe66dd2e3e cmd/go-contrib-init: add some git origin checks
Updates golang/go#17802

Change-Id: I70d30c5ff12837d51d13b5ca7e73be96eb535286
Reviewed-on: https://go-review.googlesource.com/45079
Reviewed-by: Steve Francia <spf@golang.org>
2017-06-07 22:49:11 +00:00
Brad Fitzpatrick
851770f01f cmd/go-contrib-init: add start of new tool to help new Go contributors
Updates golang/go#17802

Change-Id: Ieb4be41039d414a3ba6766d98ed95a6154f964f4
Reviewed-on: https://go-review.googlesource.com/45078
Reviewed-by: Steve Francia <spf@golang.org>
2017-06-07 22:20:13 +00:00
Keith Randall
1dbffd0798 cmd/toolstash: use "go env GOROOT" instead of runtime.GOROOT()
The GOROOT of whatever tool build toolstash is irrelevant. We want
the goroot of the "go" command we're testing.

Change-Id: Ie7e11c74cb445ea694d88c743dbc239a55d47864
Reviewed-on: https://go-review.googlesource.com/43033
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-09 20:09:15 +00:00
Keith Randall
a6971f4c11 cmd/compilebench: use go command in goroot, not environment
The "go" command is a random "go" in the environment, not
necessarily the one under test.  Use the go command in the
goroot we're testing.

This CL removes the need to add $GOROOT/bin to your path
before running compilebench.

Change-Id: Ieb7f441f8287105e13446006e73b760d80e51e03
Reviewed-on: https://go-review.googlesource.com/42932
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-09 19:43:46 +00:00
Takuto Ikuta
15b145e4e3 cmd/goimports: update doc.go for go-mode elisp
go-mode does not use go-mode-load now.
Need to use go-mode-autoloads instead.

Change-Id: I3ee2113b41972a1f700d604ea7a6c2d5b59da8bb
Reviewed-on: https://go-review.googlesource.com/42193
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-05-05 14:54:17 +00:00
Josh Bleecher Snyder
b6d1a163df Revert "cmd/compilebench: update example to use benchcmp instead of benchstat"
This reverts commit 3aa1caa08a.

Reason for revert: benchstat is preferred to benchcmp

Change-Id: I9772eb342fb631a68511986d832bb1444766afdc
Reviewed-on: https://go-review.googlesource.com/42027
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-28 05:40:08 +00:00
Marvin Stenger
3aa1caa08a cmd/compilebench: update example to use benchcmp instead of benchstat
Change-Id: Id59ee04aba4d7c50e3b7c4e0b7e9aa75955640f5
Reviewed-on: https://go-review.googlesource.com/41861
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-27 00:37:34 +00:00
Damien Lespiau
9a6c6fca12 cmd/toolstash: fix package name in godoc hint
This package has been moved since then.

Change-Id: Ibf0044cf4fcef47ae15301c2880ff129a8829516
Reviewed-on: https://go-review.googlesource.com/41856
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-26 16:36:11 +00:00
Dmitri Shuralyov
1b22574ddb cmd/godoc: fix expected test output for Go 1.8 and older
A go/build change in Go 1.9 (CL 33158) allowed for a better expected
error message for "nonexistingpkg" case. CL 37768 did that. However,
that shouldn't be done for Go 1.8 and older, since they don't have
the corresponding go/build change.

So, if the version is Go 1.8 or older, allow matching those previous
expected outputs (before CL 37768) for "nonexistingpkg" case.

Move test cases for TestCLI from a package-level variable into TestCLI
itself. This is more readable, and isGo19's value is ready in time.

Fixes golang/go#20122.

Change-Id: I5e80600a75176d9e54ffebb7730849e381568316
Reviewed-on: https://go-review.googlesource.com/41810
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-26 05:21:38 +00:00
Josh Bleecher Snyder
518248cfad cmd/compilebench: add -pkg flag to compile a single package
Sometimes, as with CL 41493, or when investigating
a reported issue, there's a package of interest
that is not part of the standard compilebench suite.
Add a -pkg flag to allow easy access to the compilebench
set of goodies (allocs, object file stats) without
having to edit and reinstall compilebench itself,
which is what I have been doing.

Change-Id: Id6ca6356cae062208f8686c0cb597ed45fc861c0
Reviewed-on: https://go-review.googlesource.com/41627
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-25 22:47:38 +00:00
Josh Bleecher Snyder
7745887299 cmd/compilebench: add object file size to package benchmarks
Protected by flag -obj.

Sample relevant output from compilecmp using this commit.

name       old obj-bytes     new obj-bytes     delta
Template          382k ± 0%         381k ± 0%   -0.23%  (p=0.002 n=6+6)
Unicode           203k ± 0%         203k ± 0%   -0.00%  (p=0.002 n=6+6)
GoTypes          1.18M ± 0%        1.17M ± 0%   -0.08%  (p=0.002 n=6+6)
Compiler         3.99M ± 0%        3.99M ± 0%   -0.08%  (p=0.002 n=6+6)
SSA              8.28M ± 0%        8.28M ± 0%   -0.02%  (p=0.002 n=6+6)
Flate             230k ± 0%         230k ± 0%   -0.05%  (p=0.002 n=6+6)
GoParser          287k ± 0%         287k ± 0%   -0.16%  (p=0.002 n=6+6)
Reflect          1.00M ± 0%        1.00M ± 0%   -0.01%  (p=0.002 n=6+6)
Tar               190k ± 0%         189k ± 0%   -0.24%  (p=0.002 n=6+6)
XML               416k ± 0%         415k ± 0%   -0.16%  (p=0.002 n=6+6)

name       old export-bytes  new export-bytes  delta
Template         19.0k ± 0%        18.2k ± 0%   -4.55%  (p=0.002 n=6+6)
Unicode          4.45k ± 0%        4.44k ± 0%   -0.11%  (p=0.002 n=6+6)
GoTypes          29.7k ± 0%        28.8k ± 0%   -3.12%  (p=0.002 n=6+6)
Compiler         75.6k ± 0%        72.5k ± 0%   -4.03%  (p=0.002 n=6+6)
SSA              76.2k ± 0%        74.8k ± 0%   -1.72%  (p=0.002 n=6+6)
Flate            4.98k ± 0%        4.87k ± 0%   -2.29%  (p=0.002 n=6+6)
GoParser         8.81k ± 0%        8.34k ± 0%   -5.30%  (p=0.002 n=6+6)
Reflect          6.25k ± 0%        6.16k ± 0%   -1.49%  (p=0.002 n=6+6)
Tar              9.49k ± 0%        9.03k ± 0%   -4.82%  (p=0.002 n=6+6)
XML              16.0k ± 0%        15.4k ± 0%   -4.03%  (p=0.002 n=6+6)


Change-Id: I3f5e6ec022cb02ad6937f7859c573ca1edc39fb7
Reviewed-on: https://go-review.googlesource.com/41053
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-04-25 00:26:14 +00:00
Alan Donovan
25abe5b322 cmd/guru: fix and reenable failing test case
And avoid assumptions about the contents of the standard hash/fnv
package.

Change-Id: I10cc95ac6e3b482da5b027d68ff218d08f425e89
Reviewed-on: https://go-review.googlesource.com/40870
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-14 23:25:34 +00:00
Brad Fitzpatrick
2a4809d2cb cmd/guru: disable a failing test for now
Updates golang/go#19464

Change-Id: I60a77bc25aa8d92c4f2fc1835d96002ea5b8bfea
Reviewed-on: https://go-review.googlesource.com/40850
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Kevin Burke <kev@inburke.com>
2017-04-14 23:03:32 +00:00
Josh Bleecher Snyder
cbb995d093 cmd/compilebench: make StdCmd respect compiler flags flag
Change-Id: I9230492805583092c52ccc87e3be7740ba794c3f
Reviewed-on: https://go-review.googlesource.com/40652
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-13 18:39:38 +00:00
Josh Bleecher Snyder
9bf174b4d3 cmd/stringer: use source importer when available
This means that running stringer should always
have the intended effect, without having to
go install the package first, which was a common
source of confusion.

The source importer is marginally slower,
but stringer is run infrequently,
and we're only typechecking one package (and fmt),
not an entire tree, as vet does.

Fixes golang/go#10249

Change-Id: Ib8cde29bd6cc596964dbe7348065932dd59075fc
Reviewed-on: https://go-review.googlesource.com/40403
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-04-12 18:56:47 +00:00
Dmitri Shuralyov
ef3dcd5937 cmd/heapview: look for tools repository in all GOPATH entries
The GOPATH environment variable is defined at
https://golang.org/cmd/go/#hdr-GOPATH_environment_variable as:

> The GOPATH environment variable lists places to look for Go code. On
> Unix, the value is a colon-separated string. On Windows, the value is
> a semicolon-separated string. On Plan 9, the value is a list.

It is legal for Go packages to be in any of those places, not only
the first entry. Look in all places for golang.org/x/tools repository.

Cache the directory that is found. It's slightly more expensive
to look for it, since potentially multiple directories must be
checked for existence.

Updates golang/go#19400.

Change-Id: I16661b7149d52ea6168fffc605c842d7a4da009b
Reviewed-on: https://go-review.googlesource.com/38778
Reviewed-by: Michael Matloob <matloob@golang.org>
2017-04-10 18:12:01 +00:00
Josh Bleecher Snyder
6e29264c4f cmd/compilebench: fix package name in comment
Change-Id: Ie5c413fc9f13cf029d8d8a6cae5754838c834395
Reviewed-on: https://go-review.googlesource.com/40170
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-10 17:39:46 +00:00
Giovanni Bajo
5584fb0720 gotype: fix default importer for Go 1.8.
Importer "source" does not exist in Go 1.8, so this means that
default usage of gotype is broken in that compiler version.

Change-Id: I517520b0cac7c62a3e213d0647a3d621e8ced58c
Reviewed-on: https://go-review.googlesource.com/40091
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-10 16:28:46 +00:00
Josh Bleecher Snyder
24acc66eab cmd/compilebench: put in correct subdirectory
Apparently there was a typo during initial import,
and compilebench was placed at the top level,
rather than in the cmd subdirectory. Oops. Fix that.

Change-Id: Ibea9ed132dca26c022ea02933defec9534105f18
Reviewed-on: https://go-review.googlesource.com/39792
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-06 18:57:16 +00:00
Josh Bleecher Snyder
5054e612af cmd/toolstash: don't build cmd for android
Linking cmd for android requires a cross-compiling toolchain,
which is not standard fare.

Skip it, and trust that the other platforms will pick up the slack.

Change-Id: Ifcf74f77e98489c859805ab7a448d80d019f3d20
Reviewed-on: https://go-review.googlesource.com/39556
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-05 15:47:30 +00:00
Kevin Burke
37a1062ad0 cmd/tip: redirect http://tip.golang.org to https
At some point we switched tip.golang.org to run in GKE, which
terminates TLS directly on port 443. This requires a new technique
for detecting a plain HTTP connection. In addition we may want to run
talks.golang.org on App Engine Flex, which uses an X-Forwarded-Proto
header to indicate HTTP, so let's prepare for that possibility.

Fixes golang/go#19759.

Change-Id: Iddc567214c5d28f61c405db065aa1b3f2c92fd85
Reviewed-on: https://go-review.googlesource.com/38800
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-03 05:32:14 +00:00
Kevin Burke
620ecdb8d7 all: apply new machine-generated doc spec to files
Updates golang/go#13560.

Change-Id: I1664807a065c7982a57d4dc9cee22ce261536c5b
Reviewed-on: https://go-review.googlesource.com/39202
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-01 01:24:29 +00:00
haya14busa
d83db204ce cmd/goimports: flush to disk before diffing
Port of gofmt change at golang.org/cl/36750

Change-Id: Ie0ef6770be6361264ed45a9a9ece950aba24e852
Reviewed-on: https://go-review.googlesource.com/39073
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-31 04:14:08 +00:00
Yasuhiro Matsumoto
d63e2b22b0 cmd/toolstash: use strings.LastIndexAny
Change-Id: I06a4610a5f5c49806a1b151a65c25bbbd881a314
Reviewed-on: https://go-review.googlesource.com/38753
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-28 14:23:59 +00:00
Yasuhiro Matsumoto
474a26d4c8 cmd/guru: Close before Remove a file
Change-Id: Ia12ff7a0f6898f8d140565d255793904ce8585c4
Reviewed-on: https://go-review.googlesource.com/38754
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-28 13:38:24 +00:00
Yasuhiro Matsumoto
963fe939f1 cmd/heapview: remove needless slash
Change-Id: Ie19a60595862c0afff9364ee21dd9598370e6c91
Reviewed-on: https://go-review.googlesource.com/38752
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-28 13:38:09 +00:00
Josh Bleecher Snyder
322b9d710a cmd/toolstash: use 'go tool dist list' to get platforms
This fixes several issues:

* The ls sed hackery generates GOARCH values mipsx and mipsxle,
  instead of mips, mips64, mipsle, and mips64le.
* It removes the dependence on the 9 command.
* It marginally increases readability.

Change-Id: Ie46abc289c2c9923eed693dcf1194f4fd3ea9bd2
Reviewed-on: https://go-review.googlesource.com/38347
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-22 14:37:47 +00:00
Matthew Dempsky
81dff79736 cmd/godoc: fix tests for cmd/compile refactorings
In golang.org/cl/38089, I removed all of the prog.go files.

Change-Id: I4d8dd021a62b5d6d8b7cb5cfe0ecd7268812805c
Reviewed-on: https://go-review.googlesource.com/38432
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-21 23:01:40 +00:00
Rob Pike
23ca8a2633 cmd/stringer: tweak "Code generated by" comment to match new standard
See https://golang.org/issue/13560 for the full discussion.

The actual change is just the addition of a final period.

Update golang/go#13560

Change-Id: Icc2f52b67181de344aa5107f94faa0e739ff993c
Reviewed-on: https://go-review.googlesource.com/38415
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-03-21 04:07:08 +00:00
Josh Bleecher Snyder
a5c9681e31 cmd/toolstash: don't pass -N when compiling runtime
The runtime cannot be compiled with optimizations disabled.
This lead to very confusing error messages
when toolstash -cmp failed.

Change-Id: Ie341d633ff9b26693b475957309591ff0757f1ab
Reviewed-on: https://go-review.googlesource.com/38378
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-03-20 21:03:53 +00:00
Tamir Duberstein
6185cb1f31 cmd/goyacc: remove empty branch
Found with honnef.co/go/tools/cmd/staticcheck.

Change-Id: I39e23936e01543db62b7b0919a3b58b65cd40099
Reviewed-on: https://go-review.googlesource.com/38174
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-15 21:33:42 +00:00
Tamir Duberstein
43bc42d6f5 cmd/goyacc: remove unused functions
Found with honnef.co/go/tools/cmd/unused.

Change-Id: Ie7ee9f687bcec1faa40c890a84666ef6c27d9b77
Reviewed-on: https://go-review.googlesource.com/38176
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-15 21:33:35 +00:00
Tamir Duberstein
d332283808 cmd/goyacc: remove ineffective break statement
Found with honnef.co/go/tools/cmd/staticcheck.

Change-Id: I7f765ef1710d151ebda5716c99587acd3a90db1f
Reviewed-on: https://go-review.googlesource.com/38173
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-15 15:30:16 +00:00
Tamir Duberstein
1f5953e340 cmd/goyacc: use a constant instead of zero value
Found with honnef.co/go/tools/cmd/unused.

Change-Id: I373d710e0f5f98dcf591826a26541d1d12696e14
Reviewed-on: https://go-review.googlesource.com/38175
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-15 15:28:09 +00:00
Tamir Duberstein
ab34c5f581 cmd/goyacc: remove unused generated bindings
Found with honnef.co/go/tools/cmd/unused (in CockroachDB).

Change-Id: I0e2f7ac6ad2a0fdc724928f316060f06c3261ece
Reviewed-on: https://go-review.googlesource.com/38178
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2017-03-14 23:14:11 +00:00
Tamir Duberstein
f2e43688df cmd/goyacc: merge variable declaration with assignment
Found with honnef.co/go/tools/cmd/simple.

Change-Id: I04c65394f1c6404f57bb2088353325899f35011f
Reviewed-on: https://go-review.googlesource.com/38177
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2017-03-14 23:13:33 +00:00
Robert Griesemer
2f69a5922b cmd/gotype: make it compile against Go 1.8 and earlier
types.SizesFor was introduced for Go 1.9. Need to provide
a local implementation to have gotype build against earlier
versions.

Fixes golang/go#19545.

Change-Id: I6fdbe414e6574eda00c01295b666230daff2dfdc
Reviewed-on: https://go-review.googlesource.com/38157
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-03-14 21:50:22 +00:00
Robert Griesemer
381149a2d6 cmd/gotype: re-introduce gotype command at traditional location
Except for the added comment in the beginning and the removal of
the 'ignore' build tag, there is no difference between gotype.go
and the original.

Fixes golang/go#19516.

Change-Id: Ie1ab9aced6e650573c2cdce0c165af1e1094213f
Reviewed-on: https://go-review.googlesource.com/38132
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-03-13 17:37:17 +00:00
Alan Donovan
7fdb908ead cmd/guru: fix tests now that go1.9 go/types returns fake packages
The go1.9 type checker now returns fake packages in addition to an
error if the package was not found at all.  This changes the behavior
of guru in a release-specific way, requiring the test to be split into
a common part and a go1.9-specific part.

In hindsight, perhaps it would have been better to place the
expectation in a comment alongside the query so that they can be
easily enabled or disabled together.  (The downside of that design is
that you can't batch-update all the expectations to match the actual
behavior.)

Change-Id: I58054adec428fbab7fe3c57097aefc827f89a46e
Reviewed-on: https://go-review.googlesource.com/37865
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-08 23:16:52 +00:00
Brad Fitzpatrick
03d3934baf cmd/tip: move tip.golang.org from App Engine to Kubernetes on GKE
Change-Id: I52ca7eaca98de27bd920ae01086b3f7724819738
Reviewed-on: https://go-review.googlesource.com/37754
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2017-03-07 03:49:08 +00:00