Skip to content

Commit 587ffa3

Browse files
committed
Merge remote-tracking branch 'origin/master' into hotfix/underflow-h2-push
2 parents ae50fec + 555af99 commit 587ffa3

File tree

859 files changed

+4453
-5984
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

859 files changed

+4453
-5984
lines changed

doc/go_spec.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--{
22
"Title": "The Go Programming Language Specification",
3-
"Subtitle": "Version of Sep 13, 2023",
3+
"Subtitle": "Version of Oct 16, 2023",
44
"Path": "/ref/spec"
55
}-->
66

@@ -4826,12 +4826,13 @@ <h4 id="Operator_precedence">Operator precedence</h4>
48264826
</p>
48274827

48284828
<pre>
4829-
+x
4830-
23 + 3*x[i]
4831-
x &lt;= f()
4832-
^a &gt;&gt; b
4833-
f() || g()
4834-
x == y+1 &amp;&amp; &lt;-chanInt &gt; 0
4829+
+x // x
4830+
42 + a - b // (42 + a) - b
4831+
23 + 3*x[i] // 23 + (3 * x[i])
4832+
x &lt;= f() // x &lt;= f()
4833+
^a &gt;&gt; b // (^a) >> b
4834+
f() || g() // f() || g()
4835+
x == y+1 &amp;&amp; &lt;-chanInt &gt; 0 // (x == (y+1)) && ((<-chanInt) > 0)
48354836
</pre>
48364837

48374838

doc/godebug.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ and the [go command documentation](/cmd/go#hdr-Build_and_test_caching).
129129
### Go 1.22
130130

131131
Go 1.22 adds a configurable limit to control the maximum acceptable RSA key size
132-
that can be used in TLS handshakes, controlled by the [`tlsmaxrsasize`setting](/pkg/crypto/tls#Conn.Handshake).
132+
that can be used in TLS handshakes, controlled by the [`tlsmaxrsasize` setting](/pkg/crypto/tls#Conn.Handshake).
133133
The default is tlsmaxrsasize=8192, limiting RSA to 8192-bit keys. To avoid
134134
denial of service attacks, this setting and default was backported to Go
135135
1.19.13, Go 1.20.8, and Go 1.21.1.

misc/ios/detect.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build ignore
6-
// +build ignore
76

87
// detect attempts to autodetect the correct
98
// values of the environment variables

src/bufio/example_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package bufio_test
66

77
import (
88
"bufio"
9+
"bytes"
910
"fmt"
1011
"os"
1112
"strconv"
@@ -137,3 +138,36 @@ func ExampleScanner_emptyFinalToken() {
137138
}
138139
// Output: "1" "2" "3" "4" ""
139140
}
141+
142+
// Use a Scanner with a custom split function to parse a comma-separated
143+
// list with an empty final value but stops at the token "STOP".
144+
func ExampleScanner_earlyStop() {
145+
onComma := func(data []byte, atEOF bool) (advance int, token []byte, err error) {
146+
i := bytes.IndexByte(data, ',')
147+
if i == -1 {
148+
if !atEOF {
149+
return 0, nil, nil
150+
}
151+
// If we have reached the end, return the last token.
152+
return 0, data, bufio.ErrFinalToken
153+
}
154+
// If the token is "STOP", stop the scanning and ignore the rest.
155+
if string(data[:i]) == "STOP" {
156+
return i + 1, nil, bufio.ErrFinalToken
157+
}
158+
// Otherwise, return the token before the comma.
159+
return i + 1, data[:i], nil
160+
}
161+
const input = "1,2,STOP,4,"
162+
scanner := bufio.NewScanner(strings.NewReader(input))
163+
scanner.Split(onComma)
164+
for scanner.Scan() {
165+
fmt.Printf("Got a token %q\n", scanner.Text())
166+
}
167+
if err := scanner.Err(); err != nil {
168+
fmt.Fprintln(os.Stderr, "reading input:", err)
169+
}
170+
// Output:
171+
// Got a token "1"
172+
// Got a token "2"
173+
}

src/bufio/scan.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ type Scanner struct {
4848
//
4949
// Scanning stops if the function returns an error, in which case some of
5050
// the input may be discarded. If that error is [ErrFinalToken], scanning
51-
// stops with no error.
51+
// stops with no error. A non-nil token delivered with [ErrFinalToken]
52+
// will be the last token, and a nil token with [ErrFinalToken]
53+
// immediately stops the scanning.
5254
//
5355
// Otherwise, the [Scanner] advances the input. If the token is not nil,
5456
// the [Scanner] returns it to the user. If the token is nil, the
@@ -114,18 +116,20 @@ func (s *Scanner) Text() string {
114116
}
115117

116118
// ErrFinalToken is a special sentinel error value. It is intended to be
117-
// returned by a Split function to indicate that the token being delivered
118-
// with the error is the last token and scanning should stop after this one.
119-
// After ErrFinalToken is received by Scan, scanning stops with no error.
119+
// returned by a Split function to indicate that the scanning should stop
120+
// with no error. If the token being delivered with this error is not nil,
121+
// the token is the last token.
122+
//
120123
// The value is useful to stop processing early or when it is necessary to
121-
// deliver a final empty token. One could achieve the same behavior
122-
// with a custom error value but providing one here is tidier.
124+
// deliver a final empty token (which is different from a nil token).
125+
// One could achieve the same behavior with a custom error value but
126+
// providing one here is tidier.
123127
// See the emptyFinalToken example for a use of this value.
124128
var ErrFinalToken = errors.New("final token")
125129

126130
// Scan advances the [Scanner] to the next token, which will then be
127-
// available through the [Scanner.Bytes] or [Scanner.Text] method. It returns false when the
128-
// scan stops, either by reaching the end of the input or an error.
131+
// available through the [Scanner.Bytes] or [Scanner.Text] method. It returns false when
132+
// there are no more tokens, either by reaching the end of the input or an error.
129133
// After Scan returns false, the [Scanner.Err] method will return any error that
130134
// occurred during scanning, except that if it was [io.EOF], [Scanner.Err]
131135
// will return nil.
@@ -148,7 +152,10 @@ func (s *Scanner) Scan() bool {
148152
if err == ErrFinalToken {
149153
s.token = token
150154
s.done = true
151-
return true
155+
// When token is not nil, it means the scanning stops
156+
// with a trailing token, and thus the return value
157+
// should be true to indicate the existence of the token.
158+
return token != nil
152159
}
153160
s.setErr(err)
154161
return false

src/cmd/asm/internal/asm/testdata/ppc64.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
409409
EXTSHCC R3, R4 // 7c640735
410410
EXTSW R3, R4 // 7c6407b4
411411
EXTSWCC R3, R4 // 7c6407b5
412+
RLWMI $7, R3, $4026531855, R6 // 50663f06
413+
RLWMI $7, R3, $1, R6 // 50663ffe
414+
RLWMI $7, R3, $2147483648, R6 // 50663800
412415
RLWMI $7, R3, $65535, R6 // 50663c3e
413416
RLWMI $7, R3, $16, $31, R6 // 50663c3e
414417
RLWMICC $7, R3, $65535, R6 // 50663c3f

src/cmd/cgo/internal/testfortran/fortran_test.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package fortran
66

77
import (
8-
"fmt"
98
"internal/testenv"
109
"os"
1110
"os/exec"
@@ -75,11 +74,18 @@ func TestFortran(t *testing.T) {
7574

7675
// Finally, run the actual test.
7776
t.Log("go", "run", "./testdata/testprog")
78-
out, err := exec.Command("go", "run", "./testdata/testprog").CombinedOutput()
79-
if err == nil && string(out) != "ok\n" {
80-
err = fmt.Errorf("expected ok")
77+
var stdout, stderr strings.Builder
78+
cmd := exec.Command("go", "run", "./testdata/testprog")
79+
cmd.Stdout = &stdout
80+
cmd.Stderr = &stderr
81+
err := cmd.Run()
82+
t.Logf("%v", cmd)
83+
if stderr.Len() != 0 {
84+
t.Logf("stderr:\n%s", stderr.String())
8185
}
8286
if err != nil {
83-
t.Errorf("%s\nOutput:\n%s", err, string(out))
87+
t.Errorf("%v\n%s", err, stdout.String())
88+
} else if stdout.String() != "ok\n" {
89+
t.Errorf("stdout:\n%s\nwant \"ok\"", stdout.String())
8490
}
8591
}

src/cmd/cgo/internal/testfortran/testdata/testprog/fortran.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ package main
66

77
// int the_answer();
88
import "C"
9-
import "os"
9+
import (
10+
"fmt"
11+
"os"
12+
)
1013

1114
func TheAnswer() int {
1215
return int(C.the_answer())
1316
}
1417

1518
func main() {
1619
if a := TheAnswer(); a != 42 {
17-
println("Unexpected result for The Answer. Got:", a, " Want: 42")
20+
fmt.Fprintln(os.Stderr, "Unexpected result for The Answer. Got:", a, " Want: 42")
1821
os.Exit(1)
1922
}
20-
println("ok")
23+
fmt.Fprintln(os.Stdout, "ok")
2124
}

src/cmd/compile/internal/ir/expr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (n *BinaryExpr) SetOp(op Op) {
181181
}
182182
}
183183

184-
// A CallExpr is a function call X(Args).
184+
// A CallExpr is a function call Fun(Args).
185185
type CallExpr struct {
186186
miniExpr
187187
Fun Node

0 commit comments

Comments
 (0)