What's new in Go 1.12?
28 January 2019
Dmitri Shuralyov
Go team, Google
Dmitri Shuralyov
Go team, Google
Go 1.10 is already 11 months old!
Go 1.11 was released on August 24th, 2018.
On November 5th, 2018 we entered the release freeze for Go 1.12.
Is Go 1.12 out yet?
import "golang.org/x/build/maintner/maintnerd/apipb"
// PrintGoReleases uses the provided maintner client // to print the latest supported Go releases. func PrintGoReleases(mc apipb.MaintnerServiceClient) error { resp, err := mc.ListGoReleases(context.Background(), &apipb.ListGoReleasesRequest{}) if err != nil { return err } for _, r := range resp.Releases { fmt.Println(r.TagName) } return nil }
Is Go 1.12 out yet?
$ go run golang.org/x/build/maintner/maintq list-releases major:1 minor:11 patch:5 tag_name:"go1.11.5" tag_commit:"35bb62e60a7779ff82c3067903b3306ff8666471" branch_name:"release-branch.go1.11" branch_commit:"f8e8303f566652fc74125e50a23eab612e8fc749" major:1 minor:10 patch:8 tag_name:"go1.10.8" tag_commit:"b0cb374daf646454998bac7b393f3236a2ab6aca" branch_name:"release-branch.go1.10" branch_commit:"bd0449f8d16a5ac1b1962c7ea07d764a7f18eca7" $
Source: twitter.com/golang/status/1083529360798302210
5Source: twitter.com/bradfitz/status/1083558450129395712
6Source: golang.org/s/release
7Source: tip.golang.org/doc/go1.12
8Changes since Go 1.11:
Sources:
github.com/golang/go/issues?q=is:closed+is:issue+milestone:Go1.12
9Things are happening:
New ports:
windows/arm
! Supports running Go on Windows 10 IoT Core on 32-bit ARM chips such as the Raspberry Pi 3.aix/ppc64
! AIX 7.2 and later on POWER8 architectures (external linking, cgo, pprof, and race detector aren't yet supported).Reserved for future:
hurd
is now a recognized value for GOOS
, reserved for the GNU/Hurd system for use with gccgo
.Improvements:
linux/arm64
.cgo
now supported on linux/ppc64
.libSystem
is used when making syscalls on macOS and iOS. Can't use syscall.Getdirentries
on iOS.Last release to support:
go
tool
vet
is no longer supported.
If you're currently doing:
go tool vet .
May replace with:
go vet ./...
godoc
and go
doc
:
godoc
no longer has a CLI and is only a web server. Use go
doc
for CLI.$ godoc -help usage: godoc ... -http string HTTP service address (default "localhost:6060") ...
go
doc
gets a new -all
flag to print all exported APIs like godoc
used to.$ go doc -help Usage of [go] doc: go doc go doc <pkg> go doc <sym>[.<method>] go doc [<pkg>].<sym>[.<method>] go doc <pkg> <sym>[.<method>]
Modules:
GO111MODULE=on
.
Only those that don't need current working directory or explicit go.mod editing. E.g., go
get
, go
list
, and go
mod
download
behave as if in empty module. go
env
GOMOD
reports system's null device (/dev/null
).
The module cache (GOPATH/pkg/mod
) must reside in a filesystem that supports file locking.
go
directive in go.mod
files indicates language version. E.g., go
1.12
.Build cache requirement:
GOCACHE=off
will cause go commands that write to the cache to fail.Binary-only packages:
Cgo:
EGLDisplay
will be translated to the Go type uintptr
.C.char
rather than the mangled name _Ctype_char
.Compiler toolchain:
runtime.CallersFrames
instead of iterating over the result of runtime.Callers
directly.runtime.KeepAlive
if needed.-u
gcflag) has been removed.linux/arm64
for the benefit of profiling tools like perf
.-lang
flag to set the Go language version to use. For example, -lang=go1.8
causes the compiler to error on type aliases.MADV_FREE
advice to release unused memory; more efficient but may result in higher reported RSS.cpu.extension=off
for GODEBUG
to disable the use of optional CPU instruction set extensions in the standard library and runtime.Let's begin with the most visible change:
crypto/tls
gains TLS 1.3 support! 🔐(A few moments later...)
MaxVersion
in Config
.TLSUnique
in ConnectionState
and renegotiation are available in TLS 1.3 and provide equivalent or better security and performance.Read
, not Handshake
. E.g., if the server rejects the client certificate.Minor changes and updates with Go 1 promise of compatibility in mind:
fmt
net/...
crypto/...
bytes
, strings
database/sql
expvar
go/...
image/...
math/...
fmt
For example, fmt.Print
ing this map:
map[uint8]string{7: "bar", 3: "foo"}
With Go 1.11:
map[7:bar 3:foo] // or map[3:foo 7:bar]
With Go 1.12:
map[3:foo 7:bar]
NaN
were previously displayed as <nil>
, now fixed.
os
ProcessState.ExitCode
method returns the process's exit code.UserHomeDir
returns the current user's home directory.RemoveAll
supports paths longer than 4096 characters on most Unix systems.
net/http/httputil
ReverseProxy
now automatically proxies WebSocket requests.
net/http
Transport
no longer rejects HTTP responses which declare HTTP Trailers but don't use chunked encoding. Instead, declared trailers are ignored.Transport
no longer handles MAX_CONCURRENT_STREAMS
values advertised from HTTP/2 servers as strictly as it did during Go 1.10 and Go 1.11. Instead, default behavior is more like Go 1.9, new TCP connections are created as needed.Client.CloseIdleConnections
method is short for Client.Transport.CloseIdleConnections
.
net
Dialer.DualStack
is ignored and deprecated. Can be disabled.Dialer.KeepAlive
is zero. Can be disabled.splice
system call is used when copying from a UnixConn
to a TCPConn
.
io
StringWriter
interface:// StringWriter is the interface that wraps the WriteString method. type StringWriter interface { WriteString(s string) (n int, err error) }
reflect
MapIter
type is an iterator for ranging over a map, follows same iteration semantics as a range
statement.
bytes
, strings
ReplaceAll
returns a copy of a byte slice/string with all non-overlapping instances of a value replaced by another.new(Reader)
is now functionally equivalent to NewReader(nil)
.
syscall/js
Wrapper
interface is used by ValueOf
.Value.Truthy
method reports the JavaScript "truthiness".Value
now represents the JavaScript undefined
value, not number zero.Callback
renamed to Func
, NewCallback
renamed to FuncOf
.
crypto/rc4
image
RegisterFormat
is now safe for concurrent use.
image/png
time
GOROOT/lib/time/zoneinfo.zip
has been updated to version 2018i. Only used if a time zone database is not provided by OS.
math
Sin
, Cos
, Tan
, and Sincos
apply Payne-Hanek range reduction to huge arguments for more accurate answers.
math/bits
Add
, Sub
, Mul
, and Div
are available in uint
, uint32
, and uint64
versions.
syscall
Syscall18
added for Windows, allowing for calls with up to 18 arguments.
testing
-benchtime
flag now supports setting an explicit iteration count with "x". For example, -benchtime=100x
.Your favorite change missing here or in the Go 1.12 release notes?
Let me know!
48