10 Go 1.10 Release Notes
Go 1.10 Release Notes
Introduction to Go 1.10
The latest Go release, version 1.10, arrives six months after Go 1.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. We expect almost all Go programs to continue to compile and run as before.
This release improves caching of built packages, adds caching of successful test results, runs vet automatically during tests, and permits passing string values directly between Go and C using cgo. A new compiler option whitelist may cause unexpected invalid flag errors in code that built successfully with older releases.
Changes to the language
There are no significant changes to the language specification.
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 package already did.
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
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 and improvements to the code generated by the compilers.
As announced in the Go 1.9 release notes, 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) andGOMIPS=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
Default GOROOT & GOTMPDIR
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 creates its temporary files and directories in that directory instead.
Build & Install
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.
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 gohelp cache.
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.
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 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 and the test2json documentation.
Cgo
Options specified by cgo using #cgo CFLAGS and the like are now checked against a whitelist of permitted options. This closes a security hole in which a downloaded package uses compiler options like -fplugin 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.
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 CC_FOR_goos_goarch 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.
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
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
The go get command now supports Fossil source code repositories.
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 profile visualizer has been updated to git version 9e20b5b (2017-11-08) from github.com/google/pprof, which includes an updated web interface.
Vet
The go 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
This release includes a new overview of available Go program diagnostic tools.
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
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 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
For the ARM 32-bit port, the assembler now supports the instructions BFC, BFI, BFX, BFXU, FMULAD, FMULAF, FMULSD,FMULSF, FNMULAD, FNMULAF, FNMULSD, FNMULSF, MULAD, MULAF, MULSD, MULSF, NMULAD, NMULAF, NMULD, NMULF, NMULSD, NMULSF,XTAB, XTABU, XTAH, and XTAHU.
For the ARM 64-bit port, the assembler now supports the VADD, VADDP, VADDV, VAND, VCMEQ, VDUP, VEOR, VLD1, VMOV,VMOVI, VMOVS, VORR, VREV32, and VST1 instructions.
For the PowerPC 64-bit port, the assembler now supports the POWER9 instructions ADDEX, CMPEQB, COPY, DARN,LDMX, MADDHD, MADDHDU, MADDLD, MFVSRLD, MTVSRDD, MTVSRWS, PASTECC, VCMPNEZB, VCMPNEZBCC, and VMSUMUDM.
For the S390X port, the assembler now supports the TMHH, TMHL, TMLH, and TMLL 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 MOVL $0, AX as an XORL instruction, to avoid clearing the condition flags unexpectedly.
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
The behavior of nested calls to LockOSThread and 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 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 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 setting. (In Go 1.9 the limit was 1024.)
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
Many applications should experience significantly lower allocation latency and overall performance overhead when the garbage collector is active.
Core library
All of the changes to the standard library are minor. The changes in bytes and net/url are the most likely to require updating of existing programs.
Minor changes to the library
As always, there are various minor changes and updates to the library, made with the Go 1 promise of compatibility in mind.
- archive/tar
-
In general, the handling of special header formats is significantly improved and expanded.
FileInfoHeaderhas always recorded the Unix UID and GID numbers from itsos.FileInfoargument (specifically, from the system-dependent information returned by theFileInfo'sSysmethod) in the returnedHeader. 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.Formatfield of typeFormatcontrols which tar header format theWriteruses. 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). TheReadersetsHeader.Formatfor each header it reads.Readerand theWriternow support arbitrary PAX records, using the newHeader.PAXRecordsfield, a generalization of the existingXattrsfield.The
Readerno longer insists that the file name or link name in GNU headers be valid UTF-8.When writing PAX- or GNU-format headers, the
Writernow includes theHeader.AccessTimeandHeader.ChangeTimefields (if set). When writing PAX-format headers, the times include sub-second precision.
- 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
ReaderandWriternow support the widely-understood Info-Zip extension that encodes the time separately in the 32-bit Unix “seconds since epoch” form. TheFileHeader's newModifiedfield of typetime.Timeobsoletes theModifiedTimeandModifiedDatefields, which continue to hold the MS-DOS encoding. TheReaderandWriternow 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, theModTimeandSetModTimemethods behave the same as in earlier releases; new code should useModifieddirectly.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
Writernever set the UTF-8 bit. In Go 1.9, theWriterchanged to set the UTF-8 bit almost always. This broke the creation of ZIP archives containing Shift-JIS file names. In Go 1.10, theWriternow 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 aFileHeader's newNonUTF8field to true disables the heuristic entirely for that file.The
Writeralso now supports setting the end-of-central-directory record's comment field, by calling theWriter's newSetCommentmethod.
- bufio
-
The new
Reader.SizeandWriter.Sizemethods report theReaderorWriter's underlying buffer size.
- bytes
-
The
Fields,FieldsFunc,Split, andSplitAfterfunctions 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
-
NewOFBnow panics if given an initialization vector of incorrect length, like the other constructors in the package always have. (Previously it returned a nilStreamimplementation.)
- 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
-
Certificate.Verifynow 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
CertificatefieldsURIs,PermittedIPRanges,ExcludedIPRanges,PermittedEmailAddresses,ExcludedEmailAddresses,PermittedURIDomains, andExcludedURIDomains. Certificates with invalid values for those fields are now rejected.The new
MarshalPKCS1PublicKeyandParsePKCS1PublicKeyfunctions convert an RSA public key to and from PKCS#1-encoded form.The new
MarshalPKCS8PrivateKeyfunction converts a private key to PKCS#8-encoded form. (ParsePKCS8PrivateKeyhas existed since Go 1.)
- crypto/x509/pkix
-
Namenow implements aStringmethod that formats the X.509 distinguished name in the standard RFC 2253 format.
- database/sql/driver
-
Drivers that currently hold on to the destination buffer provided by
driver.Rows.Nextshould 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 closingdriver.Rows.Drivers that want to construct a
sql.DBfor their clients can now implement theConnectorinterface and call the newsql.OpenDBfunction, instead of needing to encode all configuration into a string passed tosql.Open.Drivers that want to parse the configuration string only once per
sql.DBinstead of once persql.Conn, or that want access to eachsql.Conn's underlying context, can make theirDriverimplementations also implementDriverContext's newOpenConnectormethod.Drivers that implement
ExecerContextno longer need to implementExecer; similarly, drivers that implementQueryerContextno longer need to implementQueryer. 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
Connimplements the newSessionResetterinterface,database/sqlwill now callResetSessionbefore reusing theConnfor a new client.
- debug/elf
-
This release adds 348 new relocation constants divided between the relocation types
R_386,R_AARCH64,R_ARM,R_PPC64, andR_X86_64.
- debug/macho
-
Go 1.10 adds support for reading relocations from Mach-O sections, using the
Sectionstruct's newRelocsfield and the newReloc,RelocTypeARM,RelocTypeARM64,RelocTypeGeneric, andRelocTypeX86_64types and associated constants.Go 1.10 also adds support for the
LC_RPATHload command, represented by the typesRpathCmdandRpath, and new named constants for the various flag bits found in headers.
- encoding/asn1
-
Marshalnow 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.Marshalalso now respects struct tags containingapplicationdirectives.The new
MarshalWithParamsfunction marshals its argument as if the additional params were its associated struct field tag.Unmarshalnow respects struct field tags using theexplicitandtagdirectives.Both
MarshalandUnmarshalnow support a new struct field tagnumeric, indicating an ASN.1 NumericString.
- encoding/csv
-
Readernow disallows the use of nonsensicalCommaandCommentsettings, such as NUL, carriage return, newline, invalid runes, and the Unicode replacement character, or settingCommaandCommentequal to each other.In the case of a syntax error in a CSV record that spans multiple input lines,
Readernow reports the line on which the record started in theParseError's newStartLinefield.
- encoding/hex
-
The new functions
NewEncoderandNewDecoderprovide streaming conversions to and from hexadecimal, analogous to equivalent functions already in encoding/base32 and encoding/base64.When the functions
DecodeandDecodeStringencounter 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
-
The
Decoderadds a new methodDisallowUnknownFieldsthat 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,
Unmarshalcan 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.Unmarshalnow returns an error in this case.
- encoding/pem
-
EncodeandEncodeToMemoryno longer generate partial output when presented with a block that is impossible to encode as PEM data.
- encoding/xml
-
The new function
NewTokenDecoderis likeNewDecoderbut creates a decoder reading from aTokenReaderinstead of an XML-formatted byte stream. This is meant to enable the construction of XML stream transformers in client libraries.
- flag
-
The default
Usagefunction now prints its first line of output toCommandLine.Output()instead of assumingos.Stderr, so that the usage message is properly redirected for clients usingCommandLine.SetOutput.PrintDefaultsnow adds appropriate indentation after newlines in flag usage strings, so that multi-line usage strings display nicely.FlagSetadds new methodsErrorHandling,Name, andOutput, to retrieve the settings passed toNewFlagSetandFlagSet.SetOutput.
- go/doc
-
To support the doc change described above, functions returning slices of
T,*T,**T, and so on are now reported inT'sType'sFuncslist, instead of in thePackage'sFuncslist.
- go/importer
-
The
Forfunction now accepts a non-nil lookup argument.
- go/printer
-
The changes to the default formatting of Go source code discussed in the gofmt section above are implemented in the go/printerpackage and also affect the output of the higher-level go/format package.
- hash
-
Implementations of the
Hashinterface are now encouraged to implementencoding.BinaryMarshalerandencoding.BinaryUnmarshalerto allow saving and recreating their internal state, and all implementations in the standard library (hash/crc32, crypto/sha256, and so on) now implement those interfaces.
- html/template
-
The new
Srcsetcontent type allows for proper handling of values within thesrcsetattribute ofimgtags.
- math/big
-
Intnow supports conversions to and from bases 2 through 62 in itsSetStringandTextmethods. (Previously it only allowed bases 2 through 36.) The value of the constantMaxBasehas been updated.Intadds a newCmpAbsmethod that is likeCmpbut compares only the absolute values (not the signs) of its arguments.
- math/cmplx
-
Branch cuts and other boundary cases in
Asin,Asinh,Atan, andSqrthave been corrected to match the definitions used in the C99 standard.
- math/rand
-
The new
Shufflefunction and correspondingRand.Shufflemethod shuffle an input sequence.
- math
-
The new functions
RoundandRoundToEvenround their arguments to the nearest floating-point integer;Roundrounds a half-integer to its larger integer neighbor (away from zero) whileRoundToEvenrounds a half-integer to its even integer neighbor.The new functions
ErfinvandErfcinvcompute the inverse error function and the inverse complementary error function.
- mime/multipart
-
Readernow accepts parts with empty filename attributes.
- mime
-
ParseMediaTypenow discards invalid attribute values; previously it returned those values as empty strings.
- net
-
The
ConnandListenerimplementations in this package now guarantee that whenClosereturns, the underlying file descriptor has been closed. (In earlier releases, if theClosestopped pending I/O in other goroutines, the closing of the file descriptor could happen in one of those goroutines shortly afterClosereturned.)TCPListenerandUnixListenernow implementsyscall.Conn, to allow setting options on the underlying file descriptor usingsyscall.RawConn.Control.The
Connimplementations returned byPipenow support setting read and write deadlines.The
IPConn.ReadMsgIP,IPConn.WriteMsgIP,UDPConn.ReadMsgUDP, andUDPConn.WriteMsgUDP, methods are now implemented on Windows.
- net/http
-
On the client side, an HTTP proxy (most commonly configured by
ProxyFromEnvironment) can now be specified as anhttps://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 withhttp://orsocks5://.)On the server side,
FileServerand its single-file equivalentServeFilenow applyIf-Rangechecks toHEADrequests.FileServeralso now reports directory read failures to theServer'sErrorLog. The content-serving handlers also now omit theContent-Typeheader when serving zero-length content.ResponseWriter'sWriteHeadermethod now panics if passed an invalid (non-3-digit) status code.The
Serverwill no longer add an implicit Content-Type when aHandlerdoes not write any output.Redirectnow sets theContent-Typeheader before writing its HTTP response.
- net/mail
-
ParseAddressandParseAddressListnow support a variety of obsolete address formats.
- net/smtp
-
The
Clientadds a newNoopmethod, to test whether the server is still responding. It also now defends against possible SMTP injection in the inputs to theHelloandVerifymethods.
- net/textproto
-
ReadMIMEHeadernow 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
-
ResolveReferencenow preserves multiple leading slashes in the target URL. Previously it rewrote multiple leading slashes to a single slash, which resulted in thehttp.Clientfollowing 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 washttp://host/path//to/page2: the doubled slash beforepathwas incorrectly rewritten to a single slash, while the doubled slash afterpathwas correctly preserved. Go 1.10 preserves both doubled slashes, resolving tohttp://host//path//to/page2as required by RFC 3986.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
ResolveReferenceto correct that mistake. For example, this can happen if code adds a host prefix likehttp://host/to a path like/my/api, resulting in a URL with a doubled slash:http://host//my/api.UserInfo's methods now treat a nil receiver as equivalent to a pointer to a zeroUserInfo. Previously, they panicked.
- os
-
Fileadds new methodsSetDeadline,SetReadDeadline, andSetWriteDeadlinethat allow setting I/O deadlines when the underlying file descriptor supports non-blocking I/O operations. The definition of these methods matches those innet.Conn. If an I/O method fails due to missing a deadline, it will return a timeout error; the newIsTimeoutfunction reports whether an error represents a timeout.Also matching
net.Conn,File'sClosemethod now guarantee that whenClosereturns, the underlying file descriptor has been closed. (In earlier releases, if theClosestopped pending I/O in other goroutines, the closing of the file descriptor could happen in one of those goroutines shortly afterClosereturned.)On BSD, macOS, and Solaris systems,
Chtimesnow supports setting file times with nanosecond precision (assuming the underlying file system can represent them).
- reflect
-
The
Copyfunction now allows copying from a string into a byte array or byte slice, to match the built-in copy function.In structs, embedded pointers to unexported struct types were previously incorrectly reported with an empty
PkgPathin the corresponding StructField, with the result that for those fields, andValue.CanSetincorrectly returned true andValue.Setincorrectly succeeded. The underlying metadata has been corrected; for those fields,CanSetnow correctly returns false andSetnow correctly panics. This may affect reflection-based unmarshalers that could previously unmarshal into such fields but no longer can. For example, see theencoding/jsonnotes.
- runtime/pprof
-
As noted above, the blocking and mutex profiles now include symbol information so that they can be viewed without needing the binary that generated them.
- strconv
-
ParseUintnow returns the maximum magnitude integer of the appropriate size with anyErrRangeerror, as it was already documented to do. Previously it returned 0 withErrRangeerrors.
- strings
-
A new type
Builderis a replacement forbytes.Bufferfor the use case of accumulating text into astringresult. TheBuilder's API is a restricted subset ofbytes.Buffer's that allows it to safely avoid making a duplicate copy of the data during theStringmethod.
- syscall
-
On Windows, the new
SysProcAttrfieldToken, of typeTokenallows the creation of a process that runs as another user duringStartProcess(and therefore also duringos.StartProcessandexec.Cmd.Start). The new functionCreateProcessAsUsergives access to the underlying system call.On BSD, macOS, and Solaris systems,
UtimesNanois now implemented.
- time
-
LoadLocationnow uses the directory or uncompressed zip file named by the$ZONEINFOenvironment variable before looking in the default system-specific list of known installation locations or in$GOROOT/lib/time/zoneinfo.zip.The new function
LoadLocationFromTZDataallows conversion of IANA time zone file data to aLocation.
- unicode
-
The
unicodepackage and associated support throughout the system has been upgraded from Unicode 9.0 to Unicode 10.0, which adds 8,518 new characters, including four new scripts, one new property, a Bitcoin currency symbol, and 56 new emoji.
10 Go 1.10 Release Notes的更多相关文章
- MAGIC XPA最新版本Magic xpa 2.4c Release Notes
New Features, Feature Enhancements and Behavior ChangesSubforms – Behavior Change for Unsupported Ta ...
- Git for Windows v2.11.0 Release Notes
homepage faq contribute bugs questions Git for Windows v2.11.0 Release Notes Latest update: December ...
- 11 Go 1.11 Release Notes
Go 1.11 Release Notes Introduction to Go 1.11 Changes to the language Ports WebAssembly RISC-V GOARC ...
- 09 Go 1.9 Release Notes
Go 1.9 Release Notes Introduction to Go 1.9 Changes to the language Ports ppc64x requires POWER8 Fre ...
- 08 Go 1.8 Release Notes
Go 1.8 Release Notes Introduction to Go 1.8 Changes to the language Ports Known Issues Tools Assembl ...
- 06 Go 1.6 Release Notes
Go 1.6 Release Notes Introduction to Go 1.6 Changes to the language Ports Tools Cgo Compiler Toolcha ...
- 07 Go 1.7 Release Notes
Go 1.7 Release Notes Introduction to Go 1.7 Changes to the language Ports Known Issues Tools Assembl ...
- MongoDB 3.0 Release Notes
MongoDB 3.0支持WiredTiger存储引擎,提供可插拔存储引擎API,新增SCRAM-SHA-1认证机制,改进explain功能. 可插拔存储引擎API 允许第三方为MongoDB开发存储 ...
- 05 Go 1.5 Release Notes
Go 1.5 Release Notes Introduction to Go 1.5 Changes to the language Map literals The Implementation ...
随机推荐
- php 的优缺点
1.优点:开源 免费性 快捷性 [程序开发快,运行快,技术本身学习快] 插件丰富,网上的解决方案有很多,而且还有庞大的开源社区可以提供帮助. 跨平台性强 效率高 图像处理 面向对象 [在php4 ...
- shell 命令 if [ -d filename] 判断文件
作者:曹毅涵 [ -a FILE ] 如果 FILE 存在则为真. [ -b FILE ] 如果 FILE 存在且是一个块特殊文件则为真. [ -c FILE ] 如果 FILE 存在且是一个字特殊 ...
- C++中关键字explicit的作用
C++中, 一个参数的构造函数(或者除了第一个参数外其余参数都有默认值的多参构造函数), 承担了两个角色. 1 是个构造器 ,2 是个默认且隐含的类型转换操作符. 所以, 有时候在我们写下如 AAA ...
- mybatis 注解和xml 优缺点
xml: 增加了xml文件,修改麻烦,条件不确定(ifelse判断),容易出错,特殊转义字符比如大于小于 注释: 复杂sql不好用,搜集sql不方便,管理不方便,修改需重新编译 #和$区别: 相同 都 ...
- Mysql 间隙锁原理,以及Repeatable Read隔离级别下可以防止幻读原理(百度)
Mysql知识实在太丰富了,前几天百度的面试官问我MySql在Repeatable Read下面是否会有幻读出现,我说按照事务的特性当然会有, 但是面试官却说 Mysql 在Repeatable Re ...
- IntelliJ IDEA2017 修改缓存文件的路径
IDEA的缓存文件夹.IntelliJIdea2017.1,存放着IDEA的破解密码,各个项目的缓存,默认是在C盘的用户目录下,目前有1.5G大小.现在想要把它从C盘移出. 在IDEA的安装路径下中, ...
- python编码与存储读取数据(数组字典)
Camp时在python2的编码上坑了不少. 理解pyhon2的编码 python2字符串类型只有两种: str类型:b'xxx'即是str类型, 是编码后的类型,len()按字节计算 unicode ...
- 【Revit API】墙体分割
Revit中没有分割墙体的直接方法,一般采用调整原墙体的长度,再复制自身,调整复制体的长度.话不多说,直接上代码 public static void WallCopy(Document doc, X ...
- 【bzoj1040】 ZJOI2008—骑士
http://www.lydsy.com/JudgeOnline/problem.php?id=1040 (题目链接) 题意 一个基环森林,从中选出不相邻的若干个点使得这些点的点权和最大. Solut ...
- 使用alien命令让deb包和rpm包互相转换
OS version: CentOS7 / Debian9 发现alien这个命令时很惊喜,之前在debian上安装etcd找不到安装包感觉很不科学,有了alien命令事情一下就变简单了. 这里以et ...