Release note: https://golang.org/doc/go1.14
Given a set of identifiers, an identifier is called unique if it is different from every other in the set.
Two identifiers are different if they are spelled differently, or if they appear in different packages and are not exported. Otherwise, they are the same.
e.g
https://play.golang.org/p/S6KnfCj7UbV
js.Value values can no longer be compared using the == operator, and instead must be compared using their Equal method.
js.Value now has IsUndefined, IsNull, and IsNaN methods.
-mod=vendor
for operations that accept that flag.
A new value for that flag,
-mod=mod
causes the go command to instead load modules from the module cache
(as when no vendor directory is present).
When
-mod=vendor is set (explicitly or by default),
the go command now verifies that the main module's vendor/modules.txt file is consistent with its go.mod file.
$ go list -m
no longer silently omits transitive dependencies that do not provide packages in the vendor directory.
It now fails explicitly if -mod=vendor is set and information is requested for a module not mentioned in vendor/modules.txt
-modcacherw is a new flag that instructs the go command to leave newly-created directories in the module cache at their default permissions rather than making them read-only.
The use of this flag makes it more likely that tests or other tools will accidentally add files not included in the module's verified checksum. However, it allows the use of rm -rf (instead of go clean -modcache) to remove the module cache.
-modfile=file is a new flag that instructs the go command to read (and possibly write) an alternate go.mod file instead of the one in the module root directory.
A file named go.mod must still be present in order to determine the module root directory, but it is not accessed.
When -modfile is specified, an alternate go.sum file is also used: its path is derived from the -modfile flag by trimming the .mod extension and appending .sum.
Like the existing GOPRIVATE variable, the value of GOINSECURE is a comma-separated list of glob patterns.
For example, go build, go run, and other build commands can only build packages in the standard library and packages specified as .go files on the command line.
Previously, the go command would resolve each package path to the latest version of a module but would not record the module path or version. This resulted in slow, non-reproducible builds.
go get continues to work as before, as do go mod download and go list -m with explicit versions.
go commands other than go mod tidy no longer edit the go.mod file if the changes are only cosmetic.
When -mod=readonly is set, go commands will no longer fail due to a missing go directive or an erroneous // indirect comment.
Goroutines are now asynchronously preemptible.
To turn off avoid kernel bugs:
$ GODEBUG=asyncpreemptoff=1
EINTR on close() means the fd has already closed even there's an interruption.
(This can occur because the Linux kernel always releases
the file descriptor early in the close operation, freeing it for
reuse; the steps that may return an error, such as flushing data to
the filesystem or device, occur only later in the close operation.)
Prevent blocking and handles EINTR:
Reference:
http://250bpm.com/blog:12
https://groups.google.com/forum/#!msg/golang-nuts/oqXOnR1GJ4g/Rrok3fUqAQAJ
Go issue ticket:
runtime: memory corruption on Linux 5.2+ :
https://github.com/golang/go/issues/35777
runtime: mlock of signal stack failed:
https://github.com/golang/go/issues/37436
(monitor /proc/version for linux kernel correct version)
runtime, syscall: occasional syscall failures with EINTR within ZMQ when using Go1.14beta1 but not Go1.11:
https://github.com/golang/go/issues/36281
https://github.com/pebbe/zmq4/issues/17
Kernel ticket:
https://bugzilla.kernel.org/show_bug.cgi?id=205663
A consequence of the implementation of preemption is that on Unix systems, including Linux and macOS systems, programs built with Go 1.14 will receive more signals than programs built with earlier releases.
This means that programs that use packages like syscall or golang.org/x/sys/unix will see more slow(i.e block system calls) system calls fail with EINTR errors.
(Recap: TLPI: 21.5 Interruption and Restarting of System Calls)
Those programs will have to handle those errors in some way, most likely looping to try the system call again.
For more information about this see man 7 signal(http://man7.org/linux/man-pages/man7/signal.7.html) for Linux systems or similar documentation for other systems.
The page allocator is more efficient and incurs significantly less lock contention at high values of GOMAXPROCS
This option is enabled by default (except on Windows) with the -race or -msan flags, and can be disabled with -gcflags=all=-d=checkptr=0.
The compiler can now emit machine-readable logs of key optimizations using the -json flag, including
Detailed escape analysis diagnostics (-m=2) now work again.
This release includes experimental support for compiler-inserted coverage instrumentation for fuzzing.
Bounds check elimination now uses information from slice creation and can eliminate checks for indexes with types smaller than int.
StructOf now supports creating struct types with unexported fields, by setting the PkgPath field in a StructField element.
https://buttondown.email/cryptography-dispatches/archive/cryptography-dispatches-new-crypto-in-go-114/
Overlapping interface:
Proposal: https://github.com/golang/proposal/blob/master/design/6977-overlapping-interfaces.mdLanguage spec:
https://tip.golang.org/ref/spec#Uniqueness_of_identifiersGiven a set of identifiers, an identifier is called unique if it is different from every other in the set.
Two identifiers are different if they are spelled differently, or if they appear in different packages and are not exported. Otherwise, they are the same.
e.g
https://play.golang.org/p/S6KnfCj7UbV
WebAssembly:
JavaScript values referenced from Go via js.Value objects can now be garbage collected.js.Value values can no longer be compared using the == operator, and instead must be compared using their Equal method.
js.Value now has IsUndefined, IsNull, and IsNaN methods.
Module:
Vendoring:
When the main module contains a top-level vendor directory and its go.mod file specifies go 1.14 or higher, the go command now defaults to-mod=vendor
for operations that accept that flag.
A new value for that flag,
-mod=mod
causes the go command to instead load modules from the module cache
(as when no vendor directory is present).
When
-mod=vendor is set (explicitly or by default),
the go command now verifies that the main module's vendor/modules.txt file is consistent with its go.mod file.
$ go list -m
no longer silently omits transitive dependencies that do not provide packages in the vendor directory.
It now fails explicitly if -mod=vendor is set and information is requested for a module not mentioned in vendor/modules.txt
Flags:
-mod=readonly is now set by default when the go.mod file is read-only and no top-level vendor directory is present.-modcacherw is a new flag that instructs the go command to leave newly-created directories in the module cache at their default permissions rather than making them read-only.
The use of this flag makes it more likely that tests or other tools will accidentally add files not included in the module's verified checksum. However, it allows the use of rm -rf (instead of go clean -modcache) to remove the module cache.
-modfile=file is a new flag that instructs the go command to read (and possibly write) an alternate go.mod file instead of the one in the module root directory.
A file named go.mod must still be present in order to determine the module root directory, but it is not accessed.
When -modfile is specified, an alternate go.sum file is also used: its path is derived from the -modfile flag by trimming the .mod extension and appending .sum.
Environment variables:
GOINSECURE is a new environment variable that instructs the go command to not require an HTTPS connection, and to skip certificate validation, when fetching certain modules directly from their origins.Like the existing GOPRIVATE variable, the value of GOINSECURE is a comma-separated list of glob patterns.
Commands outside modules:
When module-aware mode is enabled explicitly (by setting GO111MODULE=on), most module commands have more limited functionality if no go.mod file is present.For example, go build, go run, and other build commands can only build packages in the standard library and packages specified as .go files on the command line.
Previously, the go command would resolve each package path to the latest version of a module but would not record the module path or version. This resulted in slow, non-reproducible builds.
go get continues to work as before, as do go mod download and go list -m with explicit versions.
go.mod file maintenance:
go commands other than go mod tidy no longer remove a require directive that specifies a version of an indirect dependency that is already implied by other (transitive) dependencies of the main module.go commands other than go mod tidy no longer edit the go.mod file if the changes are only cosmetic.
When -mod=readonly is set, go commands will no longer fail due to a missing go directive or an erroneous // indirect comment.
Testing:
go test -v now streams t.Log output as it happens, rather than at the end of all tests.Runtime:
defer can now be used in performance-critical code without overhead concerns.Goroutines are now asynchronously preemptible.
To turn off avoid kernel bugs:
$ GODEBUG=asyncpreemptoff=1
EINTR on close() means the fd has already closed even there's an interruption.
(This can occur because the Linux kernel always releases
the file descriptor early in the close operation, freeing it for
reuse; the steps that may return an error, such as flushing data to
the filesystem or device, occur only later in the close operation.)
Prevent blocking and handles EINTR:
// http://250bpm.com/blog:12 // set file descriptor to non-blocking; sigprocmask() to block SIGINT; if (stop) { // handle it } while (1) { pselect() with sigmask argument which doesn't block SIGINT; if (stop) { // handle it } recv(); }
Reference:
http://250bpm.com/blog:12
https://groups.google.com/forum/#!msg/golang-nuts/oqXOnR1GJ4g/Rrok3fUqAQAJ
Go issue ticket:
runtime: memory corruption on Linux 5.2+ :
https://github.com/golang/go/issues/35777
runtime: mlock of signal stack failed:
https://github.com/golang/go/issues/37436
(monitor /proc/version for linux kernel correct version)
runtime, syscall: occasional syscall failures with EINTR within ZMQ when using Go1.14beta1 but not Go1.11:
https://github.com/golang/go/issues/36281
https://github.com/pebbe/zmq4/issues/17
Kernel ticket:
https://bugzilla.kernel.org/show_bug.cgi?id=205663
A consequence of the implementation of preemption is that on Unix systems, including Linux and macOS systems, programs built with Go 1.14 will receive more signals than programs built with earlier releases.
This means that programs that use packages like syscall or golang.org/x/sys/unix will see more slow(i.e block system calls) system calls fail with EINTR errors.
(Recap: TLPI: 21.5 Interruption and Restarting of System Calls)
Those programs will have to handle those errors in some way, most likely looping to try the system call again.
For more information about this see man 7 signal(http://man7.org/linux/man-pages/man7/signal.7.html) for Linux systems or similar documentation for other systems.
The page allocator is more efficient and incurs significantly less lock contention at high values of GOMAXPROCS
Compiler:
This release adds -d=checkptr as a compile-time option for adding instrumentation to check that Go code is following unsafe.Pointer safety rules dynamically.This option is enabled by default (except on Windows) with the -race or -msan flags, and can be disabled with -gcflags=all=-d=checkptr=0.
-d=checkptr checks the following:
- When converting unsafe.Pointer to *T, the resulting pointer must be aligned appropriately for T.
- If the result of pointer arithmetic points into a Go heap object, one of the unsafe.Pointer-typed operands must point into the same object.
The compiler can now emit machine-readable logs of key optimizations using the -json flag, including
- inlining
- escape analysis
- bounds-check elimination
- nil-check elimination.
Detailed escape analysis diagnostics (-m=2) now work again.
This release includes experimental support for compiler-inserted coverage instrumentation for fuzzing.
Bounds check elimination now uses information from slice creation and can eliminate checks for indexes with types smaller than int.
Library:
reflectStructOf now supports creating struct types with unexported fields, by setting the PkgPath field in a StructField element.
https://buttondown.email/cryptography-dispatches/archive/cryptography-dispatches-new-crypto-in-go-114/
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.