| --- |
| template: false |
| title: Go 1.10 Release Notes |
| --- |
| |
| <!-- |
| NOTE: In this document and others in this directory, the convention is to |
| set fixed-width phrases with non-fixed-width spaces, as in |
| `hello` `world`. |
| Do not send CLs removing the interior tags from such phrases. |
| --> |
| |
| <style> |
| main ul li { margin: 0.5em 0; } |
| </style> |
| |
| ## Introduction to Go 1.10 {#introduction} |
| |
| The latest Go release, version 1.10, arrives six months after [Go 1.9](go1.9). |
| Most of its changes are in the implementation of the toolchain, runtime, and libraries. |
| As always, the release maintains the Go 1 [promise of compatibility](/doc/go1compat.html). |
| We expect almost all Go programs to continue to compile and run as before. |
| |
| This release improves [caching of built packages](#build), |
| adds [caching of successful test results](#test), |
| runs [vet automatically during tests](#test-vet), |
| and |
| permits [passing string values directly between Go and C using cgo](#cgo). |
| A new [hard-coded set of safe compiler options](#cgo) may cause |
| unexpected [`invalid |
| flag`](/s/invalidflag) errors in code that built successfully with older |
| releases. |
| |
| ## Changes to the language {#language} |
| |
| There are no significant changes to the language specification. |
| |
| <!-- CL 60230 --> |
| A corner case involving shifts of untyped constants has been clarified, |
| and as a result the compilers have been updated to allow the index expression |
| `x[1.0` `<<` `s]` where `s` is an unsigned integer; |
| the [go/types](/pkg/go/types/) package already did. |
| |
| <!-- CL 73233 --> |
| The grammar for method expressions has been updated to relax the |
| syntax to allow any type expression as a receiver; |
| this matches what the compilers were already implementing. |
| For example, `struct{io.Reader}.Read` is a valid, if unusual, |
| method expression that the compilers already accepted and is |
| now permitted by the language grammar. |
| |
| ## Ports {#ports} |
| |
| There are no new supported operating systems or processor architectures in this release. |
| Most of the work has focused on strengthening the support for existing ports, |
| in particular [new instructions in the assembler](#asm) |
| and improvements to the code generated by the compilers. |
| |
| As [announced in the Go 1.9 release notes](go1.9#freebsd), |
| Go 1.10 now requires FreeBSD 10.3 or later; |
| support for FreeBSD 9.3 has been removed. |
| |
| Go now runs on NetBSD again but requires the unreleased NetBSD 8. |
| Only `GOARCH` `amd64` and `386` have |
| been fixed. The `arm` port is still broken. |
| |
| On 32-bit MIPS systems, the new environment variable settings |
| `GOMIPS=hardfloat` (the default) and |
| `GOMIPS=softfloat` select whether to use |
| hardware instructions or software emulation for floating-point computations. |
| |
| Go 1.10 is the last release that will run on OpenBSD 6.0. |
| Go 1.11 will require OpenBSD 6.2. |
| |
| Go 1.10 is the last release that will run on OS X 10.8 Mountain Lion or OS X 10.9 Mavericks. |
| Go 1.11 will require OS X 10.10 Yosemite or later. |
| |
| Go 1.10 is the last release that will run on Windows XP or Windows Vista. |
| Go 1.11 will require Windows 7 or later. |
| |
| ## Tools {#tools} |
| |
| ### Default GOROOT & GOTMPDIR {#goroot} |
| |
| If the environment variable `$GOROOT` is unset, |
| the go tool previously used the default `GOROOT` |
| set during toolchain compilation. |
| Now, before falling back to that default, the go tool attempts to |
| deduce `GOROOT` from its own executable path. |
| This allows binary distributions to be unpacked anywhere in the |
| file system and then be used without setting `GOROOT` |
| explicitly. |
| |
| By default, the go tool creates its temporary files and directories |
| in the system temporary directory (for example, `$TMPDIR` on Unix). |
| If the new environment variable `$GOTMPDIR` is set, |
| the go tool will create its temporary files and directories in that directory instead. |
| |
| ### Build & Install {#build} |
| |
| The `go` `build` command now detects out-of-date packages |
| purely based on the content of source files, specified build flags, and metadata stored in the compiled packages. |
| Modification times are no longer consulted or relevant. |
| The old advice to add `-a` to force a rebuild in cases where |
| the modification times were misleading for one reason or another |
| (for example, changes in build flags) is no longer necessary: |
| builds now always detect when packages must be rebuilt. |
| (If you observe otherwise, please file a bug.) |
| |
| The `go` `build` `-asmflags`, `-gcflags`, `-gccgoflags`, and `-ldflags` options |
| now apply by default only to the packages listed directly on the command line. |
| For example, `go` `build` `-gcflags=-m` `mypkg` |
| passes the compiler the `-m` flag when building `mypkg` |
| but not its dependencies. |
| The new, more general form `-asmflags=pattern=flags` (and similarly for the others) |
| applies the `flags` only to the packages matching the pattern. |
| For example: `go` `install` `-ldflags=cmd/gofmt=-X=main.version=1.2.3` `cmd/...` |
| installs all the commands matching `cmd/...` but only applies the `-X` option |
| to the linker flags for `cmd/gofmt`. |
| For more details, see [`go` `help` `build`](/cmd/go/#hdr-Compile_packages_and_dependencies). |
| |
| The `go` `build` command now maintains a cache of |
| recently built packages, separate from the installed packages in `$GOROOT/pkg` or `$GOPATH/pkg`. |
| The effect of the cache should be to speed builds that do not explicitly install packages |
| or when switching between different copies of source code (for example, when changing |
| back and forth between different branches in a version control system). |
| The old advice to add the `-i` flag for speed, as in `go` `build` `-i` |
| or `go` `test` `-i`, |
| is no longer necessary: builds run just as fast without `-i`. |
| For more details, see [`go` `help` `cache`](/cmd/go/#hdr-Build_and_test_caching). |
| |
| The `go` `install` command now installs only the |
| packages and commands listed directly on the command line. |
| For example, `go` `install` `cmd/gofmt` |
| installs the gofmt program but not any of the packages on which it depends. |
| The new build cache makes future commands still run as quickly as if the |
| dependencies had been installed. |
| To force the installation of dependencies, use the new |
| `go` `install` `-i` flag. |
| Installing dependency packages should not be necessary in general, |
| and the very concept of installed packages may disappear in a future release. |
| |
| Many details of the `go` `build` implementation have changed to support these improvements. |
| One new requirement implied by these changes is that |
| binary-only packages must now declare accurate import blocks in their |
| stub source code, so that those imports can be made available when |
| linking a program using the binary-only package. |
| For more details, see [`go` `help` `filetype`](/cmd/go/#hdr-File_types). |
| |
| ### Test {#test} |
| |
| The `go` `test` command now caches test results: |
| if the test executable and command line match a previous run |
| and the files and environment variables consulted by that run |
| have not changed either, `go` `test` will print |
| the previous test output, replacing the elapsed time with the string “(cached).” |
| Test caching applies only to successful test results; |
| only to `go` `test` |
| commands with an explicit list of packages; and |
| only to command lines using a subset of the |
| `-cpu`, `-list`, `-parallel`, |
| `-run`, `-short`, and `-v` test flags. |
| The idiomatic way to bypass test caching is to use `-count=1`. |
| |
| The `go` `test` command now automatically runs |
| `go` `vet` on the package being tested, |
| to identify significant problems before running the test. |
| Any such problems are treated like build errors and prevent execution of the test. |
| Only a high-confidence subset of the available `go` `vet` |
| checks are enabled for this automatic check. |
| To disable the running of `go` `vet`, use |
| `go` `test` `-vet=off`. |
| |
| The `go` `test` `-coverpkg` flag now |
| interprets its argument as a comma-separated list of patterns to match against |
| the dependencies of each test, not as a list of packages to load anew. |
| For example, `go` `test` `-coverpkg=all` |
| is now a meaningful way to run a test with coverage enabled for the test package |
| and all its dependencies. |
| Also, the `go` `test` `-coverprofile` option is now |
| supported when running multiple tests. |
| |
| In case of failure due to timeout, tests are now more likely to write their profiles before exiting. |
| |
| The `go` `test` command now always |
| merges the standard output and standard error from a given test binary execution |
| and writes both to `go` `test`'s standard output. |
| In past releases, `go` `test` only applied this |
| merging most of the time. |
| |
| The `go` `test` `-v` output |
| now includes `PAUSE` and `CONT` status update |
| lines to mark when [parallel tests](/pkg/testing/#T.Parallel) pause and continue. |
| |
| The new `go` `test` `-failfast` flag |
| disables running additional tests after any test fails. |
| Note that tests running in parallel with the failing test are allowed to complete. |
| |
| Finally, the new `go` `test` `-json` flag |
| filters test output through the new command |
| `go` `tool` `test2json` |
| to produce a machine-readable JSON-formatted description of test execution. |
| This allows the creation of rich presentations of test execution |
| in IDEs and other tools. |
| |
| For more details about all these changes, |
| see [`go` `help` `test`](/cmd/go/#hdr-Test_packages) |
| and the [test2json documentation](/cmd/test2json/). |
| |
| ### Cgo {#cgo} |
| |
| Options specified by cgo using `#cgo CFLAGS` and the like |
| are now checked against a list of permitted options. |
| This closes a security hole in which a downloaded package uses |
| compiler options like |
| <span style="white-space: nowrap">`-fplugin`</span> |
| to run arbitrary code on the machine where it is being built. |
| This can cause a build error such as `invalid flag in #cgo CFLAGS`. |
| For more background, and how to handle this error, see |
| [https://golang.org/s/invalidflag](/s/invalidflag). |
| |
| Cgo now implements a C typedef like “`typedef` `X` `Y`” using a Go type alias, |
| so that Go code may use the types `C.X` and `C.Y` interchangeably. |
| It also now supports the use of niladic function-like macros. |
| Also, the documentation has been updated to clarify that |
| Go structs and Go arrays are not supported in the type signatures of cgo-exported functions. |
| |
| Cgo now supports direct access to Go string values from C. |
| Functions in the C preamble may use the type `_GoString_` |
| to accept a Go string as an argument. |
| C code may call `_GoStringLen` and `_GoStringPtr` |
| for direct access to the contents of the string. |
| A value of type `_GoString_` |
| may be passed in a call to an exported Go function that takes an argument of Go type `string`. |
| |
| During toolchain bootstrap, the environment variables `CC` and `CC_FOR_TARGET` specify |
| the default C compiler that the resulting toolchain will use for host and target builds, respectively. |
| However, if the toolchain will be used with multiple targets, it may be necessary to specify a different C compiler for each |
| (for example, a different compiler for `darwin/arm64` versus `linux/ppc64le`). |
| The new set of environment variables <code>CC\_FOR\__goos_\__goarch_</code> |
| allows specifying a different default C compiler for each target. |
| Note that these variables only apply during toolchain bootstrap, |
| to set the defaults used by the resulting toolchain. |
| Later `go` `build` commands use the `CC` environment |
| variable or else the built-in default. |
| |
| Cgo now translates some C types that would normally map to a pointer |
| type in Go, to a `uintptr` instead. These types include |
| the `CFTypeRef` hierarchy in Darwin's CoreFoundation |
| framework and the `jobject` hierarchy in Java's JNI |
| interface. |
| |
| These types must be `uintptr` on the Go side because they |
| would otherwise confuse the Go garbage collector; they are sometimes |
| not really pointers but data structures encoded in a pointer-sized integer. |
| Pointers to Go memory must not be stored in these `uintptr` values. |
| |
| Because of this change, values of the affected types need to be |
| zero-initialized with the constant `0` instead of the |
| constant `nil`. Go 1.10 provides `gofix` |
| modules to help with that rewrite: |
| |
| go tool fix -r cftype <pkg> |
| go tool fix -r jni <pkg> |
| |
| For more details, see the [cgo documentation](/cmd/cgo/). |
| |
| ### Doc {#doc} |
| |
| The `go` `doc` tool now adds functions returning slices of `T` or `*T` |
| to the display of type `T`, similar to the existing behavior for functions returning single `T` or `*T` results. |
| For example: |
| |
| $ go doc mail.Address |
| package mail // import "net/mail" |
| |
| type Address struct { |
| Name string |
| Address string |
| } |
| Address represents a single mail address. |
| |
| func ParseAddress(address string) (*Address, error) |
| func ParseAddressList(list string) ([]*Address, error) |
| func (a *Address) String() string |
| $ |
| |
| Previously, `ParseAddressList` was only shown in the package overview (`go` `doc` `mail`). |
| |
| ### Fix {#fix} |
| |
| The `go` `fix` tool now replaces imports of `"golang.org/x/net/context"` |
| with `"context"`. |
| (Forwarding aliases in the former make it completely equivalent to the latter when using Go 1.9 or later.) |
| |
| ### Get {#get} |
| |
| The `go` `get` command now supports Fossil source code repositories. |
| |
| ### Pprof {#pprof} |
| |
| The blocking and mutex profiles produced by the `runtime/pprof` package |
| now include symbol information, so they can be viewed |
| in `go` `tool` `pprof` |
| without the binary that produced the profile. |
| (All other profile types were changed to include symbol information in Go 1.9.) |
| |
| The [`go` `tool` `pprof`](/cmd/pprof/) |
| profile visualizer has been updated to git version 9e20b5b (2017-11-08) |
| from [github.com/google/pprof](https://github.com/google/pprof), |
| which includes an updated web interface. |
| |
| ### Vet {#vet} |
| |
| The [`go` `vet`](/cmd/vet/) command now always has access to |
| complete, up-to-date type information when checking packages, even for packages using cgo or vendored imports. |
| The reports should be more accurate as a result. |
| Note that only `go` `vet` has access to this information; |
| the more low-level `go` `tool` `vet` does not |
| and should be avoided except when working on `vet` itself. |
| (As of Go 1.9, `go` `vet` provides access to all the same flags as |
| `go` `tool` `vet`.) |
| |
| ### Diagnostics {#diag} |
| |
| This release includes a new [overview of available Go program diagnostic tools](/doc/diagnostics.html). |
| |
| ### Gofmt {#gofmt} |
| |
| Two minor details of the default formatting of Go source code have changed. |
| First, certain complex three-index slice expressions previously formatted like |
| `x[i+1` `:` `j:k]` and now |
| format with more consistent spacing: `x[i+1` `:` `j` `:` `k]`. |
| Second, single-method interface literals written on a single line, |
| which are sometimes used in type assertions, |
| are no longer split onto multiple lines. |
| |
| Note that these kinds of minor updates to gofmt are expected from time to time. |
| In general, we recommend against building systems that check that source code |
| matches the output of a specific version of gofmt. |
| For example, a continuous integration test that fails if any code already checked into |
| a repository is not “properly formatted” is inherently fragile and not recommended. |
| |
| If multiple programs must agree about which version of gofmt is used to format a source file, |
| we recommend that they do this by arranging to invoke the same gofmt binary. |
| For example, in the Go open source repository, our Git pre-commit hook is written in Go |
| and could import `go/format` directly, but instead it invokes the `gofmt` |
| binary found in the current path, so that the pre-commit hook need not be recompiled |
| each time `gofmt` changes. |
| |
| ### Compiler Toolchain {#compiler} |
| |
| The compiler includes many improvements to the performance of generated code, |
| spread fairly evenly across the supported architectures. |
| |
| The DWARF debug information recorded in binaries has been improved in a few ways: |
| constant values are now recorded; |
| line number information is more accurate, making source-level stepping through a program work better; |
| and each package is now presented as its own DWARF compilation unit. |
| |
| The various [build modes](https://docs.google.com/document/d/1nr-TQHw_er6GOQRsF6T43GGhFDelrAP0NqSS_00RgZQ/edit) |
| have been ported to more systems. |
| Specifically, `c-shared` now works on `linux/ppc64le`, `windows/386`, and `windows/amd64`; |
| `pie` now works on `darwin/amd64` and also forces the use of external linking on all systems; |
| and `plugin` now works on `linux/ppc64le` and `darwin/amd64`. |
| |
| The `linux/ppc64le` port now requires the use of external linking |
| with any programs that use cgo, even uses by the standard library. |
| |
| ### Assembler {#asm} |
| |
| For the ARM 32-bit port, the assembler now supports the instructions |
| <code><small>BFC</small></code>, |
| <code><small>BFI</small></code>, |
| <code><small>BFX</small></code>, |
| <code><small>BFXU</small></code>, |
| <code><small>FMULAD</small></code>, |
| <code><small>FMULAF</small></code>, |
| <code><small>FMULSD</small></code>, |
| <code><small>FMULSF</small></code>, |
| <code><small>FNMULAD</small></code>, |
| <code><small>FNMULAF</small></code>, |
| <code><small>FNMULSD</small></code>, |
| <code><small>FNMULSF</small></code>, |
| <code><small>MULAD</small></code>, |
| <code><small>MULAF</small></code>, |
| <code><small>MULSD</small></code>, |
| <code><small>MULSF</small></code>, |
| <code><small>NMULAD</small></code>, |
| <code><small>NMULAF</small></code>, |
| <code><small>NMULD</small></code>, |
| <code><small>NMULF</small></code>, |
| <code><small>NMULSD</small></code>, |
| <code><small>NMULSF</small></code>, |
| <code><small>XTAB</small></code>, |
| <code><small>XTABU</small></code>, |
| <code><small>XTAH</small></code>, |
| and |
| <code><small>XTAHU</small></code>. |
| |
| For the ARM 64-bit port, the assembler now supports the |
| <code><small>VADD</small></code>, |
| <code><small>VADDP</small></code>, |
| <code><small>VADDV</small></code>, |
| <code><small>VAND</small></code>, |
| <code><small>VCMEQ</small></code>, |
| <code><small>VDUP</small></code>, |
| <code><small>VEOR</small></code>, |
| <code><small>VLD1</small></code>, |
| <code><small>VMOV</small></code>, |
| <code><small>VMOVI</small></code>, |
| <code><small>VMOVS</small></code>, |
| <code><small>VORR</small></code>, |
| <code><small>VREV32</small></code>, |
| and |
| <code><small>VST1</small></code> |
| instructions. |
| |
| For the PowerPC 64-bit port, the assembler now supports the POWER9 instructions |
| <code><small>ADDEX</small></code>, |
| <code><small>CMPEQB</small></code>, |
| <code><small>COPY</small></code>, |
| <code><small>DARN</small></code>, |
| <code><small>LDMX</small></code>, |
| <code><small>MADDHD</small></code>, |
| <code><small>MADDHDU</small></code>, |
| <code><small>MADDLD</small></code>, |
| <code><small>MFVSRLD</small></code>, |
| <code><small>MTVSRDD</small></code>, |
| <code><small>MTVSRWS</small></code>, |
| <code><small>PASTECC</small></code>, |
| <code><small>VCMPNEZB</small></code>, |
| <code><small>VCMPNEZBCC</small></code>, |
| and |
| <code><small>VMSUMUDM</small></code>. |
| |
| For the S390X port, the assembler now supports the |
| <code><small>TMHH</small></code>, |
| <code><small>TMHL</small></code>, |
| <code><small>TMLH</small></code>, |
| and |
| <code><small>TMLL</small></code> |
| instructions. |
| |
| For the X86 64-bit port, the assembler now supports 359 new instructions, |
| including the full AVX, AVX2, BMI, BMI2, F16C, FMA3, SSE2, SSE3, SSSE3, SSE4.1, and SSE4.2 extension sets. |
| The assembler also no longer implements <code><small>MOVL</small></code> <code><small>$0,</small></code> <code><small>AX</small></code> |
| as an <code><small>XORL</small></code> instruction, |
| to avoid clearing the condition flags unexpectedly. |
| |
| ### Gccgo {#gccgo} |
| |
| Due to the alignment of Go's semiannual release schedule with GCC's |
| annual release schedule, |
| GCC release 7 contains the Go 1.8.3 version of gccgo. |
| We expect that the next release, GCC 8, will contain the Go 1.10 |
| version of gccgo. |
| |
| ## Runtime {#runtime} |
| |
| The behavior of nested calls to |
| [`LockOSThread`](/pkg/runtime/#LockOSThread) and |
| [`UnlockOSThread`](/pkg/runtime/#UnlockOSThread) |
| has changed. |
| These functions control whether a goroutine is locked to a specific operating system thread, |
| so that the goroutine only runs on that thread, and the thread only runs that goroutine. |
| Previously, calling `LockOSThread` more than once in a row |
| was equivalent to calling it once, and a single `UnlockOSThread` |
| always unlocked the thread. |
| Now, the calls nest: if `LockOSThread` is called multiple times, |
| `UnlockOSThread` must be called the same number of times |
| in order to unlock the thread. |
| Existing code that was careful not to nest these calls will remain correct. |
| Existing code that incorrectly assumed the calls nested will become correct. |
| Most uses of these functions in public Go source code falls into the second category. |
| |
| Because one common use of `LockOSThread` and `UnlockOSThread` |
| is to allow Go code to reliably modify thread-local state (for example, Linux or Plan 9 name spaces), |
| the runtime now treats locked threads as unsuitable for reuse or for creating new threads. |
| |
| Stack traces no longer include implicit wrapper functions (previously marked `<autogenerated>`), |
| unless a fault or panic happens in the wrapper itself. |
| As a result, skip counts passed to functions like [`Caller`](/pkg/runtime/#Caller) |
| should now always match the structure of the code as written, rather than depending on |
| optimization decisions and implementation details. |
| |
| The garbage collector has been modified to reduce its impact on allocation latency. |
| It now uses a smaller fraction of the overall CPU when running, but it may run more of the time. |
| The total CPU consumed by the garbage collector has not changed significantly. |
| |
| The [`GOROOT`](/pkg/runtime/#GOROOT) function |
| now defaults (when the `$GOROOT` environment variable is not set) |
| to the `GOROOT` or `GOROOT_FINAL` in effect |
| at the time the calling program was compiled. |
| Previously it used the `GOROOT` or `GOROOT_FINAL` in effect |
| at the time the toolchain that compiled the calling program was compiled. |
| |
| There is no longer a limit on the [`GOMAXPROCS`](/pkg/runtime/#GOMAXPROCS) setting. |
| (In Go 1.9 the limit was 1024.) |
| |
| ## Performance {#performance} |
| |
| As always, the changes are so general and varied that precise |
| statements about performance are difficult to make. Most programs |
| should run a bit faster, due to speedups in the garbage collector, |
| better generated code, and optimizations in the core library. |
| |
| ## Garbage Collector {#gc} |
| |
| Many applications should experience significantly lower allocation latency and overall performance overhead when the garbage collector is active. |
| |
| ## Core library {#library} |
| |
| All of the changes to the standard library are minor. |
| The changes in [bytes](#bytes) |
| and [net/url](#net/url) are the most likely to require updating of existing programs. |
| |
| ### Minor changes to the library {#minor_library_changes} |
| |
| As always, there are various minor changes and updates to the library, |
| made with the Go 1 [promise of compatibility](/doc/go1compat) |
| in mind. |
| |
| #### [archive/tar](/pkg/archive/tar/) |
| |
| In general, the handling of special header formats is significantly improved and expanded. |
| |
| [`FileInfoHeader`](/pkg/archive/tar/#FileInfoHeader) has always |
| recorded the Unix UID and GID numbers from its [`os.FileInfo`](/pkg/os/#FileInfo) argument |
| (specifically, from the system-dependent information returned by the `FileInfo`'s `Sys` method) |
| in the returned [`Header`](/pkg/archive/tar/#Header). |
| Now it also records the user and group names corresponding to those IDs, |
| as well as the major and minor device numbers for device files. |
| |
| The new [`Header.Format`](/pkg/archive/tar/#Header) field |
| of type [`Format`](/pkg/archive/tar/#Format) |
| controls which tar header format the [`Writer`](/pkg/archive/tar/#Writer) uses. |
| The default, as before, is to select the most widely-supported header type |
| that can encode the fields needed by the header (USTAR if possible, or else PAX if possible, or else GNU). |
| The [`Reader`](/pkg/archive/tar/#Reader) sets `Header.Format` for each header it reads. |
| |
| `Reader` and the `Writer` now support arbitrary PAX records, |
| using the new [`Header.PAXRecords`](/pkg/archive/tar/#Header) field, |
| a generalization of the existing `Xattrs` field. |
| |
| The `Reader` no longer insists that the file name or link name in GNU headers |
| be valid UTF-8. |
| |
| When writing PAX- or GNU-format headers, the `Writer` now includes |
| the `Header.AccessTime` and `Header.ChangeTime` fields (if set). |
| When writing PAX-format headers, the times include sub-second precision. |
| |
| #### [archive/zip](/pkg/archive/zip/) |
| |
| Go 1.10 adds more complete support for times and character set encodings in ZIP archives. |
| |
| The original ZIP format used the standard MS-DOS encoding of year, month, day, hour, minute, and second into fields in two 16-bit values. |
| That encoding cannot represent time zones or odd seconds, so multiple extensions have been |
| introduced to allow richer encodings. |
| In Go 1.10, the [`Reader`](/pkg/archive/zip/#Reader) and [`Writer`](/pkg/archive/zip/#Writer) |
| now support the widely-understood Info-Zip extension that encodes the time separately in the 32-bit Unix “seconds since epoch” form. |
| The [`FileHeader`](/pkg/archive/zip/#FileHeader)'s new `Modified` field of type [`time.Time`](/pkg/time/#Time) |
| obsoletes the `ModifiedTime` and `ModifiedDate` fields, which continue to hold the MS-DOS encoding. |
| The `Reader` and `Writer` now adopt the common |
| convention that a ZIP archive storing a time zone-independent Unix time |
| also stores the local time in the MS-DOS field, |
| so that the time zone offset can be inferred. |
| For compatibility, the [`ModTime`](/pkg/archive/zip/#FileHeader.ModTime) and |
| [`SetModTime`](/pkg/archive/zip/#FileHeader.SetModTime) methods |
| behave the same as in earlier releases; new code should use `Modified` directly. |
| |
| The header for each file in a ZIP archive has a flag bit indicating whether |
| the name and comment fields are encoded as UTF-8, as opposed to a system-specific default encoding. |
| In Go 1.8 and earlier, the `Writer` never set the UTF-8 bit. |
| In Go 1.9, the `Writer` changed to set the UTF-8 bit almost always. |
| This broke the creation of ZIP archives containing Shift-JIS file names. |
| In Go 1.10, the `Writer` now sets the UTF-8 bit only when |
| both the name and the comment field are valid UTF-8 and at least one is non-ASCII. |
| Because non-ASCII encodings very rarely look like valid UTF-8, the new |
| heuristic should be correct nearly all the time. |
| Setting a `FileHeader`'s new `NonUTF8` field to true |
| disables the heuristic entirely for that file. |
| |
| The `Writer` also now supports setting the end-of-central-directory record's comment field, |
| by calling the `Writer`'s new [`SetComment`](/pkg/archive/zip/#Writer.SetComment) method. |
| |
| #### [bufio](/pkg/bufio/) |
| |
| The new [`Reader.Size`](/pkg/bufio/#Reader.Size) |
| and [`Writer.Size`](/pkg/bufio/#Writer.Size) |
| methods report the `Reader` or `Writer`'s underlying buffer size. |
| |
| #### [bytes](/pkg/bytes/) |
| |
| The |
| [`Fields`](/pkg/bytes/#Fields), |
| [`FieldsFunc`](/pkg/bytes/#FieldsFunc), |
| [`Split`](/pkg/bytes/#Split), |
| and |
| [`SplitAfter`](/pkg/bytes/#SplitAfter) |
| functions have always returned subslices of their inputs. |
| Go 1.10 changes each returned subslice to have capacity equal to its length, |
| so that appending to one cannot overwrite adjacent data in the original input. |
| |
| #### [crypto/cipher](/pkg/crypto/cipher/) |
| |
| [`NewOFB`](/pkg/crypto/cipher/#NewOFB) now panics if given |
| an initialization vector of incorrect length, like the other constructors in the |
| package always have. |
| (Previously it returned a nil `Stream` implementation.) |
| |
| #### [crypto/tls](/pkg/crypto/tls/) |
| |
| The TLS server now advertises support for SHA-512 signatures when using TLS 1.2. |
| The server already supported the signatures, but some clients would not select |
| them unless explicitly advertised. |
| |
| #### [crypto/x509](/pkg/crypto/x509/) |
| |
| [`Certificate.Verify`](/pkg/crypto/x509/#Certificate.Verify) |
| now enforces the name constraints for all |
| names contained in the certificate, not just the one name that a client has asked about. |
| Extended key usage restrictions are similarly now checked all at once. |
| As a result, after a certificate has been validated, now it can be trusted in its entirety. |
| It is no longer necessary to revalidate the certificate for each additional name |
| or key usage. |
| |
| Parsed certificates also now report URI names and IP, email, and URI constraints, using the new |
| [`Certificate`](/pkg/crypto/x509/#Certificate) fields |
| `URIs`, `PermittedIPRanges`, `ExcludedIPRanges`, |
| `PermittedEmailAddresses`, `ExcludedEmailAddresses`, |
| `PermittedURIDomains`, and `ExcludedURIDomains`. Certificates with |
| invalid values for those fields are now rejected. |
| |
| The new [`MarshalPKCS1PublicKey`](/pkg/crypto/x509/#MarshalPKCS1PublicKey) |
| and [`ParsePKCS1PublicKey`](/pkg/crypto/x509/#ParsePKCS1PublicKey) |
| functions convert an RSA public key to and from PKCS#1-encoded form. |
| |
| The new [`MarshalPKCS8PrivateKey`](/pkg/crypto/x509/#MarshalPKCS8PrivateKey) |
| function converts a private key to PKCS#8-encoded form. |
| ([`ParsePKCS8PrivateKey`](/pkg/crypto/x509/#ParsePKCS8PrivateKey) |
| has existed since Go 1.) |
| |
| #### [crypto/x509/pkix](/pkg/crypto/x509/pkix/) |
| |
| [`Name`](/pkg/crypto/x509/pkix/#Name) now implements a |
| [`String`](/pkg/crypto/x509/pkix/#Name.String) method that |
| formats the X.509 distinguished name in the standard RFC 2253 format. |
| |
| #### [database/sql/driver](/pkg/database/sql/driver/) |
| |
| Drivers that currently hold on to the destination buffer provided by |
| [`driver.Rows.Next`](/pkg/database/sql/driver/#Rows.Next) should ensure they no longer |
| write to a buffer assigned to the destination array outside of that call. |
| Drivers must be careful that underlying buffers are not modified when closing |
| [`driver.Rows`](/pkg/database/sql/driver/#Rows). |
| |
| Drivers that want to construct a [`sql.DB`](/pkg/database/sql/#DB) for |
| their clients can now implement the [`Connector`](/pkg/database/sql/driver/#Connector) interface |
| and call the new [`sql.OpenDB`](/pkg/database/sql/#OpenDB) function, |
| instead of needing to encode all configuration into a string |
| passed to [`sql.Open`](/pkg/database/sql/#Open). |
| |
| Drivers that want to parse the configuration string only once per `sql.DB` |
| instead of once per [`sql.Conn`](/pkg/database/sql/#Conn), |
| or that want access to each `sql.Conn`'s underlying context, |
| can make their [`Driver`](/pkg/database/sql/driver/#Driver) |
| implementations also implement [`DriverContext`](/pkg/database/sql/driver/#DriverContext)'s |
| new `OpenConnector` method. |
| |
| Drivers that implement [`ExecerContext`](/pkg/database/sql/driver/#ExecerContext) |
| no longer need to implement [`Execer`](/pkg/database/sql/driver/#Execer); |
| similarly, drivers that implement [`QueryerContext`](/pkg/database/sql/driver/#QueryerContext) |
| no longer need to implement [`Queryer`](/pkg/database/sql/driver/#Queryer). |
| Previously, even if the context-based interfaces were implemented they were ignored |
| unless the non-context-based interfaces were also implemented. |
| |
| To allow drivers to better isolate different clients using a cached driver connection in succession, |
| if a [`Conn`](/pkg/database/sql/driver/#Conn) implements the new |
| [`SessionResetter`](/pkg/database/sql/driver/#SessionResetter) interface, |
| `database/sql` will now call `ResetSession` before |
| reusing the `Conn` for a new client. |
| |
| #### [debug/elf](/pkg/debug/elf/) |
| |
| This release adds 348 new relocation constants divided between the relocation types |
| [`R_386`](/pkg/debug/elf/#R_386), |
| [`R_AARCH64`](/pkg/debug/elf/#R_AARCH64), |
| [`R_ARM`](/pkg/debug/elf/#R_ARM), |
| [`R_PPC64`](/pkg/debug/elf/#R_PPC64), |
| and |
| [`R_X86_64`](/pkg/debug/elf/#R_X86_64). |
| |
| #### [debug/macho](/pkg/debug/macho/) |
| |
| Go 1.10 adds support for reading relocations from Mach-O sections, |
| using the [`Section`](/pkg/debug/macho#Section) struct's new `Relocs` field |
| and the new [`Reloc`](/pkg/debug/macho/#Reloc), |
| [`RelocTypeARM`](/pkg/debug/macho/#RelocTypeARM), |
| [`RelocTypeARM64`](/pkg/debug/macho/#RelocTypeARM64), |
| [`RelocTypeGeneric`](/pkg/debug/macho/#RelocTypeGeneric), |
| and |
| [`RelocTypeX86_64`](/pkg/debug/macho/#RelocTypeX86_64) |
| types and associated constants. |
| |
| Go 1.10 also adds support for the `LC_RPATH` load command, |
| represented by the types |
| [`RpathCmd`](/pkg/debug/macho/#RpathCmd) and |
| [`Rpath`](/pkg/debug/macho/#Rpath), |
| and new [named constants](/pkg/debug/macho/#pkg-constants) |
| for the various flag bits found in headers. |
| |
| #### [encoding/asn1](/pkg/encoding/asn1/) |
| |
| [`Marshal`](/pkg/encoding/asn1/#Marshal) now correctly encodes |
| strings containing asterisks as type UTF8String instead of PrintableString, |
| unless the string is in a struct field with a tag forcing the use of PrintableString. |
| `Marshal` also now respects struct tags containing `application` directives. |
| |
| The new [`MarshalWithParams`](/pkg/encoding/asn1/#MarshalWithParams) |
| function marshals its argument as if the additional params were its associated |
| struct field tag. |
| |
| [`Unmarshal`](/pkg/encoding/asn1/#Unmarshal) now respects |
| struct field tags using the `explicit` and `tag` |
| directives. |
| |
| Both `Marshal` and `Unmarshal` now support a new struct field tag |
| `numeric`, indicating an ASN.1 NumericString. |
| |
| #### [encoding/csv](/pkg/encoding/csv/) |
| |
| [`Reader`](/pkg/encoding/csv/#Reader) now disallows the use of |
| nonsensical `Comma` and `Comment` settings, |
| such as NUL, carriage return, newline, invalid runes, and the Unicode replacement character, |
| or setting `Comma` and `Comment` equal to each other. |
| |
| In the case of a syntax error in a CSV record that spans multiple input lines, `Reader` |
| now reports the line on which the record started in the [`ParseError`](/pkg/encoding/csv/#ParseError)'s new `StartLine` field. |
| |
| #### [encoding/hex](/pkg/encoding/hex/) |
| |
| The new functions |
| [`NewEncoder`](/pkg/encoding/hex/#NewEncoder) |
| and |
| [`NewDecoder`](/pkg/encoding/hex/#NewDecoder) |
| provide streaming conversions to and from hexadecimal, |
| analogous to equivalent functions already in |
| [encoding/base32](/pkg/encoding/base32/) |
| and |
| [encoding/base64](/pkg/encoding/base64/). |
| |
| When the functions |
| [`Decode`](/pkg/encoding/hex/#Decode) |
| and |
| [`DecodeString`](/pkg/encoding/hex/#DecodeString) |
| encounter malformed input, |
| they now return the number of bytes already converted |
| along with the error. |
| Previously they always returned a count of 0 with any error. |
| |
| #### [encoding/json](/pkg/encoding/json/) |
| |
| The [`Decoder`](/pkg/encoding/json/#Decoder) |
| adds a new method |
| [`DisallowUnknownFields`](/pkg/encoding/json/#Decoder.DisallowUnknownFields) |
| that causes it to report inputs with unknown JSON fields as a decoding error. |
| (The default behavior has always been to discard unknown fields.) |
| |
| As a result of [fixing a reflect bug](#reflect), |
| [`Unmarshal`](/pkg/encoding/json/#Unmarshal) |
| can no longer decode into fields inside |
| embedded pointers to unexported struct types, |
| because it cannot initialize the unexported embedded pointer |
| to point at fresh storage. |
| `Unmarshal` now returns an error in this case. |
| |
| #### [encoding/pem](/pkg/encoding/pem/) |
| |
| [`Encode`](/pkg/encoding/pem/#Encode) |
| and |
| [`EncodeToMemory`](/pkg/encoding/pem/#EncodeToMemory) |
| no longer generate partial output when presented with a |
| block that is impossible to encode as PEM data. |
| |
| #### [encoding/xml](/pkg/encoding/xml/) |
| |
| The new function |
| [`NewTokenDecoder`](/pkg/encoding/xml/#NewTokenDecoder) |
| is like |
| [`NewDecoder`](/pkg/encoding/xml/#NewDecoder) |
| but creates a decoder reading from a [`TokenReader`](/pkg/encoding/xml/#TokenReader) |
| instead of an XML-formatted byte stream. |
| This is meant to enable the construction of XML stream transformers in client libraries. |
| |
| #### [flag](/pkg/flag/) |
| |
| The default |
| [`Usage`](/pkg/flag/#Usage) function now prints |
| its first line of output to |
| `CommandLine.Output()` |
| instead of assuming `os.Stderr`, |
| so that the usage message is properly redirected for |
| clients using `CommandLine.SetOutput`. |
| |
| [`PrintDefaults`](/pkg/flag/#PrintDefaults) now |
| adds appropriate indentation after newlines in flag usage strings, |
| so that multi-line usage strings display nicely. |
| |
| [`FlagSet`](/pkg/flag/#FlagSet) adds new methods |
| [`ErrorHandling`](/pkg/flag/#FlagSet.ErrorHandling), |
| [`Name`](/pkg/flag/#FlagSet.Name), |
| and |
| [`Output`](/pkg/flag/#FlagSet.Output), |
| to retrieve the settings passed to |
| [`NewFlagSet`](/pkg/flag/#NewFlagSet) |
| and |
| [`FlagSet.SetOutput`](/pkg/flag/#FlagSet.SetOutput). |
| |
| #### [go/doc](/pkg/go/doc/) |
| |
| To support the [doc change](#doc) described above, |
| functions returning slices of `T`, `*T`, `**T`, and so on |
| are now reported in `T`'s [`Type`](/pkg/go/doc/#Type)'s `Funcs` list, |
| instead of in the [`Package`](/pkg/go/doc/#Package)'s `Funcs` list. |
| |
| #### [go/importer](/pkg/go/importer/) |
| |
| The [`For`](/pkg/go/importer/#For) function now accepts a non-nil lookup argument. |
| |
| #### [go/printer](/pkg/go/printer/) |
| |
| The changes to the default formatting of Go source code |
| discussed in the [gofmt section](#gofmt) above |
| are implemented in the [go/printer](/pkg/go/printer/) package |
| and also affect the output of the higher-level [go/format](/pkg/go/format/) package. |
| |
| #### [hash](/pkg/hash/) |
| |
| Implementations of the [`Hash`](/pkg/hash/#Hash) interface are now |
| encouraged to implement [`encoding.BinaryMarshaler`](/pkg/encoding/#BinaryMarshaler) |
| and [`encoding.BinaryUnmarshaler`](/pkg/encoding/#BinaryUnmarshaler) |
| to allow saving and recreating their internal state, |
| and all implementations in the standard library |
| ([hash/crc32](/pkg/hash/crc32/), [crypto/sha256](/pkg/crypto/sha256/), and so on) |
| now implement those interfaces. |
| |
| #### [html/template](/pkg/html/template/) |
| |
| The new [`Srcset`](/pkg/html/template#Srcset) content |
| type allows for proper handling of values within the |
| [`srcset`](https://w3c.github.io/html/semantics-embedded-content.html#element-attrdef-img-srcset) |
| attribute of `img` tags. |
| |
| #### [math/big](/pkg/math/big/) |
| |
| [`Int`](/pkg/math/big/#Int) now supports conversions to and from bases 2 through 62 |
| in its [`SetString`](/pkg/math/big/#Int.SetString) and [`Text`](/pkg/math/big/#Text) methods. |
| (Previously it only allowed bases 2 through 36.) |
| The value of the constant `MaxBase` has been updated. |
| |
| [`Int`](/pkg/math/big/#Int) adds a new |
| [`CmpAbs`](/pkg/math/big/#CmpAbs) method |
| that is like [`Cmp`](/pkg/math/big/#Cmp) but |
| compares only the absolute values (not the signs) of its arguments. |
| |
| [`Float`](/pkg/math/big/#Float) adds a new |
| [`Sqrt`](/pkg/math/big/#Float.Sqrt) method to |
| compute square roots. |
| |
| #### [math/cmplx](/pkg/math/cmplx/) |
| |
| Branch cuts and other boundary cases in |
| [`Asin`](/pkg/math/cmplx/#Asin), |
| [`Asinh`](/pkg/math/cmplx/#Asinh), |
| [`Atan`](/pkg/math/cmplx/#Atan), |
| and |
| [`Sqrt`](/pkg/math/cmplx/#Sqrt) |
| have been corrected to match the definitions used in the C99 standard. |
| |
| #### [math/rand](/pkg/math/rand/) |
| |
| The new [`Shuffle`](/pkg/math/rand/#Shuffle) function and corresponding |
| [`Rand.Shuffle`](/pkg/math/rand/#Rand.Shuffle) method |
| shuffle an input sequence. |
| |
| #### [math](/pkg/math/) |
| |
| The new functions |
| [`Round`](/pkg/math/#Round) |
| and |
| [`RoundToEven`](/pkg/math/#RoundToEven) |
| round their arguments to the nearest floating-point integer; |
| `Round` rounds a half-integer to its larger integer neighbor (away from zero) |
| while `RoundToEven` rounds a half-integer to its even integer neighbor. |
| |
| The new functions |
| [`Erfinv`](/pkg/math/#Erfinv) |
| and |
| [`Erfcinv`](/pkg/math/#Erfcinv) |
| compute the inverse error function and the |
| inverse complementary error function. |
| |
| #### [mime/multipart](/pkg/mime/multipart/) |
| |
| [`Reader`](/pkg/mime/multipart/#Reader) |
| now accepts parts with empty filename attributes. |
| |
| #### [mime](/pkg/mime/) |
| |
| [`ParseMediaType`](/pkg/mime/#ParseMediaType) now discards |
| invalid attribute values; previously it returned those values as empty strings. |
| |
| #### [net](/pkg/net/) |
| |
| The [`Conn`](/pkg/net/#Conn) and |
| [`Listener`](/pkg/net/#Conn) implementations |
| in this package now guarantee that when `Close` returns, |
| the underlying file descriptor has been closed. |
| (In earlier releases, if the `Close` stopped pending I/O |
| in other goroutines, the closing of the file descriptor could happen in one of those |
| goroutines shortly after `Close` returned.) |
| |
| [`TCPListener`](/pkg/net/#TCPListener) and |
| [`UnixListener`](/pkg/net/#UnixListener) |
| now implement |
| [`syscall.Conn`](/pkg/syscall/#Conn), |
| to allow setting options on the underlying file descriptor |
| using [`syscall.RawConn.Control`](/pkg/syscall/#RawConn). |
| |
| The `Conn` implementations returned by [`Pipe`](/pkg/net/#Pipe) |
| now support setting read and write deadlines. |
| |
| The [`IPConn.ReadMsgIP`](/pkg/net/#IPConn.ReadMsgIP), |
| [`IPConn.WriteMsgIP`](/pkg/net/#IPConn.WriteMsgIP), |
| [`UDPConn.ReadMsgUDP`](/pkg/net/#UDPConn.ReadMsgUDP), |
| and |
| [`UDPConn.WriteMsgUDP`](/pkg/net/#UDPConn.WriteMsgUDP), |
| methods are now implemented on Windows. |
| |
| #### [net/http](/pkg/net/http/) |
| |
| On the client side, an HTTP proxy (most commonly configured by |
| [`ProxyFromEnvironment`](/pkg/net/http/#ProxyFromEnvironment)) |
| can now be specified as an `https://` URL, |
| meaning that the client connects to the proxy over HTTPS before issuing a standard, proxied HTTP request. |
| (Previously, HTTP proxy URLs were required to begin with `http://` or `socks5://`.) |
| |
| On the server side, [`FileServer`](/pkg/net/http/#FileServer) and its single-file equivalent [`ServeFile`](/pkg/net/http/#ServeFile) |
| now apply `If-Range` checks to `HEAD` requests. |
| `FileServer` also now reports directory read failures to the [`Server`](/pkg/net/http/#Server)'s `ErrorLog`. |
| The content-serving handlers also now omit the `Content-Type` header when serving zero-length content. |
| |
| [`ResponseWriter`](/pkg/net/http/#ResponseWriter)'s `WriteHeader` method now panics |
| if passed an invalid (non-3-digit) status code. |
| |
| <!-- CL 46631 --> |
| The `Server` will no longer add an implicit Content-Type when a `Handler` does not write any output. |
| |
| [`Redirect`](/pkg/net/http/#Redirect) now sets the `Content-Type` header before writing its HTTP response. |
| |
| #### [net/mail](/pkg/net/mail/) |
| |
| [`ParseAddress`](/pkg/net/mail/#ParseAddress) and |
| [`ParseAddressList`](/pkg/net/mail/#ParseAddressList) |
| now support a variety of obsolete address formats. |
| |
| #### [net/smtp](/pkg/net/smtp/) |
| |
| The [`Client`](/pkg/net/smtp/#Client) adds a new |
| [`Noop`](/pkg/net/smtp/#Client.Noop) method, |
| to test whether the server is still responding. |
| It also now defends against possible SMTP injection in the inputs |
| to the [`Hello`](/pkg/net/smtp/#Client.Hello) |
| and [`Verify`](/pkg/net/smtp/#Client.Verify) methods. |
| |
| #### [net/textproto](/pkg/net/textproto/) |
| |
| [`ReadMIMEHeader`](/pkg/net/textproto/#ReadMIMEHeader) |
| now rejects any header that begins with a continuation (indented) header line. |
| Previously a header with an indented first line was treated as if the first line |
| were not indented. |
| |
| #### [net/url](/pkg/net/url/) |
| |
| [`ResolveReference`](/pkg/net/url/#ResolveReference) |
| now preserves multiple leading slashes in the target URL. |
| Previously it rewrote multiple leading slashes to a single slash, |
| which resulted in the [`http.Client`](/pkg/net/http/#Client) |
| following certain redirects incorrectly. |
| |
| For example, this code's output has changed: |
| |
| base, _ := url.Parse("http://host//path//to/page1") |
| target, _ := url.Parse("page2") |
| fmt.Println(base.ResolveReference(target)) |
| |
| Note the doubled slashes around `path`. |
| In Go 1.9 and earlier, the resolved URL was `http://host/path//to/page2`: |
| the doubled slash before `path` was incorrectly rewritten |
| to a single slash, while the doubled slash after `path` was |
| correctly preserved. |
| Go 1.10 preserves both doubled slashes, resolving to `http://host//path//to/page2` |
| as required by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-5.2). |
| |
| This change may break existing buggy programs that unintentionally |
| construct a base URL with a leading doubled slash in the path and inadvertently |
| depend on `ResolveReference` to correct that mistake. |
| For example, this can happen if code adds a host prefix |
| like `http://host/` to a path like `/my/api`, |
| resulting in a URL with a doubled slash: `http://host//my/api`. |
| |
| [`UserInfo`](/pkg/net/url/#UserInfo)'s methods |
| now treat a nil receiver as equivalent to a pointer to a zero `UserInfo`. |
| Previously, they panicked. |
| |
| #### [os](/pkg/os/) |
| |
| [`File`](/pkg/os/#File) adds new methods |
| [`SetDeadline`](/pkg/os/#File.SetDeadline), |
| [`SetReadDeadline`](/pkg/os/#File.SetReadDeadline), |
| and |
| [`SetWriteDeadline`](/pkg/os/#File.SetWriteDeadline) |
| that allow setting I/O deadlines when the |
| underlying file descriptor supports non-blocking I/O operations. |
| The definition of these methods matches those in [`net.Conn`](/pkg/net/#Conn). |
| If an I/O method fails due to missing a deadline, it will return a |
| timeout error; the |
| new [`IsTimeout`](/pkg/os/#IsTimeout) function |
| reports whether an error represents a timeout. |
| |
| Also matching `net.Conn`, |
| `File`'s |
| [`Close`](/pkg/os/#File.Close) method |
| now guarantee that when `Close` returns, |
| the underlying file descriptor has been closed. |
| (In earlier releases, |
| if the `Close` stopped pending I/O |
| in other goroutines, the closing of the file descriptor could happen in one of those |
| goroutines shortly after `Close` returned.) |
| |
| On BSD, macOS, and Solaris systems, |
| [`Chtimes`](/pkg/os/#Chtimes) |
| now supports setting file times with nanosecond precision |
| (assuming the underlying file system can represent them). |
| |
| #### [reflect](/pkg/reflect/) |
| |
| The [`Copy`](/pkg/reflect/#Copy) function now allows copying |
| from a string into a byte array or byte slice, to match the |
| [built-in copy function](/pkg/builtin/#copy). |
| |
| In structs, embedded pointers to unexported struct types were |
| previously incorrectly reported with an empty `PkgPath` |
| in the corresponding [StructField](/pkg/reflect/#StructField), |
| with the result that for those fields, |
| and [`Value.CanSet`](/pkg/reflect/#Value.CanSet) |
| incorrectly returned true and |
| [`Value.Set`](/pkg/reflect/#Value.Set) |
| incorrectly succeeded. |
| The underlying metadata has been corrected; |
| for those fields, |
| `CanSet` now correctly returns false |
| and `Set` now correctly panics. |
| This may affect reflection-based unmarshalers |
| that could previously unmarshal into such fields |
| but no longer can. |
| For example, see the [`encoding/json` notes](#encoding/json). |
| |
| #### [runtime/pprof](/pkg/runtime/pprof/) |
| |
| As [noted above](#pprof), the blocking and mutex profiles |
| now include symbol information so that they can be viewed without needing |
| the binary that generated them. |
| |
| #### [strconv](/pkg/strconv/) |
| |
| [`ParseUint`](/pkg/strconv/#ParseUint) now returns |
| the maximum magnitude integer of the appropriate size |
| with any `ErrRange` error, as it was already documented to do. |
| Previously it returned 0 with `ErrRange` errors. |
| |
| #### [strings](/pkg/strings/) |
| |
| A new type |
| [`Builder`](/pkg/strings/#Builder) is a replacement for |
| [`bytes.Buffer`](/pkg/bytes/#Buffer) for the use case of |
| accumulating text into a `string` result. |
| The `Builder`'s API is a restricted subset of `bytes.Buffer`'s |
| that allows it to safely avoid making a duplicate copy of the data |
| during the [`String`](/pkg/strings/#Builder.String) method. |
| |
| #### [syscall](/pkg/syscall/) |
| |
| On Windows, |
| the new [`SysProcAttr`](/pkg/syscall/#SysProcAttr) field `Token`, |
| of type [`Token`](/pkg/syscall/#Token) allows the creation of a process that |
| runs as another user during [`StartProcess`](/pkg/syscall/#StartProcess) |
| (and therefore also during [`os.StartProcess`](/pkg/os/#StartProcess) and |
| [`exec.Cmd.Start`](/pkg/os/exec/#Cmd.Start)). |
| The new function [`CreateProcessAsUser`](/pkg/syscall/#CreateProcessAsUser) |
| gives access to the underlying system call. |
| |
| On BSD, macOS, and Solaris systems, [`UtimesNano`](/pkg/syscall/#UtimesNano) |
| is now implemented. |
| |
| #### [time](/pkg/time/) |
| |
| [`LoadLocation`](/pkg/time/#LoadLocation) now uses the directory |
| or uncompressed zip file named by the `$ZONEINFO` |
| environment variable before looking in the default system-specific list of |
| known installation locations or in `$GOROOT/lib/time/zoneinfo.zip`. |
| |
| The new function [`LoadLocationFromTZData`](/pkg/time/#LoadLocationFromTZData) |
| allows conversion of IANA time zone file data to a [`Location`](/pkg/time/#Location). |
| |
| #### [unicode](/pkg/unicode/) |
| |
| The [`unicode`](/pkg/unicode/) package and associated |
| support throughout the system has been upgraded from Unicode 9.0 to |
| [Unicode 10.0](https://www.unicode.org/versions/Unicode10.0.0/), |
| which adds 8,518 new characters, including four new scripts, one new property, |
| a Bitcoin currency symbol, and 56 new emoji. |