Jun 01, 2021 Article blog
2. 2, compiler improvements, including slightly smaller binaries
3. 3, embedded tzdata (time zone data)
4. 4, increase testing. T B. TempDir
Go Team
announced the official release of
Go 1.15
this morning.
Because of the impact of this year's outbreak, so although this version released as scheduled, but the content of the change is not much.
Most of its changes are implemented in toolchains, runtimes, and libraries. A
s always, this release retains a promise of
Go 1
This guarantees that almost all
Go
programs will compile and run as normally as before.
Go 1.15
includes significant improvements to the linker, improved allocation of small objects with a large number of cores, and deprecation of
X.509 CommonName
GOPROXY
now supports skipping agents that return errors and adding a new embedded
tzdata
package.
Let's take a look at the specific changes that deserve attention.
(Recommended course: Go tutorial)
Official design document address: https://golang.org/s/better-linker, from a naming point of view, is a better linker (this is nonsense).
This version of
Go
reduces the use (time and memory) of linker resources and improves code robustness/maintainability. F
or
ELF
operating systems
Linux
FreeBSD
OpenBSD
Dragonfly
and
S olaris
running on the
amd64
architecture, the link speed of a representative large
Go
assembly is increased by 20% and the average memory requirement is reduced by 30%.
NetBSD
I
mprovements to other
/OS
combinations. K
ey factors in improving link program performance are the target file format of the new design, as well as improvements in the internal phases to improve concurrence (for example, by applying relocation in parallel to symbols). T
he target file in
Go 1.15
is slightly larger than its 1.14 equivalent. T
hese changes are part of a multi-version project to modernize
Go
Linker, which means that other improvements to the Linker are expected in future releases.
The linker now defaults to the internal link mode of
-buildmode=pie
on
linux/amd64
and
linux/arm64
so these configurations no longer require
C
linker.
The security rules for package
unsafe
allow
unsafe.Pointer
converts to
uintptr
P
reviously, in some cases, the compiler allowed multiple chain conversions (such as
syscall.Syscall(…,uintptr(uintptr(ptr)),…)
)。 T
he compiler now only needs one conversion.
Code that uses multiple conversions should be updated to meet security rules.
Compared to
Go 1.14
Go 1.15
reduces the typical binary size by approximately 5% compared to
Go 1.14
by eliminating certain types of
GC
metadata and more aggressively eliminating unused type metadata. T
he toolchain now mitigates
Intel CPU
errata
SKX102
on
GOARCH=amd64
by aligning the function with the 32-byte boundary and filling the jump instruction.
Although this padding increases the binary size, it goes far beyond what the above binary size improvements make up.
Go 1.15
adds
-spectre
flag to both the compiler and the assembler to allow
Spectre
mitigations to be enabled. T
hese are almost absolutely unnecessary and are provided primarily as "defense-in-depth" mechanisms.
For more information, see
Spectre Wiki
page.
The compiler will now reject
//go: compiler
instructions, which are meaningless to the declarations it uses, and a "misplaced compiler instruction" error.
Such error-using instructions have been corrupted before, but the compiler silently ignores them.
The compiler's
-json
optimization logging report now has a large copy
>= 128 字节
and contains a description of the escape analysis decision.
(Recommended course: Go Web programming)
Added a new package:
time/tzdata
when the system can't find time zone data (such as Windows, etc.), by importing the package, embedding time zone data in the program, or by passing
-tags timetzdata
at compile time to achieve the same effect.
Check out this
issue
https://github.com/golang/go/issues/38017
and the description of the package
time/tzdata
https://golang.org/pkg/time/tzdata/.
Test generation of temporary files is quite common, this in order to better solve this problem.
See issue for
issue
https://github.com/golang/go/issues/35998.
Introduce
context
into
testing
package.
See
issue
https://github.com/golang/go/issues/28135
for details.
darwin/386
darwin/arm
are no longer supported;
riscv64
is better;
linux/arm64
is now supported as Class I
port
net/url.URL RawFragment
and
EscapedFragment
see issue:
https://github.com/golang/go/issues/37776;
net/url.URL.Redacted
see
issue
for details:
https://github.com/golang/go/issues/34855;
3.
time.Ticker.Reset
we know that
Timer
has
Reset
this time for
Ticker
also increased, see
issue
https://github.com/golang/go/issues/33184;
regexp.Regexp.SubexpIndex
see
issue
https://github.com/golang/go/issues/32420;
sync.Map.LoadAndDelete
see
issue
https://github.com/golang/go/issues/33762
for details;
crypto/tls.Dialer.DialContext
see
issue
for details:
https://github.com/golang/go/issues/18482;
There are other
API
changes, not to mention.
go env GOMODCACHE
https://github.com/golang/go/issues/34527;
opt-in fallbacks in GOPROXY
:
https://github.com/golang/go/issues/37367
;
vet:warn about string(int)
and
detect impossible interface assertions
https://github.com/golang/go/issues/32479
and
https://github.com/golang/go/issues/4483;
println
allows two values to be printed.
println(twoValues())
;
panic
Displays printable values instead of addresses.
Like what:
type MyString string
panic(MyString("hello"))
Print now:
panic: (main.MyString) (0x48aa00,0x4c0840)
Expect to print:
panic: main.MyString("hello")
Readability is much better.
amd64
Linux
forkAndExec
uses
dup3
sha512
algorithm speed increased by 15%;
ReadMemStats
delay reduced by 95%;
channel
reception in the off state;
int
value to
interface{}
does not allocate additional memory;
(Recommended micro-class: Go micro-class)
For more detailed changes, see the official release document https://golang.org/doc/go1.15.
Here's a look at some notable changes in Go 1.15, and I hope it's helpful.