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
Jonathan Amsterdam
b2f7fe607d cmd/stringer: type check using export data
Use go/packages to find and type check packages using export data.

In addition to type checking with export data, this should also enable
cmd/stringer to work correctly when using go modules.

jba: took over CL, tweaked package.Config use.

Change-Id: Ie253378b52fbd909f7194dfd09c039aab63dd8f0
Reviewed-on: https://go-review.googlesource.com/c/126535
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-04 22:01:59 +00:00
Rebecca Stambler
d810ce9e47 cmd/guru: remove Go 1.9 handling, since we no longer support 1.8
Some tests were split off for Go 1.9, when we still supported Go 1.8.
This change recombines them and removes the special handling for 1.9.

Fixes golang/go#24421

Change-Id: Ic871f4c3af4bb90b00cdd6d7b8f3253783554535
Reviewed-on: https://go-review.googlesource.com/c/161000
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2019-02-04 19:56:32 +00:00
Rebecca Stambler
51e363b66d internal/lsp: implement diff for computing text edits
Rather than replacing the whole file on gofmt or goimports, use the Myers
diff algorithm to compute diffs for a file. We send those back as text
edits.

Change-Id: I4f8cce5b27d51eae1911049ea002558a84cdf1bf
Reviewed-on: https://go-review.googlesource.com/c/158579
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-02-01 23:18:25 +00:00
Brad Fitzpatrick
0e05534988 cmd/tip: delete
The cmd/tip program moved to x/build (along with its history) in:

  https://go.googlesource.com/build/+/63986c177d1ff5d2629840f6b00c445f1cb932bf

(There's no associated Gerrit CL; the merge commit of x/build's old
HEAD + a git-filter-branch of x/tools's cmd/tip was pushed directly to
Gerrit's git server, without creating Gerrit CLs for review for each
commit in its history)

Updates golang/go#29981

Change-Id: I16b9b1b0079e3d7b6851cb3e7322a878ece73e23
Reviewed-on: https://go-review.googlesource.com/c/160817
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-02-01 18:59:10 +00:00
Michael Matloob
3c4dfba64b cmd/heapview: delete
This is all dead code that never went anywhere.

Change-Id: I79db05d6391709bb9ae3d86f557246f1dd3b21f7
Reviewed-on: https://go-review.googlesource.com/c/159957
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-28 22:39:01 +00:00
Andrew Bonventre
d66bd3c5d5 cmd/godoc: add x/xerrors redirect
Change-Id: I367caa5f8c90e53768b07427248ed2bcc83a58e3
Reviewed-on: https://go-review.googlesource.com/c/159739
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-01-25 23:20:54 +00:00
Ian Cottrell
78ee07aa94 cmd/gopls/integration: git ignore temporary vscode files
Change-Id: I9585fb227f44c4bf8071247bb6b89b6fed6cf83b
Reviewed-on: https://go-review.googlesource.com/c/159277
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-01-24 00:41:07 +00:00
tell-k
85a87a81a9 cmd/present: fix CSS when printing slides
The existing CSS style was causing slides to not align with page
boundaries when printing slides. The cause of that is the CSS transform
property that is applied to automatically scale size of slides.
This change clears the transform property just before printing.

Fixes golang/go#29480

Change-Id: I6f719ad1b716e9bda8ba83007c3d1d7dece9ce08
GitHub-Last-Rev: d46dfee57601b2e9127c5e8e80e596dc2a2f24fa
GitHub-Pull-Request: golang/tools#67
Reviewed-on: https://go-review.googlesource.com/c/155940
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-01-23 18:36:29 +00:00
Dmitri Shuralyov
9279ec27fd cmd/tip: also fetch x/net repository before building cmd/godoc
x/tools/cmd/godoc uses at least one Go package from x/net as of
CL 157197.

Don't add it to signature because we don't want the signature to
change whenever new commits to x/net are pushed, causing tip.golang.org
to be redeployed. This is because x/net is not considered a critical
component of the website at this time, and that's not expected to
change soon.

When the website begins using modules, it will specify the x/net
version precisely and this decision will no longer matter.

Fixes golang/go#29874

Change-Id: I1fa76bb81f8d2ffc2314375e2dfe4898c3af58de
Reviewed-on: https://go-review.googlesource.com/c/158937
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-23 02:11:25 +00:00
Rebecca Stambler
b258f6da23 cmd/gopls: rename "golsp" to "gopls", as in "Go Please"
Change-Id: Ie5688759ce21bffa6745eb86ef3606639e3ce335
Reviewed-on: https://go-review.googlesource.com/c/158197
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-16 23:16:16 +00:00
Rebecca Stambler
fc1d57b08d cmd/golsp: add a debugging tool to connect with golsp on a port
This change allows golsp to be run on a port, with an intermediary
command passing the data through. This allows for improved logging.
Also, add necessary changes to VSCode integration to allow changing the
name of the command for golsp.

Change-Id: I20dca1a50296636e57e022342ee70f0610ad1531
Reviewed-on: https://go-review.googlesource.com/c/157497
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-11 21:44:48 +00:00
David Chase
d30e00c240 splitdwarf: initial working commit
splitdwarf osxMachoFile [ osxDsymFile ]

splitdwarf takes an executable produced by go build as input,
and uncompresses and copies the DWARF segment into a separate
file in the way that is expected by OSX-hosted tools
(lldb and ports of gdb).
If osxDsymFile is not named explicitly, the default of
"<osxMachoFile>.dSYM/Contents/Resources/DWARF/<osxMachoFile>"
is used instead, with directories created as needed.

If the input file contains no UUID, then one is created by
hashing non-DWARF segment contents, and added to the
executable. This is necessary because gdb and lldb both
expect matching UUIDs to be present in the executable
and its debugging symbols.

Includes a modified version of debug/macho, with additional
definitions and the ability to write segments, sections, and
some MachO load commands added.

Change-Id: Ia5b0e289260f72bbca392cdf2c7c0a75e3ca40e5
Reviewed-on: https://go-review.googlesource.com/c/143357
Reviewed-by: Austin Clements <austin@google.com>
2019-01-09 16:56:30 +00:00
David Chase
d674b4ad67 cmd/splitdwarf: copy debug/macho
The splitdwarf command will need a modified version of debug/macho.
This is a verbatim copy from std as of Go 1.11, which we'll modify in
the next CL.

Change-Id: Ia9ded870d1ba91dad21f9f6dc5bb38f9f6cc0e80
Reviewed-on: https://go-review.googlesource.com/c/152240
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
2019-01-09 16:55:59 +00:00
Dmitri Shuralyov
9ea1c200b2 cmd/godoc: add x/website redirect
Add a redirect for the recently created x/website subrepository.

It's not yet included at https://golang.org/pkg/#subrepo because it's
in development. Once development reaches the point that x/website
is the canonical location of the golang.org server, we can consider
including x/website at https://golang.org/pkg/#subrepo (just like
x/blog, x/tour, x/build are already included there).

Updates golang/go#29206

Change-Id: I6889c1f5e40f11abca944b217a7354f76c08c8eb
Reviewed-on: https://go-review.googlesource.com/c/156337
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-04 17:33:42 +00:00
Iskander Sharipov
ca9055ed7d cmd/guru: fix incorrect case order in describe.go
Since *ast.CommClause implements ast.Stmt, type switch for
it would never execute in the original code, it will always
execute ast.Stmt branch.

Moving concrete types before interfaces help in this case.

Change-Id: Id84f2f7f3fac859029155d8e6debf4a8ef170b26
Reviewed-on: https://go-review.googlesource.com/c/153397
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-01-02 21:33:36 +00:00
Rob Pike
92cdcd90bf godoc: choose a smaller-output example as help when there are unexpected arguments
Change CL 153869 added a help message when there are leftover arguments,
as that used to invoke the command-line interface that is now gone.
But the example in the help text (go doc -all net/http) generates a huge
amount of output.

Use a very simple, small-output example instead, to illustrate how to
solve the problem without scrolling the program description hundreds
of screenfuls away.

Change-Id: I1887af1f3e853bf3a852dc374746074f1cd39441
Reviewed-on: https://go-review.googlesource.com/c/155157
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-12-20 02:49:03 +00:00
Filippo Valsorda
88e3b261f2 cmd/godoc: print a helpful error if used for command-line docs
The command-line interface was recently removed in favor of "go doc".

Change-Id: Idfcfca3b2eafaf63148a2ed88d4d25c61d9e3c69
Reviewed-on: https://go-review.googlesource.com/c/153869
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-12-19 18:50:13 +00:00
Ian Cottrell
a072e66104 internal/lsp: refactor the command line handling
This switched the golsp binary to support a sub-command model so it can grow
some guru like command line query capabilites

Change-Id: I1a7a49bb17701e62004bba636d6bee9de2481ffd
Reviewed-on: https://go-review.googlesource.com/c/154559
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2018-12-17 23:08:30 +00:00
pjw
728ed46ae0 cmd/golsp: make each log message result from a single call to fmt.Fprintf
If several RPCs finish together the existing code may mix the log
messages, making reading them difficult.

Change-Id: I1de15373f739c97ccfaf210511b5f5443f7ef036
Reviewed-on: https://go-review.googlesource.com/c/154346
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2018-12-17 18:23:37 +00:00
Brad Fitzpatrick
3c39ce7b61 tip: fix, update tip.golang.org
Primarily for golang/go#29251 but also update the base Docker layer
from Go 1.9 to Go 1.11, update other deps, and fix some Kubernetes
config cleanups that happened prior without testing apparently.

Fixes golang/go#29251

Change-Id: I0aafccdfedfc0d9ebb75d0c1a3b0819245ea5f19
Reviewed-on: https://go-review.googlesource.com/c/154181
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-12-14 17:12:54 +00:00
Chris Broadfoot
837e80568c godoc/proxy: remove use of httputil.ReverseProxy for /share
ReverseProxy doesn't re-set the Request's Host field, only
Request.URL.Host.
The HTTP/2 client prefers Request.Host over Request.URL.Host, so this
results in the request being sent back to the host that originally
accepted the request.
This results in an infinite redirect (and consumption of many connections to
itself).
See Issue golang/go#28168 for details.

Replace it with a simple proxy that drops all the headers (except
Content-Type).

I tried setting the proxy.Director, but it still didn't work. Could do
with some more investigation.

Fixes golang/go#28134.

Change-Id: I5051ce72a379dcacfbe8484f58f8cf7d9385024d
Reviewed-on: https://go-review.googlesource.com/c/141718
Run-TryBot: Chris Broadfoot <cbro@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-12-12 17:29:21 +00:00
Rebecca Stambler
feaab9440b cmd/golsp/integration/vscode: add language server client for testing
We've been using https://github.com/stamblerre/vscode-test-golsp to test
the golsp. Ideally, we'd like to add integration tests with the major
editors, so we're moving this basic extension into x/tools, with the
intention of integration tests here. This is not meant to be used by any
users of golsp; it is only for testing.

Change-Id: I7c45e7c638311d29629ff6d3291332e68cf4621a
Reviewed-on: https://go-review.googlesource.com/c/153438
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-12-10 22:45:52 +00:00
Rebecca Stambler
85346a3911 cmd/golsp: enable logging to a default location
Add a default "auto" value to the "--logfile" flag that allows logs to be
written to a default location.

Change-Id: I1952ad2622b824795906c6b8183b58f88c35fb62
Reviewed-on: https://go-review.googlesource.com/c/153197
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-12-10 17:49:56 +00:00
Brad Fitzpatrick
d0ca3933b7 cmd/bundle: change the behavior of the -underscore flag
It used to rewrite golang.org/x/* imports to golang_org/x/*.

But https://golang.org/cl/147443 renamed golang_org/x to internal/x,
which broke the ability to run "go generate" in net/http, which runs
this command.

Given that net/http (and Go itself) is the only caller of cmd/bundle
or the -underscore flag, repurpose it to instead rewrite the
golang.org/x imports to internal/x, like CL 147443. But we keep its
name out of laziness and to minimize the number of cross-repo changes
needed.

Change-Id: I310ce8b45812a26c8b3522eaf407fffff138b1be
Reviewed-on: https://go-review.googlesource.com/c/152097
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-12-01 03:58:26 +00:00
Andrew Stribblehill
1c3d964395 cmd/goimports: update Emacs install instructions
When I tried to use the Emacs instructions, I found there was no go-mode-autoloads available. Searching, I found: https://github.com/dominikh/go-mode.el/issues/222

Removing the (require) line solved my problem.

I don't know what the add-to-list invocation was supposed to do, so I propose removing it too.

Change-Id: I027654dd2c634f0747dcefee71f413866049a608
GitHub-Last-Rev: 7d43dabf6a46210eaaa849900c13cd52001878cb
GitHub-Pull-Request: golang/tools#57
Reviewed-on: https://go-review.googlesource.com/c/151680
Reviewed-by: Dominik Honnef <dominik@honnef.co>
2018-11-30 05:20:23 +00:00
Austin Clements
b4e97c0ed8 cmd/stress: prefix logs with start date/time
Currently, stress logs are named "/tmp/go-stress-" plus a random
number. This makes it really annoying to tease apart failures from
different stress runs.

This CL changes the default prefix to

  "/tmp/go-stress-<ISO 8601 date/time>-<random number>"

where the date/time part is when the stress command started.  This
naming clusters logs by stress invocation, making it easy to tease
apart invocations, even if there are multiple stresses running
concurrently or they are run back-to-back.

This also provides a flag to override this prefix.

Change-Id: I043e5ee7168ba6db4e2355e39b147071edbc6864
Reviewed-on: https://go-review.googlesource.com/c/150047
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-11-27 19:52:27 +00:00
Dima
9c8bd463e3 cmd/guru: add type position to describe command
Add typepos field to json output of describe command. This field shows where
type of current (under cursor) identifier is defined. This will help code editors
implement command 'Go to type definition'.

Implements [#27308](https://github.com/golang/go/issues/27308)

Change-Id: I4e02ddbdc03fecec98135b8996f9562a88a9cfb8
GitHub-Last-Rev: be47e397a293a96d3d39776d6090d861e7904a24
GitHub-Pull-Request: golang/tools#50
Reviewed-on: https://go-review.googlesource.com/c/140379
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-11-20 20:06:22 +00:00
Agniva De Sarker
c340431777 cmd/godoc: start RunIndexer synchronously when index is present
Until the index is read completely, search requests will serve
an "indexing in progress" message. We make this synchronous
to allow the index to be read completely before starting to serve
requests.

Fixes golang/go#24965

Change-Id: I6b094374a9c5cc923f0582107dde2b652e64fd96
Reviewed-on: https://go-review.googlesource.com/c/148998
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-11-12 23:23:51 +00:00
matematik7
84d77ece31 cmd/bundle: permit empty -prefix
This enables bundling of programs with `main` method to single file.
I used this to upload code for the new codejam.

Change-Id: I9e65ba8717c1d81d6fb9bef8f234c21fc5b91421
GitHub-Last-Rev: 5d0d623c46ff1629e7371693ddf0916df328e319
GitHub-Pull-Request: golang/tools#32
Reviewed-on: https://go-review.googlesource.com/c/105515
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-11-09 15:23:16 +00:00
Ian Cottrell
96e9e165b7 cmd/golsp: format logging for the lsp inspector
This improves the logging capabilities of the jsonrpc 2 library to always
include the method and also an optional elapsed time.
This is used to implement an lsp inspector compatible logging mode in the golsp.

Change-Id: I2f7ac8b9298c4364b1b89cf6f696b534557ed139
Reviewed-on: https://go-review.googlesource.com/c/146157
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2018-11-02 22:32:51 +00:00
Agniva De Sarker
92b943e6bf cmd/tip: enable playground on tip.golang.org
Updates golang/go#28536

Change-Id: I3ece72aacd4635f4580be404672394a47791a1e8
Reviewed-on: https://go-review.googlesource.com/c/146917
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-02 05:00:50 +00:00
David Symonds
45ff765b48 cmd/stringer: accept simple type conversion expressions in constant ValueSpec
This permits constants of the form `const X = T(A)` to add `X` to the
stringer output for type `T`.

While those constants can be rewritten as `const X T = T(A)`, that
becomes tedious and visually noisy when `T` is a long name. It is quite
easy to address this easy and common case, while not attempting to solve
this with full generality.

Fixes #11581.

Change-Id: Ifb8e43515f05493de190e02577260d94dd851581
Reviewed-on: https://go-review.googlesource.com/c/146577
Run-TryBot: David Symonds <dsymonds@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2018-11-01 07:19:27 +00:00
Paul Jolly
240a8bfde1 cmd/stringer: move away from using os.Args[0]
stringer's usage currently uses os.Args[0] to refer to the program name
as a defensive measure in case stringer is compiled and then run using a
name other than stringer, e.g. mystringer. However, the following lines
of the usage docs hardcode "stringer." So it seems this has little
benefit.

Indeed this style of using os.Args[0] can make the usage information of
stringer extremely ugly when stringer itself is invoked with an absolute
path:

Usage of /tmp/tmp.ahddh3ZjE7/.gobincache/golang.org/x/tools/@v/v0.0.0-20181030000716-a0a13e073c7b/golang.org/x/tools/cmd/stringer/stringer:
        stringer [flags] -type T [directory]
        stringer [flags] -type T files... # Must be a single package

...

Instead, opt for the simpler approach of hardcoding stringer throughout.

Change-Id: Ia296c8d9a91c94e77b7cc2b6242908c959fb5985
Reviewed-on: https://go-review.googlesource.com/c/145799
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Rob Pike <r@golang.org>
2018-10-30 21:27:03 +00:00
Agniva De Sarker
def2677374 cmd/godoc: cleanup documentation for CLI mode
- Removed all documentation which referred to godoc's CLI capabilities.
- Added some missing flags which were not documented.
- Removed some redundant mentions of "web server" because now it is
just a web server.
- Converted some links to https

Change-Id: I7ddcf417d2bc3df13183adcfd0f82af9a37a1b91
Reviewed-on: https://go-review.googlesource.com/c/143077
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-18 18:24:39 +00:00
Brad Fitzpatrick
4cdd33fd98 cmd/tip: make tip.golang.org also serve & redirect beta.golang.org to tip
We're turning down the old (and neglected) beta.golang.org godoc VM.
It's not different enough from tip.golang.org, which is more reliable
than it used to be.

Now beta.golang.org will just redirect to tip.

Updates golang/go#25978
Fixes golang/go#21073

Change-Id: Iae7fe4c82c14cec7381e75a2e214210d38b6e623
Reviewed-on: https://go-review.googlesource.com/c/120056
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-10-17 18:38:13 +00:00
Alan Donovan
aa46a01996 go/ssa/ssautil: add AllPackages method
In go1.10, go/packages falls back to loading all packages
from source but not typechecking function bodies for imports.
The ssautil.Packages function would nonetheless provide
the partially-typed ASTs to the SSA builder, which would crash.
Now Packages only passes syntax trees to the SSA builder for
the initial packages, which are the only ones guaranteed to be
fully typed.

It is impossible to discern whether the caller of Packages intends to
build SSA code for dependencies, as in some clients such as
cmd/callgraph, so we add a new function, AllPackages, that expresses
this intent.

Fixes golang/go#28106

Change-Id: I6a88b7c7545e9de90b61f5bee0e6de3d2e21b548
Reviewed-on: https://go-review.googlesource.com/c/141686
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-15 18:41:29 +00:00
Andrew Bonventre
13216ffa54 cmd/present: address minor comments not applied in a previous change
These changes were suggested in golang.org/cl/140841 but were not
applied in that change. They are small documentation fixes and a
switch from using fmt.Fprintf/os.Exit to log.Fatalf.

Change-Id: I9393261f8f28b589678866dd7b8904d46629fb4b
Reviewed-on: https://go-review.googlesource.com/c/141685
Reviewed-by: Andrew Gerrand <adg@golang.org>
2018-10-13 14:52:46 +00:00
Chris Broadfoot
d3c6139142 cmd/godoc: synchronously init corpus for index mode
The corpus needs to be init'd before generating the index.

Regression caused by CL 141397.

Updates golang/go#25443.

Change-Id: I04d19bf5d279031cc8ddf0f850d81eb06fc5efa8
Reviewed-on: https://go-review.googlesource.com/c/141717
Run-TryBot: Chris Broadfoot <cbro@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-11 23:40:14 +00:00
Koichi Shiraishi
be3ddffac4 cmd/guru: fix several functions godoc comment prefix
The several functions not exported, Use "The xxx function ..." rule.

Change-Id: Iaba2490b4a9675213f70d055bd9ded9e5a245aa5
Reviewed-on: https://go-review.googlesource.com/c/47872
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-10-11 18:05:12 +00:00
LE Manh Cuong
1f849cf54d cmd/godoc: do not use httptest
httptest assumes it's running a test, it registers its own flags, which
means godoc ends up with mysterious flags.

By implement an http.ResponseWriter, we do not need to use httptest.

Fixes golang/go#28138

Change-Id: Ia0de8597c3edb0e7bdea6d8b3b2f1618a12f9239
Reviewed-on: https://go-review.googlesource.com/c/141417
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-11 04:24:14 +00:00
Brad Fitzpatrick
e5fe289229 godoc, cmd/godoc: remove CLI support
godoc is now just a webserver (the one that runs golang.org)

A future change might rename this to something else, but not now.

Fixes golang/go#25443

Change-Id: Ib95d0589e13f4c7a717ff28d694f1472e427eef4
Reviewed-on: https://go-review.googlesource.com/c/141397
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2018-10-11 02:31:40 +00:00
Andrew Bonventre
37fd46feae cmd/present: merge appengine and non-appengine files
Without changing the behavior of the present command for local
usage (using the local socket for running examples, defaulting to
the current directory for all content). Add flags and set them to
the appropriate values if running on App Engine.

Notably, since the Go files must be in the same directory as
app.yaml, the content root must be ./content/ to avoid listing
the present source files.

It also defaults to running example snippets via the HTTPTransport
(https://play.golang.org/compile) instead of locally when on App
Engine.

There are also some small cleanup code changes.

Update golang/go#28080

Change-Id: I40bb7923107614f88d2bfdffd34a824d4bacb3a1
Reviewed-on: https://go-review.googlesource.com/c/140841
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-10-10 21:11:20 +00:00
Chris Broadfoot
65a9b9c4ab cmd/godoc: add missing Dockerfile ARG
Also moves the ARG declarations immediately before they're used to
make this omission less likely for future additions.

Change-Id: Id52a936d978f96d3c629feff69fc9dc4ae1b8463
Reviewed-on: https://go-review.googlesource.com/c/140377
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-10 15:29:03 +00:00
Bryan C. Mills
a2cab1077b cmd/gorename: set GO111MODULE=off in gorename_test
Updates golang/go#27858

Change-Id: Ia823c49d8f05831c833df9f745a879c94c915626
Reviewed-on: https://go-review.googlesource.com/c/139319
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-10-08 20:39:09 +00:00
Chris Broadfoot
f60d9635b1 cmd/godoc: add version info for golang.org
Adds version information for package docs for the production version of
godoc running on golang.org.

Updates golang/go#5778.

Change-Id: I8b56e8152b20b34104f274263a6c0b5a0180093b
Reviewed-on: https://go-review.googlesource.com/c/139557
Reviewed-by: Devon H. O'Dell <devon.odell@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-06 00:25:42 +00:00
Chris Broadfoot
1f2a8f46bd cmd/godoc: add cloud build config
Deploys no longer depend on Docker.

With only Make and gcloud installed, the following should deploy a new version:

$ git clone https://go.googlesource.com/tools
$ cd tools
$ cd cmd/godoc
$ make cloud-build deploy

Updates golang/go#27205.

Change-Id: I5cc1142e02dc288450d55dbd4da4b30c0a080bd5
Reviewed-on: https://go-review.googlesource.com/c/139240
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-04 02:18:13 +00:00
Chris Broadfoot
a3d532c85d cmd/godoc: add make publish to migrate traffic
Also rename `make build` and `make push` to `make docker-build` and
`make docker-push` in preparation to introduce Cloud Build (removing
the dependency on Docker).

Updates golang/go#27205.

Change-Id: Iae19b9a6f77d09246a1332c7ec9eceec449cdba8
Reviewed-on: https://go-review.googlesource.com/c/139239
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-04 01:25:03 +00:00
Bryan C. Mills
9fb5a2f241 all: set GO111MODULE=off for tests that use GOPATHs in testdata.
Some users may set GO111MODULE=on, and we will eventually want to be able to
build x/tools itself in module mode.

Updates golang/go#27858
Updates golang/go#27852

Change-Id: Iaf488b2a89e6526471530245cb580f1f0391a770
Reviewed-on: https://go-review.googlesource.com/137815
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2018-10-03 17:21:27 +00:00
Chris Broadfoot
2f84ea8ef8 cmd/godoc: move regression tests to a go test
Run them separately from the other tests in godoc_test by requiring a
regtest.host flag and by filtering on the test name.

Updates golang/go#27205.

Change-Id: I166d2278a3f6954307f7c935567a81e73f78e7bb
Reviewed-on: https://go-review.googlesource.com/c/139238
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-03 02:47:31 +00:00
Chris Broadfoot
390954b1ab cmd/godoc: re-enable host checking, allow test versions
test.golang.org is no longer -- instead allow access to version-specific
App Engine URLs (like 20181002t1342-dot-golang-org.appspot.com).

App Engine Flex uses the X-Forwarded-Proto to signify the proto used by
the originating request (it always uses h1 on 8080 when proxying the
request).

Updates golang/go#27205.

Change-Id: I423ffe65df325500a2fa04c7b655797ecc6ad037
Reviewed-on: https://go-review.googlesource.com/c/139237
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-03 01:52:03 +00:00
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