What else is in Go 1.11?
27 June 2018
Daniel Martí
Daniel Martí
Sources:
github.com/golang/go/issues?q=is:open+is:issue+milestone:Go1.11
2Dropped:
Minor additions, like -race on linux/ppc64le and -msan on linux/arm64.
riscv and riscv64 reserved as GOARCH values reserved for the future.
A replacement for x/tools/go/loader with several advantages:
./...GOCACHEvar _ = T{
F1: 1,
F2: 1,
VeryLongNameJustBecause: 1,
F3: 1,
}The tweaked heuristic now gives us:
var _ = T{
F1: 1,
F2: 1,
VeryLongNameJustBecause: 1,
F3: 1,
}
Optimized binaries now include more accurate info, like:
DWARF sections (debugging info) are now compressed by default
8libSystem.so--
Juju/c=4/l=4 46.3s ± 4% 38.0s ± 4% -18.06% (p=0.001 n=7+7) Kubelet/c=4/l=4 48.1s ± 2% 39.0s ± 5% -18.93% (p=0.002 n=6+6)
gccgo and go/types already errored herefunc f(v interface{}) {
switch x := v.(type) {
}
}panic can now be inlined
-l=4 makes the inlining more agressive, also enabling mid-stack inlining
-l=4 has been tweaked and improved-l=4 still makes some programs larger and slowerfor k := range m {
delete(m, k)
}GoMapClear/Reflexive/1 92.2ns ± 1% 47.1ns ± 2% -48.89% (p=0.000 n=9+9) GoMapClear/Reflexive/10 108ns ± 1% 48ns ± 2% -55.68% (p=0.000 n=10+10) GoMapClear/Reflexive/100 303ns ± 2% 110ns ± 3% -63.56% (p=0.000 n=10+10) GoMapClear/Reflexive/1000 3.58µs ± 3% 1.23µs ± 2% -65.49% (p=0.000 n=9+10) GoMapClear/Reflexive/10000 28.2µs ± 3% 10.3µs ± 2% -63.55% (p=0.000 n=9+10)
append(s, make([]T, n)...)
ExtendSlice/IntSlice 103ns ± 4% 57ns ± 4% -44.55% (p=0.000 n=18+18) ExtendSlice/PointerSlice 155ns ± 3% 77ns ± 3% -49.93% (p=0.000 n=20+20) ExtendSlice/NoGrow 50.2ns ± 3% 5.2ns ± 2% -89.67% (p=0.000 n=18+18)
The prove pass derives facts from code, to be used to delete unnecessary
branches and bounds checks.
Most importantly, it now recognizes transitive relations:
The bounds check is what panics if the index is out of bounds, so in this case
it can be removed.
Let's begin with some of the most visible changes:
os.UserCacheDir; $HOME/.cache on most Unix systemsos/user adds a osusergo build tag use pure Go without CGO_ENABLED=0time now accepts parsing numeric timezones like +03net/http adds support for CIDR and ports in NO_PROXY, like NO_PROXY=10.0.0.0/8net/http/httputil.ReverseProxy gained an ErrorHandlercrypto funcs now randomly read an extra bytetext/template can now modify variables via the = token:{{ $v := "init" }}
{{ if true }}
{{ $v = "changed" }}
{{ end }}
v: {{ $v }} {{/* "changed" */}}<Paste>io/ioutil.TempFile can now be told where to put the random characters:ioutil.TempFile("", "foo-") // /tmp/foo-123456
ioutil.TempFile("", "foo-*.txt") // /tmp/foo-123456.txtWhat about performance?
arm64; especially crypto and byte handlingmath/big were rewritten to be much fastersplice syscallsync.RWMutexDaniel Martí