The first RC of Go 1.20 has been released, and the official version is planned to be launched in February next year.
Download address: https://go.dev/dl/#go1.20rc1
It’s worth noting that Go 1.20 was the last version to support running on macOS 10.13 High Sierra or 10.14 Mojave. Go 1.21 will require macOS 10.15 Catalina or later.
Additionally, Go 1.20 adds support for FreeBSD on RISC-V (
GOARCH=riscv64) for experimental support.
Go 1.20 currently contains 4 changes in syntax.
- Conversion from slice (slice) to array
Go 1.7 added the function of converting from slice (slice) to array pointer, and Go 1.20 has extended this function – it can be directly converted from slice to array.
For example, given a slice
byte(x)can be written as
s := make(byte, 2, 4) a0 := byte(s) a1 := byte(s[1:]) // a1 == s a2 := byte(s) // a2 == s a4 := byte(s) // panics: len(byte) > len(s) s0 := (*byte)(s) // s0 != nil s1 := (*byte)(s[1:]) // &s1 == &s s2 := (*byte)(s) // &s2 == &s s4 := (*byte)(s) // panics: len(byte) > len(s) var t string t0 := string t1 := (*string) t2 := (*string) u := make(byte, 0) u0 := (*byte)(u) // u0 != nil
- standard library
unsafeThe package defines 3 new functions:
In Go 1.17,
unsafeThe package adds the Slice function:
unsafe.Slice(ptr, len)return a
TA slice of type whose underlying array is derived from
ptrInitially, its length and capacity are
Together with the 3 functions newly defined by Go 1.20, these 4 functions provide complete functions for constructing and deconstructing slices and string values.
See https://tip.golang.org/ref/spec/#Package_unsafe for details.
Comparable types such as ordinary interfaces can now satisfy
comparableConstraints, even if the type arguments are not strictly comparable types.
The Go language specification has been updated. The value of a structure variable is only compared with one field at a time, and the order of field comparison is consistent with the order in which the fields are defined in the structure. Once the value comparison of a certain field is inconsistent, the comparison will stop immediately.
This change has no impact on the code.
Finally, since Go 1.20 is still in the development stage, the current public Release Notes are also in draft status.
#RC1 #released #News Fast Delivery