From ac5387b8c64e817fdad843e56596bf6c1acbbf2d Mon Sep 17 00:00:00 2001
From: Colin Cross
+The
+It is currently supported on arm64, amd64, ppc64, loong64 and riscv64.
+
+For example, the start of the Special instructions
+
+PCALIGN
pseudo-instruction is used to indicate that the next instruction should be aligned
+to a specified boundary by padding with no-op instructions.
+MOVD
instruction below is aligned to 32 bytes:
+
+PCALIGN $32
+MOVD $2, R0
+
+
diff --git a/doc/go1.17_spec.html b/doc/go1.17_spec.html index 0b374e7bf..c87d9aff3 100644 --- a/doc/go1.17_spec.html +++ b/doc/go1.17_spec.html @@ -7,8 +7,11 @@
-This is a reference manual for the Go programming language. For -more information and other documents, see golang.org. +This is the reference manual for the Go programming language as it was for +language version 1.17, in October 2021, before the introduction of generics. +It is provided for historical interest. +The current reference manual can be found here. +For more information and other documents, see go.dev.
@@ -914,7 +917,7 @@ are required when different numeric types are mixed in an expression
or assignment. For instance, int32
and int
are not the same type even though they may have the same size on a
particular architecture.
-
+
nil
maps.
A nil
map is equivalent to an empty map except that no elements
may be added.
+
++
and --
operators form
statements, not expressions, they fall
outside the operator hierarchy.
As a consequence, statement *p++
is the same as (*p)++
.
+
+
There are five precedence levels for binary operators. Multiplication operators bind strongest, followed by addition diff --git a/doc/go_mem.html b/doc/go_mem.html index 661e1e781..026c1172e 100644 --- a/doc/go_mem.html +++ b/doc/go_mem.html @@ -159,6 +159,7 @@ union of the sequenced before and synchronized before relations. For an ordinary (non-synchronizing) data read r on a memory location x, W(r) must be a write w that is visible to r, where visible means that both of the following hold: +
-First, any implementation can, upon detecting a data race,
+Any implementation can, upon detecting a data race,
report the race and halt execution of the program.
Implementations using ThreadSanitizer
(accessed with “go
build
-race
”)
@@ -229,7 +230,18 @@ do exactly this.
-Otherwise, a read r of a memory location x +A read of an array, struct, or complex number +may by implemented as a read of each individual sub-value +(array element, struct field, or real/imaginary component), +in any order. +Similarly, a write of an array, struct, or complex number +may be implemented as a write of each individual sub-value, +in any order. +
+ ++A read r of a memory location x +holding a value that is not larger than a machine word must observe some write w such that r does not happen before w and there is no write w' such that w happens before w' diff --git a/doc/go_spec.html b/doc/go_spec.html index c39a44236..7b9dd3862 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -10,7 +10,7 @@ This is the reference manual for the Go programming language. The pre-Go1.18 version, without generics, can be found here. -For more information and other documents, see golang.org. +For more information and other documents, see go.dev.
@@ -70,6 +70,14 @@ enumerations or code snippets that are not further specified. The character
+A link of the form [Go 1.xx] indicates that a described
+language feature (or some aspect of it) was changed or added with language version 1.xx and
+thus requires at minimum that language version to build.
+For details, see the linked section
+in the appendix.
+
@@ -263,7 +271,8 @@ continue for import return var
The following character sequences represent operators
-(including assignment operators) and punctuation:
+(including assignment operators) and punctuation
+[Go 1.18]:
Source code representation
+ & += &= && == != ( )
@@ -281,7 +290,8 @@ An integer literal is a sequence of digits representing an
integer constant.
An optional prefix sets a non-decimal base:
0b
or 0B
for binary, 0
, 0o
, or 0O
for octal,
-and 0x
or 0X
for hexadecimal.
+and 0x
or 0X
for hexadecimal
+[Go 1.13].
A single 0
is considered a decimal zero.
In hexadecimal literals, letters a
through f
and A
through F
represent values 10 through 15.
@@ -347,7 +357,8 @@ prefix, an integer part (hexadecimal digits), a radix point, a fractional part (
and an exponent part (p
or P
followed by an optional sign and decimal digits).
One of the integer part or the fractional part may be elided; the radix point may be elided as well,
but the exponent part is required. (This syntax matches the one given in IEEE 754-2008 §5.12.3.)
-An exponent value exp scales the mantissa (integer and fractional part) by 2exp.
+An exponent value exp scales the mantissa (integer and fractional part) by 2exp
+[Go 1.13].
@@ -411,7 +422,8 @@ It consists of an integer or
floating-point literal
followed by the lowercase letter i
.
The value of an imaginary literal is the value of the respective
-integer or floating-point literal multiplied by the imaginary unit i.
+integer or floating-point literal multiplied by the imaginary unit i
+[Go 1.13]
@@ -884,7 +896,7 @@ are required when different numeric types are mixed in an expression or assignment. For instance,int32
andint
are not the same type even though they may have the same size on a particular architecture. - +String types
@@ -1340,6 +1352,7 @@ interface{}For convenience, the predeclared type
any
is an alias for the empty interface. +[Go 1.18]@@ -1375,13 +1388,15 @@ as the
File
interface. In a slightly more general form an interfaceT
may use a (possibly qualified) interface type nameE
as an interface element. This is called -embedding interfaceE
inT
. +embedding interfaceE
inT
+[Go 1.14]. The type set ofT
is the intersection of the type sets defined byT
's explicitly declared methods and the type sets ofT
’s embedded interfaces. In other words, the type set ofT
is the set of all types that implement all the explicitly declared methods ofT
and also all the methods of -E
. +E
+[Go 1.18].@@ -1420,7 +1435,8 @@ type ReadCloser interface {In their most general form, an interface element may also be an arbitrary type term
@@ -2303,7 +2319,9 @@ as an operand, and in aT
, or a term of the form~T
specifying the underlying typeT
, -or a union of termst1|t2|…|tn
. +or a union of termst1|t2|…|tn
+[Go 1.18]. Together with method specifications, these elements enable the precise definition of an interface's type set as follows:The following identifiers are implicitly declared in the -universe block: +universe block +[Go 1.18] +[Go 1.21]:
Types: @@ -2487,7 +2505,8 @@ TypeSpec = AliasDecl | TypeDef .Alias declarations
-An alias declaration binds an identifier to the given type. +An alias declaration binds an identifier to the given type +[Go 1.9].
@@ -2636,7 +2655,8 @@ func (l *List[T]) Len() int { … } A type parameter list declares the type parameters of a generic function or type declaration. The type parameter list looks like an ordinary function parameter list except that the type parameter names must all be present and the list is enclosed -in square brackets rather than parentheses. +in square brackets rather than parentheses +[Go 1.18].@@ -2719,7 +2739,8 @@ type T6[P int] struct{ f *T6[P] } // ok: reference to T6 is not in type paraA type constraint is an interface that defines the set of permissible type arguments for the respective type parameter and controls the -operations supported by values of that type parameter. +operations supported by values of that type parameter +[Go 1.18].
@@ -2749,7 +2770,8 @@ other interfaces based on their type sets. But this should get us going for now. The predeclared interface typecomparable
denotes the set of all non-interface types that are -strictly comparable. +strictly comparable +[Go 1.18].@@ -2782,7 +2804,8 @@ if
@@ -3910,7 +3933,7 @@ ForT
is an element of the type set defined byC
; i.e., ifT
implementsC
. As an exception, a strictly comparable type constraint may also be satisfied by a comparable -(not necessarily strictly comparable) type argument. +(not necessarily strictly comparable) type argument +[Go 1.20]. More precisely:a
of type parameter type thatP
is instantiated with, and the type ofa[x]
is the type of the (identical) element types.
a[x]
may not be assigned to if P
's type set
- includes string types.
+ includes string types.@@ -4306,7 +4329,7 @@ with the same underlying array.
A generic function or type is instantiated by substituting type arguments -for the type parameters. +for the type parameters [Go 1.18]. Instantiation proceeds in two steps:
@@ -4491,7 +4514,7 @@ the type parameters of the functions that need to be instantiated and for which no explicit type arguments is provided. These type parameters are called bound type parameters. For instance, in thededup
example above, the type parameters
-P
and E
are bound to dedup
.
+S
and E
are bound to dedup
.
An argument to a generic function call may be a generic function itself.
The type parameters of that function are included in the set of bound
type parameters.
@@ -4639,7 +4662,7 @@ Type inference succeeds if no unification step fails and the map has
an entry for each type parameter.
-
+
For example, given the type equation with the bound type parameter
P
The right operand in a shift expression must have integer type
+[Go 1.13]
or be an untyped constant representable by a
value of type uint
.
If the left operand of a non-constant shift expression is an untyped constant,
@@ -4803,6 +4827,7 @@ As the ++
and --
operators form
statements, not expressions, they fall
outside the operator hierarchy.
As a consequence, statement *p++
is the same as (*p)++
.
+
There are five precedence levels for binary operators.
Multiplication operators bind strongest, followed by addition
@@ -4825,12 +4850,13 @@ For instance, x / y * z
is the same as (x / y) * z
.
-+x -23 + 3*x[i] -x <= f() -^a >> b -f() || g() -x == y+1 && <-chanInt > 0 ++x // x +42 + a - b // (42 + a) - b +23 + 3*x[i] // 23 + (3 * x[i]) +x <= f() // x <= f() +^a >> b // (^a) >> b +f() || g() // f() || g() +x == y+1 && <-chanInt > 0 // (x == (y+1)) && ((<-chanInt) > 0)@@ -5207,7 +5233,7 @@ Specifically:
Logical operators apply to boolean values and yield a result of the same type as the operands. -The right operand is evaluated conditionally. +The left operand is evaluated, and then the right if the condition requires it.
@@ -5424,7 +5450,8 @@ in any of these cases:x
is a string andT
is a slice of bytes or runes.
x
is a slice, T
is an array or a pointer to an array,
+ x
is a slice, T
is an array [Go 1.20]
+ or a pointer to an array [Go 1.17],
and the slice and array types have identical element types.
[]byte("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'} @@ -5785,24 +5812,28 @@ determine the evaluation order of individual initialization expressions in Otherwise, when evaluating the operands of an expression, assignment, or return statement, -all function calls, method calls, and -communication operations are evaluated in lexical left-to-right -order. +all function calls, method calls, +receive operations, +and binary logical operations +are evaluated in lexical left-to-right order.For example, in the (function-local) assignment
-y[f()], ok = g(h(), i()+x[j()], <-c), k() +y[f()], ok = g(z || h(), i()+x[j()], <-c), k()the function calls and communication happen in the order -
f()
,h()
,i()
,j()
, +f()
,h()
(ifz
+evaluates to false),i()
,j()
,<-c
,g()
, andk()
. However, the order of those events compared to the evaluation and indexing ofx
and the evaluation -ofy
is not specified. +ofy
andz
is not specified, +except as required lexically. For instance,g
+cannot be called before its arguments are evaluated.@@ -6510,7 +6541,6 @@ additionally it may specify an init and a post statement, such as an assignment, an increment or decrement statement. The init statement may be a short variable declaration, but the post statement must not. -Variables declared by the init statement are re-used in each iteration.@@ -6542,12 +6572,55 @@ for cond { S() } is the same as for ; cond ; { S() } for { S() } is the same as for true { S() }++Each iteration has its own separate declared variable (or variables) +[Go 1.22]. +The variable used by the first iteration is declared by the init statement. +The variable used by each subsequent iteration is declared implicitly before +executing the post statement and initialized to the value of the previous +iteration's variable at that moment. +
+ ++var prints []func() +for i := 0; i < 5; i++ { + prints = append(prints, func() { println(i) }) + i++ +} +for _, p := range prints { + p() +} ++ ++prints +
+ ++1 +3 +5 ++ ++Prior to [Go 1.22], iterations share one set of variables +instead of having their own separate variables. +In that case, the example above prints +
+ ++6 +6 +6 ++For statements with
range
clauseA "for" statement with a "range" clause -iterates through all entries of an array, slice, string or map, -or values received on a channel. For each entry it assigns iteration values +iterates through all entries of an array, slice, string or map, values received on +a channel, or integer values from zero to an upper limit [Go 1.22]. +For each entry it assigns iteration values to corresponding iteration variables if present and then executes the block.
@@ -6558,12 +6631,12 @@ RangeClause = [ ExpressionList "=" | IdentifierList ":=" ] "range" Expression .The expression on the right in the "range" clause is called the range expression, its core type must be -an array, pointer to an array, slice, string, map, or channel permitting -receive operations. +an array, pointer to an array, slice, string, map, channel permitting +receive operations, or an integer. As with an assignment, if present the operands on the left must be addressable or map index expressions; they -denote the iteration variables. If the range expression is a channel, at most -one iteration variable is permitted, otherwise there may be up to two. +denote the iteration variables. If the range expression is a channel or integer, +at most one iteration variable is permitted, otherwise there may be up to two. If the last iteration variable is the blank identifier, the range clause is equivalent to the same clause without that identifier.
@@ -6588,6 +6661,7 @@ array or slice a [n]E, *[n]E, or []E index i int a[i] E string s string type index i int see below rune map m map[K]V key k K m[k] V channel c chan E, <-chan E element e E +integer n integer type value i see below@@ -6626,22 +6700,36 @@ For channels, the iteration values produced are the successive values sent on the channel until the channel is closed. If the channel is
nil
, the range expression blocks forever.
-The iteration values are assigned to the respective -iteration variables as in an assignment statement. -
+n
, the iteration values 0 through n-1
+are produced in increasing order.
+If n
<= 0, the loop does not run any iterations.
+
The iteration variables may be declared by the "range" clause using a form of
short variable declaration
(:=
).
-In this case their types are set to the types of the respective iteration values
-and their scope is the block of the "for"
-statement; they are re-used in each iteration.
-If the iteration variables are declared outside the "for" statement,
-after execution their values will be those of the last iteration.
+In this case their scope is the block of the "for" statement
+and each iteration has its own new variables [Go 1.22]
+(see also "for" statements with a ForClause).
+If the range expression is a (possibly untyped) integer expression n
,
+the variable has the same type as if it was
+declared with initialization
+expression n
.
+Otherwise, the variables have the types of their respective iteration values.
+
+If the iteration variables are not explicitly declared by the "range" clause,
+they must be preexisting.
+In this case, the iteration values are assigned to the respective variables
+as in an assignment statement.
+If the range expression is a (possibly untyped) integer expression n
,
+n
too must be assignable to the iteration variable;
+if there is no iteration variable, n
must be assignable to int
.
@@ -6678,6 +6766,17 @@ for w := range ch { // empty a channel for range ch {} + +// call f(0), f(1), ... f(9) +for i := range 10 { + // type of i is int (default type for untyped constant 10) + f(i) +} + +// invalid: 256 cannot be assigned to uint8 +var u uint8 +for u = range 256 { +}@@ -7229,7 +7328,8 @@ n3 := copy(b, "Hello, World!") // n3 == 5, b is []byte("Hello")
The built-in function clear
takes an argument of map,
slice, or type parameter type,
-and deletes or zeroes out all elements.
+and deletes or zeroes out all elements
+[Go 1.21].
@@ -7496,7 +7596,8 @@ The precise behavior is implementation-dependent. The built-in functions@@ -8272,7 +8377,8 @@ of constant size.min
andmax
compute the smallest—or largest, respectively—value of a fixed number of arguments of ordered types. -There must be at least one argument. +There must be at least one argument +[Go 1.21].@@ -8212,8 +8313,8 @@ of if the general conversion rules take care of this.
A
@@ -8224,6 +8325,10 @@ bits = *(*uint64)(unsafe.Pointer(&f)) type ptr unsafe.Pointer bits = *(*uint64)(ptr(&f)) +func f[P ~*B, B any](p P) uintptr { + return uintptr(unsafe.Pointer(p)) +} + var p ptr = nilPointer
is a pointer type but aPointer
value may not be dereferenced. -Any pointer or value of underlying typeuintptr
can be -converted to a type of underlying typePointer
and vice versa. +Any pointer or value of core typeuintptr
can be +converted to a type of core typePointer
and vice versa. The effect of converting betweenPointer
anduintptr
is implementation-defined.
The function Add
adds len
to ptr
-and returns the updated pointer unsafe.Pointer(uintptr(ptr) + uintptr(len))
.
+and returns the updated pointer unsafe.Pointer(uintptr(ptr) + uintptr(len))
+[Go 1.17].
The len
argument must be of integer type or an untyped constant.
A constant len
argument must be representable by a value of type int
;
if it is an untyped constant it is given type int
.
@@ -8292,7 +8398,8 @@ and whose length and capacity are len
.
except that, as a special case, if ptr
is nil
and len
is zero,
-Slice
returns nil
.
+Slice
returns nil
+[Go 1.17].
@@ -8301,14 +8408,16 @@ A constant len
argument must be non-negative and run-time panic occurs.
+a run-time panic occurs
+[Go 1.17].
The function SliceData
returns a pointer to the underlying array of the slice
argument.
If the slice's capacity cap(slice)
is not zero, that pointer is &slice[:1][0]
.
If slice
is nil
, the result is nil
.
-Otherwise it is a non-nil
pointer to an unspecified memory address.
+Otherwise it is a non-nil
pointer to an unspecified memory address
+[Go 1.20].
@@ -8317,12 +8426,14 @@ The function String
returns a string
value whose under
The same requirements apply to the ptr
and len
argument as in the function
Slice
. If len
is zero, the result is the empty string ""
.
Since Go strings are immutable, the bytes passed to String
must not be modified afterwards.
+[Go 1.20]
The function StringData
returns a pointer to the underlying bytes of the str
argument.
For an empty string the return value is unspecified, and may be nil
.
-Since Go strings are immutable, the bytes returned by StringData
must not be modified.
+Since Go strings are immutable, the bytes returned by StringData
must not be modified
+[Go 1.20].
+The Go 1 compatibility guarantee ensures that +programs written to the Go 1 specification will continue to compile and run +correctly, unchanged, over the lifetime of that specification. +More generally, as adjustments are made and features added to the language, +the compatibility guarantee ensures that a Go program that works with a +specific Go language version will continue to work with any subsequent version. +
+ +
+For instance, the ability to use the prefix 0b
for binary
+integer literals was introduced with Go 1.13, indicated
+by [Go 1.13] in the section on
+integer literals.
+Source code containing an integer literal such as 0b1011
+will be rejected if the implied or required language version used by
+the compiler is older than Go 1.13.
+
+The following table describes the minimum language version required for +features introduced after Go 1. +
+ +0b
, 0B
, 0o
,
+and 0O
for binary, and octal literals, respectively.
+0x
and 0X
.
+i
may be used with any (binary, decimal, hexadecimal)
+integer or floating-point literal, not just decimal literals.
+_
.
+unsafe
includes the new functions
+Add
and Slice
.
++The 1.18 release adds polymorphic functions and types ("generics") to the language. +Specifically: +
+~
.
+~T
type elements.
+any
and comparable
.
+unsafe
includes the new functions
+SliceData
, String
, and StringData
.
+comparable
constraints, even if the type arguments are not strictly comparable.
+min
, max
, and clear
.
+@@ -8487,7 +8737,7 @@ Finally, two types that are not bound type parameters unify loosely identical type terms, both or neither embed the predeclared type comparable, - corresponding method types unify per the element matching mode, + corresponding method types unify exactly, and the method set of one of the interfaces is a subset of the method set of the other interface. diff --git a/doc/godebug.md b/doc/godebug.md index d26555503..a7619c9a3 100644 --- a/doc/godebug.md +++ b/doc/godebug.md @@ -129,11 +129,71 @@ and the [go command documentation](/cmd/go#hdr-Build_and_test_caching). ### Go 1.22 Go 1.22 adds a configurable limit to control the maximum acceptable RSA key size -that can be used in TLS handshakes, controlled by the [`tlsmaxrsasize`setting](/pkg/crypto/tls#Conn.Handshake). +that can be used in TLS handshakes, controlled by the [`tlsmaxrsasize` setting](/pkg/crypto/tls#Conn.Handshake). The default is tlsmaxrsasize=8192, limiting RSA to 8192-bit keys. To avoid denial of service attacks, this setting and default was backported to Go 1.19.13, Go 1.20.8, and Go 1.21.1. +Go 1.22 made it an error for a request or response read by a net/http +client or server to have an empty Content-Length header. +This behavior is controlled by the `httplaxcontentlength` setting. + +Go 1.22 changed the behavior of ServeMux to accept extended +patterns and unescape both patterns and request paths by segment. +This behavior can be controlled by the +[`httpmuxgo121` setting](/pkg/net/http/#ServeMux). + +Go 1.22 added the [Alias type](/pkg/go/types#Alias) to [go/types](/pkg/go/types) +for the explicit representation of [type aliases](/ref/spec#Type_declarations). +Whether the type checker produces `Alias` types or not is controlled by the +[`gotypesalias` setting](/pkg/go/types#Alias). +For Go 1.22 it defaults to `gotypesalias=0`. +For Go 1.23, `gotypealias=1` will become the default. +This setting will be removed in a future release, Go 1.24 at the earliest. + +Go 1.22 changed the default minimum TLS version supported by both servers +and clients to TLS 1.2. The default can be reverted to TLS 1.0 using the +[`tls10server` setting](/pkg/crypto/tls/#Config). + +Go 1.22 changed the default TLS cipher suites used by clients and servers when +not explicitly configured, removing the cipher suites which used RSA based key +exchange. The default can be revert using the [`tlsrsakex` setting](/pkg/crypto/tls/#Config). + +Go 1.22 disabled +[`ConnectionState.ExportKeyingMaterial`](/pkg/crypto/tls/#ConnectionState.ExportKeyingMaterial) +when the connection supports neither TLS 1.3 nor Extended Master Secret +(implemented in Go 1.21). It can be reenabled with the [`tlsunsafeekm` +setting](/pkg/crypto/tls/#ConnectionState.ExportKeyingMaterial). + +Go 1.22 changed how the runtime interacts with transparent huge pages on Linux. +In particular, a common default Linux kernel configuration can result in +significant memory overheads, and Go 1.22 no longer works around this default. +To work around this issue without adjusting kernel settings, transparent huge +pages can be disabled for Go memory with the +[`disablethp` setting](/pkg/runtime#hdr-Environment_Variable). +This behavior was backported to Go 1.21.1, but the setting is only available +starting with Go 1.21.6. +This setting may be removed in a future release, and users impacted by this issue +should adjust their Linux configuration according to the recommendations in the +[GC guide](/doc/gc-guide#Linux_transparent_huge_pages), or switch to a Linux +distribution that disables transparent huge pages altogether. + +Go 1.22 added contention on runtime-internal locks to the [`mutex` +profile](/pkg/runtime/pprof#Profile). Contention on these locks is always +reported at `runtime._LostContendedRuntimeLock`. Complete stack traces of +runtime locks can be enabled with the [`runtimecontentionstacks` +setting](/pkg/runtime#hdr-Environment_Variable). These stack traces have +non-standard semantics, see setting documentation for details. + +Go 1.22 added a new [`crypto/x509.Certificate`](/pkg/crypto/x509/#Certificate) +field, [`Policies`](/pkg/crypto/x509/#Certificate.Policies), which supports +certificate policy OIDs with components larger than 31 bits. By default this +field is only used during parsing, when it is populated with policy OIDs, but +not used during marshaling. It can be used to marshal these larger OIDs, instead +of the existing PolicyIdentifiers field, by using the +[`x509usepolicies` setting.](/pkg/crypto/x509/#CreateCertificate). + + ### Go 1.21 Go 1.21 made it a run-time error to call `panic` with a nil interface value, @@ -191,7 +251,7 @@ There is no plan to remove this setting. ### Go 1.18 Go 1.18 removed support for SHA1 in most X.509 certificates, -controlled by the [`x509sha1` setting](/crypto/x509#InsecureAlgorithmError). +controlled by the [`x509sha1` setting](/pkg/crypto/x509#InsecureAlgorithmError). This setting will be removed in a future release, Go 1.22 at the earliest. ### Go 1.10 -- cgit v1.2.3