1
0
mirror of https://github.com/golang/go synced 2024-11-22 23:50:03 -07:00
Commit Graph

59227 Commits

Author SHA1 Message Date
Jes Cok
26c11bcffe re3 2024-02-28 06:34:55 +08:00
Jes Cok
eae2f49850 re2 2024-02-27 23:22:08 +08:00
Jes Cok
0225178195 re1 2024-02-27 22:33:01 +08:00
Jes Cok
c5a52f8586 re 2024-02-27 18:43:17 +08:00
Jes Cok
f7f4f2bb6f reflect: add Overflow methods to Type
This CL adds new methods synonymous with the method of the same name
in reflect.Value to reflect.Type: OverflowComplex, OverflowFloat,
OverflowInt, OverflowUint.

Fixes #60427
2024-02-27 18:32:25 +08:00
Roland Shoemaker
ccbc725f2d html/template: escape additional tokens in MarshalJSON errors
Escape "</script" and "<!--" in errors returned from MarshalJSON errors
when attempting to marshal types in script blocks. This prevents any
user controlled content from prematurely terminating the script block.

Fixes #65697

Change-Id: Icf0e26c54ea7d9c1deed0bff11b6506c99ddef1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/564196
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-02-27 02:20:11 +00:00
Bryan C. Mills
fc0d9a4b7d net/http: reject client-side retries in server timeout tests
This breaks an unbounded client-side retry loop if the server's
timeout happens to fire during its final read of the TLS handshake.

The retry loop was observed on wasm platforms at CL 557437.
I was also able to reproduce chains of dozens of retries on my
linux/amd64 workstation by adjusting some timeouts and adding a couple
of sleeps, as in this patch:
https://gist.github.com/bcmills/d0a0a57e5f64eebc24e8211d8ea502b3
However, on linux/amd64 on my workstation the test always eventually
breaks out of the retry loop due to timing jitter.

I couldn't find a retry-specific hook in the http.Client,
http.Transport, or tls.Config structs, so I have instead abused the
Transport.Proxy hook for this purpose. Separately, we may want to
consider adding a retry-specific hook, or changing the net/http
implementation to avoid transparently retrying in this case.

Fixes #65410.
Updates #65178.

Change-Id: I0e43c039615fe815f0a4ba99a8813c48b1fdc7e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/559835
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2024-02-26 22:45:28 +00:00
Alan Donovan
f8b4653500 std: fix more nilness findings
(found with x/tools/go/analysis/passes/nilness)

Change-Id: I1bdc7811efbecea95608e634f894cb6c656e3a5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/564221
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-26 22:01:11 +00:00
guoguangwu
0fefe417db cmd/gofmt: remove impossible err!=nil conditional
Change-Id: Ife63c766cefc14d2f6bdd3c706f913b1b6f99949
GitHub-Last-Rev: 04e23349e6
GitHub-Pull-Request: golang/go#65929
Reviewed-on: https://go-review.googlesource.com/c/go/+/566099
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-02-26 21:42:29 +00:00
Tobias Klauser
51a2418f38 net: use bytealg.IndexByte in cgoLookupAddrPTR
Change-Id: I76f4dc1e8bda98936c1198cb45ce8141ca88845b
Reviewed-on: https://go-review.googlesource.com/c/go/+/566235
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-26 21:40:30 +00:00
guoguangwu
74642ddf2e crypto/tls: fix typo in comment
Change-Id: I77371ef99797e2b53f1292c9d6a4eb157f116f88
GitHub-Last-Rev: 7ce7d014c0
GitHub-Pull-Request: golang/go#65836
Reviewed-on: https://go-review.googlesource.com/c/go/+/565440
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-26 21:34:41 +00:00
guoguangwu
70a2e84e91 crypto/ecdsa: fix typo
Change-Id: I32580ffb31ffad05a7c8d3aa0c491aff9f55ea6a
GitHub-Last-Rev: 67516eaa18
GitHub-Pull-Request: golang/go#65565
Reviewed-on: https://go-review.googlesource.com/c/go/+/562316
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-26 21:33:58 +00:00
cui fliter
73847aa41b os: add available godoc link
Change-Id: I430c9a7c4936d7a8c8c787aa63de9a796d20fdf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/539597
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-26 21:33:12 +00:00
Quan Tong
aa9d2de559 cmd/go: print the package containing the unmatched embed patterns
Fixes #49534

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: Ia95868ecc1c3dc9715c0fdc7ab1f30348fffaef5
Reviewed-on: https://go-review.googlesource.com/c/go/+/540017
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-26 21:14:55 +00:00
cui fliter
db67824361 syscall: add available godoc link
Change-Id: I0fcb79f471cdb8b464924d9b04c675f120861f67
Reviewed-on: https://go-review.googlesource.com/c/go/+/539835
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-26 21:03:59 +00:00
cui fliter
601eb78de2 text: add available godoc link
Change-Id: Idbc110cfc4fd6bbbc8b79807ac14abf7b30e0e65
Reviewed-on: https://go-review.googlesource.com/c/go/+/539855
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2024-02-26 20:57:51 +00:00
cui fliter
65172c2036 regexp: add available godoc link
Signed-off-by: cui fliter <imcusg@gmail.com>
Change-Id: I85339293d4cfb691125f991ec7162e9be186efdc
Reviewed-on: https://go-review.googlesource.com/c/go/+/539599
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-02-26 20:50:01 +00:00
cui fliter
cab90c84d1 sync: add available godoc link
Change-Id: I9bc5fd29b0eec8ceadcfee2116de5e7524ef92c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/539617
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-26 20:48:55 +00:00
Andy Pan
1a4fdb9529 doc/next: add the missing slashes ahead of net#Dialer and net#ListenConfig
Change-Id: I216189f181ee73d16602c5cc86eb4d6b439a142b
Reviewed-on: https://go-review.googlesource.com/c/go/+/566595
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2024-02-26 20:48:16 +00:00
guoguangwu
519a7bb1e7 crypto/x509: fix typo
Change-Id: I0911c59280e4a208a3deee1f70b47adc60fb734b
GitHub-Last-Rev: 12e95ade68
GitHub-Pull-Request: golang/go#65833
Reviewed-on: https://go-review.googlesource.com/c/go/+/565439
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2024-02-26 20:48:11 +00:00
aimuz
080fc4cf87 net/netip: introduce parsePrefixError for better error handling
Refactor ParsePrefix to return a parsePrefixError containing the input
string and a detailed message on failure, improving error context and
maintaining consistent error formatting within the netip package.

Change-Id: I8d9fb2f833b0f96f43a14622e66e225b54440410
GitHub-Last-Rev: e17bec3afa
GitHub-Pull-Request: golang/go#65798
Reviewed-on: https://go-review.googlesource.com/c/go/+/565275
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-26 20:48:08 +00:00
Mateusz Poliwczak
f63faf3689 net: don't force cgo resolver for .local subdomain queries
The cgo resolver sends DNS queries for .local subdomain
lookups, just as we do in the go resolver.
We don't need to fallback to the cgo resolver for this
domains when nsswitch.conf uses only file and dns modules.

This has a benefit that we select a consistent resolver,
that is only based on the system configuration, regardless
of the queried domain.

Updates #63978

Change-Id: I9166103adb94d7ab52992925f413f361130e7c52
GitHub-Last-Rev: e2bc5874cb
GitHub-Pull-Request: golang/go#63986
Reviewed-on: https://go-review.googlesource.com/c/go/+/540555
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2024-02-26 20:46:36 +00:00
Tobias Klauser
4760b33326 time: use bytealg.IndexByte in byteString
Change-Id: I0d42bca7c6ee63c05a0ca09c165f2f591edf7c34
Reviewed-on: https://go-review.googlesource.com/c/go/+/565356
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2024-02-26 20:46:01 +00:00
Alessandro Arzilli
08029be9fc cmd/compile/internal/dwarfgen: refactor putvar and putAbstractVar
Currently, changing putvar or putAbstractVar involves:

1. changing the abbrevs array to add new abbrevs or modify existing ones
2. changing the DW_ABRV_XXX const block to add the new abbrevs, this const
   block must match the changes to the abbrevs array
3. change the code at the start of putvar and putAbstractVar that selects
   the abbrev to use
4. change the body of putvar/putAbstractVar to emit the right attributes in
   the right sequence

Each change must agree with all other, this is error prone and if an mistake
is made there is no compile time or runtime check detecting it. Erroneous
code will simply produce unreadable debug sections.

This commit adds a mechanism to automatically generate code for abbrev
selection as well as the abbrev definitions based on static examination of
the body of putvar and putAbstractVar.

TestPutVarAbbrevGenerator is responsible for checking that the generated
code is kept updated and will regenerated it by passing the '-generate'
option to it.

benchstat output:

                         |    old.txt    |               new.txt                |
                         |    sec/op     |    sec/op      vs base               |
Template                    153.8m ±  6%    153.0m ±  6%       ~ (p=0.853 n=10)
Unicode                     98.98m ± 19%   100.22m ± 15%       ~ (p=0.796 n=10)
GoTypes                    1013.7m ± 13%    943.6m ±  8%       ~ (p=0.353 n=10)
Compiler                    98.48m ± 10%    97.79m ±  6%       ~ (p=0.353 n=10)
SSA                          8.921 ± 31%     6.872 ± 37%       ~ (p=0.912 n=10)
Flate                       114.3m ± 21%    128.0m ± 36%       ~ (p=0.436 n=10)
GoParser                    219.0m ± 27%    214.9m ± 26%       ~ (p=0.631 n=10)
Reflect                     447.5m ± 20%    452.6m ± 22%       ~ (p=0.684 n=10)
Tar                         166.9m ± 27%    166.2m ± 27%       ~ (p=0.529 n=10)
XML                         218.6m ± 25%    219.3m ± 24%       ~ (p=0.631 n=10)
LinkCompiler                492.7m ± 12%    523.2m ± 13%       ~ (p=0.315 n=10)
ExternalLinkCompiler         1.684 ±  3%     1.684 ±  2%       ~ (p=0.684 n=10)
LinkWithoutDebugCompiler    296.0m ±  8%    304.9m ± 12%       ~ (p=0.579 n=10)
StdCmd                       69.59 ± 15%     70.76 ± 14%       ~ (p=0.436 n=10)
geomean                     516.0m          511.5m        -0.87%

                         |   old.txt    |               new.txt               |
                         | user-sec/op  | user-sec/op   vs base               |
Template                   281.5m ± 10%   269.6m ± 13%       ~ (p=0.315 n=10)
Unicode                    107.3m ±  8%   110.2m ±  8%       ~ (p=0.165 n=10)
GoTypes                     2.414 ± 16%    2.181 ±  9%       ~ (p=0.315 n=10)
Compiler                   116.0m ± 16%   119.1m ± 11%       ~ (p=0.971 n=10)
SSA                         25.47 ± 39%    17.75 ± 52%       ~ (p=0.739 n=10)
Flate                      205.2m ± 25%   256.2m ± 43%       ~ (p=0.393 n=10)
GoParser                   456.8m ± 28%   427.0m ± 24%       ~ (p=0.912 n=10)
Reflect                    960.3m ± 22%   990.5m ± 23%       ~ (p=0.280 n=10)
Tar                        299.8m ± 27%   307.9m ± 27%       ~ (p=0.631 n=10)
XML                        425.0m ± 21%   432.8m ± 24%       ~ (p=0.353 n=10)
LinkCompiler               768.1m ± 11%   796.9m ± 14%       ~ (p=0.631 n=10)
ExternalLinkCompiler        1.713 ±  5%    1.666 ±  4%       ~ (p=0.190 n=10)
LinkWithoutDebugCompiler   313.0m ±  9%   316.7m ± 12%       ~ (p=0.481 n=10)
geomean                    588.6m         579.5m        -1.55%

          |   old.txt    |                new.txt                |
          |  text-bytes  |  text-bytes   vs base                 |
HelloSize   842.9Ki ± 0%   842.9Ki ± 0%       ~ (p=1.000 n=10) ¹
CmdGoSize   10.95Mi ± 0%   10.95Mi ± 0%       ~ (p=1.000 n=10) ¹
geomean     3.003Mi        3.003Mi       +0.00%
¹ all samples are equal

          |   old.txt    |                new.txt                |
          |  data-bytes  |  data-bytes   vs base                 |
HelloSize   15.08Ki ± 0%   15.08Ki ± 0%       ~ (p=1.000 n=10) ¹
CmdGoSize   314.7Ki ± 0%   314.7Ki ± 0%       ~ (p=1.000 n=10) ¹
geomean     68.88Ki        68.88Ki       +0.00%
¹ all samples are equal

          |   old.txt    |                new.txt                |
          |  bss-bytes   |  bss-bytes    vs base                 |
HelloSize   396.8Ki ± 0%   396.8Ki ± 0%       ~ (p=1.000 n=10) ¹
CmdGoSize   428.8Ki ± 0%   428.8Ki ± 0%       ~ (p=1.000 n=10) ¹
geomean     412.5Ki        412.5Ki       +0.00%
¹ all samples are equal

          |   old.txt    |               new.txt               |
          |  exe-bytes   |  exe-bytes    vs base               |
HelloSize   1.310Mi ± 0%   1.310Mi ± 0%  -0.01% (p=0.000 n=10)
CmdGoSize   16.37Mi ± 0%   16.37Mi ± 0%  -0.00% (p=0.000 n=10)
geomean     4.631Mi        4.631Mi       -0.00%

Change-Id: I7edf37b5a47fd9aceef931ddf2c701e66a7b38b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/563815
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-26 20:45:07 +00:00
apocelipes
5bce5362da sync: simplify the code with atomic.Pointer
Change-Id: I79797be6b385c9927d68350334d7f7387007085f
GitHub-Last-Rev: 3daa3b144f
GitHub-Pull-Request: golang/go#65937
Reviewed-on: https://go-review.googlesource.com/c/go/+/566815
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-26 18:12:29 +00:00
Damien Neil
e596e88318 path/filepath: add Localize
Add the Localize function, which takes an io/fs slash-separated path
and returns an operating system path.

Localize returns an error if the path cannot be represented on
the current platform.

Replace internal/safefile.FromFS with Localize,
which serves the same purpose as this function.

The internal/safefile package remains separate from path/filepath
to avoid a dependency cycle with the os package.

Fixes #57151

Change-Id: I75c88047ddea17808276761da07bf79172c4f6fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/531677
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-26 18:08:14 +00:00
Jes Cok
7b583fd1a1 net/http: allow multiple spaces between method and path in mux patterns
Fixes #64910

Change-Id: I14fd1e35c95b14591e3ad7b889dc1ab19a008730
GitHub-Last-Rev: b8d436cdee
GitHub-Pull-Request: golang/go#65868
Reviewed-on: https://go-review.googlesource.com/c/go/+/565916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-02-26 16:36:30 +00:00
Matteo Vaccari
5225da7001 expvar: avoid conflict with user-defined "GET /" route.
With the new routing style in go 1.22, declaring

    http.Handle("GET /", h)

generates a conflict with route "/debug/vars" declared in the expvar
package. You get an error such as:

panic: pattern "GET /" (registered at ...) conflicts with pattern
"/debug/vars" (registered at ...expvar.go:384): GET / matches fewer
methods than /debug/vars, but has a more general path pattern

This patch prevents that error.  Adding GET is correct because no other
method makes sense with /debug/vars.

We preserve the traditional behaviour when GODEBUG=httpmuxgo121=1 is
specified.

Fixes #65723

Change-Id: Id2b963ebad41a1ebdcceb73baf3436d59aac73a0
GitHub-Last-Rev: 9c2b9f74a7
GitHub-Pull-Request: golang/go#65745
Reviewed-on: https://go-review.googlesource.com/c/go/+/564735
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-02-26 15:31:33 +00:00
guoguangwu
7a64b0f07b runtime/coverage: remove refs to deprecated io/ioutil
Change-Id: I66965e6a61cf1726db06670978a4654b84f3fd72
GitHub-Last-Rev: 90023e4843
GitHub-Pull-Request: golang/go#65900
Reviewed-on: https://go-review.googlesource.com/c/go/+/566356
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-26 14:39:20 +00:00
qmuntal
7db8b9e518 path/filepath: support multiple TestAbs runs on Windows
TestAbs modifies the absTests global variable on Windows, which makes
the test to fail if it is run more than once, i.e. executing
"go test -run ^TestAbs$ -count 2 path/filepath".

This CL fixes the issue by clipping the absTests slices before
appending more elements to it.

Change-Id: I8f1144b2f10b8fa1b847e6639c0bda7baafc2dac
Reviewed-on: https://go-review.googlesource.com/c/go/+/566396
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-02-26 07:59:11 +00:00
rogeryk
08d9397170 text/template: add "else with" action
Add "else with" action will reduce the template complexity in some use cases(#57646).
This action will be added:
  {{with pipeline}} T1 {{else with pipeline}} T0 {{end}}.

Fixes #57646

Change-Id: I90ed546ab671805f753343b00bd3c9d1a1d5581d
Reviewed-on: https://go-review.googlesource.com/c/go/+/545376
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-24 21:59:12 +00:00
Max 👨🏽‍💻 Coplan
e0fc269f77 net/http: make FileServer look good on mobile
Currently when viewing directories on a phone, the text is small and
often hard to tap correctly.  This commit adds the viewport property to
the page to make it look correct on phones.  This commit also makes the
page behave in Standards Mode instead of Quirks Mode which does not
effect the behavior of this page but makes me feel good inside ☺️

Change-Id: I4babcf79085e85fba57453b7a235e4750a269a42
Reviewed-on: https://go-review.googlesource.com/c/go/+/552595
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Max Coplan <mchcopl@gmail.com>
2024-02-24 19:36:28 +00:00
Ian Lance Taylor
ef84d62cfc net: skip TestReadLine if /etc/services does not exist
Fixes #65905

Change-Id: I42326d3b743e80d5226ea374eca5c9edaef4dd4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/566535
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-02-24 00:04:48 +00:00
Andy Pan
e803857813 path/filepath: delete the deprecated joinNonEmpty and isUNC
Change-Id: I4ce88b2e8e8d24afb63ca7246ce0c418fcb02c9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/564715
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-23 23:50:06 +00:00
Robert Griesemer
b899e0b8cc go/types: generate errors_test.go from types2 source
This CL reduces the amount of code that needs to be maintained
manually by about 50 LOC.

Change-Id: I022688d6db58bf58e7844487582725a23ca820be
Reviewed-on: https://go-review.googlesource.com/c/go/+/566515
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-02-23 21:21:46 +00:00
Robert Griesemer
720306359a go/types, types2: make error handling more similar
This change will make error handling between go/types and types2
more similar which will in turn allow more go/types files to be
generated from types2 sources.

Specifically:
- add Checker.newError to create error_ objects
- s/error_.errorf/error_.addf/
- remove error_.String (use error_.msg instead)
- replace Checker.report with error_.report
- make error_.report as similar as currently possible
- adjust dependencies

The new code consistently uses newError/addf/report
to report all errors.

Change-Id: Ibd6fd743a4f7746b4aa6b93fe768814dad9ee9c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/566096
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-23 21:21:43 +00:00
Mauri de Souza Meneguzzo
727e8d3863 runtime: add crash stack support for arm
Change-Id: Ide4002d1cf82f2daaf7261b367c391dedbbf7719
GitHub-Last-Rev: 80ee248c3e
GitHub-Pull-Request: golang/go#65308
Reviewed-on: https://go-review.googlesource.com/c/go/+/558699
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-23 21:00:52 +00:00
Michael Pratt
e58486e599 Revert "os: make use of pidfd on linux"
This reverts CL 528438.

Reason for revert: Implicated in "bad FD" test failures. Full extent of
issue still unclear.

For #62654.
Fixes #65857.

Change-Id: I066e38040544c506917e90255bd0e330964a0276
Reviewed-on: https://go-review.googlesource.com/c/go/+/566477
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-23 18:31:19 +00:00
Michael Pratt
c4e4afc90e Revert "os: make FindProcess use pidfd on Linux"
This reverts CL 542699.

Reason for revert: Some applications assume FindProcess does not return
errors.

For #62654.
Fixes #65866.

Change-Id: Ic185a6253c8e508b08150b618c39a9905f6cdd60
Reviewed-on: https://go-review.googlesource.com/c/go/+/566476
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2024-02-23 18:29:45 +00:00
Jonathan Amsterdam
0e7c9846c4 cmd: don't require build tags in relnote pathnames
Due to a bug in golang.org/x/build/relnote, API features affecting
specific builds would need to include those build tags in relnote
pathnames.

This CL vendors in the fixed golang.org/x/build. (That caused other
modules to be vendored in as well.)

It also renames the syscall relnote file to remove the build tags
from its pathname.

For #64169.

Change-Id: Iaf6cd9099df1156f4e20c63d519a862ea19a7a3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/566455
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-02-23 18:08:27 +00:00
Meng Zhuo
ad377e906a math: add round assembly implementations on riscv64
goos: linux
goarch: riscv64
pkg: math
            │ floor_old.bench │           floor_new.bench           │
            │     sec/op      │   sec/op     vs base                │
Ceil              54.12n ± 0%   22.05n ± 0%  -59.26% (p=0.000 n=10)
Floor             40.80n ± 0%   22.05n ± 0%  -45.96% (p=0.000 n=10)
Round             20.73n ± 0%   20.74n ± 0%        ~ (p=0.441 n=10)
RoundToEven       24.07n ± 0%   24.07n ± 0%        ~ (p=1.000 n=10)
Trunc             38.73n ± 0%   22.05n ± 0%  -43.07% (p=0.000 n=10)
geomean           33.58n        22.17n       -33.98%

Change-Id: I24fb9e3bbf8146da253b6791b21377bea1afbd16
Reviewed-on: https://go-review.googlesource.com/c/go/+/504737
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: M Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: M Zhuo <mengzhuo1203@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
2024-02-23 08:34:12 +00:00
Andy Pan
27e104ba09 os: avoid writing within the tree during testing CopyFS
Change-Id: I1d3e7c100ddfbd2ea9a7bb9e8efae89893c8365a
Reviewed-on: https://go-review.googlesource.com/c/go/+/566335
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
2024-02-23 05:09:01 +00:00
Andy Pan
faf2a8416a internal/poll: revise the determination about [handled] and improve the code readability for SendFile
There were a bit too many conditional branches in the old code,
resulting in a poor readability. It could be more concise by reducing
and consolidating some of the conditions.

Furthermore, how we've determined whether or not the data transimission
was handled by sendfile(2) seems inappropriate, because it marked the
operation as unhandled whenever any non-retryable error occurs from
calling sendfile(2), it doesn't look like a right approach, at least
this is an inconsistent behavior with what we've done in Splice.

Related to #64044

Change-Id: Ieb65e0879a8841654d0e64a1263a4e43179df1ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/537275
TryBot-Result: Gopher Robot <gobot@golang.org>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-23 05:06:03 +00:00
Andy Pan
d9be60974b os: implement CopyFS
Fixes #62484

Change-Id: I5d8950dedf86af48f42a641940b34e62aa2cddcb
Reviewed-on: https://go-review.googlesource.com/c/go/+/558995
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-23 00:19:54 +00:00
Axel Wagner
8a0fbd75a5 encoding/xml: reject XML declaration after start of document
The XML specification requires an XML declaration, if present, to only
appear at the very beginning of the document, not even preceded by
whitespace. The parser currently accepts it at any part of the input.

Rejecting whitespace at the beginning of the file might break too many
users. This change instead only rejects an XML declaration preceded by
a non-whitespace token *and* allows the Encoder to emit whitespace
before an XML declaration. This means that a token stream produced by
the Decoder can be passed to the Encoder without error, while we still
don't emit clearly invalid XML.

This might break programs depending on Decoder allowing arbitrary XML
before the XML declaration.

Fixes #65691.

Change-Id: Ib1d4b3116aee63f40fd377f90595780b4befd1ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/564035
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-22 22:50:20 +00:00
Nicolas Hillegeer
d892cb496a internal/trace/v2: make readBatch param more permissive
This function is copied to x/exp/trace. In https://go.dev/cl/566255 a
change is made where the source is a bytes.Reader instead of a
bufio.Reader from one of the two callers. Change the prototype here
instead of diverging the implementations.

Change-Id: I594224663996eadbc8c388442d68ac5706c52c8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/566236
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-02-22 22:21:26 +00:00
Robert Griesemer
db57e5a040 go/types, types2: remove unreachable func (minor cleanup)
In some places we can't use unreachable() because it does
not terminate control flow and we need to resort to panic.
Be consistent and just use panic("unreachable") everywhere.
This also opens the door to reporting more specific panic
messages.

Mechanical change: s/unreachable()/panic("unreachable")/

Minor cleanup for better consistency.

Change-Id: I6b52af7c21dcfaa1ca19839d14040552db5d4cb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/566135
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-02-22 19:32:17 +00:00
Robert Griesemer
f278f756bd go/types: : generate operand.go from types2 source
This CL reduces the amount of code that needs to be maintained
manually by about 400 LOC.

Change-Id: I03f77c8067aebfdb2a1cce6827ded733ff55e1cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/565837
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2024-02-22 16:40:18 +00:00
Robert Griesemer
55bb3d1c10 go/types: : generate assignments.go from types2 source
This CL reduces the amount of code that needs to be maintained
manually by about 600 LOC.

Change-Id: I7107c8050075281bf6840a9f5234d70e09734ce6
Reviewed-on: https://go-review.googlesource.com/c/go/+/565836
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-22 16:40:15 +00:00
Michael Pratt
638b9023e3 runtime: be careful about crash FD changes during panic
There are two separate cases here:

The base case is simple: a concurrent call to SetCrashOutput while
panicking will switch the crash FD, which could cause the first half of
writes to go to the old FD, and the second half to the new FD. This
isn't a correctness problem, but would be annoying to see in practice.
Since it is easy to check for, I simply drop any changes if panicking is
already in progress.

The second case is more important: SetCrashOutput will close the old FD
after the new FD is swapped, but writeErrData has no locking around use
of the fd, so SetCrashOutput could close the FD out from under
writeErrData, causing lost writes. We handle this similarly, by not
allowing SetCrashOutput to close the old FD if a panic is in progress,
but we have to be more careful about synchronization between
writeErrData and setCrashFD to ensure that writeErrData can't observe
the old FD while setCrashFD allows close.

For #42888.

Change-Id: I7270b2cc5ea58a15ba40145b7a96d557acdfe842
Reviewed-on: https://go-review.googlesource.com/c/go/+/559801
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-22 15:37:30 +00:00