Граф коммитов

412 Коммитов

Автор SHA1 Сообщение Дата
Alan Donovan 283fce21c1 x/tools: drop go1.18 support
Updates golang/go#64407

Change-Id: I247a7ff7f07613674f8e31e4cb9c5a68762d2203
Reviewed-on: https://go-review.googlesource.com/c/tools/+/567418
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-29 16:54:26 +00:00
Alan Donovan 67611a11a1 internal/typeparams: eliminate type aliases
Change-Id: I660520bbb1dae855e52bf92492045bb3b16eff8d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/549119
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-12 19:05:56 +00:00
Alan Donovan 23c86e8ed6 internal/typeparams: delete const Enabled=true and simplify
Change-Id: I8e95226d03d94027aee803a0431320bc7ee83600
Reviewed-on: https://go-review.googlesource.com/c/tools/+/549235
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-12 19:05:48 +00:00
Peter Weinberger 365db56d19 tools: clean up after removing all references to ioutil
Although ioutil.ReadDir is deprecated, the suggested replacement has
a different signature, returning []fs.DirEntry rather than []fs.FileEntry.

Some of the places where this occurs are better left referring to ioutil,
as build.Config wants the old behavior. (go/buildutil/util.go and
godoc/vfs/os.go) When someday build gets updated, these can be easily
found, and changed.

Some of the place use Mode().IsRegular() (cmd/toolstash/mail.go and
internal/fastwalk/fastwal_portable.go) and the code needs a minor adjustment.

And, happily, in all the other  places one can use os.ReadDir directly
as only Name() is called.

There are no remaining instances of the generated ioutilReadDir().

Change-Id: I165ca27eafe2fe37fdf14390543b21f7e198281e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/528135
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2023-09-18 16:47:49 +00:00
Peter Weinbergr 559c4300da tools: replace references to obsolete package ioutils
ioutil defines 7 functions. 6 of these are replaced by
functions in io or os with the same signature.
ReadDir is deprecated, but the suggested replacement has a different
signature.

These changes were generated by a program, with some manual adjutments.
The program replaces ReadDir with a call to a function named ioutilReadDir
that has the same signature. The code for this function
is added to files if necessary. The program replaces all the others
with their new versions. The program removes the 'io/ioutil' import
and adds, as necessary, 'os', 'io', and 'io/fs', the latter being
needed for the signature of ioutilReadDir.

The automatic process fails in a few ways:
1. ReadFile occurs only in a comment but the program adds an unneeded import.
2. ioutilReadDir is added to more than one file in the same package
Both of these could be viewed as bugs and fixed by looking harder.

After manual adjustment, two tests failed:
1. gopls/internal/lsp/regtesg/mis:TestGenerateProgress. The reason
	 was a use of ioutil in a txtar constant. The calls were changed,
	 but the code is not smart enough to change the import inside the
	 string constant. (Or it's not smart enough not to change the
	 contents of a string.)
2. gopls/internal/lsp/analysis/deprecated, which wants to see a use
	 of ioutil

These tests were adjused by hand, and all tests (-short) pass.

Change-Id: If9efe40bbb0edda36173d9a88afaf71245db8e79
Reviewed-on: https://go-review.googlesource.com/c/tools/+/527675
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2023-09-12 20:13:37 +00:00
cui fliter 9161e3af9e all: remove repetitive words
Change-Id: Idad45a4c8352116b68eca172329214dbfb89b294
Reviewed-on: https://go-review.googlesource.com/c/tools/+/509696
Run-TryBot: shuang cui <imcusg@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2023-07-19 19:13:53 +00:00
cui fliter ce1b96b591 all: fix some comments
Change-Id: Id334943c9be6e035d52a8d8a4bd26e0e31ae9791
Reviewed-on: https://go-review.googlesource.com/c/tools/+/492578
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Tim King <taking@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
2023-05-05 17:25:45 +00:00
cui fliter bd5dfbb418 all: fix some comments
Change-Id: I44a562ec6d71dcf638333a855083f46201ef9a5e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/464236
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-01-31 16:03:41 +00:00
cui fliter dc88e7b4a2 godoc: fix some comments
Change-Id: Ia43fc5183e97d7d612216722e5255734d28ac508
GitHub-Last-Rev: aa1b6bbb37
GitHub-Pull-Request: golang/tools#403
Reviewed-on: https://go-review.googlesource.com/c/tools/+/436455
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-10-04 18:24:48 +00:00
cui fliter 0e011a0e6c all: use constant to avoid repeated definitions
Change-Id: I9e0a167cc3a9772412f3ec809eeb4720ae331c98
GitHub-Last-Rev: 4a909d88f4
GitHub-Pull-Request: golang/tools#398
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431637
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-09-19 15:32:23 +00:00
Russ Cox a3cac11881 godoc/redirect: delete golang.org-specific code
This logic is now in x/website.
Delete from here to avoid confusion.

Change-Id: Iec8efaa3490fa471a4ebd7e1fb34b4927a39062d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/301309
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2022-08-16 14:47:05 +00:00
aarzilli 79f3242e4b godoc: support go1.19 doc comment syntax
Call go/doc.(*Package).HTML on go1.19 instead of the deprecated
go/doc.ToHTML.

Change-Id: Ie604d9ace7adc179f7c2e345f17a2e0c0365d1a2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/411381
Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
2022-07-19 22:18:38 +00:00
Russ Cox d5f48fca53 all: gofmt
Gofmt to update doc comments to the new formatting.

(There are so many files in x/tools I am breaking up the
gofmt'ing into multiple CLs. This is the leftovers.)

For golang/go#51082.

Change-Id: Id9d440cde9de7093d2ffe06cbaa7098993823d6b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399363
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-12 17:53:17 +00:00
aarzilli c6fca02004 godoc: handle type parameters correctly in LinkifyText
LinkifyText should not generate links to global declarations for
identifiers that are type parameters.

Because the syntactic resolver does not record the declaration for type
parameters declared in the method receiver (see
https://golang.org/issue/50956) a name lookup is used as a workaround.
This is fine here because it is only applied to undeclared indentifiers
and LinkifyText is only ever called on a single declaration at a time,
not on a full AST.

Updates golang/go#50717

Change-Id: I32f2203ce80c060ee18ca8b964a2d5fd80f41957
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382714
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Peter Weinberger <pjw@google.com>
2022-02-14 18:01:21 +00:00
Bryan C. Mills 939c2c050f godoc/redirect: close HTTP response bodies in TestRedirect
In https://go.dev/issue/50879, we observe ECONNRESET errors from
'dial' in TestRedirect for various paths. That seems to imply that a
unique connection is being dialed for each path — but these
connections are all going through http.DefaultTransport, which has a
30-second keepalive, and the test takes well under that amount of time
to complete.

The only reason we would be dialing a connection per request would be
if the connection itself leaks — and, indeed, inspecting the test in
more detail it fails to close the response body.

I don't know why failing to close the response body would lead to
ECONNRESET errors, but at the very least fixing that issue should
reduce the number of 'dial' operations and thus the number of
platform-specific failure modes.

Fixes golang/go#50879.
(Maybe.)

Change-Id: I5af47ee3683c54106424c66e94b021a0ec7e6d2d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/381736
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-28 18:44:56 +00:00
aarzilli 4754748303 godoc: fix addNames for generics
The type of a function receiver can now also be a IndexExpr.

Fixes golang/go#50413

Change-Id: I5ac7bee8ea6b594be00d00c7fed2e2a9fe260b10
Reviewed-on: https://go-review.googlesource.com/c/tools/+/373857
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-06 16:18:51 +00:00
Zvonimir Pavlinovic d6a9af8af0 godoc/analysis: remove deprecated analysis package
Change-Id: I862cae902ea2ff7ed36722d536039cc617200de6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/358954
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2021-10-29 00:04:41 +00:00
Tom Freudenberg f05e912406 godoc/static: add gopher/pkg.png image
Replace the link to the gopher pkg.png from an online location
to a local file.

This will prevent any privacy issue on godoc so that there is no ping anymore to golang.org
when opening private documentation generated by godoc.

Another benefit is that it allows the image to load when godoc is used offline.

Last the img is placed to the upper section.

For golang/go#32011.

Change-Id: I1459bf2613251e3e12404087ea9083b64a4f70c2
GitHub-Last-Rev: c32ef9541e
GitHub-Pull-Request: golang/tools#315
Reviewed-on: https://go-review.googlesource.com/c/tools/+/313097
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
2021-05-07 20:56:39 +00:00
Dmitri Shuralyov 682c7e60bf godoc/static: link to golang.org for content moved out of Go root
More of the golang.org website content has moved from the Go tree to
the x/website repository in CL 291711, resulting in broken links or
otherwise missing resources in godoc. None of it is affecting godoc's
core functionality, but it's good to fix broken links, so link to the
resources served by golang.org for now.

If it becomes important to make these resources available while godoc
is running offline, that can be done later. (It will be easier once
we can start relying on //go:embed for all supported Go versions.)

Include a local copy of a favicon.ico since the one in Go root is no
longer there as of CL 300549.

For golang/go#32011.

Change-Id: If5bd8e61b72dd9ca1db469d9121e43742846c115
Reviewed-on: https://go-review.googlesource.com/c/tools/+/300394
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-03-30 17:48:30 +00:00
Russ Cox 8e4f4c8659 godoc: delete GoogleCN logic
The GoogleCN code is specific to the code for golang.org,
which no longer uses golang.org/x/tools/godoc.

For golang/go#32011.

Change-Id: If13e3ed93d57f9d8a6c0f8a09b8343567dd6c0b1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/296373
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-03-12 18:55:53 +00:00
Russ Cox 54dc8c5edb playground: remove /share registration, add Proxy
The /share registration is not needed by programs like
talks and blog, only by golang.org, so installing it by default
is unnecessary and perhaps more exposure than people running
those servers intend.

Add Proxy to allow recreating the /share registration (unlikely)
or installing the proxy on an alternate mux (more likely).

Change-Id: Ibb33add804d353920d405bf022428e48b3815da3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/293449
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-02-25 15:03:53 +00:00
Russ Cox 2363391a5b all: go fmt ./...
Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Not strictly necessary but will avoid gofmt changes later
as people edit these files.

Change-Id: I20749ed82e18938a305d9425d0739f0ea7bd24c0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/294414
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-20 03:28:52 +00:00
Russ Cox 123adc86bc godoc/vfs: add io/fs adapter
Change-Id: Iaeea108ce2803d3ee1ece5d2d67fbe353576fbd7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/291669
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2021-02-15 12:39:31 +00:00
Russ Cox 5bd3da9b64 godoc: convert Markdown files to HTML during serving
For golang.org today, Markdown is converted to HTML during
the static file embedding, but that precludes using Markdown with
"live serving".

Moving the code here lets godoc itself do the conversion and
therefore works with live serving. It is also more consistent with
re-executing templates during serving for Template:true files.

When a file is .md but also has Template: true, templates apply
first, so that templates can generate Markdown.
This is reversed from what x/website was doing (Markdown before templates)
but that decision was mostly forced by doing it during static
embedding and not necessarily the right one.
There's no reason to force switching to raw HTML just because
you want to use a template.
(A template can of course still generate HTML.)

Change-Id: I7db6d54b43e45803e965df7a1ab2f26293285cfd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/251343
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-02-12 16:44:11 +00:00
Dmitri Shuralyov 6140657873 godoc: show earliest version when identifier was added
CL 85396 implemented parsePackageAPIInfo with the idea that each
identifier shows up in exactly one of api/go*.txt files, when it
was added. We now know that it may show up more than once, when
the signature changes (generally in a compatible way, such as
when existing types are replaced with aliases to an equivalent
type).

Modify the algorithm to parse the api/go*.txt files in reverse
order, in order to find and display the earliest Go version when
each identifier was first added.

Fixes golang/go#44081.
Updates golang/go#5778.

Change-Id: I83171fd8c161d703f284011375d74b824c279d41
Reviewed-on: https://go-review.googlesource.com/c/tools/+/289089
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-09 00:10:52 +00:00
Julie Qiu 05664e2e8d godoc: change godoc.org links to pkg.go.dev
Links to godoc.org pages are changed to link to pkg.go.dev.

CL 253017 and CL 234678 are also backported.

For golang/go#36106

Change-Id: I6a875f5b43e456f11d8eeccfc5ef647a5501c4d3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275235
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-12-07 16:54:04 +00:00
phillc fa0125251c all: replace 'the the ' with 'the '
`find . -type f \( -name "*.go" -or -name "*.yaml" \) -print0 | xargs -0 gsed -i 's/the the /the /g'`

Change-Id: I422158bbe559d4eb00490f619306a94765dc18e4
GitHub-Last-Rev: d0df252001
GitHub-Pull-Request: golang/tools#253
Reviewed-on: https://go-review.googlesource.com/c/tools/+/256258
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-09-21 21:00:52 +00:00
Muhammad Hamza Farrukh 76a6aac657 present: fix newline parsing for go present
Pressing enter on editable go present code adds a new 'pre' html tag
which isn't being handled properly. This fix in play.js adds a newline
to the html is being parsed whenever it sees a 'pre' tag.

Fixes golang/go#41139

Change-Id: I042d13999f4a8518fb282c4c5bfb3a5197215449
Reviewed-on: https://go-review.googlesource.com/c/tools/+/251697
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-09-03 15:36:55 +00:00
Russ Cox 97606e3207 godoc: fix panic in Presentation.ServeFile
The redirect to drop index.html must be done using r.URL.Path,
not relpath, because those might differ. Cutting len("index.html")
bytes off a string that doesn't end in index.html is incorrect.

While we're here, silence an annoying log print during go test.

For golang/go#40665.

Change-Id: I36553b041f53eab9c42da6b77184e90800a97e92
Reviewed-on: https://go-review.googlesource.com/c/tools/+/251080
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-08-27 16:23:30 +00:00
Rebecca Stambler 6be401e3f7 godoc/static: replace innerHTML with textContent
Setting innerHTML is a more heavyweight operation that supports HTML.
What's being done here doesn't use HTML, so it's viable to use the more
lightweight textContent.

Change-Id: I46e9359ffe776001836cc09fea88b04364870db7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/235577
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-05-28 18:54:14 +00:00
Agniva De Sarker 693125cf94 all: run prettier on js and css
Command used: docker run --rm -it --volume "$PWD":/wd agniva/prettier "**/*.{js,css}"

Updates golang/go#21719

Change-Id: I892718781206430a8f85da38a762b54191ce023a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/183878
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2020-05-28 15:31:44 +00:00
Dmitri Shuralyov ead0a56930 godoc/vfs/mapfs: panic on invalid New usage
mapfs.New documentation says:

> Map keys should be forward slash-separated pathnames
> and not contain a leading slash.

It is invalid input if a provided path contains a leading slash, and it
causes the returned filesystem to have undefined behavior. Package mapfs
is often used in tests, so this can lead to a serious problem elsewhere.

Help detect invalid API usage sooner by validating input, and panicking
when it contains leading slashes. Programs that use mapfs API correctly
will be unaffected, and it will be faster for incorrect programs—if any
exist today or will be created in the future—to detect and correct such
problems.

Fixes golang/go#34591.

Change-Id: I77e5f0f4628edf83480604135f58bfb62e521d80
Reviewed-on: https://go-review.googlesource.com/c/tools/+/197859
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-05-08 23:23:36 +00:00
Tamir Duberstein 5e2df02acb godoc/static: update jquery.treeview to 1.4.2
This has the primary benefit of clarifying the license as MIT.

Images have been "losslessly compressed" upstream; see
https://github.com/jzaefferer/jquery-treeview/commit/ca711d9.

Retrieved from
https://github.com/jzaefferer/jquery-treeview/releases/tag/1.4.2.

Change-Id: Ia111cbdf246d9adafa3d1c8cfbd7f0c5763cc935
Reviewed-on: https://go-review.googlesource.com/c/tools/+/223077
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-03-12 15:35:18 +00:00
Rebecca Stambler 207d3de1fa all: fix some staticcheck errors
Updates golang/go#35718

Change-Id: I10bfd5421cd44bb58b8bcaa6e9205040c25f51be
Reviewed-on: https://go-review.googlesource.com/c/tools/+/208257
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-29 04:53:41 +00:00
Dmitri Shuralyov 6ed6e6036b godoc/static: update copyright year to 2013
The generated static.go file was missing a license header when it was
created in 2013 in CL 12805046. CL 38165 added a license header, using
the current year in the template. This causes the static.go file to go
"out of date" whenever the year changes.

Change the copyright year to be a fixed year when the file was created.
This way, the TestStaticIsUpToDate test will stop breaking every year.

Updates golang/go#36360
Updates golang/go#11811

Change-Id: If1597b0d93b7eacf23b7de103a6d7e3ca049bb4f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/213119
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-01-02 16:51:58 +00:00
Dan Kortschak 6c68fec0bc all: remove many cases of space-space
Change-Id: I49eb8410d4143c67dfccf027f8b2794e66963415
Reviewed-on: https://go-review.googlesource.com/c/tools/+/212580
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-12-30 19:07:42 +00:00
Dmitri Shuralyov b0650ceb63 godoc/static: re-add "or" function call to package.html template
It was removed unintentionally in CL 101295, where the intention was
to remove the (eq $.Dirname "/src") condition.

Updates golang/go#35812

Change-Id: I1591ed221f0d510fb1ffa51a3ecd48d8327fdfbb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/208661
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
2019-11-26 05:54:41 +00:00
Dmitri Shuralyov 688c506a55 cmd/godoc, godoc/static: remove remnants of golang.org website
The canonical home for the golang.org website by now is
the golang.org/x/website/cmd/golangorg command. That is
the command that should be used to run the website locally
instead of godoc.

This change reduces the scope of x/tools/cmd/godoc to be
a minimal Go Documentation Server. It removes the remaining
pieces of the golang.org website and changes the title from
"The Go Programming Language" to "Go Documentation Server".

The web tree is modified as follows:

• The index page has been modified to redirect to /pkg/,
  which serves a list of packages.
• The /doc/ tree is removed.
• The /robots.txt and /opensearch.xml pages are removed, since
  the primary use case for godoc now is a local web server.
• The Google Analytics sections are removed from static templates,
  since it's always an empty value in local web server mode.

Fixes golang/go#32011
Updates golang/go#29206

Change-Id: Id62c5f335fa2059774893ef4dcd268649278e99d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/207777
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2019-11-20 19:55:55 +00:00
Anthony Fok dc59f20efa all: fix typo ("identifer" → "identifier")
Change-Id: Ib61b94136923ec74154ff56c5237bea1877c8f14
Reviewed-on: https://go-review.googlesource.com/c/tools/+/207843
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-11-19 21:19:57 +00:00
Dan Kortschak af92b0ef1f godoc/vfs/zipfs: fix godoc formatting
Change-Id: I0303e362e82b713823b46247d15baa2ff6f6a344
Reviewed-on: https://go-review.googlesource.com/c/tools/+/199617
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-07 15:17:16 +00:00
Jay Conrod 7c411dea38 godoc/vfs: fix union logic in NameSpace.ReadDir
ReadDir now returns files from directories in all matching mount
points if no Go files are present in any of them. The behavior now
matches the documentation.

Fixes golang/go#34571

Change-Id: I3a0c8d49a5906ec33ebe9e3efea9d2b9d267506c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/197801
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-09-30 20:11:59 +00:00
Dmitri Shuralyov e7abfedfab godoc, godoc/vfs: improve documentation of GetPageInfo, hasPathPrefix
Change GetPageInfo method documentation to match the method name.

Prefer using "reports whether" in a function that returns a boolean.
This style is more idiomatic.

Updates golang/go#33655

Change-Id: I1a781e7b4f5b4b629fdf4f48e2e97183f63508f9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/196977
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
2019-09-29 04:10:59 +00:00
Dmitri Shuralyov 3ac2a5bbd9 godoc: remove Corpus.testDir field
It was indeed unused.

Updates golang/go#33655

Change-Id: Icb9b9a3d201cc573ae294063b64e38890f37b9ab
Reviewed-on: https://go-review.googlesource.com/c/tools/+/196978
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-24 05:20:46 +00:00
Ainar Garipov feee8acb39 all: fix more typos
Change-Id: I978ad5e1800ebfceb78aaced438331a8341715d4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194697
Reviewed-by: Toshihiro Shiino <shiino.toshihiro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-11 15:13:14 +00:00
Kevin Burke d72b05d2b1 godoc: apply gofmt
Using Go 1.12.9.

Change-Id: I3df42ca98e9af19742ce4d528eea453ef541f892
Reviewed-on: https://go-review.googlesource.com/c/tools/+/162997
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-08-25 03:11:27 +00:00
Dmitri Shuralyov 09281b52a1 godoc: re-add test for ignoring //line comments in source code
The original CL 84050044 added a test case, and it happened to be
in between various CLI test cases. CLI support was removed from
x/tools/cmd/godoc in CL 141397, as part of golang/go#25443.
Re-add a test case for this behavior to prevent regressions.

Updates golang/go#32092
Updates golang/go#25443
Updates golang/go#5247

Change-Id: I0cea74cfe40d120e398a9005676134c5bad6136c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177737
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-05-28 20:18:05 +00:00
Dmitri Shuralyov 1da8801a95 godoc: declare small victory over the punched card tyranny
At least inside this one package.

It's because golang.org/x/tools/cmd/godoc no longer has CLI support
as of golang/go#25443, it is now only a web server. Luckily, browsers
that display HTML pages are not constrained to the fixed width of
punched cards. On the contrary, they seem to embrace a wide variety of
arbitrary page widths, ranging from narrow to wide. This is in part due
to the proliferation of internet access on device form factors such as
the mobile phone, tablet, laptop, and desktop.

So the punchCardWidth constant is now unused and can be removed. This
is a followup to CL 141397 that removed most of the CLI support code,
including the function comment_textFunc, which was its only user. Same
goes for containsOnlySpace.

Updates golang/go#25443

Change-Id: I61fabe6ea801c88758fb2c6aefa70b53d52e2cb5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172975
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-17 16:27:34 +00:00
Andrew Bonventre d1a3278ee7 godoc/util: serve SVG files raw
When a godoc Presentation is serving a file, it will sniff its
contents to determine if it contains "human-readable" text. If
it does, then it serves the contents of the file with surrounding
HTML. SVG files should not be served with any additional HTML even
though their contents are not a binary format (just like CSS or JS
files).

Updates golang/go#9936

Change-Id: Id3dd3b6cda4f103b08f6e924923426a86bd46ec8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177498
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-16 01:51:32 +00:00
Brad Fitzpatrick 2a413a02cc godoc/static: let client use vet check returned by /compile endpoint
(Forked off Yury Smolsky's CL 176618)

With this change, the playground.js client now asks the server to do a
vet check in the same HTTP request as the /compile (and run) step. If
the server replies that it understands the request (VetErrors or VetOK
in the repsonse), then the client can avoid the latency of a second
HTTP roundtrip. We'll remove the /vet handler after we see it fall out
of use from older clients.

Updates golang/go#31970

Change-Id: I5b123883e19cbc6a8ec30c50705e6b945a4d322d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176939
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2019-05-13 21:41:31 +00:00
Dmitri Shuralyov bd17c084df godoc/env: replace with golangorgenv
This change replaces the env package with a new golangorgenv package.

The previous env package existed primarily to configure the godoc
instance that was running golang.org. By now, the golang.org website
has been factored out to x/website, which has its own env package,
but ends up still using this env package indirectly via x/tools/godoc.

The goal of this change is to make env available for other services
that run on subdomains of golang.org, so they can continue to safely
rely on the x/tools/playground, which will be modified in the next
commit to also use the new golangorgenv.

The golangorgenv package replaces the IsProd function with a more
specific one. Start using it in packages x/tools/{,cmd}/godoc. Also,
re-arrange the order of checks to give the host suffix check higher
priority than the environment variable check. This way, if the
environment variable isn't set, the host suffix check gets a chance
to run.

When getting the value of "X-AppEngine-Country" header, use its
canonical format "X-Appengine-Country" to avoid an allocation.
This does not change behavior.

Updates golang/go#30486

Change-Id: I97b47211a45ca0351f31fcb4fa6d408a4b0c4c7c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/165459
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-07 16:39:06 +00:00