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>
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>
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>
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>
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>
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>
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>
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.
Fixesgolang/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>
The type of a function receiver can now also be a IndexExpr.
Fixesgolang/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>
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>
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>
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>
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>
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>
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>
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.
Fixesgolang/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>
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>
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.
Fixesgolang/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>
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>
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>
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.
Fixesgolang/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>
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>
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>
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.
Fixesgolang/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>
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.
Fixesgolang/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>
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>
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>
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>
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>
(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>
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>