From 807d4851b07d11caed1c21e95d9caba329fc1623 Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Mon, 13 Nov 2023 10:14:34 -0500 Subject: [PATCH] _content/doc: remove html release notes Now that the notes are in Markdown, we don't need the html files. For golang/go#64169. Change-Id: I25f0b636ed4101c38966a2b7d97ec5e5e3cb827e Reviewed-on: https://go-review.googlesource.com/c/website/+/541975 Run-TryBot: Jonathan Amsterdam Reviewed-by: Dmitri Shuralyov TryBot-Result: Gopher Robot Reviewed-by: Dmitri Shuralyov --- _content/doc/go1.1.html | 1097 -------------------- _content/doc/go1.10.html | 1446 --------------------------- _content/doc/go1.11.html | 932 ----------------- _content/doc/go1.12.html | 947 ------------------ _content/doc/go1.13.html | 1064 -------------------- _content/doc/go1.14.html | 929 ----------------- _content/doc/go1.15.html | 1063 -------------------- _content/doc/go1.16.html | 1237 ----------------------- _content/doc/go1.17.html | 1248 ----------------------- _content/doc/go1.18.html | 1411 -------------------------- _content/doc/go1.19.html | 1028 ------------------- _content/doc/go1.2.html | 977 ------------------ _content/doc/go1.20.html | 1291 ------------------------ _content/doc/go1.21.html | 1357 ------------------------- _content/doc/go1.3.html | 606 ------------ _content/doc/go1.4.html | 894 ----------------- _content/doc/go1.5.html | 1308 ------------------------ _content/doc/go1.6.html | 920 ----------------- _content/doc/go1.7.html | 1279 ------------------------ _content/doc/go1.8.html | 1668 ------------------------------- _content/doc/go1.9.html | 1022 ------------------- _content/doc/go1.html | 2038 -------------------------------------- 22 files changed, 25762 deletions(-) delete mode 100644 _content/doc/go1.1.html delete mode 100644 _content/doc/go1.10.html delete mode 100644 _content/doc/go1.11.html delete mode 100644 _content/doc/go1.12.html delete mode 100644 _content/doc/go1.13.html delete mode 100644 _content/doc/go1.14.html delete mode 100644 _content/doc/go1.15.html delete mode 100644 _content/doc/go1.16.html delete mode 100644 _content/doc/go1.17.html delete mode 100644 _content/doc/go1.18.html delete mode 100644 _content/doc/go1.19.html delete mode 100644 _content/doc/go1.2.html delete mode 100644 _content/doc/go1.20.html delete mode 100644 _content/doc/go1.21.html delete mode 100644 _content/doc/go1.3.html delete mode 100644 _content/doc/go1.4.html delete mode 100644 _content/doc/go1.5.html delete mode 100644 _content/doc/go1.6.html delete mode 100644 _content/doc/go1.7.html delete mode 100644 _content/doc/go1.8.html delete mode 100644 _content/doc/go1.9.html delete mode 100644 _content/doc/go1.html diff --git a/_content/doc/go1.1.html b/_content/doc/go1.1.html deleted file mode 100644 index 14d39352ee..0000000000 --- a/_content/doc/go1.1.html +++ /dev/null @@ -1,1097 +0,0 @@ - - -

Introduction to Go 1.1

- -

-The release of Go version 1 (Go 1 or Go 1.0 for short) -in March of 2012 introduced a new period -of stability in the Go language and libraries. -That stability has helped nourish a growing community of Go users -and systems around the world. -Several "point" releases since -then—1.0.1, 1.0.2, and 1.0.3—have been issued. -These point releases fixed known bugs but made -no non-critical changes to the implementation. -

- -

-This new release, Go 1.1, keeps the promise -of compatibility but adds a couple of significant -(backwards-compatible, of course) language changes, has a long list -of (again, compatible) library changes, and -includes major work on the implementation of the compilers, -libraries, and run-time. -The focus is on performance. -Benchmarking is an inexact science at best, but we see significant, -sometimes dramatic speedups for many of our test programs. -We trust that many of our users' programs will also see improvements -just by updating their Go installation and recompiling. -

- -

-This document summarizes the changes between Go 1 and Go 1.1. -Very little if any code will need modification to run with Go 1.1, -although a couple of rare error cases surface with this release -and need to be addressed if they arise. -Details appear below; see the discussion of -64-bit ints and Unicode literals -in particular. -

- -

Changes to the language

- -

-The Go compatibility document promises -that programs written to the Go 1 language specification will continue to operate, -and those promises are maintained. -In the interest of firming up the specification, though, there are -details about some error cases that have been clarified. -There are also some new language features. -

- -

Integer division by zero

- -

-In Go 1, integer division by a constant zero produced a run-time panic: -

- -
-func f(x int) int {
-	return x/0
-}
-
- -

-In Go 1.1, an integer division by constant zero is not a legal program, so it is a compile-time error. -

- -

Surrogates in Unicode literals

- -

-The definition of string and rune literals has been refined to exclude surrogate halves from the -set of valid Unicode code points. -See the Unicode section for more information. -

- -

Method values

- -

-Go 1.1 now implements -method values, -which are functions that have been bound to a specific receiver value. -For instance, given a -Writer -value w, -the expression -w.Write, -a method value, is a function that will always write to w; it is equivalent to -a function literal closing over w: -

- -
-func (p []byte) (n int, err error) {
-	return w.Write(p)
-}
-
- -

-Method values are distinct from method expressions, which generate functions -from methods of a given type; the method expression (*bufio.Writer).Write -is equivalent to a function with an extra first argument, a receiver of type -(*bufio.Writer): -

- -
-func (w *bufio.Writer, p []byte) (n int, err error) {
-	return w.Write(p)
-}
-
- -

-Updating: No existing code is affected; the change is strictly backward-compatible. -

- -

Return requirements

- -

-Before Go 1.1, a function that returned a value needed an explicit "return" -or call to panic at -the end of the function; this was a simple way to make the programmer -be explicit about the meaning of the function. But there are many cases -where a final "return" is clearly unnecessary, such as a function with -only an infinite "for" loop. -

- -

-In Go 1.1, the rule about final "return" statements is more permissive. -It introduces the concept of a -terminating statement, -a statement that is guaranteed to be the last one a function executes. -Examples include -"for" loops with no condition and "if-else" -statements in which each half ends in a "return". -If the final statement of a function can be shown syntactically to -be a terminating statement, no final "return" statement is needed. -

- -

-Note that the rule is purely syntactic: it pays no attention to the values in the -code and therefore requires no complex analysis. -

- -

-Updating: The change is backward-compatible, but existing code -with superfluous "return" statements and calls to panic may -be simplified manually. -Such code can be identified by go vet. -

- -

Changes to the implementations and tools

- -

Status of gccgo

- -

-The GCC release schedule does not coincide with the Go release schedule, so some skew is inevitable in -gccgo's releases. -The 4.8.0 version of GCC shipped in March, 2013 and includes a nearly-Go 1.1 version of gccgo. -Its library is a little behind the release, but the biggest difference is that method values are not implemented. -Sometime around July 2013, we expect 4.8.2 of GCC to ship with a gccgo -providing a complete Go 1.1 implementation. -

- -

Command-line flag parsing

- -

-In the gc toolchain, the compilers and linkers now use the -same command-line flag parsing rules as the Go flag package, a departure -from the traditional Unix flag parsing. This may affect scripts that invoke -the tool directly. -For example, -go tool 6c -Fw -Dfoo must now be written -go tool 6c -F -w -D foo. -

- -

Size of int on 64-bit platforms

- -

-The language allows the implementation to choose whether the int type and -uint types are 32 or 64 bits. Previous Go implementations made int -and uint 32 bits on all systems. Both the gc and gccgo implementations -now make -int and uint 64 bits on 64-bit platforms such as AMD64/x86-64. -Among other things, this enables the allocation of slices with -more than 2 billion elements on 64-bit platforms. -

- -

-Updating: -Most programs will be unaffected by this change. -Because Go does not allow implicit conversions between distinct -numeric types, -no programs will stop compiling due to this change. -However, programs that contain implicit assumptions -that int is only 32 bits may change behavior. -For example, this code prints a positive number on 64-bit systems and -a negative one on 32-bit systems: -

- -
-x := ^uint32(0) // x is 0xffffffff
-i := int(x)     // i is -1 on 32-bit systems, 0xffffffff on 64-bit
-fmt.Println(i)
-
- -

Portable code intending 32-bit sign extension (yielding -1 on all systems) -would instead say: -

- -
-i := int(int32(x))
-
- -

Heap size on 64-bit architectures

- -

-On 64-bit architectures, the maximum heap size has been enlarged substantially, -from a few gigabytes to several tens of gigabytes. -(The exact details depend on the system and may change.) -

- -

-On 32-bit architectures, the heap size has not changed. -

- -

-Updating: -This change should have no effect on existing programs beyond allowing them -to run with larger heaps. -

- -

Unicode

- -

-To make it possible to represent code points greater than 65535 in UTF-16, -Unicode defines surrogate halves, -a range of code points to be used only in the assembly of large values, and only in UTF-16. -The code points in that surrogate range are illegal for any other purpose. -In Go 1.1, this constraint is honored by the compiler, libraries, and run-time: -a surrogate half is illegal as a rune value, when encoded as UTF-8, or when -encoded in isolation as UTF-16. -When encountered, for example in converting from a rune to UTF-8, it is -treated as an encoding error and will yield the replacement rune, -utf8.RuneError, -U+FFFD. -

- -

-This program, -

- -
-import "fmt"
-
-func main() {
-    fmt.Printf("%+q\n", string(0xD800))
-}
-
- -

-printed "\ud800" in Go 1.0, but prints "\ufffd" in Go 1.1. -

- -

-Surrogate-half Unicode values are now illegal in rune and string constants, so constants such as -'\ud800' and "\ud800" are now rejected by the compilers. -When written explicitly as UTF-8 encoded bytes, -such strings can still be created, as in "\xed\xa0\x80". -However, when such a string is decoded as a sequence of runes, as in a range loop, it will yield only utf8.RuneError -values. -

- -

-The Unicode byte order mark U+FEFF, encoded in UTF-8, is now permitted as the first -character of a Go source file. -Even though its appearance in the byte-order-free UTF-8 encoding is clearly unnecessary, -some editors add the mark as a kind of "magic number" identifying a UTF-8 encoded file. -

- -

-Updating: -Most programs will be unaffected by the surrogate change. -Programs that depend on the old behavior should be modified to avoid the issue. -The byte-order-mark change is strictly backward-compatible. -

- -

Race detector

- -

-A major addition to the tools is a race detector, a way to -find bugs in programs caused by concurrent access of the same -variable, where at least one of the accesses is a write. -This new facility is built into the go tool. -For now, it is only available on Linux, Mac OS X, and Windows systems with -64-bit x86 processors. -To enable it, set the -race flag when building or testing your program -(for instance, go test -race). -The race detector is documented in a separate article. -

- -

The gc assemblers

- -

-Due to the change of the int to 64 bits and -a new internal representation of functions, -the arrangement of function arguments on the stack has changed in the gc toolchain. -Functions written in assembly will need to be revised at least -to adjust frame pointer offsets. -

- -

-Updating: -The go vet command now checks that functions implemented in assembly -match the Go function prototypes they implement. -

- -

Changes to the go command

- -

-The go command has acquired several -changes intended to improve the experience for new Go users. -

- -

-First, when compiling, testing, or running Go code, the go command will now give more detailed error messages, -including a list of paths searched, when a package cannot be located. -

- -
-$ go build foo/quxx
-can't load package: package foo/quxx: cannot find package "foo/quxx" in any of:
-        /home/you/go/src/pkg/foo/quxx (from $GOROOT)
-        /home/you/src/foo/quxx (from $GOPATH)
-
- -

-Second, the go get command no longer allows $GOROOT -as the default destination when downloading package source. -To use the go get -command, a valid $GOPATH is now required. -

- -
-$ GOPATH= go get code.google.com/p/foo/quxx
-package code.google.com/p/foo/quxx: cannot download, $GOPATH not set. For more details see: go help gopath
-
- -

-Finally, as a result of the previous change, the go get command will also fail -when $GOPATH and $GOROOT are set to the same value. -

- -
-$ GOPATH=$GOROOT go get code.google.com/p/foo/quxx
-warning: GOPATH set to GOROOT (/home/you/go) has no effect
-package code.google.com/p/foo/quxx: cannot download, $GOPATH must not be set to $GOROOT. For more details see: go help gopath
-
- -

Changes to the go test command

- -

-The go test -command no longer deletes the binary when run with profiling enabled, -to make it easier to analyze the profile. -The implementation sets the -c flag automatically, so after running, -

- -
-$ go test -cpuprofile cpuprof.out mypackage
-
- -

-the file mypackage.test will be left in the directory where go test was run. -

- -

-The go test -command can now generate profiling information -that reports where goroutines are blocked, that is, -where they tend to stall waiting for an event such as a channel communication. -The information is presented as a -blocking profile -enabled with the --blockprofile -option of -go test. -Run go help test for more information. -

- -

Changes to the go fix command

- -

-The fix command, usually run as -go fix, no longer applies fixes to update code from -before Go 1 to use Go 1 APIs. -To update pre-Go 1 code to Go 1.1, use a Go 1.0 toolchain -to convert the code to Go 1.0 first. -

- -

Build constraints

- -

-The "go1.1" tag has been added to the list of default -build constraints. -This permits packages to take advantage of the new features in Go 1.1 while -remaining compatible with earlier versions of Go. -

- -

-To build a file only with Go 1.1 and above, add this build constraint: -

- -
-// +build go1.1
-
- -

-To build a file only with Go 1.0.x, use the converse constraint: -

- -
-// +build !go1.1
-
- -

Additional platforms

- -

-The Go 1.1 toolchain adds experimental support for freebsd/arm, -netbsd/386, netbsd/amd64, netbsd/arm, -openbsd/386 and openbsd/amd64 platforms. -

- -

-An ARMv6 or later processor is required for freebsd/arm or -netbsd/arm. -

- -

-Go 1.1 adds experimental support for cgo on linux/arm. -

- -

Cross compilation

- -

-When cross-compiling, the go tool will disable cgo -support by default. -

- -

-To explicitly enable cgo, set CGO_ENABLED=1. -

- -

Performance

- -

-The performance of code compiled with the Go 1.1 gc tool suite should be noticeably -better for most Go programs. -Typical improvements relative to Go 1.0 seem to be about 30%-40%, sometimes -much more, but occasionally less or even non-existent. -There are too many small performance-driven tweaks through the tools and libraries -to list them all here, but the following major changes are worth noting: -

- -
    -
  • The gc compilers generate better code in many cases, most noticeably for -floating point on the 32-bit Intel architecture.
  • -
  • The gc compilers do more in-lining, including for some operations -in the run-time such as append -and interface conversions.
  • -
  • There is a new implementation of Go maps with significant reduction in -memory footprint and CPU time.
  • -
  • The garbage collector has been made more parallel, which can reduce -latencies for programs running on multiple CPUs.
  • -
  • The garbage collector is also more precise, which costs a small amount of -CPU time but can reduce the size of the heap significantly, especially -on 32-bit architectures.
  • -
  • Due to tighter coupling of the run-time and network libraries, fewer -context switches are required on network operations.
  • -
- -

Changes to the standard library

- -

bufio.Scanner

- -

-The various routines to scan textual input in the -bufio -package, -ReadBytes, -ReadString -and particularly -ReadLine, -are needlessly complex to use for simple purposes. -In Go 1.1, a new type, -Scanner, -has been added to make it easier to do simple tasks such as -read the input as a sequence of lines or space-delimited words. -It simplifies the problem by terminating the scan on problematic -input such as pathologically long lines, and having a simple -default: line-oriented input, with each line stripped of its terminator. -Here is code to reproduce the input a line at a time: -

- -
-scanner := bufio.NewScanner(os.Stdin)
-for scanner.Scan() {
-    fmt.Println(scanner.Text()) // Println will add back the final '\n'
-}
-if err := scanner.Err(); err != nil {
-    fmt.Fprintln(os.Stderr, "reading standard input:", err)
-}
-
- -

-Scanning behavior can be adjusted through a function to control subdividing the input -(see the documentation for SplitFunc), -but for tough problems or the need to continue past errors, the older interface -may still be required. -

- -

net

- -

-The protocol-specific resolvers in the net package were formerly -lax about the network name passed in. -Although the documentation was clear -that the only valid networks for -ResolveTCPAddr -are "tcp", -"tcp4", and "tcp6", the Go 1.0 implementation silently accepted any string. -The Go 1.1 implementation returns an error if the network is not one of those strings. -The same is true of the other protocol-specific resolvers ResolveIPAddr, -ResolveUDPAddr, and -ResolveUnixAddr. -

- -

-The previous implementation of -ListenUnixgram -returned a -UDPConn as -a representation of the connection endpoint. -The Go 1.1 implementation instead returns a -UnixConn -to allow reading and writing -with its -ReadFrom -and -WriteTo -methods. -

- -

-The data structures -IPAddr, -TCPAddr, and -UDPAddr -add a new string field called Zone. -Code using untagged composite literals (e.g. net.TCPAddr{ip, port}) -instead of tagged literals (net.TCPAddr{IP: ip, Port: port}) -will break due to the new field. -The Go 1 compatibility rules allow this change: client code must use tagged literals to avoid such breakages. -

- -

-Updating: -To correct breakage caused by the new struct field, -go fix will rewrite code to add tags for these types. -More generally, go vet will identify composite literals that -should be revised to use field tags. -

- -

reflect

- -

-The reflect package has several significant additions. -

- -

-It is now possible to run a "select" statement using -the reflect package; see the description of -Select -and -SelectCase -for details. -

- -

-The new method -Value.Convert -(or -Type.ConvertibleTo) -provides functionality to execute a Go conversion or type assertion operation -on a -Value -(or test for its possibility). -

- -

-The new function -MakeFunc -creates a wrapper function to make it easier to call a function with existing -Values, -doing the standard Go conversions among the arguments, for instance -to pass an actual int to a formal interface{}. -

- -

-Finally, the new functions -ChanOf, -MapOf -and -SliceOf -construct new -Types -from existing types, for example to construct the type []T given -only T. -

- - -

time

-

-On FreeBSD, Linux, NetBSD, OS X and OpenBSD, previous versions of the -time package -returned times with microsecond precision. -The Go 1.1 implementation on these -systems now returns times with nanosecond precision. -Programs that write to an external format with microsecond precision -and read it back, expecting to recover the original value, will be affected -by the loss of precision. -There are two new methods of Time, -Round -and -Truncate, -that can be used to remove precision from a time before passing it to -external storage. -

- -

-The new method -YearDay -returns the one-indexed integral day number of the year specified by the time value. -

- -

-The -Timer -type has a new method -Reset -that modifies the timer to expire after a specified duration. -

- -

-Finally, the new function -ParseInLocation -is like the existing -Parse -but parses the time in the context of a location (time zone), ignoring -time zone information in the parsed string. -This function addresses a common source of confusion in the time API. -

- -

-Updating: -Code that needs to read and write times using an external format with -lower precision should be modified to use the new methods. -

- -

Exp and old subtrees moved to go.exp and go.text subrepositories

- -

-To make it easier for binary distributions to access them if desired, the exp -and old source subtrees, which are not included in binary distributions, -have been moved to the new go.exp subrepository at -code.google.com/p/go.exp. To access the ssa package, -for example, run -

- -
-$ go get code.google.com/p/go.exp/ssa
-
- -

-and then in Go source, -

- -
-import "code.google.com/p/go.exp/ssa"
-
- -

-The old package exp/norm has also been moved, but to a new repository -go.text, where the Unicode APIs and other text-related packages will -be developed. -

- -

New packages

- -

-There are three new packages. -

- -
    -
  • -The go/format package provides -a convenient way for a program to access the formatting capabilities of the -go fmt command. -It has two functions, -Node to format a Go parser -Node, -and -Source -to reformat arbitrary Go source code into the standard format as provided by the -go fmt command. -
  • - -
  • -The net/http/cookiejar package provides the basics for managing HTTP cookies. -
  • - -
  • -The runtime/race package provides low-level facilities for data race detection. -It is internal to the race detector and does not otherwise export any user-visible functionality. -
  • -
- -

Minor changes to the library

- -

-The following list summarizes a number of minor changes to the library, mostly additions. -See the relevant package documentation for more information about each change. -

- -
    -
  • -The bytes package has two new functions, -TrimPrefix -and -TrimSuffix, -with self-evident properties. -Also, the Buffer type -has a new method -Grow that -provides some control over memory allocation inside the buffer. -Finally, the -Reader type now has a -WriteTo method -so it implements the -io.WriterTo interface. -
  • - -
  • -The compress/gzip package has -a new Flush -method for its -Writer -type that flushes its underlying flate.Writer. -
  • - -
  • -The crypto/hmac package has a new function, -Equal, to compare two MACs. -
  • - -
  • -The crypto/x509 package -now supports PEM blocks (see -DecryptPEMBlock for instance), -and a new function -ParseECPrivateKey to parse elliptic curve private keys. -
  • - -
  • -The database/sql package -has a new -Ping -method for its -DB -type that tests the health of the connection. -
  • - -
  • -The database/sql/driver package -has a new -Queryer -interface that a -Conn -may implement to improve performance. -
  • - -
  • -The encoding/json package's -Decoder -has a new method -Buffered -to provide access to the remaining data in its buffer, -as well as a new method -UseNumber -to unmarshal a value into the new type -Number, -a string, rather than a float64. -
  • - -
  • -The encoding/xml package -has a new function, -EscapeText, -which writes escaped XML output, -and a method on -Encoder, -Indent, -to specify indented output. -
  • - -
  • -In the go/ast package, a -new type CommentMap -and associated methods makes it easier to extract and process comments in Go programs. -
  • - -
  • -In the go/doc package, -the parser now keeps better track of stylized annotations such as TODO(joe) -throughout the code, -information that the godoc -command can filter or present according to the value of the -notes flag. -
  • - -
  • -The undocumented and only partially implemented "noescape" feature of the -html/template -package has been removed; programs that depend on it will break. -
  • - -
  • -The image/jpeg package now -reads progressive JPEG files and handles a few more subsampling configurations. -
  • - -
  • -The io package now exports the -io.ByteWriter interface to capture the common -functionality of writing a byte at a time. -It also exports a new error, ErrNoProgress, -used to indicate a Read implementation is looping without delivering data. -
  • - -
  • -The log/syslog package now provides better support -for OS-specific logging features. -
  • - -
  • -The math/big package's -Int type -now has methods -MarshalJSON -and -UnmarshalJSON -to convert to and from a JSON representation. -Also, -Int -can now convert directly to and from a uint64 using -Uint64 -and -SetUint64, -while -Rat -can do the same with float64 using -Float64 -and -SetFloat64. -
  • - -
  • -The mime/multipart package -has a new method for its -Writer, -SetBoundary, -to define the boundary separator used to package the output. -The Reader also now -transparently decodes any quoted-printable parts and removes -the Content-Transfer-Encoding header when doing so. -
  • - -
  • -The -net package's -ListenUnixgram -function has changed return types: it now returns a -UnixConn -rather than a -UDPConn, which was -clearly a mistake in Go 1.0. -Since this API change fixes a bug, it is permitted by the Go 1 compatibility rules. -
  • - -
  • -The net package includes a new type, -Dialer, to supply options to -Dial. -
  • - -
  • -The net package adds support for -link-local IPv6 addresses with zone qualifiers, such as fe80::1%lo0. -The address structures IPAddr, -UDPAddr, and -TCPAddr -record the zone in a new field, and functions that expect string forms of these addresses, such as -Dial, -ResolveIPAddr, -ResolveUDPAddr, and -ResolveTCPAddr, -now accept the zone-qualified form. -
  • - -
  • -The net package adds -LookupNS to its suite of resolving functions. -LookupNS returns the NS records for a host name. -
  • - -
  • -The net package adds protocol-specific -packet reading and writing methods to -IPConn -(ReadMsgIP -and WriteMsgIP) and -UDPConn -(ReadMsgUDP and -WriteMsgUDP). -These are specialized versions of PacketConn's -ReadFrom and WriteTo methods that provide access to out-of-band data associated -with the packets. -
  • - -
  • -The net package adds methods to -UnixConn to allow closing half of the connection -(CloseRead and -CloseWrite), -matching the existing methods of TCPConn. -
  • - -
  • -The net/http package includes several new additions. -ParseTime parses a time string, trying -several common HTTP time formats. -The PostFormValue method of -Request is like -FormValue but ignores URL parameters. -The CloseNotifier interface provides a mechanism -for a server handler to discover when a client has disconnected. -The ServeMux type now has a -Handler method to access a path's -Handler without executing it. -The Transport can now cancel an in-flight request with -CancelRequest. -Finally, the Transport is now more aggressive at closing TCP connections when -a Response.Body is closed before -being fully consumed. -
  • - -
  • -The net/mail package has two new functions, -ParseAddress and -ParseAddressList, -to parse RFC 5322-formatted mail addresses into -Address structures. -
  • - -
  • -The net/smtp package's -Client type has a new method, -Hello, -which transmits a HELO or EHLO message to the server. -
  • - -
  • -The net/textproto package -has two new functions, -TrimBytes and -TrimString, -which do ASCII-only trimming of leading and trailing spaces. -
  • - -
  • -The new method os.FileMode.IsRegular makes it easy to ask if a file is a plain file. -
  • - -
  • -The os/signal package has a new function, -Stop, which stops the package delivering -any further signals to the channel. -
  • - -
  • -The regexp package -now supports Unix-original leftmost-longest matches through the -Regexp.Longest -method, while -Regexp.Split slices -strings into pieces based on separators defined by the regular expression. -
  • - -
  • -The runtime/debug package -has three new functions regarding memory usage. -The FreeOSMemory -function triggers a run of the garbage collector and then attempts to return unused -memory to the operating system; -the ReadGCStats -function retrieves statistics about the collector; and -SetGCPercent -provides a programmatic way to control how often the collector runs, -including disabling it altogether. -
  • - -
  • -The sort package has a new function, -Reverse. -Wrapping the argument of a call to -sort.Sort -with a call to Reverse causes the sort order to be reversed. -
  • - -
  • -The strings package has two new functions, -TrimPrefix -and -TrimSuffix -with self-evident properties, and the new method -Reader.WriteTo so the -Reader -type now implements the -io.WriterTo interface. -
  • - -
  • -The syscall package's -Fchflags function on various BSDs -(including Darwin) has changed signature. -It now takes an int as the first parameter instead of a string. -Since this API change fixes a bug, it is permitted by the Go 1 compatibility rules. -
  • -
  • -The syscall package also has received many updates -to make it more inclusive of constants and system calls for each supported operating system. -
  • - -
  • -The testing package now automates the generation of allocation -statistics in tests and benchmarks using the new -AllocsPerRun function. And the -ReportAllocs -method on testing.B will enable printing of -memory allocation statistics for the calling benchmark. It also introduces the -AllocsPerOp method of -BenchmarkResult. -There is also a new -Verbose function to test the state of the -v -command-line flag, -and a new -Skip method of -testing.B and -testing.T -to simplify skipping an inappropriate test. -
  • - -
  • -In the text/template -and -html/template packages, -templates can now use parentheses to group the elements of pipelines, simplifying the construction of complex pipelines. -Also, as part of the new parser, the -Node interface got two new methods to provide -better error reporting. -Although this violates the Go 1 compatibility rules, -no existing code should be affected because this interface is explicitly intended only to be used -by the -text/template -and -html/template -packages and there are safeguards to guarantee that. -
  • - -
  • -The implementation of the unicode package has been updated to Unicode version 6.2.0. -
  • - -
  • -In the unicode/utf8 package, -the new function ValidRune reports whether the rune is a valid Unicode code point. -To be valid, a rune must be in range and not be a surrogate half. -
  • -
diff --git a/_content/doc/go1.10.html b/_content/doc/go1.10.html deleted file mode 100644 index 412b2407d2..0000000000 --- a/_content/doc/go1.10.html +++ /dev/null @@ -1,1446 +0,0 @@ - - - - - - -

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 hard-coded set of safe compiler options 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) 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

- -

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 create 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 go help 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 list 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. -

-

-FileInfoHeader has always -recorded the Unix UID and GID numbers from its os.FileInfo argument -(specifically, from the system-dependent information returned by the FileInfo's Sys method) -in the returned 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 field -of type Format -controls which tar header format the 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 sets Header.Format for each header it reads. -

-

-Reader and the Writer now support arbitrary PAX records, -using the new Header.PAXRecords 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
-
-

-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 and 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's new Modified field of type 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 and -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 method. -

-
- -
bufio
-
-

-The new Reader.Size -and Writer.Size -methods report the Reader or Writer's underlying buffer size. -

-
- -
bytes
-
-

-The -Fields, -FieldsFunc, -Split, -and -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
-
-

-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
-
-

-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.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 fields -URIs, PermittedIPRanges, ExcludedIPRanges, -PermittedEmailAddresses, ExcludedEmailAddresses, -PermittedURIDomains, and ExcludedURIDomains. Certificates with -invalid values for those fields are now rejected. -

- -

-The new MarshalPKCS1PublicKey -and ParsePKCS1PublicKey -functions convert an RSA public key to and from PKCS#1-encoded form. -

- -

-The new MarshalPKCS8PrivateKey -function converts a private key to PKCS#8-encoded form. -(ParsePKCS8PrivateKey -has existed since Go 1.) -

-
- -
crypto/x509/pkix
-
-

-Name now implements a -String method 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.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. -

-

-Drivers that want to construct a sql.DB for -their clients can now implement the Connector interface -and call the new sql.OpenDB function, -instead of needing to encode all configuration into a string -passed to sql.Open. -

-

-Drivers that want to parse the configuration string only once per sql.DB -instead of once per sql.Conn, -or that want access to each sql.Conn's underlying context, -can make their Driver -implementations also implement DriverContext's -new OpenConnector method. -

-

-Drivers that implement ExecerContext -no longer need to implement Execer; -similarly, drivers that implement QueryerContext -no longer need to implement 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 implements the new -SessionResetter interface, -database/sql will now call ResetSession before -reusing the Conn for 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, -and -R_X86_64. -

-
- -
debug/macho
-
-

-Go 1.10 adds support for reading relocations from Mach-O sections, -using the Section struct's new Relocs field -and the new Reloc, -RelocTypeARM, -RelocTypeARM64, -RelocTypeGeneric, -and -RelocTypeX86_64 -types and associated constants. -

-

-Go 1.10 also adds support for the LC_RPATH load command, -represented by the types -RpathCmd and -Rpath, -and new named constants -for the various flag bits found in headers. -

-
- -
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 -function marshals its argument as if the additional params were its associated -struct field tag. -

-

-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
-
-

-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's new StartLine field. -

-
- -
encoding/hex
-
-

-The new functions -NewEncoder -and -NewDecoder -provide streaming conversions to and from hexadecimal, -analogous to equivalent functions already in -encoding/base32 -and -encoding/base64. -

- -

-When the functions -Decode -and -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
-
-

-The Decoder -adds a new method -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, -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
-
-

-Encode -and -EncodeToMemory -no longer generate partial output when presented with a -block that is impossible to encode as PEM data. -

-
- -
encoding/xml
-
-

-The new function -NewTokenDecoder -is like -NewDecoder -but creates a decoder reading from a TokenReader -instead of an XML-formatted byte stream. -This is meant to enable the construction of XML stream transformers in client libraries. -

-
- -
flag
-
-

-The default -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 now -adds appropriate indentation after newlines in flag usage strings, -so that multi-line usage strings display nicely. -

-

-FlagSet adds new methods -ErrorHandling, -Name, -and -Output, -to retrieve the settings passed to -NewFlagSet -and -FlagSet.SetOutput. -

-
- -
go/doc
-
-

-To support the doc change described above, -functions returning slices of T, *T, **T, and so on -are now reported in T's Type's Funcs list, -instead of in the Package's Funcs list. -

-
- -
go/importer
-
-

-The For function 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/printer package -and also affect the output of the higher-level go/format package. -

-
- -
hash
-
-

-Implementations of the Hash interface are now -encouraged to implement encoding.BinaryMarshaler -and encoding.BinaryUnmarshaler -to 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 Srcset content -type allows for proper handling of values within the -srcset -attribute of img tags. -

-
- -
math/big
-
-

-Int now supports conversions to and from bases 2 through 62 -in its SetString and Text methods. -(Previously it only allowed bases 2 through 36.) -The value of the constant MaxBase has been updated. -

-

-Int adds a new -CmpAbs method -that is like Cmp but -compares only the absolute values (not the signs) of its arguments. -

-

-Float adds a new -Sqrt method to -compute square roots. -

-
- -
math/cmplx
-
-

-Branch cuts and other boundary cases in -Asin, -Asinh, -Atan, -and -Sqrt -have been corrected to match the definitions used in the C99 standard. -

-
- -
math/rand
-
-

-The new Shuffle function and corresponding -Rand.Shuffle method -shuffle an input sequence. -

-
- -
math
-
-

-The new functions -Round -and -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 -and -Erfcinv -compute the inverse error function and the -inverse complementary error function. -

-
- -
mime/multipart
-
-

-Reader -now accepts parts with empty filename attributes. -

-
- -
mime
-
-

-ParseMediaType now discards -invalid attribute values; previously it returned those values as empty strings. -

-
- -
net
-
-

-The Conn and -Listener 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 and -UnixListener -now implement -syscall.Conn, -to allow setting options on the underlying file descriptor -using syscall.RawConn.Control. -

- -

-The Conn implementations returned by Pipe -now support setting read and write deadlines. -

- -

-The IPConn.ReadMsgIP, -IPConn.WriteMsgIP, -UDPConn.ReadMsgUDP, -and -UDPConn.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 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 and its single-file equivalent ServeFile -now apply If-Range checks to HEAD requests. -FileServer also now reports directory read failures to the Server's ErrorLog. -The content-serving handlers also now omit the Content-Type header when serving zero-length content. -

-

-ResponseWriter's WriteHeader method now panics -if passed an invalid (non-3-digit) status code. -

-

- -The Server will no longer add an implicit Content-Type when a Handler does not write any output. -

-

-Redirect now sets the Content-Type header before writing its HTTP response. -

-
- -
net/mail
-
-

-ParseAddress and -ParseAddressList -now support a variety of obsolete address formats. -

-
- -
net/smtp
-
-

-The Client adds a new -Noop method, -to test whether the server is still responding. -It also now defends against possible SMTP injection in the inputs -to the Hello -and Verify methods. -

-
- -
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
-
-

-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 -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. -

- -

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's methods -now treat a nil receiver as equivalent to a pointer to a zero UserInfo. -Previously, they panicked. -

-
- -
os
-
-

-File adds new methods -SetDeadline, -SetReadDeadline, -and -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. -If an I/O method fails due to missing a deadline, it will return a -timeout error; the -new IsTimeout function -reports whether an error represents a timeout. -

- -

-Also matching net.Conn, -File's -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 -now supports setting file times with nanosecond precision -(assuming the underlying file system can represent them). -

-
- -
reflect
-
-

-The Copy function 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 PkgPath -in the corresponding StructField, -with the result that for those fields, -and Value.CanSet -incorrectly returned true and -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. -

-
- -
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
-
-

-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
-
-

-A new type -Builder is a replacement for -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 method. -

-
- -
syscall
-
-

-On Windows, -the new SysProcAttr field Token, -of type Token allows the creation of a process that -runs as another user during StartProcess -(and therefore also during os.StartProcess and -exec.Cmd.Start). -The new function CreateProcessAsUser -gives access to the underlying system call. -

- -

-On BSD, macOS, and Solaris systems, UtimesNano -is now implemented. -

-
- -
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 -allows conversion of IANA time zone file data to a Location. -

-
- -
unicode
-
-

-The unicode package 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. -

-
diff --git a/_content/doc/go1.11.html b/_content/doc/go1.11.html deleted file mode 100644 index 394e711b5e..0000000000 --- a/_content/doc/go1.11.html +++ /dev/null @@ -1,932 +0,0 @@ - - - - - - -

Introduction to Go 1.11

- -

- The latest Go release, version 1.11, arrives six months after Go 1.10. - 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. -

- -

Changes to the language

- -

- There are no changes to the language specification. -

- -

Ports

- -

- As announced in the Go 1.10 release notes, Go 1.11 now requires - OpenBSD 6.2 or later, macOS 10.10 Yosemite or later, or Windows 7 or later; - support for previous versions of these operating systems has been removed. -

- -

- Go 1.11 supports the upcoming OpenBSD 6.4 release. Due to changes in - the OpenBSD kernel, older versions of Go will not work on OpenBSD 6.4. -

- -

- There are known issues with NetBSD on i386 hardware. -

- -

- The race detector is now supported on linux/ppc64le - and, to a lesser extent, on netbsd/amd64. The NetBSD race detector support - has known issues. -

- -

- The memory sanitizer (-msan) is now supported on linux/arm64. -

- -

- The build modes c-shared and c-archive are now supported on - freebsd/amd64. -

- -

- On 64-bit MIPS systems, the new environment variable settings - GOMIPS64=hardfloat (the default) and - GOMIPS64=softfloat select whether to use - hardware instructions or software emulation for floating-point computations. - For 32-bit systems, the environment variable is still GOMIPS, - as added in Go 1.10. -

- -

- On soft-float ARM systems (GOARM=5), Go now uses a more - efficient software floating point interface. This is transparent to - Go code, but ARM assembly that uses floating-point instructions not - guarded on GOARM will break and must be ported to - the new interface. -

- -

- Go 1.11 on ARMv7 no longer requires a Linux kernel configured - with KUSER_HELPERS. This setting is enabled in default - kernel configurations, but is sometimes disabled in stripped-down - configurations. -

- -

WebAssembly

-

- Go 1.11 adds an experimental port to WebAssembly - (js/wasm). -

-

- Go programs currently compile to one WebAssembly module that - includes the Go runtime for goroutine scheduling, garbage - collection, maps, etc. - As a result, the resulting size is at minimum around - 2 MB, or 500 KB compressed. Go programs can call into JavaScript - using the new experimental - syscall/js package. - Binary size and interop with other languages has not yet been a - priority but may be addressed in future releases. -

-

- As a result of the addition of the new GOOS value - "js" and GOARCH value "wasm", - Go files named *_js.go or *_wasm.go will - now be ignored by Go - tools except when those GOOS/GOARCH values are being used. - If you have existing filenames matching those patterns, you will need to rename them. -

-

- More information can be found on the - WebAssembly wiki page. -

- -

RISC-V GOARCH values reserved

-

- The main Go compiler does not yet support the RISC-V architecture - but we've reserved the GOARCH values - "riscv" and "riscv64", as used by Gccgo, - which does support RISC-V. This means that Go files - named *_riscv.go will now also - be ignored by Go - tools except when those GOOS/GOARCH values are being used. -

- -

Tools

- -

Modules, package versioning, and dependency management

-

- Go 1.11 adds preliminary support for a new concept called “modules,” - an alternative to GOPATH with integrated support for versioning and - package distribution. - Using modules, developers are no longer confined to working inside GOPATH, - version dependency information is explicit yet lightweight, - and builds are more reliable and reproducible. -

- -

- Module support is considered experimental. - Details are likely to change in response to feedback from Go 1.11 users, - and we have more tools planned. - Although the details of module support may change, projects that convert - to modules using Go 1.11 will continue to work with Go 1.12 and later. - If you encounter bugs using modules, - please file issues - so we can fix them. For more information, see the - go command documentation. -

- -

Import path restriction

- -

- Because Go module support assigns special meaning to the - @ symbol in command line operations, - the go command now disallows the use of - import paths containing @ symbols. - Such import paths were never allowed by go get, - so this restriction can only affect users building - custom GOPATH trees by other means. -

- -

Package loading

- -

- The new package - golang.org/x/tools/go/packages - provides a simple API for locating and loading packages of Go source code. - Although not yet part of the standard library, for many tasks it - effectively replaces the go/build - package, whose API is unable to fully support modules. - Because it runs an external query command such as - go list - to obtain information about Go packages, it enables the construction of - analysis tools that work equally well with alternative build systems - such as Bazel - and Buck. -

- -

Build cache requirement

- -

- Go 1.11 will be the last release to support setting the environment - variable GOCACHE=off to disable the - build cache, - introduced in Go 1.10. - Starting in Go 1.12, the build cache will be required, - as a step toward eliminating $GOPATH/pkg. - The module and package loading support described above - already require that the build cache be enabled. - If you have disabled the build cache to avoid problems you encountered, - please file an issue to let us know about them. -

- -

Compiler toolchain

- -

- More functions are now eligible for inlining by default, including - functions that call panic. -

- -

- The compiler toolchain now supports column information - in line - directives. -

- -

- A new package export data format has been introduced. - This should be transparent to end users, except for speeding up - build times for large Go projects. - If it does cause problems, it can be turned off again by - passing -gcflags=all=-iexport=false to - the go tool when building a binary. -

- -

- The compiler now rejects unused variables declared in a type switch - guard, such as x in the following example: -

-
-func f(v interface{}) {
-	switch x := v.(type) {
-	}
-}
-
-

- This was already rejected by both gccgo - and go/types. -

- -

Assembler

- -

- The assembler for amd64 now accepts AVX512 instructions. -

- -

Debugging

- -

- The compiler now produces significantly more accurate debug - information for optimized binaries, including variable location - information, line numbers, and breakpoint locations. - - This should make it possible to debug binaries - compiled without -N -l. - - There are still limitations to the quality of the debug information, - some of which are fundamental, and some of which will continue to - improve with future releases. -

- -

- DWARF sections are now compressed by default because of the expanded - and more accurate debug information produced by the compiler. - - This is transparent to most ELF tools (such as debuggers on Linux - and *BSD) and is supported by the Delve debugger on all platforms, - but has limited support in the native tools on macOS and Windows. - - To disable DWARF compression, - pass -ldflags=-compressdwarf=false to - the go tool when building a binary. -

- -

- Go 1.11 adds experimental support for calling Go functions from - within a debugger. - - This is useful, for example, to call String methods - when paused at a breakpoint. - - This is currently only supported by Delve (version 1.1.0 and up). -

- -

Test

- -

- Since Go 1.10, the go test command runs - go vet on the package being tested, - to identify problems before running the test. Since vet - typechecks the code with go/types - before running, tests that do not typecheck will now fail. - - In particular, tests that contain an unused variable inside a - closure compiled with Go 1.10, because the Go compiler incorrectly - accepted them (Issue #3059), - but will now fail, since go/types correctly reports an - "unused variable" error in this case. -

- -

- The -memprofile flag - to go test now defaults to the - "allocs" profile, which records the total bytes allocated since the - test began (including garbage-collected bytes). -

- -

Vet

- -

- The go vet - command now reports a fatal error when the package under analysis - does not typecheck. Previously, a type checking error simply caused - a warning to be printed, and vet to exit with status 1. -

- -

- Additionally, go vet - has become more robust when format-checking printf wrappers. - Vet now detects the mistake in this example: -

- -
-func wrapper(s string, args ...interface{}) {
-	fmt.Printf(s, args...)
-}
-
-func main() {
-	wrapper("%s", 42)
-}
-
- -

Trace

- -

- With the new runtime/trace - package's user - annotation API, users can record application-level information - in execution traces and create groups of related goroutines. - The go tool trace - command visualizes this information in the trace view and the new - user task/region analysis page. -

- -

Cgo

- -

-Since Go 1.10, cgo has translated some C pointer types to the Go -type uintptr. These types include -the CFTypeRef hierarchy in Darwin's CoreFoundation -framework and the jobject hierarchy in Java's JNI -interface. In Go 1.11, several improvements have been made to the code -that detects these types. Code that uses these types may need some -updating. See the Go 1.10 release notes for -details. -

- -

Go command

- -

- The environment variable GOFLAGS may now be used - to set default flags for the go command. - This is useful in certain situations. - Linking can be noticeably slower on underpowered systems due to DWARF, - and users may want to set -ldflags=-w by default. - For modules, some users and CI systems will want vendoring always, - so they should set -mod=vendor by default. - For more information, see the go - command documentation. -

- -

Godoc

- -

- Go 1.11 will be the last release to support godoc's command-line interface. - In future releases, godoc will only be a web server. Users should use - go doc for command-line help output instead. -

- -

- The godoc web server now shows which version of Go introduced - new API features. The initial Go version of types, funcs, and methods are shown - right-aligned. For example, see UserCacheDir, with "1.11" - on the right side. For struct fields, inline comments are added when the struct field was - added in a Go version other than when the type itself was introduced. - For a struct field example, see - ClientTrace.Got1xxResponse. -

- -

Gofmt

- -

- One minor detail of the default formatting of Go source code has changed. - When formatting expression lists with inline comments, the comments were - aligned according to a heuristic. - However, in some cases the alignment would be split up too easily, or - introduce too much whitespace. - The heuristic has been changed to behave better for human-written code. -

- -

- Note that these kinds of minor updates to gofmt are expected from time to - time. - In general, systems that need consistent formatting of Go source code should - use a specific version of the gofmt binary. - See the go/format package documentation for more - information. -

- -

Run

- -

- - The go run - command now allows a single import path, a directory name or a - pattern matching a single package. - This allows go run pkg or go run dir, most importantly go run . -

- -

Runtime

- -

- The runtime now uses a sparse heap layout so there is no longer a - limit to the size of the Go heap (previously, the limit was 512GiB). - This also fixes rare "address space conflict" failures in mixed Go/C - binaries or binaries compiled with -race. -

- -

- On macOS and iOS, the runtime now uses libSystem.dylib instead of - calling the kernel directly. This should make Go binaries more - compatible with future versions of macOS and iOS. - The syscall package still makes direct - system calls; fixing this is planned for a future release. -

- -

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 better generated code and -optimizations in the core library. -

- -

-There were multiple performance changes to the math/big -package as well as many changes across the tree specific to GOARCH=arm64. -

- -

Compiler toolchain

- -

- The compiler now optimizes map clearing operations of the form: -

-
-for k := range m {
-	delete(m, k)
-}
-
- -

- The compiler now optimizes slice extension of the form - append(s, make([]T, n)...). -

- -

- The compiler now performs significantly more aggressive bounds-check - and branch elimination. Notably, it now recognizes transitive - relations, so if i<j and j<len(s), - it can use these facts to eliminate the bounds check - for s[i]. It also understands simple arithmetic such - as s[i-10] and can recognize more inductive cases in - loops. Furthermore, the compiler now uses bounds information to more - aggressively optimize shift operations. -

- -

Core library

- -

- All of the changes to the standard library are minor. -

- -

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. -

- - - - - - -
crypto
-
-

- Certain crypto operations, including - ecdsa.Sign, - rsa.EncryptPKCS1v15 and - rsa.GenerateKey, - now randomly read an extra byte of randomness to ensure tests don't rely on internal behavior. -

- -
- -
crypto/cipher
-
-

- The new function NewGCMWithTagSize - implements Galois Counter Mode with non-standard tag lengths for compatibility with existing cryptosystems. -

- -
- -
crypto/rsa
-
-

- PublicKey now implements a - Size method that - returns the modulus size in bytes. -

- -
- -
crypto/tls
-
-

- ConnectionState's new - ExportKeyingMaterial - method allows exporting keying material bound to the - connection according to RFC 5705. -

- -
- -
crypto/x509
-
-

- The deprecated, legacy behavior of treating the CommonName field as - a hostname when no Subject Alternative Names are present is now disabled when the CN is not a - valid hostname. - The CommonName can be completely ignored by adding the experimental value - x509ignoreCN=1 to the GODEBUG environment variable. - When the CN is ignored, certificates without SANs validate under chains with name constraints - instead of returning NameConstraintsWithoutSANs. -

- -

- Extended key usage restrictions are again checked only if they appear in the KeyUsages - field of VerifyOptions, instead of always being checked. - This matches the behavior of Go 1.9 and earlier. -

- -

- The value returned by SystemCertPool - is now cached and might not reflect system changes between invocations. -

- -
- -
debug/elf
-
-

- More ELFOSABI - and EM - constants have been added. -

- -
- -
encoding/asn1
-
-

- Marshal and Unmarshal - now support "private" class annotations for fields. -

- -
- -
encoding/base32
-
-

- The decoder now consistently - returns io.ErrUnexpectedEOF for an incomplete - chunk. Previously it would return io.EOF in some - cases. -

- -
- -
encoding/csv
-
-

- The Reader now rejects attempts to set - the Comma - field to a double-quote character, as double-quote characters - already have a special meaning in CSV. -

- -
- - - -
html/template
-
-

- The package has changed its behavior when a typed interface - value is passed to an implicit escaper function. Previously such - a value was written out as (an escaped form) - of <nil>. Now such values are ignored, just - as an untyped nil value is (and always has been) - ignored. -

- -
- -
image/gif
-
-

- Non-looping animated GIFs are now supported. They are denoted by having a - LoopCount of -1. -

- -
- -
io/ioutil
-
-

- The TempFile - function now supports specifying where the random characters in - the filename are placed. If the prefix argument - includes a "*", the random string replaces the - "*". For example, a prefix argument of "myname.*.bat" will - result in a random filename such as - "myname.123456.bat". If no "*" is - included the old behavior is retained, and the random digits are - appended to the end. -

- -
- -
math/big
-
- -

- ModInverse now returns nil when g and n are not relatively prime. The result was previously undefined. -

- -
- -
mime/multipart
-
-

- The handling of form-data with missing/empty file names has been - restored to the behavior in Go 1.9: in the - Form for - the form-data part the value is available in - the Value field rather than the File - field. In Go releases 1.10 through 1.10.3 a form-data part with - a missing/empty file name and a non-empty "Content-Type" field - was stored in the File field. This change was a - mistake in 1.10 and has been reverted to the 1.9 behavior. -

- -
- -
mime/quotedprintable
-
-

- To support invalid input found in the wild, the package now - permits non-ASCII bytes but does not validate their encoding. -

- -
- -
net
-
-

- The new ListenConfig type and the new - Dialer.Control field permit - setting socket options before accepting and creating connections, respectively. -

- -

- The syscall.RawConn Read - and Write methods now work correctly on Windows. -

- -

- The net package now automatically uses the - splice system call - on Linux when copying data between TCP connections in - TCPConn.ReadFrom, as called by - io.Copy. The result is faster, more efficient TCP proxying. -

- -

- The TCPConn.File, - UDPConn.File, - UnixConn.File, - and IPConn.File - methods no longer put the returned *os.File into - blocking mode. -

- -
- -
net/http
-
-

- The Transport type has a - new MaxConnsPerHost - option that permits limiting the maximum number of connections - per host. -

- -

- The Cookie type has a new - SameSite field - (of new type also named - SameSite) to represent the new cookie attribute recently supported by most browsers. - The net/http's Transport does not use the SameSite - attribute itself, but the package supports parsing and serializing the - attribute for browsers to use. -

- -

- It is no longer allowed to reuse a Server - after a call to - Shutdown or - Close. It was never officially supported - in the past and had often surprising behavior. Now, all future calls to the server's Serve - methods will return errors after a shutdown or close. -

- - - -

- The constant StatusMisdirectedRequest is now defined for HTTP status code 421. -

- -

- The HTTP server will no longer cancel contexts or send on - CloseNotifier - channels upon receiving pipelined HTTP/1.1 requests. Browsers do - not use HTTP pipelining, but some clients (such as - Debian's apt) may be configured to do so. -

- -

- ProxyFromEnvironment, which is used by the - DefaultTransport, now - supports CIDR notation and ports in the NO_PROXY environment variable. -

- -
- -
net/http/httputil
-
-

- The - ReverseProxy - has a new - ErrorHandler - option to permit changing how errors are handled. -

- -

- The ReverseProxy now also passes - "TE: trailers" request headers - through to the backend, as required by the gRPC protocol. -

- -
- -
os
-
-

- The new UserCacheDir function - returns the default root directory to use for user-specific cached data. -

- -

- The new ModeIrregular - is a FileMode bit to represent - that a file is not a regular file, but nothing else is known about it, or that - it's not a socket, device, named pipe, symlink, or other file type for which - Go has a defined mode bit. -

- -

- Symlink now works - for unprivileged users on Windows 10 on machines with Developer - Mode enabled. -

- -

- When a non-blocking descriptor is passed - to NewFile, the - resulting *File will be kept in non-blocking - mode. This means that I/O for that *File will use - the runtime poller rather than a separate thread, and that - the SetDeadline - methods will work. -

- -
- -
os/signal
-
-

- The new Ignored function reports - whether a signal is currently ignored. -

- -
- -
os/user
-
-

- The os/user package can now be built in pure Go - mode using the build tag "osusergo", - independent of the use of the environment - variable CGO_ENABLED=0. Previously the only way to use - the package's pure Go implementation was to disable cgo - support across the entire program. -

- -
- - - -
runtime
-
- -

- Setting the GODEBUG=tracebackancestors=N - environment variable now extends tracebacks with the stacks at - which goroutines were created, where N limits the - number of ancestor goroutines to report. -

- -
- -
runtime/pprof
-
-

- This release adds a new "allocs" profile type that profiles - total number of bytes allocated since the program began - (including garbage-collected bytes). This is identical to the - existing "heap" profile viewed in -alloc_space mode. - Now go test -memprofile=... reports an "allocs" profile - instead of "heap" profile. -

- -
- -
sync
-
-

- The mutex profile now includes reader/writer contention - for RWMutex. - Writer/writer contention was already included in the mutex - profile. -

- -
- -
syscall
-
-

- On Windows, several fields were changed from uintptr to a new - Pointer - type to avoid problems with Go's garbage collector. The same change was made - to the golang.org/x/sys/windows - package. For any code affected, users should first migrate away from the syscall - package to the golang.org/x/sys/windows package, and then change - to using the Pointer, while obeying the - unsafe.Pointer conversion rules. -

- -

- On Linux, the flags parameter to - Faccessat - is now implemented just as in glibc. In earlier Go releases the - flags parameter was ignored. -

- -

- On Linux, the flags parameter to - Fchmodat - is now validated. Linux's fchmodat doesn't support the flags parameter - so we now mimic glibc's behavior and return an error if it's non-zero. -

- -
- -
text/scanner
-
-

- The Scanner.Scan method now returns - the RawString token - instead of String - for raw string literals. -

- -
- -
text/template
-
-

- Modifying template variables via assignments is now permitted via the = token: -

-
-  {{ $v := "init" }}
-  {{ if true }}
-    {{ $v = "changed" }}
-  {{ end }}
-  v: {{ $v }} {{/* "changed" */}}
- -

- In previous versions untyped nil values passed to - template functions were ignored. They are now passed as normal - arguments. -

- -
- -
time
-
-

- Parsing of timezones denoted by sign and offset is now - supported. In previous versions, numeric timezone names - (such as +03) were not considered valid, and only - three-letter abbreviations (such as MST) were accepted - when expecting a timezone name. -

-
diff --git a/_content/doc/go1.12.html b/_content/doc/go1.12.html deleted file mode 100644 index 21d77f1108..0000000000 --- a/_content/doc/go1.12.html +++ /dev/null @@ -1,947 +0,0 @@ - - - - - - -

Introduction to Go 1.12

- -

- The latest Go release, version 1.12, arrives six months after Go 1.11. - 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. -

- -

Changes to the language

- -

- There are no changes to the language specification. -

- -

Ports

- -

- The race detector is now supported on linux/arm64. -

- -

- Go 1.12 is the last release that is supported on FreeBSD 10.x, which has - already reached end-of-life. Go 1.13 will require FreeBSD 11.2+ or FreeBSD - 12.0+. - FreeBSD 12.0+ requires a kernel with the COMPAT_FREEBSD11 option set (this is the default). -

- -

- cgo is now supported on linux/ppc64. -

- -

- hurd is now a recognized value for GOOS, reserved - for the GNU/Hurd system for use with gccgo. -

- -

Windows

- -

- Go's new windows/arm port supports running Go on Windows 10 - IoT Core on 32-bit ARM chips such as the Raspberry Pi 3. -

- -

AIX

- -

- Go now supports AIX 7.2 and later on POWER8 architectures (aix/ppc64). External linking, cgo, pprof and the race detector aren't yet supported. -

- -

Darwin

- -

- Go 1.12 is the last release that will run on macOS 10.10 Yosemite. - Go 1.13 will require macOS 10.11 El Capitan or later. -

- -

- libSystem is now used when making syscalls on Darwin, - ensuring forward-compatibility with future versions of macOS and iOS. - - The switch to libSystem triggered additional App Store - checks for private API usage. Since it is considered private, - syscall.Getdirentries now always fails with - ENOSYS on iOS. - Additionally, syscall.Setrlimit - reports invalid argument in places where it historically - succeeded. These consequences are not specific to Go and users should expect - behavioral parity with libSystem's implementation going forward. -

- -

Tools

- -

go tool vet no longer supported

- -

- The go vet command has been rewritten to serve as the - base for a range of different source code analysis tools. See - the golang.org/x/tools/go/analysis - package for details. A side-effect is that go tool vet - is no longer supported. External tools that use go tool - vet must be changed to use go - vet. Using go vet instead of go tool - vet should work with all supported versions of Go. -

- -

- As part of this change, the experimental -shadow option - is no longer available with go vet. Checking for - variable shadowing may now be done using -

-go get -u golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
-go vet -vettool=$(which shadow)
-
-

- -

Tour

- -

-The Go tour is no longer included in the main binary distribution. To -run the tour locally, instead of running go tool tour, -manually install it: -

-go get -u golang.org/x/tour
-tour
-
-

- -

Build cache requirement

- -

- The build cache is now - required as a step toward eliminating - $GOPATH/pkg. Setting the environment variable - GOCACHE=off will cause go commands that write to the - cache to fail. -

- -

Binary-only packages

- -

- Go 1.12 is the last release that will support binary-only packages. -

- -

Cgo

- -

- Go 1.12 will translate the C type EGLDisplay to the Go type uintptr. - This change is similar to how Go 1.10 and newer treats Darwin's CoreFoundation - and Java's JNI types. See the - cgo documentation - for more information. -

- -

- Mangled C names are no longer accepted in packages that use Cgo. Use the Cgo - names instead. For example, use the documented cgo name C.char - rather than the mangled name _Ctype_char that cgo generates. -

- -

Modules

- -

- When GO111MODULE is set to on, the go - command now supports module-aware operations outside of a module directory, - provided that those operations do not need to resolve import paths relative to - the current directory or explicitly edit the go.mod file. - Commands such as go get, - go list, and - go mod download behave as if in a - module with initially-empty requirements. - In this mode, go env GOMOD reports - the system's null device (/dev/null or NUL). -

- -

- go commands that download and extract modules are now safe to - invoke concurrently. - The module cache (GOPATH/pkg/mod) must reside in a filesystem that - supports file locking. -

- -

- The go directive in a go.mod file now indicates the - version of the language used by the files within that module. - It will be set to the current release - (go 1.12) if no existing version is - present. - If the go directive for a module specifies a - version newer than the toolchain in use, the go command - will attempt to build the packages regardless, and will note the mismatch only if - that build fails. -

- -

- This changed use of the go directive means that if you - use Go 1.12 to build a module, thus recording go 1.12 - in the go.mod file, you will get an error when - attempting to build the same module with Go 1.11 through Go 1.11.3. - Go 1.11.4 or later will work fine, as will releases older than Go 1.11. - If you must use Go 1.11 through 1.11.3, you can avoid the problem by - setting the language version to 1.11, using the Go 1.12 go tool, - via go mod edit -go=1.11. -

- -

- When an import cannot be resolved using the active modules, - the go command will now try to use the modules mentioned in the - main module's replace directives before consulting the module - cache and the usual network sources. - If a matching replacement is found but the replace directive does - not specify a version, the go command uses a pseudo-version - derived from the zero time.Time (such - as v0.0.0-00010101000000-000000000000). -

- -

Compiler toolchain

- -

- The compiler's live variable analysis has improved. This may mean that - finalizers will be executed sooner in this release than in previous - releases. If that is a problem, consider the appropriate addition of a - runtime.KeepAlive call. -

- -

- More functions are now eligible for inlining by default, including - functions that do nothing but call another function. - This extra inlining makes it additionally important to use - runtime.CallersFrames - instead of iterating over the result of - runtime.Callers directly. -

-// Old code which no longer works correctly (it will miss inlined call frames).
-var pcs [10]uintptr
-n := runtime.Callers(1, pcs[:])
-for _, pc := range pcs[:n] {
-	f := runtime.FuncForPC(pc)
-	if f != nil {
-		fmt.Println(f.Name())
-	}
-}
-
-
-// New code which will work correctly.
-var pcs [10]uintptr
-n := runtime.Callers(1, pcs[:])
-frames := runtime.CallersFrames(pcs[:n])
-for {
-	frame, more := frames.Next()
-	fmt.Println(frame.Function)
-	if !more {
-		break
-	}
-}
-
-

- -

- Wrappers generated by the compiler to implement method expressions - are no longer reported - by runtime.CallersFrames - and runtime.Stack. They - are also not printed in panic stack traces. - - This change aligns the gc toolchain to match - the gccgo toolchain, which already elided such wrappers - from stack traces. - - Clients of these APIs might need to adjust for the missing - frames. For code that must interoperate between 1.11 and 1.12 - releases, you can replace the method expression x.M - with the function literal func (...) { x.M(...) } . -

- -

- The compiler now accepts a -lang flag to set the Go language - version to use. For example, -lang=go1.8 causes the compiler to - emit an error if the program uses type aliases, which were added in Go 1.9. - Language changes made before Go 1.12 are not consistently enforced. -

- -

- The compiler toolchain now uses different conventions to call Go - functions and assembly functions. This should be invisible to users, - except for calls that simultaneously cross between Go and - assembly and cross a package boundary. If linking results - in an error like "relocation target not defined for ABIInternal (but - is defined for ABI0)", please refer to the - compatibility section - of the ABI design document. -

- -

- There have been many improvements to the DWARF debug information - produced by the compiler, including improvements to argument - printing and variable location information. -

- -

- Go programs now also maintain stack frame pointers on linux/arm64 - for the benefit of profiling tools like perf. The frame pointer - maintenance has a small run-time overhead that varies but averages around 3%. - To build a toolchain that does not use frame pointers, set - GOEXPERIMENT=noframepointer when running make.bash. -

- -

- The obsolete "safe" compiler mode (enabled by the -u gcflag) has been removed. -

- -

godoc and go doc

- -

- In Go 1.12, godoc no longer has a command-line interface and - is only a web server. Users should use go doc - for command-line help output instead. Go 1.12 is the last release that will - include the godoc webserver; in Go 1.13 it will be available - via go get. -

- -

- go doc now supports the -all flag, - which will cause it to print all exported APIs and their documentation, - as the godoc command line used to do. -

- -

- go doc also now includes the -src flag, - which will show the target's source code. -

- -

Trace

- -

- The trace tool now supports plotting mutator utilization curves, - including cross-references to the execution trace. These are useful - for analyzing the impact of the garbage collector on application - latency and throughput. -

- -

Assembler

- -

- On arm64, the platform register was renamed from - R18 to R18_PLATFORM to prevent accidental - use, as the OS could choose to reserve this register. -

- -

Runtime

- -

- Go 1.12 significantly improves the performance of sweeping when a - large fraction of the heap remains live. This reduces allocation - latency immediately following a garbage collection. -

- -

- The Go runtime now releases memory back to the operating system more - aggressively, particularly in response to large allocations that - can't reuse existing heap space. -

- -

- The Go runtime's timer and deadline code is faster and scales better - with higher numbers of CPUs. In particular, this improves the - performance of manipulating network connection deadlines. -

- -

- On Linux, the runtime now uses MADV_FREE to release unused - memory. This is more efficient but may result in higher reported - RSS. The kernel will reclaim the unused data when it is needed. - To revert to the Go 1.11 behavior (MADV_DONTNEED), set the - environment variable GODEBUG=madvdontneed=1. -

- -

- Adding cpu.extension=off to the - GODEBUG environment - variable now disables the use of optional CPU instruction - set extensions in the standard library and runtime. This is not - yet supported on Windows. -

- -

- Go 1.12 improves the accuracy of memory profiles by fixing - overcounting of large heap allocations. -

- -

- Tracebacks, runtime.Caller, - and runtime.Callers no longer include - compiler-generated initialization functions. Doing a traceback - during the initialization of a global variable will now show a - function named PKG.init.ializers. -

- -

Core library

- -

TLS 1.3

- -

- Go 1.12 adds opt-in support for TLS 1.3 in the crypto/tls package as - specified by RFC 8446. It can - be enabled by adding the value tls13=1 to the GODEBUG - environment variable. It will be enabled by default in Go 1.13. -

- -

- To negotiate TLS 1.3, make sure you do not set an explicit MaxVersion in - Config and run your program with - the environment variable GODEBUG=tls13=1 set. -

- -

- All TLS 1.2 features except TLSUnique in - ConnectionState - and renegotiation are available in TLS 1.3 and provide equivalent or - better security and performance. Note that even though TLS 1.3 is backwards - compatible with previous versions, certain legacy systems might not work - correctly when attempting to negotiate it. RSA certificate keys too small - to be secure (including 512-bit keys) will not work with TLS 1.3. -

- -

- TLS 1.3 cipher suites are not configurable. All supported cipher suites are - safe, and if PreferServerCipherSuites is set in - Config the preference order - is based on the available hardware. -

- -

- Early data (also called "0-RTT mode") is not currently supported as a - client or server. Additionally, a Go 1.12 server does not support skipping - unexpected early data if a client sends it. Since TLS 1.3 0-RTT mode - involves clients keeping state regarding which servers support 0-RTT, - a Go 1.12 server cannot be part of a load-balancing pool where some other - servers do support 0-RTT. If switching a domain from a server that supported - 0-RTT to a Go 1.12 server, 0-RTT would have to be disabled for at least the - lifetime of the issued session tickets before the switch to ensure - uninterrupted operation. -

- -

- In TLS 1.3 the client is the last one to speak in the handshake, so if it causes - an error to occur on the server, it will be returned on the client by the first - Read, not by - Handshake. For - example, that will be the case if the server rejects the client certificate. - Similarly, session tickets are now post-handshake messages, so are only - received by the client upon its first - Read. -

- -

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. -

- - - -
bufio
-
-

- Reader's UnreadRune and - UnreadByte methods will now return an error - if they are called after Peek. -

- -
- -
bytes
-
-

- The new function ReplaceAll returns a copy of - a byte slice with all non-overlapping instances of a value replaced by another. -

- -

- A pointer to a zero-value Reader is now - functionally equivalent to NewReader(nil). - Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases. -

- -
- -
crypto/rand
-
-

- A warning will now be printed to standard error the first time - Reader.Read is blocked for more than 60 seconds waiting - to read entropy from the kernel. -

- -

- On FreeBSD, Reader now uses the getrandom - system call if available, /dev/urandom otherwise. -

- -
- -
crypto/rc4
-
-

- This release removes the assembly implementations, leaving only - the pure Go version. The Go compiler generates code that is - either slightly better or slightly worse, depending on the exact - CPU. RC4 is insecure and should only be used for compatibility - with legacy systems. -

- -
- -
crypto/tls
-
-

- If a client sends an initial message that does not look like TLS, the server - will no longer reply with an alert, and it will expose the underlying - net.Conn in the new field Conn of - RecordHeaderError. -

- -
- -
database/sql
-
-

- A query cursor can now be obtained by passing a - *Rows - value to the Row.Scan method. -

- -
- -
expvar
-
-

- The new Delete method allows - for deletion of key/value pairs from a Map. -

- -
- -
fmt
-
-

- Maps are now printed in key-sorted order to ease testing. The ordering rules are: -

    -
  • When applicable, nil compares low -
  • ints, floats, and strings order by < -
  • NaN compares less than non-NaN floats -
  • bool compares false before true -
  • Complex compares real, then imaginary -
  • Pointers compare by machine address -
  • Channel values compare by machine address -
  • Structs compare each field in turn -
  • Arrays compare each element in turn -
  • Interface values compare first by reflect.Type describing the concrete type - and then by concrete value as described in the previous rules. -
-

- -

- When printing maps, non-reflexive key values like NaN were previously - displayed as <nil>. As of this release, the correct values are printed. -

- -
- -
go/doc
-
-

- To address some outstanding issues in cmd/doc, - this package has a new Mode bit, - PreserveAST, which controls whether AST data is cleared. -

- -
- -
go/token
-
-

- The File type has a new - LineStart field, - which returns the position of the start of a given line. This is especially useful - in programs that occasionally handle non-Go files, such as assembly, but wish to use - the token.Pos mechanism to identify file positions. -

- -
- -
image
-
-

- The RegisterFormat function is now safe for concurrent use. -

- -
- -
image/png
-
-

- Paletted images with fewer than 16 colors now encode to smaller outputs. -

- -
- -
io
-
-

- The new StringWriter interface wraps the - WriteString function. -

- -
- -
math
-
-

- The functions - Sin, - Cos, - Tan, - and Sincos now - apply Payne-Hanek range reduction to huge arguments. This - produces more accurate answers, but they will not be bit-for-bit - identical with the results in earlier releases. -

-
- -
math/bits
-
-

- New extended precision operations Add, Sub, Mul, and Div are available in uint, uint32, and uint64 versions. -

- -
- -
net
-
-

- The - Dialer.DualStack setting is now ignored and deprecated; - RFC 6555 Fast Fallback ("Happy Eyeballs") is now enabled by default. To disable, set - Dialer.FallbackDelay to a negative value. -

- -

- Similarly, TCP keep-alives are now enabled by default if - Dialer.KeepAlive is zero. - To disable, set it to a negative value. -

- -

- On Linux, the splice system call is now used when copying from a - UnixConn to a - TCPConn. -

-
- -
net/http
-
-

- The HTTP server now rejects misdirected HTTP requests to HTTPS servers with a plaintext "400 Bad Request" response. -

- -

- The new Client.CloseIdleConnections - method calls the Client's underlying Transport's CloseIdleConnections - if it has one. -

- -

- The Transport no longer rejects HTTP responses which declare - HTTP Trailers but don't use chunked encoding. Instead, the declared trailers are now just ignored. -

- -

- The Transport no longer handles MAX_CONCURRENT_STREAMS values - advertised from HTTP/2 servers as strictly as it did during Go 1.10 and Go 1.11. The default behavior is now back - to how it was in Go 1.9: each connection to a server can have up to MAX_CONCURRENT_STREAMS requests - active and then new TCP connections are created as needed. In Go 1.10 and Go 1.11 the http2 package - would block and wait for requests to finish instead of creating new connections. - To get the stricter behavior back, import the - golang.org/x/net/http2 package - directly and set - Transport.StrictMaxConcurrentStreams to - true. -

- -
- -
net/url
-
-

- Parse, - ParseRequestURI, - and - URL.Parse - now return an - error for URLs containing ASCII control characters, which includes NULL, - tab, and newlines. -

- -
- -
net/http/httputil
-
-

- The ReverseProxy now automatically - proxies WebSocket requests. -

- -
- -
os
-
-

- The new ProcessState.ExitCode method - returns the process's exit code. -

- -

- ModeCharDevice has been added to the ModeType bitmask, allowing for - ModeDevice | ModeCharDevice to be recovered when masking a - FileMode with ModeType. -

- -

- The new function UserHomeDir returns the - current user's home directory. -

- -

- RemoveAll now supports paths longer than 4096 characters - on most Unix systems. -

- -

- File.Sync now uses F_FULLFSYNC on macOS - to correctly flush the file contents to permanent storage. - This may cause the method to run more slowly than in previous releases. -

- -

- File now supports - a SyscallConn - method returning - a syscall.RawConn - interface value. This may be used to invoke system-specific - operations on the underlying file descriptor. -

- -
- -
path/filepath
-
-

- The IsAbs function now returns true when passed - a reserved filename on Windows such as NUL. - List of reserved names. -

- -
- -
reflect
-
-

- A new MapIter type is - an iterator for ranging over a map. This type is exposed through the - Value type's new - MapRange method. - This follows the same iteration semantics as a range statement, with Next - to advance the iterator, and Key/Value to access each entry. -

- -
- -
regexp
-
-

- Copy is no longer necessary - to avoid lock contention, so it has been given a partial deprecation comment. - Copy - may still be appropriate if the reason for its use is to make two copies with - different Longest settings. -

- -
- -
runtime/debug
-
-

- A new BuildInfo type - exposes the build information read from the running binary, available only in - binaries built with module support. This includes the main package path, main - module information, and the module dependencies. This type is given through the - ReadBuildInfo function - on BuildInfo. -

- -
- -
strings
-
-

- The new function ReplaceAll returns a copy of - a string with all non-overlapping instances of a value replaced by another. -

- -

- A pointer to a zero-value Reader is now - functionally equivalent to NewReader(nil). - Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases. -

- -

- The new Builder.Cap method returns the capacity of the builder's underlying byte slice. -

- -

- The character mapping functions Map, - Title, - ToLower, - ToLowerSpecial, - ToTitle, - ToTitleSpecial, - ToUpper, and - ToUpperSpecial - now always guarantee to return valid UTF-8. In earlier releases, if the input was invalid UTF-8 but no character replacements - needed to be applied, these routines incorrectly returned the invalid UTF-8 unmodified. -

- -
- -
syscall
-
-

- 64-bit inodes are now supported on FreeBSD 12. Some types have been adjusted accordingly. -

- -

- The Unix socket - (AF_UNIX) - address family is now supported for compatible versions of Windows. -

- -

- The new function Syscall18 - has been introduced for Windows, allowing for calls with up to 18 arguments. -

- -
- -
syscall/js
-
-

-

- The Callback type and NewCallback function have been renamed; - they are now called - Func and - FuncOf, respectively. - This is a breaking change, but WebAssembly support is still experimental - and not yet subject to the - Go 1 compatibility promise. Any code using the - old names will need to be updated. -

- -

- If a type implements the new - Wrapper - interface, - ValueOf - will use it to return the JavaScript value for that type. -

- -

- The meaning of the zero - Value - has changed. It now represents the JavaScript undefined value - instead of the number zero. - This is a breaking change, but WebAssembly support is still experimental - and not yet subject to the - Go 1 compatibility promise. Any code relying on - the zero Value - to mean the number zero will need to be updated. -

- -

- The new - Value.Truthy - method reports the - JavaScript "truthiness" - of a given value. -

- -
- -
testing
-
-

- The -benchtime flag now supports setting an explicit iteration count instead of a time when the value ends with an "x". For example, -benchtime=100x runs the benchmark 100 times. -

- -
- -
text/template
-
-

- When executing a template, long context values are no longer truncated in errors. -

-

- executing "tmpl" at <.very.deep.context.v...>: map has no entry for key "notpresent" -

-

- is now -

-

- executing "tmpl" at <.very.deep.context.value.notpresent>: map has no entry for key "notpresent" -

- -
-

- If a user-defined function called by a template panics, the - panic is now caught and returned as an error by - the Execute or ExecuteTemplate method. -

-
- -
time
-
-

- The time zone database in $GOROOT/lib/time/zoneinfo.zip - has been updated to version 2018i. Note that this ZIP file is - only used if a time zone database is not provided by the operating - system. -

- -
- -
unsafe
-
-

- It is invalid to convert a nil unsafe.Pointer to uintptr and back with arithmetic. - (This was already invalid, but will now cause the compiler to misbehave.) -

- -
diff --git a/_content/doc/go1.13.html b/_content/doc/go1.13.html deleted file mode 100644 index c5fb9cd2a7..0000000000 --- a/_content/doc/go1.13.html +++ /dev/null @@ -1,1064 +0,0 @@ - - - - - - -

Introduction to Go 1.13

- -

- The latest Go release, version 1.13, arrives six months after Go 1.12. - 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. -

- -

- As of Go 1.13, the go command by default downloads and authenticates - modules using the Go module mirror and Go checksum database run by Google. See - https://proxy.golang.org/privacy - for privacy information about these services and the - go command documentation - for configuration details including how to disable the use of these servers or use - different ones. If you depend on non-public modules, see the - documentation for configuring your environment. -

- -

Changes to the language

- -

- Per the number literal proposal, - Go 1.13 supports a more uniform and modernized set of number literal prefixes. -

    -
  • - Binary integer literals: - The prefix 0b or 0B indicates a binary integer literal - such as 0b1011. -
  • - -
  • - Octal integer literals: - The prefix 0o or 0O indicates an octal integer literal - such as 0o660. - The existing octal notation indicated by a leading 0 followed by - octal digits remains valid. -
  • - -
  • - Hexadecimal floating point literals: - The prefix 0x or 0X may now be used to express the mantissa of a - floating-point number in hexadecimal format such as 0x1.0p-1021. - A hexadecimal floating-point number must always have an exponent, written as the letter - p or P followed by an exponent in decimal. The exponent scales - the mantissa by 2 to the power of the exponent. -
  • - -
  • - Imaginary literals: - The imaginary suffix i may now be used with any (binary, decimal, hexadecimal) - integer or floating-point literal. -
  • - -
  • - Digit separators: - The digits of any number literal may now be separated (grouped) using underscores, such as - in 1_000_000, 0b_1010_0110, or 3.1415_9265. - An underscore may appear between any two digits or the literal prefix and the first digit. -
  • -
-

- -

- Per the signed shift counts proposal - Go 1.13 removes the restriction that a shift count - must be unsigned. This change eliminates the need for many artificial uint conversions, - solely introduced to satisfy this (now removed) restriction of the << and >> operators. -

- -

- These language changes were implemented by changes to the compiler, and corresponding internal changes to the library - packages go/scanner and - text/scanner (number literals), - and go/types (signed shift counts). -

- -

- If your code uses modules and your go.mod files specifies a language version, be sure - it is set to at least 1.13 to get access to these language changes. - You can do this by editing the go.mod file directly, or you can run - go mod edit -go=1.13. -

- -

Ports

- -

- Go 1.13 is the last release that will run on Native Client (NaCl). -

- -

- For GOARCH=wasm, the new environment variable GOWASM takes a comma-separated list of experimental features that the binary gets compiled with. - The valid values are documented here. -

- -

AIX

- -

- AIX on PPC64 (aix/ppc64) now supports cgo, external - linking, and the c-archive and pie build - modes. -

- -

Android

- -

- Go programs are now compatible with Android 10. -

- -

Darwin

- -

- As announced in the Go 1.12 release notes, - Go 1.13 now requires macOS 10.11 El Capitan or later; - support for previous versions has been discontinued. -

- -

FreeBSD

- -

- As announced in the Go 1.12 release notes, - Go 1.13 now requires FreeBSD 11.2 or later; - support for previous versions has been discontinued. - FreeBSD 12.0 or later requires a kernel with the COMPAT_FREEBSD11 - option set (this is the default). -

- -

Illumos

- -

- Go now supports Illumos with GOOS=illumos. - The illumos build tag implies the solaris - build tag. -

- -

Windows

- -

- The Windows version specified by internally-linked Windows binaries - is now Windows 7 rather than NT 4.0. This was already the minimum - required version for Go, but can affect the behavior of system calls - that have a backwards-compatibility mode. These will now behave as - documented. Externally-linked binaries (any program using cgo) have - always specified a more recent Windows version. -

- -

Tools

- -

Modules

- -

Environment variables

- -

- The GO111MODULE - environment variable continues to default to auto, but - the auto setting now activates the module-aware mode of - the go command whenever the current working directory contains, - or is below a directory containing, a go.mod file — even if the - current directory is within GOPATH/src. This change simplifies - the migration of existing code within GOPATH/src and the ongoing - maintenance of module-aware packages alongside non-module-aware importers. -

- -

- The new - GOPRIVATE - environment variable indicates module paths that are not publicly available. - It serves as the default value for the lower-level GONOPROXY - and GONOSUMDB variables, which provide finer-grained control over - which modules are fetched via proxy and verified using the checksum database. -

- -

- The GOPROXY - environment variable may now be set to a comma-separated list of proxy - URLs or the special token direct, and - its default value is - now https://proxy.golang.org,direct. When resolving a package - path to its containing module, the go command will try all - candidate module paths on each proxy in the list in succession. An unreachable - proxy or HTTP status code other than 404 or 410 terminates the search without - consulting the remaining proxies. -

- -

- The new - GOSUMDB - environment variable identifies the name, and optionally the public key and - server URL, of the database to consult for checksums of modules that are not - yet listed in the main module's go.sum file. - If GOSUMDB does not include an explicit URL, the URL is chosen by - probing the GOPROXY URLs for an endpoint indicating support for - the checksum database, falling back to a direct connection to the named - database if it is not supported by any proxy. If GOSUMDB is set - to off, the checksum database is not consulted and only the - existing checksums in the go.sum file are verified. -

- -

- Users who cannot reach the default proxy and checksum database (for example, - due to a firewalled or sandboxed configuration) may disable their use by - setting GOPROXY to direct, and/or - GOSUMDB to off. - go env -w - can be used to set the default values for these variables independent of - platform: -

-
-go env -w GOPROXY=direct
-go env -w GOSUMDB=off
-
- -

go get

- -

- In module-aware mode, - go get - with the -u flag now updates a smaller set of modules that is - more consistent with the set of packages updated by - go get -u in GOPATH mode. - go get -u continues to update the - modules and packages named on the command line, but additionally updates only - the modules containing the packages imported by the named packages, - rather than the transitive module requirements of the modules containing the - named packages. -

- -

- Note in particular that go get -u - (without additional arguments) now updates only the transitive imports of the - package in the current directory. To instead update all of the packages - transitively imported by the main module (including test dependencies), use - go get -u all. -

- -

- As a result of the above changes to - go get -u, the - go get subcommand no longer supports - the -m flag, which caused go get to - stop before loading packages. The -d flag remains supported, and - continues to cause go get to stop after downloading - the source code needed to build dependencies of the named packages. -

- -

- By default, go get -u in module mode - upgrades only non-test dependencies, as in GOPATH mode. It now also accepts - the -t flag, which (as in GOPATH mode) - causes go get to include the packages imported - by tests of the packages named on the command line. -

- -

- In module-aware mode, the go get subcommand now - supports the version suffix @patch. The @patch - suffix indicates that the named module, or module containing the named - package, should be updated to the highest patch release with the same - major and minor versions as the version found in the build list. -

- -

- If a module passed as an argument to go get - without a version suffix is already required at a newer version than the - latest released version, it will remain at the newer version. This is - consistent with the behavior of the -u flag for module - dependencies. This prevents unexpected downgrades from pre-release versions. - The new version suffix @upgrade explicitly requests this - behavior. @latest explicitly requests the latest version - regardless of the current version. -

- -

Version validation

- -

- When extracting a module from a version control system, the go - command now performs additional validation on the requested version string. -

- -

- The +incompatible version annotation bypasses the requirement - of semantic - import versioning for repositories that predate the introduction of - modules. The go command now verifies that such a version does not - include an explicit go.mod file. -

- -

- The go command now verifies the mapping - between pseudo-versions and - version-control metadata. Specifically: -

    -
  • The version prefix must be of the form vX.0.0, or derived - from a tag on an ancestor of the named revision, or derived from a tag that - includes build metadata on - the named revision itself.
  • - -
  • The date string must match the UTC timestamp of the revision.
  • - -
  • The short name of the revision must use the same number of characters as - what the go command would generate. (For SHA-1 hashes as used - by git, a 12-digit prefix.)
  • -
-

- -

- If a require directive in the - main module uses - an invalid pseudo-version, it can usually be corrected by redacting the - version to just the commit hash and re-running a go command, such - as go list -m all - or go mod tidy. For example, -

-
require github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c
-

can be redacted to

-
require github.com/docker/docker e7b5f7dbe98c
-

which currently resolves to

-
require github.com/docker/docker v0.7.3-0.20190319215453-e7b5f7dbe98c
- -

- If one of the transitive dependencies of the main module requires an invalid - version or pseudo-version, the invalid version can be replaced with a valid - one using a - replace directive in - the go.mod file of the main module. If the replacement is a - commit hash, it will be resolved to the appropriate pseudo-version as above. - For example, -

-
replace github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c => github.com/docker/docker e7b5f7dbe98c
-

currently resolves to

-
replace github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c => github.com/docker/docker v0.7.3-0.20190319215453-e7b5f7dbe98c
- -

Go command

- -

- The go env - command now accepts a -w flag to set the per-user default value - of an environment variable recognized by the - go command, and a corresponding -u flag to unset a - previously-set default. Defaults set via - go env -w are stored in the - go/env file within - os.UserConfigDir(). -

- -

- The - go version command now accepts arguments naming - executables and directories. When invoked on an executable, - go version prints the version of Go used to build - the executable. If the -m flag is used, - go version prints the executable's embedded module - version information, if available. When invoked on a directory, - go version prints information about executables - contained in the directory and its subdirectories. -

- -

- The new go - build flag -trimpath removes all file system paths - from the compiled executable, to improve build reproducibility. -

- -

- If the -o flag passed to go build - refers to an existing directory, go build will now - write executable files within that directory for main packages - matching its package arguments. -

- -

- The go build flag -tags now takes a - comma-separated list of build tags, to allow for multiple tags in - GOFLAGS. The - space-separated form is deprecated but still recognized and will be maintained. -

- -

- go - generate now sets the generate build tag so that - files may be searched for directives but ignored during build. -

- -

- As announced in the Go 1.12 release - notes, binary-only packages are no longer supported. Building a binary-only - package (marked with a //go:binary-only-package comment) now - results in an error. -

- -

Compiler toolchain

- -

- The compiler has a new implementation of escape analysis that is - more precise. For most Go code should be an improvement (in other - words, more Go variables and expressions allocated on the stack - instead of heap). However, this increased precision may also break - invalid code that happened to work before (for example, code that - violates - the unsafe.Pointer - safety rules). If you notice any regressions that appear - related, the old escape analysis pass can be re-enabled - with go build -gcflags=all=-newescape=false. - The option to use the old escape analysis will be removed in a - future release. -

- -

- The compiler no longer emits floating point or complex constants - to go_asm.h files. These have always been emitted in a - form that could not be used as numeric constant in assembly code. -

- -

Assembler

- -

- The assembler now supports many of the atomic instructions - introduced in ARM v8.1. -

- -

gofmt

- -

- gofmt (and with that go fmt) now canonicalizes - number literal prefixes and exponents to use lower-case letters, but - leaves hexadecimal digits alone. This improves readability when using the new octal prefix - (0O becomes 0o), and the rewrite is applied consistently. - gofmt now also removes unnecessary leading zeroes from a decimal integer - imaginary literal. (For backwards-compatibility, an integer imaginary literal - starting with 0 is considered a decimal, not an octal number. - Removing superfluous leading zeroes avoids potential confusion.) - For instance, 0B1010, 0XabcDEF, 0O660, - 1.2E3, and 01i become 0b1010, 0xabcDEF, - 0o660, 1.2e3, and 1i after applying gofmt. -

- -

godoc and go doc

- -

- The godoc webserver is no longer included in the main binary distribution. - To run the godoc webserver locally, manually install it first: -

-go get golang.org/x/tools/cmd/godoc
-godoc
-
-

- -

- The - go doc - command now always includes the package clause in its output, except for - commands. This replaces the previous behavior where a heuristic was used, - causing the package clause to be omitted under certain conditions. -

- -

Runtime

- -

- Out of range panic messages now include the index that was out of - bounds and the length (or capacity) of the slice. For - example, s[3] on a slice of length 1 will panic with - "runtime error: index out of range [3] with length 1". -

- -

- This release improves performance of most uses of defer - by 30%. -

- -

- The runtime is now more aggressive at returning memory to the - operating system to make it available to co-tenant applications. - Previously, the runtime could retain memory for five or more minutes - following a spike in the heap size. It will now begin returning it - promptly after the heap shrinks. However, on many OSes, including - Linux, the OS itself reclaims memory lazily, so process RSS will not - decrease until the system is under memory pressure. -

- -

Core library

- -

TLS 1.3

- -

- As announced in Go 1.12, Go 1.13 enables support for TLS 1.3 in the - crypto/tls package by default. It can be disabled by adding the - value tls13=0 to the GODEBUG - environment variable. The opt-out will be removed in Go 1.14. -

- -

- See the Go 1.12 release notes for important - compatibility information. -

- -

crypto/ed25519

- -

- The new crypto/ed25519 - package implements the Ed25519 signature - scheme. This functionality was previously provided by the - golang.org/x/crypto/ed25519 - package, which becomes a wrapper for - crypto/ed25519 when used with Go 1.13+. -

- -

Error wrapping

- -

- Go 1.13 contains support for error wrapping, as first proposed in - the - Error Values proposal and discussed on the - associated issue. -

-

- An error e can wrap another error w by providing - an Unwrap method that returns w. Both e - and w are available to programs, allowing e to provide - additional context to w or to reinterpret it while still allowing - programs to make decisions based on w. -

-

- To support wrapping, fmt.Errorf now has a %w - verb for creating wrapped errors, and three new functions in - the errors package ( - errors.Unwrap, - errors.Is and - errors.As) simplify unwrapping - and inspecting wrapped errors. -

-

- For more information, read the errors package - documentation, or see - the Error Value FAQ. - There will soon be a blog post as well. -

- -

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. -

- -
bytes
-
-

- The new ToValidUTF8 function returns a - copy of a given byte slice with each run of invalid UTF-8 byte sequences replaced by a given slice. -

- -
- -
context
-
-

- The formatting of contexts returned by WithValue no longer depends on fmt and will not stringify in the same way. Code that depends on the exact previous stringification might be affected. -

- -
- -
crypto/tls
-
-

- Support for SSL version 3.0 (SSLv3) - is now deprecated and will be removed in Go 1.14. Note that SSLv3 is the - cryptographically broken - protocol predating TLS. -

- -

- SSLv3 was always disabled by default, other than in Go 1.12, when it was - mistakenly enabled by default server-side. It is now again disabled by - default. (SSLv3 was never supported client-side.) -

- -

- Ed25519 certificates are now supported in TLS versions 1.2 and 1.3. -

- -
- -
crypto/x509
-
-

- Ed25519 keys are now supported in certificates and certificate requests - according to RFC 8410, as well as by the - ParsePKCS8PrivateKey, - MarshalPKCS8PrivateKey, - and ParsePKIXPublicKey functions. -

- -

- The paths searched for system roots now include /etc/ssl/cert.pem - to support the default location in Alpine Linux 3.7+. -

- -
- -
database/sql
-
-

- The new NullTime type represents a time.Time that may be null. -

- -

- The new NullInt32 type represents an int32 that may be null. -

- -
- -
debug/dwarf
-
-

- The Data.Type - method no longer panics if it encounters an unknown DWARF tag in - the type graph. Instead, it represents that component of the - type with - an UnsupportedType - object. -

- -
- -
errors
-
- -

- The new function As finds the first - error in a given error’s chain (sequence of wrapped errors) - that matches a given target’s type, and if so, sets the target to that error value. -

-

- The new function Is reports whether a given error value matches an - error in another’s chain. -

-

- The new function Unwrap returns the result of calling - Unwrap on a given error, if one exists. -

- -
- -
fmt
-
- -

- The printing verbs %x and %X now format floating-point and - complex numbers in hexadecimal notation, in lower-case and upper-case respectively. -

- - -

- The new printing verb %O formats integers in base 8, emitting the 0o prefix. -

- - -

- The scanner now accepts hexadecimal floating-point values, digit-separating underscores - and leading 0b and 0o prefixes. - See the Changes to the language for details. -

- - -

The Errorf function - has a new verb, %w, whose operand must be an error. - The error returned from Errorf will have an - Unwrap method which returns the operand of %w. -

- -
- - -
go/scanner
-
-

- The scanner has been updated to recognize the new Go number literals, specifically - binary literals with 0b/0B prefix, octal literals with 0o/0O prefix, - and floating-point numbers with hexadecimal mantissa. The imaginary suffix i may now be used with any number - literal, and underscores may be used as digit separators for grouping. - See the Changes to the language for details. -

- -
- -
go/types
-
-

- The type-checker has been updated to follow the new rules for integer shifts. - See the Changes to the language for details. -

- -
- - - -
html/template
-
-

- When using a <script> tag with "module" set as the - type attribute, code will now be interpreted as JavaScript module script. -

- -
- -
log
-
-

- The new Writer function returns the output destination for the standard logger. -

- -
- -
math/big
-
-

- The new Rat.SetUint64 method sets the Rat to a uint64 value. -

- -

- For Float.Parse, if base is 0, underscores - may be used between digits for readability. - See the Changes to the language for details. -

- -

- For Int.SetString, if base is 0, underscores - may be used between digits for readability. - See the Changes to the language for details. -

- -

- Rat.SetString now accepts non-decimal floating point representations. -

- -
- -
math/bits
-
-

- The execution time of Add, - Sub, - Mul, - RotateLeft, and - ReverseBytes is now - guaranteed to be independent of the inputs. -

- -
- -
net
-
-

- On Unix systems where use-vc is set in resolv.conf, TCP is used for DNS resolution. -

- -

- The new field ListenConfig.KeepAlive - specifies the keep-alive period for network connections accepted by the listener. - If this field is 0 (the default) TCP keep-alives will be enabled. - To disable them, set it to a negative value. -

-

- Note that the error returned from I/O on a connection that was - closed by a keep-alive timeout will have a - Timeout method that returns true if called. - This can make a keep-alive error difficult to distinguish from - an error returned due to a missed deadline as set by the - SetDeadline - method and similar methods. - Code that uses deadlines and checks for them with - the Timeout method or - with os.IsTimeout - may want to disable keep-alives, or - use errors.Is(syscall.ETIMEDOUT) (on Unix systems) - which will return true for a keep-alive timeout and false for a - deadline timeout. -

- -
- -
net/http
-
-

- The new fields Transport.WriteBufferSize - and Transport.ReadBufferSize - allow one to specify the sizes of the write and read buffers for a Transport. - If either field is zero, a default size of 4KB is used. -

- -

- The new field Transport.ForceAttemptHTTP2 - controls whether HTTP/2 is enabled when a non-zero Dial, DialTLS, or DialContext - func or TLSClientConfig is provided. -

- -

- Transport.MaxConnsPerHost now works - properly with HTTP/2. -

- -

- TimeoutHandler's - ResponseWriter now implements the - Pusher interface. -

- -

- The StatusCode 103 "Early Hints" has been added. -

- -

- Transport now uses the Request.Body's - io.ReaderFrom implementation if available, to optimize writing the body. -

- -

- On encountering unsupported transfer-encodings, http.Server now - returns a "501 Unimplemented" status as mandated by the HTTP specification RFC 7230 Section 3.3.1. -

- -

- The new Server fields - BaseContext and - ConnContext - allow finer control over the Context values provided to requests and connections. -

- -

- http.DetectContentType now correctly detects RAR signatures, and can now also detect RAR v5 signatures. -

- -

- The new Header method - Clone returns a copy of the receiver. -

- -

- A new function NewRequestWithContext has been added and it - accepts a Context that controls the entire lifetime of - the created outgoing Request, suitable for use with - Client.Do and Transport.RoundTrip. -

- -

- The Transport no longer logs errors when servers - gracefully shut down idle connections using a "408 Request Timeout" response. -

- -
- -
os
-
-

- The new UserConfigDir function - returns the default directory to use for user-specific configuration data. -

- -

- If a File is opened using the O_APPEND flag, its - WriteAt method will always return an error. -

- -
- -
os/exec
-
-

- On Windows, the environment for a Cmd always inherits the - %SYSTEMROOT% value of the parent process unless the - Cmd.Env field includes an explicit value for it. -

- -
- -
reflect
-
-

- The new Value.IsZero method reports whether a Value is the zero value for its type. -

- -

- The MakeFunc function now allows assignment conversions on returned values, instead of requiring exact type match. This is particularly useful when the type being returned is an interface type, but the value actually returned is a concrete value implementing that type. -

- -
- -
runtime
-
-

- Tracebacks, runtime.Caller, - and runtime.Callers now refer to the function that - initializes the global variables of PKG - as PKG.init instead of PKG.init.ializers. -

- -
- -
strconv
-
-

- For strconv.ParseFloat, - strconv.ParseInt - and strconv.ParseUint, - if base is 0, underscores may be used between digits for readability. - See the Changes to the language for details. -

- -
- -
strings
-
-

- The new ToValidUTF8 function returns a - copy of a given string with each run of invalid UTF-8 byte sequences replaced by a given string. -

- -
- -
sync
-
-

- The fast paths of Mutex.Lock, Mutex.Unlock, - RWMutex.Lock, RWMutex.RUnlock, and - Once.Do are now inlined in their callers. - For the uncontended cases on amd64, these changes make Once.Do twice as fast, and the - Mutex/RWMutex methods up to 10% faster. -

- -

- Large Pool no longer increase stop-the-world pause times. -

- -

- Pool no longer needs to be completely repopulated after every GC. It now retains some objects across GCs, - as opposed to releasing all objects, reducing load spikes for heavy users of Pool. -

- -
- -
syscall
-
-

- Uses of _getdirentries64 have been removed from - Darwin builds, to allow Go binaries to be uploaded to the macOS - App Store. -

- -

- The new ProcessAttributes and ThreadAttributes fields in - SysProcAttr have been introduced for Windows, - exposing security settings when creating new processes. -

- -

- EINVAL is no longer returned in zero - Chmod mode on Windows. -

- -

- Values of type Errno can be tested against error values in - the os package, - like ErrExist, using - errors.Is. -

- -
- -
syscall/js
-
-

- TypedArrayOf has been replaced by - CopyBytesToGo and - CopyBytesToJS for copying bytes - between a byte slice and a Uint8Array. -

- -
- -
testing
-
-

- When running benchmarks, B.N is no longer rounded. -

- -

- The new method B.ReportMetric lets users report - custom benchmark metrics and override built-in metrics. -

- -

- Testing flags are now registered in the new Init function, - which is invoked by the generated main function for the test. - As a result, testing flags are now only registered when running a test binary, - and packages that call flag.Parse during package initialization may cause tests to fail. -

- -
- -
text/scanner
-
-

- The scanner has been updated to recognize the new Go number literals, specifically - binary literals with 0b/0B prefix, octal literals with 0o/0O prefix, - and floating-point numbers with hexadecimal mantissa. - Also, the new AllowDigitSeparators - mode allows number literals to contain underscores as digit separators (off by default for backwards-compatibility). - See the Changes to the language for details. -

- -
- -
text/template
-
-

- The new slice function - returns the result of slicing its first argument by the following arguments. -

- -
- -
time
-
-

- Day-of-year is now supported by Format - and Parse. -

- -

- The new Duration methods - Microseconds and - Milliseconds return - the duration as an integer count of their respectively named units. -

- -
- -
unicode
-
-

- The unicode package and associated - support throughout the system has been upgraded from Unicode 10.0 to - Unicode 11.0, - which adds 684 new characters, including seven new scripts, and 66 new emoji. -

- -
diff --git a/_content/doc/go1.14.html b/_content/doc/go1.14.html deleted file mode 100644 index 14c78d21e6..0000000000 --- a/_content/doc/go1.14.html +++ /dev/null @@ -1,929 +0,0 @@ - - - - - - -

Introduction to Go 1.14

- -

- The latest Go release, version 1.14, arrives six months after Go 1.13. - 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. -

- -

- Module support in the go command is now ready for production use, - and we encourage all users to migrate to Go - modules for dependency management. If you are unable to migrate due to a problem in the Go - toolchain, please ensure that the problem has an - open issue - filed. (If the issue is not on the Go1.15 milestone, please let us - know why it prevents you from migrating so that we can prioritize it - appropriately.) -

- -

Changes to the language

- -

- Per the overlapping interfaces proposal, - Go 1.14 now permits embedding of interfaces with overlapping method sets: - methods from an embedded interface may have the same names and identical signatures - as methods already present in the (embedding) interface. This solves problems that typically - (but not exclusively) occur with diamond-shaped embedding graphs. - Explicitly declared methods in an interface must remain - unique, as before. -

- -

Ports

- -

Darwin

- -

- Go 1.14 is the last release that will run on macOS 10.11 El Capitan. - Go 1.15 will require macOS 10.12 Sierra or later. -

- -

- Go 1.14 is the last Go release to support 32-bit binaries on - macOS (the darwin/386 port). They are no longer - supported by macOS, starting with macOS 10.15 (Catalina). - Go continues to support the 64-bit darwin/amd64 port. -

- -

- Go 1.14 will likely be the last Go release to support 32-bit - binaries on iOS, iPadOS, watchOS, and tvOS - (the darwin/arm port). Go continues to support the - 64-bit darwin/arm64 port. -

- -

Windows

- -

- Go binaries on Windows now - have DEP - (Data Execution Prevention) enabled. -

- -

- On Windows, creating a file - via os.OpenFile with - the os.O_CREATE flag, or - via syscall.Open with - the syscall.O_CREAT - flag, will now create the file as read-only if the - bit 0o200 (owner write permission) is not set in the - permission argument. This makes the behavior on Windows more like - that on Unix systems. -

- -

WebAssembly

- -

- JavaScript values referenced from Go via js.Value - objects can now be garbage collected. -

- -

- js.Value values can no longer be compared using - the == operator, and instead must be compared using - their Equal method. -

- -

- js.Value now - has IsUndefined, IsNull, - and IsNaN methods. -

- -

RISC-V

- -

- Go 1.14 contains experimental support for 64-bit RISC-V on Linux - (GOOS=linux, GOARCH=riscv64). Be aware - that performance, assembly syntax stability, and possibly - correctness are a work in progress. -

- -

FreeBSD

- -

- Go now supports the 64-bit ARM architecture on FreeBSD 12.0 or later (the - freebsd/arm64 port). -

- -

Native Client (NaCl)

- -

- As announced in the Go 1.13 release notes, - Go 1.14 drops support for the Native Client platform (GOOS=nacl). -

- -

Illumos

- -

- The runtime now respects zone CPU caps - (the zone.cpu-cap resource control) - for runtime.NumCPU and the default value - of GOMAXPROCS. -

- -

Tools

- -

Go command

- -

Vendoring

- - -

- When the main module contains a top-level vendor directory and - its go.mod file specifies go 1.14 or - higher, the go command now defaults to -mod=vendor - for operations that accept that flag. A new value for that flag, - -mod=mod, causes the go command to instead load - modules from the module cache (as when no vendor directory is - present). -

- -

- When -mod=vendor is set (explicitly or by default), the - go command now verifies that the main module's - vendor/modules.txt file is consistent with its - go.mod file. -

- -

- go list -m no longer silently omits - transitive dependencies that do not provide packages in - the vendor directory. It now fails explicitly if - -mod=vendor is set and information is requested for a module not - mentioned in vendor/modules.txt. -

- -

Flags

- -

- The go get command no longer accepts - the -mod flag. Previously, the flag's setting either - was ignored or - caused the build to fail. -

- -

- -mod=readonly is now set by default when the go.mod - file is read-only and no top-level vendor directory is present. -

- -

- -modcacherw is a new flag that instructs the go - command to leave newly-created directories in the module cache at their - default permissions rather than making them read-only. - The use of this flag makes it more likely that tests or other tools will - accidentally add files not included in the module's verified checksum. - However, it allows the use of rm -rf - (instead of go clean -modcache) - to remove the module cache. -

- -

- -modfile=file is a new flag that instructs the go - command to read (and possibly write) an alternate go.mod file - instead of the one in the module root directory. A file - named go.mod must still be present in order to determine the - module root directory, but it is not accessed. When -modfile is - specified, an alternate go.sum file is also used: its path is - derived from the -modfile flag by trimming the .mod - extension and appending .sum. -

- -

Environment variables

- -

- GOINSECURE is a new environment variable that instructs - the go command to not require an HTTPS connection, and to skip - certificate validation, when fetching certain modules directly from their - origins. Like the existing GOPRIVATE variable, the value - of GOINSECURE is a comma-separated list of glob patterns. -

- -

Commands outside modules

- -

- When module-aware mode is enabled explicitly (by setting - GO111MODULE=on), most module commands have more - limited functionality if no go.mod file is present. For - example, go build, - go run, and other build commands can only build - packages in the standard library and packages specified as .go - files on the command line. -

- -

- Previously, the go command would resolve each package path - to the latest version of a module but would not record the module path - or version. This resulted in slow, - non-reproducible builds. -

- -

- go get continues to work as before, as do - go mod download and - go list -m with explicit versions. -

- -

+incompatible versions

- - -

- If the latest version of a module contains a go.mod file, - go get will no longer upgrade to an - incompatible - major version of that module unless such a version is requested explicitly - or is already required. - go list also omits incompatible major versions - for such a module when fetching directly from version control, but may - include them if reported by a proxy. -

- - -

go.mod file maintenance

- - -

- go commands other than - go mod tidy no longer - remove a require directive that specifies a version of an indirect dependency - that is already implied by other (transitive) dependencies of the main - module. -

- -

- go commands other than - go mod tidy no longer - edit the go.mod file if the changes are only cosmetic. -

- -

- When -mod=readonly is set, go commands will no - longer fail due to a missing go directive or an erroneous - // indirect comment. -

- -

Module downloading

- -

- The go command now supports Subversion repositories in module mode. -

- -

- The go command now includes snippets of plain-text error messages - from module proxies and other HTTP servers. - An error message will only be shown if it is valid UTF-8 and consists of only - graphic characters and spaces. -

- -

Testing

- -

- go test -v now streams t.Log output as it happens, - rather than at the end of all tests. -

- -

Runtime

- -

- This release improves the performance of most uses - of defer to incur almost zero overhead compared to - calling the deferred function directly. - As a result, defer can now be used in - performance-critical code without overhead concerns. -

- -

- Goroutines are now asynchronously preemptible. - As a result, loops without function calls no longer potentially - deadlock the scheduler or significantly delay garbage collection. - This is supported on all platforms except windows/arm, - darwin/arm, js/wasm, and - plan9/*. -

- -

- A consequence of the implementation of preemption is that on Unix - systems, including Linux and macOS systems, programs built with Go - 1.14 will receive more signals than programs built with earlier - releases. - This means that programs that use packages - like syscall - or golang.org/x/sys/unix - will see more slow system calls fail with EINTR errors. - Those programs will have to handle those errors in some way, most - likely looping to try the system call again. For more - information about this - see man - 7 signal for Linux systems or similar documentation for - other systems. -

- -

- The page allocator is more efficient and incurs significantly less - lock contention at high values of GOMAXPROCS. - This is most noticeable as lower latency and higher throughput for - large allocations being done in parallel and at a high rate. -

- -

- Internal timers, used by - time.After, - time.Tick, - net.Conn.SetDeadline, - and friends, are more efficient, with less lock contention and fewer - context switches. - This is a performance improvement that should not cause any user - visible changes. -

- -

Compiler

- -

- This release adds -d=checkptr as a compile-time option - for adding instrumentation to check that Go code is following - unsafe.Pointer safety rules dynamically. - This option is enabled by default (except on Windows) with - the -race or -msan flags, and can be - disabled with -gcflags=all=-d=checkptr=0. - Specifically, -d=checkptr checks the following: -

- -
    -
  1. - When converting unsafe.Pointer to *T, - the resulting pointer must be aligned appropriately - for T. -
  2. -
  3. - If the result of pointer arithmetic points into a Go heap object, - one of the unsafe.Pointer-typed operands must point - into the same object. -
  4. -
- -

- Using -d=checkptr is not currently recommended on - Windows because it causes false alerts in the standard library. -

- -

- The compiler can now emit machine-readable logs of key optimizations - using the -json flag, including inlining, escape - analysis, bounds-check elimination, and nil-check elimination. -

- -

- Detailed escape analysis diagnostics (-m=2) now work again. - This had been dropped from the new escape analysis implementation in - the previous release. -

- -

- All Go symbols in macOS binaries now begin with an underscore, - following platform conventions. -

- -

- This release includes experimental support for compiler-inserted - coverage instrumentation for fuzzing. - See issue 14565 for more - details. - This API may change in future releases. -

- -

- Bounds check elimination now uses information from slice creation and can - eliminate checks for indexes with types smaller than int. -

- -

Core library

- -

New byte sequence hashing package

- -

- Go 1.14 includes a new package, - hash/maphash, - which provides hash functions on byte sequences. - These hash functions are intended to be used to implement hash tables or - other data structures that need to map arbitrary strings or byte - sequences to a uniform distribution on unsigned 64-bit integers. -

-

- The hash functions are collision-resistant but not cryptographically secure. -

-

- The hash value of a given byte sequence is consistent within a - single process, but will be different in different processes. -

- -

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. -

- -
crypto/tls
-
-

- Support for SSL version 3.0 (SSLv3) has been removed. Note that SSLv3 is the - cryptographically broken - protocol predating TLS. -

- -

- TLS 1.3 can't be disabled via the GODEBUG environment - variable anymore. Use the - Config.MaxVersion - field to configure TLS versions. -

- -

- When multiple certificate chains are provided through the - Config.Certificates - field, the first one compatible with the peer is now automatically - selected. This allows for example providing an ECDSA and an RSA - certificate, and letting the package automatically select the best one. - Note that the performance of this selection is going to be poor unless the - Certificate.Leaf - field is set. The - Config.NameToCertificate - field, which only supports associating a single certificate with - a give name, is now deprecated and should be left as nil. - Similarly the - Config.BuildNameToCertificate - method, which builds the NameToCertificate field - from the leaf certificates, is now deprecated and should not be - called. -

- -

- The new CipherSuites - and InsecureCipherSuites - functions return a list of currently implemented cipher suites. - The new CipherSuiteName - function returns a name for a cipher suite ID. -

- -

- The new - (*ClientHelloInfo).SupportsCertificate and - - (*CertificateRequestInfo).SupportsCertificate - methods expose whether a peer supports a certain certificate. -

- -

- The tls package no longer supports the legacy Next Protocol - Negotiation (NPN) extension and now only supports ALPN. In previous - releases it supported both. There are no API changes and applications - should function identically as before. Most other clients and servers have - already removed NPN support in favor of the standardized ALPN. -

- -

- RSA-PSS signatures are now used when supported in TLS 1.2 handshakes. This - won't affect most applications, but custom - Certificate.PrivateKey - implementations that don't support RSA-PSS signatures will need to use the new - - Certificate.SupportedSignatureAlgorithms - field to disable them. -

- -

- Config.Certificates and - Config.GetCertificate - can now both be nil if - Config.GetConfigForClient - is set. If the callbacks return neither certificates nor an error, the - unrecognized_name is now sent. -

- -

- The new CertificateRequestInfo.Version - field provides the TLS version to client certificates callbacks. -

- -

- The new TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 and - TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 constants use - the final names for the cipher suites previously referred to as - TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 and - TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305. -

-
-
- -
crypto/x509
-
-

- Certificate.CreateCRL - now supports Ed25519 issuers. -

-
-
- -
debug/dwarf
-
-

- The debug/dwarf package now supports reading DWARF - version 5. -

-

- The new - method (*Data).AddSection - supports adding arbitrary new DWARF sections from the input file - to the DWARF Data. -

- -

- The new - method (*Reader).ByteOrder - returns the byte order of the current compilation unit. - This may be used to interpret attributes that are encoded in the - native ordering, such as location descriptions. -

- -

- The new - method (*LineReader).Files - returns the file name table from a line reader. - This may be used to interpret the value of DWARF attributes such - as AttrDeclFile. -

-
-
- -
encoding/asn1
-
-

- Unmarshal - now supports ASN.1 string type BMPString, represented by the new - TagBMPString - constant. -

-
-
- -
encoding/json
-
-

- The Decoder - type supports a new - method InputOffset - that returns the input stream byte offset of the current - decoder position. -

- -

- Compact no longer - escapes the U+2028 and U+2029 characters, which - was never a documented feature. For proper escaping, see HTMLEscape. -

- -

- Number no longer - accepts invalid numbers, to follow the documented behavior more closely. - If a program needs to accept invalid numbers like the empty string, - consider wrapping the type with Unmarshaler. -

- -

- Unmarshal - can now support map keys with string underlying type which implement - encoding.TextUnmarshaler. -

-
-
- -
go/build
-
-

- The Context - type has a new field Dir which may be used to set - the working directory for the build. - The default is the current directory of the running process. - In module mode, this is used to locate the main module. -

-
-
- -
go/doc
-
-

- The new - function NewFromFiles - computes package documentation from a list - of *ast.File's and associates examples with the - appropriate package elements. - The new information is available in a new Examples - field - in the Package, Type, - and Func types, and a - new Suffix - field in - the Example - type. -

-
-
- -
io/ioutil
-
-

- TempDir can now create directories - whose names have predictable prefixes and suffixes. - As with TempFile, if the pattern - contains a '*', the random string replaces the last '*'. -

-
-
- -
log
-
-

- The - new Lmsgprefix - flag may be used to tell the logging functions to emit the - optional output prefix immediately before the log message rather - than at the start of the line. -

-
-
- -
math
-
-

- The new FMA function - computes x*y+z in floating point with no - intermediate rounding of the x*y - computation. Several architectures implement this computation - using dedicated hardware instructions for additional performance. -

-
-
- -
math/big
-
-

- The GCD method - now allows the inputs a and b to be - zero or negative. -

-
-
- -
math/bits
-
-

- The new functions - Rem, - Rem32, and - Rem64 - support computing a remainder even when the quotient overflows. -

-
-
- -
mime
-
-

- The default type of .js and .mjs files - is now text/javascript rather - than application/javascript. - This is in accordance - with an - IETF draft that treats application/javascript as obsolete. -

-
-
- -
mime/multipart
-
-

- The - new Reader - method NextRawPart - supports fetching the next MIME part without transparently - decoding quoted-printable data. -

-
-
- -
net/http
-
-

- The new Header - method Values - can be used to fetch all values associated with a - canonicalized key. -

- -

- The - new Transport - field DialTLSContext - can be used to specify an optional dial function for creating - TLS connections for non-proxied HTTPS requests. - This new field can be used instead - of DialTLS, - which is now considered deprecated; DialTLS will - continue to work, but new code should - use DialTLSContext, which allows the transport to - cancel dials as soon as they are no longer needed. -

- -

- On Windows, ServeFile now correctly - serves files larger than 2GB. -

-
-
- -
net/http/httptest
-
-

- The - new Server - field EnableHTTP2 - supports enabling HTTP/2 on the test server. -

-
-
- -
net/textproto
-
-

- The - new MIMEHeader - method Values - can be used to fetch all values associated with a canonicalized - key. -

-
-
- -
net/url
-
-

- When parsing of a URL fails - (for example by Parse - or ParseRequestURI), - the resulting Error message - will now quote the unparsable URL. - This provides clearer structure and consistency with other parsing errors. -

-
-
- -
os/signal
-
-

- On Windows, - the CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, - and CTRL_SHUTDOWN_EVENT events now generate - a syscall.SIGTERM signal, similar to how Control-C - and Control-Break generate a syscall.SIGINT signal. -

-
-
- -
plugin
-
-

- The plugin package now supports freebsd/amd64. -

-
-
- -
reflect
-
-

- StructOf now - supports creating struct types with unexported fields, by - setting the PkgPath field in - a StructField element. -

-
-
- -
runtime
-
-

- runtime.Goexit can no longer be aborted by a - recursive panic/recover. -

- -

- On macOS, SIGPIPE is no longer forwarded to signal - handlers installed before the Go runtime is initialized. - This is necessary because macOS delivers SIGPIPE - to the main thread - rather than the thread writing to the closed pipe. -

-
-
- -
runtime/pprof
-
-

- The generated profile no longer includes the pseudo-PCs used for inline - marks. Symbol information of inlined functions is encoded in - the format - the pprof tool expects. This is a fix for the regression introduced - during recent releases. -

-
-
- -
strconv
-
-

- The NumError - type now has - an Unwrap - method that may be used to retrieve the reason that a conversion - failed. - This supports using NumError values - with errors.Is to see - if the underlying error - is strconv.ErrRange - or strconv.ErrSyntax. -

-
-
- -
sync
-
-

- Unlocking a highly contended Mutex now directly - yields the CPU to the next goroutine waiting for - that Mutex. This significantly improves the - performance of highly contended mutexes on high CPU count - machines. -

-
-
- -
testing
-
-

- The testing package now supports cleanup functions, called after - a test or benchmark has finished, by calling - T.Cleanup or - B.Cleanup respectively. -

-
-
- -
text/template
-
-

- The text/template package now correctly reports errors when a - parenthesized argument is used as a function. - This most commonly shows up in erroneous cases like - {{if (eq .F "a") or (eq .F "b")}}. - This should be written as {{if or (eq .F "a") (eq .F "b")}}. - The erroneous case never worked as expected, and will now be - reported with an error can't give argument to non-function. -

- -

- JSEscape now - escapes the & and = characters to - mitigate the impact of its output being misused in HTML contexts. -

-
-
- -
unicode
-
-

- The unicode package and associated - support throughout the system has been upgraded from Unicode 11.0 to - Unicode 12.0, - which adds 554 new characters, including four new scripts, and 61 new emoji. -

-
-
diff --git a/_content/doc/go1.15.html b/_content/doc/go1.15.html deleted file mode 100644 index a863f30f90..0000000000 --- a/_content/doc/go1.15.html +++ /dev/null @@ -1,1063 +0,0 @@ - - - - - - -

Introduction to Go 1.15

- -

- The latest Go release, version 1.15, arrives six months after Go 1.14. - 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. -

- -

- Go 1.15 includes substantial improvements to the linker, - improves allocation for small objects at high core counts, and - deprecates X.509 CommonName. - GOPROXY now supports skipping proxies that return errors and - a new embedded tzdata package has been added. -

- -

Changes to the language

- -

- There are no changes to the language. -

- -

Ports

- -

Darwin

- -

- As announced in the Go 1.14 release - notes, Go 1.15 requires macOS 10.12 Sierra or later; support for - previous versions has been discontinued. -

- -

- As announced in the Go 1.14 release - notes, Go 1.15 drops support for 32-bit binaries on macOS, iOS, - iPadOS, watchOS, and tvOS (the darwin/386 - and darwin/arm ports). Go continues to support the - 64-bit darwin/amd64 and darwin/arm64 ports. -

- -

Windows

- -

- Go now generates Windows ASLR executables when -buildmode=pie - cmd/link flag is provided. Go command uses -buildmode=pie - by default on Windows. -

- -

- The -race and -msan flags now always - enable -d=checkptr, which checks uses - of unsafe.Pointer. This was previously the case on all - OSes except Windows. -

- -

- Go-built DLLs no longer cause the process to exit when it receives a - signal (such as Ctrl-C at a terminal). -

- -

Android

- -

- When linking binaries for Android, Go 1.15 explicitly selects - the lld linker available in recent versions of the NDK. - The lld linker avoids crashes on some devices, and is - planned to become the default NDK linker in a future NDK version. -

- -

OpenBSD

- -

- Go 1.15 adds support for OpenBSD 6.7 on GOARCH=arm - and GOARCH=arm64. Previous versions of Go already - supported OpenBSD 6.7 on GOARCH=386 - and GOARCH=amd64. -

- -

RISC-V

- -

- There has been progress in improving the stability and performance - of the 64-bit RISC-V port on Linux (GOOS=linux, - GOARCH=riscv64). It also now supports asynchronous - preemption. -

- -

386

- -

- Go 1.15 is the last release to support x87-only floating-point - hardware (GO386=387). Future releases will require at - least SSE2 support on 386, raising Go's - minimum GOARCH=386 requirement to the Intel Pentium 4 - (released in 2000) or AMD Opteron/Athlon 64 (released in 2003). -

- -

Tools

- -

Go command

- -

- The GOPROXY environment variable now supports skipping proxies - that return errors. Proxy URLs may now be separated with either commas - (,) or pipe characters (|). If a proxy URL is - followed by a comma, the go command will only try the next proxy - in the list after a 404 or 410 HTTP response. If a proxy URL is followed by a - pipe character, the go command will try the next proxy in the - list after any error. Note that the default value of GOPROXY - remains https://proxy.golang.org,direct, which does not fall - back to direct in case of errors. -

- -

go test

- -

- Changing the -timeout flag now invalidates cached test results. A - cached result for a test run with a long timeout will no longer count as - passing when go test is re-invoked with a short one. -

- -

Flag parsing

- -

- Various flag parsing issues in go test and - go vet have been fixed. Notably, flags specified - in GOFLAGS are handled more consistently, and - the -outputdir flag now interprets relative paths relative to the - working directory of the go command (rather than the working - directory of each individual test). -

- -

Module cache

- -

- The location of the module cache may now be set with - the GOMODCACHE environment variable. The default value of - GOMODCACHE is GOPATH[0]/pkg/mod, the location of the - module cache before this change. -

- -

- A workaround is now available for Windows "Access is denied" errors in - go commands that access the module cache, caused by external - programs concurrently scanning the file system (see - issue #36568). The workaround is - not enabled by default because it is not safe to use when Go versions lower - than 1.14.2 and 1.13.10 are running concurrently with the same module cache. - It can be enabled by explicitly setting the environment variable - GODEBUG=modcacheunzipinplace=1. -

- -

Vet

- -

New warning for string(x)

- -

- The vet tool now warns about conversions of the - form string(x) where x has an integer type - other than rune or byte. - Experience with Go has shown that many conversions of this form - erroneously assume that string(x) evaluates to the - string representation of the integer x. - It actually evaluates to a string containing the UTF-8 encoding of - the value of x. - For example, string(9786) does not evaluate to the - string "9786"; it evaluates to the - string "\xe2\x98\xba", or "☺". -

- -

- Code that is using string(x) correctly can be rewritten - to string(rune(x)). - Or, in some cases, calling utf8.EncodeRune(buf, x) with - a suitable byte slice buf may be the right solution. - Other code should most likely use strconv.Itoa - or fmt.Sprint. -

- -

- This new vet check is enabled by default when - using go test. -

- -

- We are considering prohibiting the conversion in a future release of Go. - That is, the language would change to only - permit string(x) for integer x when the - type of x is rune or byte. - Such a language change would not be backward compatible. - We are using this vet check as a first trial step toward changing - the language. -

- -

New warning for impossible interface conversions

- -

- The vet tool now warns about type assertions from one interface type - to another interface type when the type assertion will always fail. - This will happen if both interface types implement a method with the - same name but with a different type signature. -

- -

- There is no reason to write a type assertion that always fails, so - any code that triggers this vet check should be rewritten. -

- -

- This new vet check is enabled by default when - using go test. -

- -

- We are considering prohibiting impossible interface type assertions - in a future release of Go. - Such a language change would not be backward compatible. - We are using this vet check as a first trial step toward changing - the language. -

- -

Runtime

- -

- If panic is invoked with a value whose type is derived from any - of: bool, complex64, complex128, float32, float64, - int, int8, int16, int32, int64, string, - uint, uint8, uint16, uint32, uint64, uintptr, - then the value will be printed, instead of just its address. - Previously, this was only true for values of exactly these types. -

- -

- On a Unix system, if the kill command - or kill system call is used to send - a SIGSEGV, SIGBUS, - or SIGFPE signal to a Go program, and if the signal - is not being handled via - os/signal.Notify, - the Go program will now reliably crash with a stack trace. - In earlier releases the behavior was unpredictable. -

- -

- Allocation of small objects now performs much better at high core - counts, and has lower worst-case latency. -

- -

- Converting a small integer value into an interface value no longer - causes allocation. -

- -

- Non-blocking receives on closed channels now perform as well as - non-blocking receives on open channels. -

- -

Compiler

- -

- Package unsafe's safety - rules allow converting an unsafe.Pointer - into uintptr when calling certain - functions. Previously, in some cases, the compiler allowed multiple - chained conversions (for example, syscall.Syscall(…, - uintptr(uintptr(ptr)), …)). The compiler - now requires exactly one conversion. Code that used multiple - conversions should be updated to satisfy the safety rules. -

- -

- Go 1.15 reduces typical binary sizes by around 5% compared to Go - 1.14 by eliminating certain types of GC metadata and more - aggressively eliminating unused type metadata. -

- -

- The toolchain now mitigates - Intel - CPU erratum SKX102 on GOARCH=amd64 by aligning - functions to 32 byte boundaries and padding jump instructions. While - this padding increases binary sizes, this is more than made up for - by the binary size improvements mentioned above. -

- -

- Go 1.15 adds a -spectre flag to both the - compiler and the assembler, to allow enabling Spectre mitigations. - These should almost never be needed and are provided mainly as a - “defense in depth” mechanism. - See the Spectre wiki page for details. -

- -

- The compiler now rejects //go: compiler directives that - have no meaning for the declaration they are applied to with a - "misplaced compiler directive" error. Such misapplied directives - were broken before, but were silently ignored by the compiler. -

- -

- The compiler's -json optimization logging now reports - large (>= 128 byte) copies and includes explanations of escape - analysis decisions. -

- -

Linker

- -

- This release includes substantial improvements to the Go linker, - which reduce linker resource usage (both time and memory) and - improve code robustness/maintainability. -

- -

- For a representative set of large Go programs, linking is 20% faster - and requires 30% less memory on average, for ELF-based - OSes (Linux, FreeBSD, NetBSD, OpenBSD, Dragonfly, and Solaris) - running on amd64 architectures, with more modest - improvements for other architecture/OS combinations. -

- -

- The key contributors to better linker performance are a newly - redesigned object file format, and a revamping of internal - phases to increase concurrency (for example, applying relocations to - symbols in parallel). Object files in Go 1.15 are slightly larger - than their 1.14 equivalents. -

- -

- These changes are part of a multi-release project - to modernize the Go - linker, meaning that there will be additional linker - improvements expected in future releases. -

- -

- The linker now defaults to internal linking mode - for -buildmode=pie on - linux/amd64 and linux/arm64, so these - configurations no longer require a C linker. External linking - mode (which was the default in Go 1.14 for - -buildmode=pie) can still be requested with - -ldflags=-linkmode=external flag. -

- -

Objdump

- -

- The objdump tool now supports - disassembling in GNU assembler syntax with the -gnu - flag. -

- -

Core library

- -

New embedded tzdata package

- -

- Go 1.15 includes a new package, - time/tzdata, - that permits embedding the timezone database into a program. - Importing this package (as import _ "time/tzdata") - permits the program to find timezone information even if the - timezone database is not available on the local system. - You can also embed the timezone database by building - with -tags timetzdata. - Either approach increases the size of the program by about 800 KB. -

- -

Cgo

- -

- Go 1.15 will translate the C type EGLConfig to the - Go type uintptr. This change is similar to how Go - 1.12 and newer treats EGLDisplay, Darwin's CoreFoundation and - Java's JNI types. See the cgo - documentation for more information. -

- -

- In Go 1.15.3 and later, cgo will not permit Go code to allocate an - undefined struct type (a C struct defined as just struct - S; or similar) on the stack or heap. - Go code will only be permitted to use pointers to those types. - Allocating an instance of such a struct and passing a pointer, or a - full struct value, to C code was always unsafe and unlikely to work - correctly; it is now forbidden. - The fix is to either rewrite the Go code to use only pointers, or to - ensure that the Go code sees the full definition of the struct by - including the appropriate C header file. -

- -

X.509 CommonName deprecation

- -

- The deprecated, legacy behavior of treating the CommonName - field on X.509 certificates as a host name when no Subject Alternative Names - are present is now disabled by default. It can be temporarily re-enabled by - adding the value x509ignoreCN=0 to the GODEBUG - environment variable. -

- -

- Note that if the CommonName is an invalid host name, it's always - ignored, regardless of GODEBUG settings. Invalid names include - those with any characters other than letters, digits, hyphens and underscores, - and those with empty labels or trailing dots. -

- -

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. -

- -
bufio
-
-

- When a Scanner is - used with an invalid - io.Reader that - incorrectly returns a negative number from Read, - the Scanner will no longer panic, but will instead - return the new error - ErrBadReadCount. -

-
-
- -
context
-
-

- Creating a derived Context using a nil parent is now explicitly - disallowed. Any attempt to do so with the - WithValue, - WithDeadline, or - WithCancel functions - will cause a panic. -

-
-
- -
crypto
-
-

- The PrivateKey and PublicKey types in the - crypto/rsa, - crypto/ecdsa, and - crypto/ed25519 packages - now have an Equal method to compare keys for equivalence - or to make type-safe interfaces for public keys. The method signature - is compatible with - go-cmp's - definition of equality. -

- -

- Hash now implements - fmt.Stringer. -

-
-
- -
crypto/ecdsa
-
-

- The new SignASN1 - and VerifyASN1 - functions allow generating and verifying ECDSA signatures in the standard - ASN.1 DER encoding. -

-
-
- -
crypto/elliptic
-
-

- The new MarshalCompressed - and UnmarshalCompressed - functions allow encoding and decoding NIST elliptic curve points in compressed format. -

-
-
- -
crypto/rsa
-
-

- VerifyPKCS1v15 - now rejects invalid short signatures with missing leading zeroes, according to RFC 8017. -

-
-
- -
crypto/tls
-
-

- The new - Dialer - type and its - DialContext - method permit using a context to both connect and handshake with a TLS server. -

- -

- The new - VerifyConnection - callback on the Config type - allows custom verification logic for every connection. It has access to the - ConnectionState - which includes peer certificates, SCTs, and stapled OCSP responses. -

- -

- Auto-generated session ticket keys are now automatically rotated every 24 hours, - with a lifetime of 7 days, to limit their impact on forward secrecy. -

- -

- Session ticket lifetimes in TLS 1.2 and earlier, where the session keys - are reused for resumed connections, are now limited to 7 days, also to - limit their impact on forward secrecy. -

- -

- The client-side downgrade protection checks specified in RFC 8446 are now - enforced. This has the potential to cause connection errors for clients - encountering middleboxes that behave like unauthorized downgrade attacks. -

- -

- SignatureScheme, - CurveID, and - ClientAuthType - now implement fmt.Stringer. -

- -

- The ConnectionState - fields OCSPResponse and SignedCertificateTimestamps - are now repopulated on client-side resumed connections. -

- -

- tls.Conn - now returns an opaque error on permanently broken connections, wrapping - the temporary - net.Error. To access the - original net.Error, use - errors.As (or - errors.Unwrap) instead of a - type assertion. -

-
-
- -
crypto/x509
-
-

- If either the name on the certificate or the name being verified (with - VerifyOptions.DNSName - or VerifyHostname) - are invalid, they will now be compared case-insensitively without further - processing (without honoring wildcards or stripping trailing dots). - Invalid names include those with any characters other than letters, - digits, hyphens and underscores, those with empty labels, and names on - certificates with trailing dots. -

- -

- The new CreateRevocationList - function and RevocationList type - allow creating RFC 5280-compliant X.509 v2 Certificate Revocation Lists. -

- -

- CreateCertificate - now automatically generates the SubjectKeyId if the template - is a CA and doesn't explicitly specify one. -

- -

- CreateCertificate - now returns an error if the template specifies MaxPathLen but is not a CA. -

- -

- On Unix systems other than macOS, the SSL_CERT_DIR - environment variable can now be a colon-separated list. -

- -

- On macOS, binaries are now always linked against - Security.framework to extract the system trust roots, - regardless of whether cgo is available. The resulting behavior should be - more consistent with the OS verifier. -

-
-
- -
crypto/x509/pkix
-
-

- Name.String - now prints non-standard attributes from - Names if - ExtraNames is nil. -

-
-
- -
database/sql
-
-

- The new DB.SetConnMaxIdleTime - method allows removing a connection from the connection pool after - it has been idle for a period of time, without regard to the total - lifespan of the connection. The DBStats.MaxIdleTimeClosed - field shows the total number of connections closed due to - DB.SetConnMaxIdleTime. -

- -

- The new Row.Err getter - allows checking for query errors without calling - Row.Scan. -

-
-
- -
database/sql/driver
-
-

- The new Validator - interface may be implemented by Conn to allow drivers - to signal if a connection is valid or if it should be discarded. -

-
-
- -
debug/pe
-
-

- The package now defines the - IMAGE_FILE, IMAGE_SUBSYSTEM, - and IMAGE_DLLCHARACTERISTICS constants used by the - PE file format. -

-
-
- -
encoding/asn1
-
-

- Marshal now sorts the components - of SET OF according to X.690 DER. -

- -

- Unmarshal now rejects tags and - Object Identifiers which are not minimally encoded according to X.690 DER. -

-
-
- -
encoding/json
-
-

- The package now has an internal limit to the maximum depth of - nesting when decoding. This reduces the possibility that a - deeply nested input could use large quantities of stack memory, - or even cause a "goroutine stack exceeds limit" panic. -

-
-
- -
flag
-
-

- When the flag package sees -h or -help, - and those flags are not defined, it now prints a usage message. - If the FlagSet was created with - ExitOnError, - FlagSet.Parse would then - exit with a status of 2. In this release, the exit status for -h - or -help has been changed to 0. In particular, this applies to - the default handling of command line flags. -

-
-
- -
fmt
-
-

- The printing verbs %#g and %#G now preserve - trailing zeros for floating-point values. -

-
-
- -
go/format
-
-

- The Source and - Node functions - now canonicalize number literal prefixes and exponents as part - of formatting Go source code. This matches the behavior of the - gofmt command as it - was implemented since Go 1.13. -

-
-
- -
html/template
-
-

- The package now uses Unicode escapes (\uNNNN) in all - JavaScript and JSON contexts. This fixes escaping errors in - application/ld+json and application/json - contexts. -

-
-
- -
io/ioutil
-
-

- TempDir and - TempFile - now reject patterns that contain path separators. - That is, calls such as ioutil.TempFile("/tmp", "../base*") will no longer succeed. - This prevents unintended directory traversal. -

-
-
- -
math/big
-
-

- The new Int.FillBytes - method allows serializing to fixed-size pre-allocated byte slices. -

-
-
- -
math/cmplx
-
-

- The functions in this package were updated to conform to the C99 standard - (Annex G IEC 60559-compatible complex arithmetic) with respect to handling - of special arguments such as infinity, NaN and signed zero. -

-
-
- -
net
-
-

- If an I/O operation exceeds a deadline set by - the Conn.SetDeadline, - Conn.SetReadDeadline, - or Conn.SetWriteDeadline methods, it will now - return an error that is or wraps - os.ErrDeadlineExceeded. - This may be used to reliably detect whether an error is due to - an exceeded deadline. - Earlier releases recommended calling the Timeout - method on the error, but I/O operations can return errors for - which Timeout returns true although a - deadline has not been exceeded. -

- -

- The new Resolver.LookupIP - method supports IP lookups that are both network-specific and accept a context. -

-
-
- -
net/http
-
-

- Parsing is now stricter as a hardening measure against request smuggling attacks: - non-ASCII white space is no longer trimmed like SP and HTAB, and support for the - "identity" Transfer-Encoding was dropped. -

-
-
- -
net/http/httputil
-
-

- ReverseProxy - now supports not modifying the X-Forwarded-For - header when the incoming Request.Header map entry - for that field is nil. -

- -

- When a Switching Protocol (like WebSocket) request handled by - ReverseProxy - is canceled, the backend connection is now correctly closed. -

-
-
- -
net/http/pprof
-
-

- All profile endpoints now support a "seconds" parameter. When present, - the endpoint profiles for the specified number of seconds and reports the difference. - The meaning of the "seconds" parameter in the cpu profile and - the trace endpoints is unchanged. -

-
-
- -
net/url
-
-

- The new URL field - RawFragment and method EscapedFragment - provide detail about and control over the exact encoding of a particular fragment. - These are analogous to - RawPath and EscapedPath. -

-

- The new URL - method Redacted - returns the URL in string form with any password replaced with xxxxx. -

-
-
- -
os
-
-

- If an I/O operation exceeds a deadline set by - the File.SetDeadline, - File.SetReadDeadline, - or File.SetWriteDeadline - methods, it will now return an error that is or wraps - os.ErrDeadlineExceeded. - This may be used to reliably detect whether an error is due to - an exceeded deadline. - Earlier releases recommended calling the Timeout - method on the error, but I/O operations can return errors for - which Timeout returns true although a - deadline has not been exceeded. -

- -

- Packages os and net now automatically - retry system calls that fail with EINTR. Previously - this led to spurious failures, which became more common in Go - 1.14 with the addition of asynchronous preemption. Now this is - handled transparently. -

- -

- The os.File type now - supports a ReadFrom - method. This permits the use of the copy_file_range - system call on some systems when using - io.Copy to copy data - from one os.File to another. A consequence is that - io.CopyBuffer - will not always use the provided buffer when copying to a - os.File. If a program wants to force the use of - the provided buffer, it can be done by writing - io.CopyBuffer(struct{ io.Writer }{dst}, src, buf). -

-
-
- -
plugin
-
-

- DWARF generation is now supported (and enabled by default) for -buildmode=plugin on macOS. -

-
-
-

- Building with -buildmode=plugin is now supported on freebsd/amd64. -

-
-
- -
reflect
-
-

- Package reflect now disallows accessing methods of all - non-exported fields, whereas previously it allowed accessing - those of non-exported, embedded fields. Code that relies on the - previous behavior should be updated to instead access the - corresponding promoted method of the enclosing variable. -

-
-
- -
regexp
-
-

- The new Regexp.SubexpIndex - method returns the index of the first subexpression with the given name - within the regular expression. -

-
-
- -
runtime
-
-

- Several functions, including - ReadMemStats - and - GoroutineProfile, - no longer block if a garbage collection is in progress. -

-
-
- -
runtime/pprof
-
-

- The goroutine profile now includes the profile labels associated with each - goroutine at the time of profiling. This feature is not yet implemented for - the profile reported with debug=2. -

-
-
- -
strconv
-
-

- FormatComplex and ParseComplex are added for working with complex numbers. -

-

- FormatComplex converts a complex number into a string of the form (a+bi), where a and b are the real and imaginary parts. -

-

- ParseComplex converts a string into a complex number of a specified precision. ParseComplex accepts complex numbers in the format N+Ni. -

-
-
- -
sync
-
-

- The new method - Map.LoadAndDelete - atomically deletes a key and returns the previous value if present. -

-

- The method - Map.Delete - is more efficient. -

-
-
- -
syscall
-
-

- On Unix systems, functions that use - SysProcAttr - will now reject attempts to set both the Setctty - and Foreground fields, as they both use - the Ctty field but do so in incompatible ways. - We expect that few existing programs set both fields. -

-

- Setting the Setctty field now requires that the - Ctty field be set to a file descriptor number in the - child process, as determined by the ProcAttr.Files field. - Using a child descriptor always worked, but there were certain - cases where using a parent file descriptor also happened to work. - Some programs that set Setctty will need to change - the value of Ctty to use a child descriptor number. -

- -

- It is now possible to call - system calls that return floating point values - on windows/amd64. -

-
-
- -
testing
-
-

- The testing.T type now has a - Deadline method - that reports the time at which the test binary will have exceeded its - timeout. -

- -

- A TestMain function is no longer required to call - os.Exit. If a TestMain function returns, - the test binary will call os.Exit with the value returned - by m.Run. -

- -

- The new methods - T.TempDir and - B.TempDir - return temporary directories that are automatically cleaned up - at the end of the test. -

- -

- go test -v now groups output by - test name, rather than printing the test name on each line. -

-
-
- -
text/template
-
-

- JSEscape now - consistently uses Unicode escapes (\u00XX), which are - compatible with JSON. -

-
-
- -
time
-
-

- The new method - Ticker.Reset - supports changing the duration of a ticker. -

- -

- When returning an error, ParseDuration now quotes the original value. -

-
-
diff --git a/_content/doc/go1.16.html b/_content/doc/go1.16.html deleted file mode 100644 index 109af993e6..0000000000 --- a/_content/doc/go1.16.html +++ /dev/null @@ -1,1237 +0,0 @@ - - - - - - -

Introduction to Go 1.16

- -

- The latest Go release, version 1.16, arrives six months after Go 1.15. - 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. -

- -

Changes to the language

- -

- There are no changes to the language. -

- -

Ports

- -

Darwin and iOS

- -

- Go 1.16 adds support of 64-bit ARM architecture on macOS (also known as - Apple Silicon) with GOOS=darwin, GOARCH=arm64. - Like the darwin/amd64 port, the darwin/arm64 - port supports cgo, internal and external linking, c-archive, - c-shared, and pie build modes, and the race - detector. -

- -

- The iOS port, which was previously darwin/arm64, has - been renamed to ios/arm64. GOOS=ios - implies the - darwin build tag, just as GOOS=android - implies the linux build tag. This change should be - transparent to anyone using gomobile to build iOS apps. -

- -

- The introduction of GOOS=ios means that file names - like x_ios.go will now only be built for - GOOS=ios; see - go - help buildconstraint for details. - Existing packages that use file names of this form will have to - rename the files. -

- -

- Go 1.16 adds an ios/amd64 port, which targets the iOS - simulator running on AMD64-based macOS. Previously this was - unofficially supported through darwin/amd64 with - the ios build tag set. See also - misc/ios/README for - details about how to build programs for iOS and iOS simulator. -

- -

- Go 1.16 is the last release that will run on macOS 10.12 Sierra. - Go 1.17 will require macOS 10.13 High Sierra or later. -

- -

NetBSD

- -

- Go now supports the 64-bit ARM architecture on NetBSD (the - netbsd/arm64 port). -

- -

OpenBSD

- -

- Go now supports the MIPS64 architecture on OpenBSD - (the openbsd/mips64 port). This port does not yet - support cgo. -

- -

- On the 64-bit x86 and 64-bit ARM architectures on OpenBSD (the - openbsd/amd64 and openbsd/arm64 ports), system - calls are now made through libc, instead of directly using - the SYSCALL/SVC instruction. This ensures - forward-compatibility with future versions of OpenBSD. In particular, - OpenBSD 6.9 onwards will require system calls to be made through - libc for non-static Go binaries. -

- -

386

- -

- As announced in the Go 1.15 release notes, - Go 1.16 drops support for x87 mode compilation (GO386=387). - Support for non-SSE2 processors is now available using soft float - mode (GO386=softfloat). - Users running on non-SSE2 processors should replace GO386=387 - with GO386=softfloat. -

- -

RISC-V

- -

- The linux/riscv64 port now supports cgo and - -buildmode=pie. This release also includes performance - optimizations and code generation improvements for RISC-V. -

- -

Tools

- -

Go command

- -

Modules

- -

- Module-aware mode is enabled by default, regardless of whether a - go.mod file is present in the current working directory or a - parent directory. More precisely, the GO111MODULE environment - variable now defaults to on. To switch to the previous behavior, - set GO111MODULE to auto. -

- -

- Build commands like go build and go - test no longer modify go.mod and go.sum - by default. Instead, they report an error if a module requirement or checksum - needs to be added or updated (as if the -mod=readonly flag were - used). Module requirements and sums may be adjusted with go - mod tidy or go get. -

- -

- go install now accepts arguments with - version suffixes (for example, go install - example.com/cmd@v1.0.0). This causes go - install to build and install packages in module-aware mode, - ignoring the go.mod file in the current directory or any parent - directory, if there is one. This is useful for installing executables without - affecting the dependencies of the main module. -

- -

- go install, with or without a version suffix (as - described above), is now the recommended way to build and install packages in - module mode. go get should be used with the - -d flag to adjust the current module's dependencies without - building packages, and use of go get to build and - install packages is deprecated. In a future release, the -d flag - will always be enabled. -

- -

- retract directives may now be used in a go.mod file - to indicate that certain published versions of the module should not be used - by other modules. A module author may retract a version after a severe problem - is discovered or if the version was published unintentionally. -

- -

- The go mod vendor - and go mod tidy subcommands now accept - the -e flag, which instructs them to proceed despite errors in - resolving missing packages. -

- -

- The go command now ignores requirements on module versions - excluded by exclude directives in the main module. Previously, - the go command used the next version higher than an excluded - version, but that version could change over time, resulting in - non-reproducible builds. -

- -

- In module mode, the go command now disallows import paths that - include non-ASCII characters or path elements with a leading dot character - (.). Module paths with these characters were already disallowed - (see Module paths and versions), - so this change affects only paths within module subdirectories. -

- -

Embedding Files

- -

- The go command now supports including - static files and file trees as part of the final executable, - using the new //go:embed directive. - See the documentation for the new - embed - package for details. -

- -

go test

- -

- When using go test, a test that - calls os.Exit(0) during execution of a test function - will now be considered to fail. - This will help catch cases in which a test calls code that calls - os.Exit(0) and thereby stops running all future tests. - If a TestMain function calls os.Exit(0) - that is still considered to be a passing test. -

- -

- go test reports an error when the -c - or -i flags are used together with unknown flags. Normally, - unknown flags are passed to tests, but when -c or -i - are used, tests are not run. -

- -

go get

- -

- The go get -insecure flag is - deprecated and will be removed in a future version. This flag permits - fetching from repositories and resolving custom domains using insecure - schemes such as HTTP, and also bypasses module sum validation using the - checksum database. To permit the use of insecure schemes, use the - GOINSECURE environment variable instead. To bypass module - sum validation, use GOPRIVATE or GONOSUMDB. - See go help environment for details. -

- -

- go get example.com/mod@patch now - requires that some version of example.com/mod already be - required by the main module. - (However, go get -u=patch continues - to patch even newly-added dependencies.) -

- -

GOVCS environment variable

- -

- GOVCS is a new environment variable that limits which version - control tools the go command may use to download source code. - This mitigates security issues with tools that are typically used in trusted, - authenticated environments. By default, git and hg - may be used to download code from any repository. svn, - bzr, and fossil may only be used to download code - from repositories with module paths or package paths matching patterns in - the GOPRIVATE environment variable. See - go - help vcs for details. -

- -

The all pattern

- -

- When the main module's go.mod file - declares go 1.16 or higher, the all - package pattern now matches only those packages that are transitively imported - by a package or test found in the main module. (Packages imported by tests - of packages imported by the main module are no longer included.) This is - the same set of packages retained - by go mod vendor since Go 1.11. -

- -

The -toolexec build flag

- -

- When the -toolexec build flag is specified to use a program when - invoking toolchain programs like compile or asm, the environment variable - TOOLEXEC_IMPORTPATH is now set to the import path of the package - being built. -

- -

The -i build flag

- -

- The -i flag accepted by go build, - go install, and go test is - now deprecated. The -i flag instructs the go command - to install packages imported by packages named on the command line. Since - the build cache was introduced in Go 1.10, the -i flag no longer - has a significant effect on build times, and it causes errors when the install - directory is not writable. -

- -

The list command

- -

- When the -export flag is specified, the BuildID - field is now set to the build ID of the compiled package. This is equivalent - to running go tool buildid on - go list -exported -f {{.Export}}, - but without the extra step. -

- -

The -overlay flag

- -

- The -overlay flag specifies a JSON configuration file containing - a set of file path replacements. The -overlay flag may be used - with all build commands and go mod subcommands. - It is primarily intended to be used by editor tooling such as gopls to - understand the effects of unsaved changes to source files. The config file - maps actual file paths to replacement file paths and the go - command and its builds will run as if the actual file paths exist with the - contents given by the replacement file paths, or don't exist if the replacement - file paths are empty. -

- -

Cgo

- -

- The cgo tool will no longer try to translate - C struct bitfields into Go struct fields, even if their size can be - represented in Go. The order in which C bitfields appear in memory - is implementation dependent, so in some cases the cgo tool produced - results that were silently incorrect. -

- -

Vet

- -

New warning for invalid testing.T use in -goroutines

- -

- The vet tool now warns about invalid calls to the testing.T - method Fatal from within a goroutine created during the test. - This also warns on calls to Fatalf, FailNow, and - Skip{,f,Now} methods on testing.T tests or - testing.B benchmarks. -

- -

- Calls to these methods stop the execution of the created goroutine and not - the Test* or Benchmark* function. So these are - required to be called by the goroutine - running the test or benchmark function. For example: -

- -
-func TestFoo(t *testing.T) {
-    go func() {
-        if condition() {
-            t.Fatal("oops") // This exits the inner func instead of TestFoo.
-        }
-        ...
-    }()
-}
-
- -

- Code calling t.Fatal (or a similar method) from a created - goroutine should be rewritten to signal the test failure using - t.Error and exit the goroutine early using an alternative - method, such as using a return statement. The previous example - could be rewritten as: -

- -
-func TestFoo(t *testing.T) {
-    go func() {
-        if condition() {
-            t.Error("oops")
-            return
-        }
-        ...
-    }()
-}
-
- -

New warning for frame pointer

- -

- The vet tool now warns about amd64 assembly that clobbers the BP - register (the frame pointer) without saving and restoring it, - contrary to the calling convention. Code that doesn't preserve the - BP register must be modified to either not use BP at all or preserve - BP by saving and restoring it. An easy way to preserve BP is to set - the frame size to a nonzero value, which causes the generated - prologue and epilogue to preserve the BP register for you. - See CL 248260 for example - fixes. -

- -

New warning for asn1.Unmarshal

- -

- The vet tool now warns about incorrectly passing a non-pointer or nil argument to - asn1.Unmarshal. - This is like the existing checks for - encoding/json.Unmarshal - and encoding/xml.Unmarshal. -

- -

Runtime

- -

- The new runtime/metrics package - introduces a stable interface for reading - implementation-defined metrics from the Go runtime. - It supersedes existing functions like - runtime.ReadMemStats - and - debug.GCStats - and is significantly more general and efficient. - See the package documentation for more details. -

- -

- Setting the GODEBUG environment variable - to inittrace=1 now causes the runtime to emit a single - line to standard error for each package init, - summarizing its execution time and memory allocation. This trace can - be used to find bottlenecks or regressions in Go startup - performance. - The GODEBUG - documentation describes the format. -

- -

- On Linux, the runtime now defaults to releasing memory to the - operating system promptly (using MADV_DONTNEED), rather - than lazily when the operating system is under memory pressure - (using MADV_FREE). This means process-level memory - statistics like RSS will more accurately reflect the amount of - physical memory being used by Go processes. Systems that are - currently using GODEBUG=madvdontneed=1 to improve - memory monitoring behavior no longer need to set this environment - variable. -

- -

- Go 1.16 fixes a discrepancy between the race detector and - the Go memory model. The race detector now - more precisely follows the channel synchronization rules of the - memory model. As a result, the detector may now report races it - previously missed. -

- -

Compiler

- -

- The compiler can now inline functions with - non-labeled for loops, method values, and type - switches. The inliner can also detect more indirect calls where - inlining is possible. -

- -

Linker

- -

- This release includes additional improvements to the Go linker, - reducing linker resource usage (both time and memory) and improving - code robustness/maintainability. These changes form the second half - of a two-release project to - modernize the Go - linker. -

- -

- The linker changes in 1.16 extend the 1.15 improvements to all - supported architecture/OS combinations (the 1.15 performance improvements - were primarily focused on ELF-based OSes and - amd64 architectures). For a representative set of - large Go programs, linking is 20-25% faster than 1.15 and requires - 5-15% less memory on average for linux/amd64, with larger - improvements for other architectures and OSes. Most binaries are - also smaller as a result of more aggressive symbol pruning. -

- -

- On Windows, go build -buildmode=c-shared now generates Windows - ASLR DLLs by default. ASLR can be disabled with --ldflags=-aslr=false. -

- -

Core library

- -

Embedded Files

- -

- The new embed package - provides access to files embedded in the program during compilation - using the new //go:embed directive. -

- -

File Systems

- -

- The new io/fs package - defines the fs.FS interface, - an abstraction for read-only trees of files. - The standard library packages have been adapted to make use - of the interface as appropriate. -

- -

- On the producer side of the interface, - the new embed.FS type - implements fs.FS, as does - zip.Reader. - The new os.DirFS function - provides an implementation of fs.FS backed by a tree - of operating system files. -

- -

- On the consumer side, - the new http.FS - function converts an fs.FS to an - http.FileSystem. - Also, the html/template - and text/template - packages’ ParseFS - functions and methods read templates from an fs.FS. -

- -

- For testing code that implements fs.FS, - the new testing/fstest - package provides a TestFS - function that checks for and reports common mistakes. - It also provides a simple in-memory file system implementation, - MapFS, - which can be useful for testing code that accepts fs.FS - implementations. -

- -

Deprecation of io/ioutil

- -

- The io/ioutil package has - turned out to be a poorly defined and hard to understand collection - of things. All functionality provided by the package has been moved - to other packages. The io/ioutil package remains and - will continue to work as before, but we encourage new code to use - the new definitions in the io and - os packages. - - Here is a list of the new locations of the names exported - by io/ioutil: -

-

- -

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/zip
-
-

- The new Reader.Open - method implements the fs.FS - interface. -

-
-
- -
crypto/dsa
-
-

- The crypto/dsa package is now deprecated. - See issue #40337. -

-
-
- -
crypto/hmac
-
-

- New will now panic if - separate calls to the hash generation function fail to return new values. - Previously, the behavior was undefined and invalid outputs were sometimes - generated. -

-
-
- -
crypto/tls
-
-

- I/O operations on closing or closed TLS connections can now be detected - using the new net.ErrClosed - error. A typical use would be errors.Is(err, net.ErrClosed). -

- -

- A default write deadline is now set in - Conn.Close - before sending the "close notify" alert, in order to prevent blocking - indefinitely. -

- -

- Clients now return a handshake error if the server selects - - an ALPN protocol that was not in - - the list advertised by the client. -

- -

- Servers will now prefer other available AEAD cipher suites (such as ChaCha20Poly1305) - over AES-GCM cipher suites if either the client or server doesn't have AES hardware - support, unless both - Config.PreferServerCipherSuites - and Config.CipherSuites - are set. The client is assumed not to have AES hardware support if it does - not signal a preference for AES-GCM cipher suites. -

- -

- Config.Clone now - returns nil if the receiver is nil, rather than panicking. -

-
-
- -
crypto/x509
-
-

- The GODEBUG=x509ignoreCN=0 flag will be removed in Go 1.17. - It enables the legacy behavior of treating the CommonName - field on X.509 certificates as a host name when no Subject Alternative - Names are present. -

- -

- ParseCertificate and - CreateCertificate - now enforce string encoding restrictions for the DNSNames, - EmailAddresses, and URIs fields. These fields - can only contain strings with characters within the ASCII range. -

- -

- CreateCertificate - now verifies the generated certificate's signature using the signer's - public key. If the signature is invalid, an error is returned, instead of - a malformed certificate. -

- -

- DSA signature verification is no longer supported. Note that DSA signature - generation was never supported. - See issue #40337. -

- -

- On Windows, Certificate.Verify - will now return all certificate chains that are built by the platform - certificate verifier, instead of just the highest ranked chain. -

- -

- The new SystemRootsError.Unwrap - method allows accessing the Err - field through the errors package functions. -

- -

- On Unix systems, the crypto/x509 package is now more - efficient in how it stores its copy of the system cert pool. - Programs that use only a small number of roots will use around a - half megabyte less memory. -

- -
-
- -
debug/elf
-
-

- More DT - and PT - constants have been added. -

-
-
- -
encoding/asn1
-
-

- Unmarshal and - UnmarshalWithParams - now return an error instead of panicking when the argument is not - a pointer or is nil. This change matches the behavior of other - encoding packages such as encoding/json. -

-
-
- -
encoding/json
-
-

- The json struct field tags understood by - Marshal, - Unmarshal, - and related functionality now permit semicolon characters within - a JSON object name for a Go struct field. -

-
-
- -
encoding/xml
-
-

- The encoder has always taken care to avoid using namespace prefixes - beginning with xml, which are reserved by the XML - specification. - Now, following the specification more closely, that check is - case-insensitive, so that prefixes beginning - with XML, XmL, and so on are also - avoided. -

-
-
- -
flag
-
-

- The new Func function - allows registering a flag implemented by calling a function, - as a lighter-weight alternative to implementing the - Value interface. -

-
-
- -
go/build
-
-

- The Package - struct has new fields that report information - about //go:embed directives in the package: - EmbedPatterns, - EmbedPatternPos, - TestEmbedPatterns, - TestEmbedPatternPos, - XTestEmbedPatterns, - XTestEmbedPatternPos. -

- -

- The Package field - IgnoredGoFiles - will no longer include files that start with "_" or ".", - as those files are always ignored. - IgnoredGoFiles is for files ignored because of - build constraints. -

- -

- The new Package - field IgnoredOtherFiles - has a list of non-Go files ignored because of build constraints. -

-
-
- -
go/build/constraint
-
-

- The new - go/build/constraint - package parses build constraint lines, both the original - // +build syntax and the //go:build - syntax that will be introduced in Go 1.17. - This package exists so that tools built with Go 1.16 will be able - to process Go 1.17 source code. - See https://golang.org/design/draft-gobuild - for details about the build constraint syntaxes and the planned - transition to the //go:build syntax. - Note that //go:build lines are not supported - in Go 1.16 and should not be introduced into Go programs yet. -

-
-
- -
html/template
-
-

- The new template.ParseFS - function and template.Template.ParseFS - method are like template.ParseGlob - and template.Template.ParseGlob, - but read the templates from an fs.FS. -

-
-
- -
io
-
-

- The package now defines a - ReadSeekCloser interface. -

- -

- The package now defines - Discard, - NopCloser, and - ReadAll, - to be used instead of the same names in the - io/ioutil package. -

-
-
- -
log
-
-

- The new Default function - provides access to the default Logger. -

-
-
- -
log/syslog
-
-

- The Writer - now uses the local message format - (omitting the host name and using a shorter time stamp) - when logging to custom Unix domain sockets, - matching the format already used for the default log socket. -

-
-
- -
mime/multipart
-
-

- The Reader's - ReadForm - method no longer rejects form data - when passed the maximum int64 value as a limit. -

-
-
- -
net
-
-

- The case of I/O on a closed network connection, or I/O on a network - connection that is closed before any of the I/O completes, can now - be detected using the new ErrClosed - error. A typical use would be errors.Is(err, net.ErrClosed). - In earlier releases the only way to reliably detect this case was to - match the string returned by the Error method - with "use of closed network connection". -

- -

- In previous Go releases the default TCP listener backlog size on Linux systems, - set by /proc/sys/net/core/somaxconn, was limited to a maximum of 65535. - On Linux kernel version 4.1 and above, the maximum is now 4294967295. -

- -

- On Linux, host name lookups no longer use DNS before checking - /etc/hosts when /etc/nsswitch.conf - is missing; this is common on musl-based systems and makes - Go programs match the behavior of C programs on those systems. -

-
-
- -
net/http
-
-

- In the net/http package, the - behavior of StripPrefix - has been changed to strip the prefix from the request URL's - RawPath field in addition to its Path field. - In past releases, only the Path field was trimmed, and so if the - request URL contained any escaped characters the URL would be modified to - have mismatched Path and RawPath fields. - In Go 1.16, StripPrefix trims both fields. - If there are escaped characters in the prefix part of the request URL the - handler serves a 404 instead of its previous behavior of invoking the - underlying handler with a mismatched Path/RawPath pair. -

- -

- The net/http package now rejects HTTP range requests - of the form "Range": "bytes=--N" where "-N" is a negative suffix length, for - example "Range": "bytes=--2". It now replies with a 416 "Range Not Satisfiable" response. -

- -

- Cookies set with SameSiteDefaultMode - now behave according to the current spec (no attribute is set) instead of - generating a SameSite key without a value. -

- -

- The Client now sends - an explicit Content-Length: 0 - header in PATCH requests with empty bodies, - matching the existing behavior of POST and PUT. -

- -

- The ProxyFromEnvironment - function no longer returns the setting of the HTTP_PROXY - environment variable for https:// URLs when - HTTPS_PROXY is unset. -

- -

- The Transport - type has a new field - GetProxyConnectHeader - which may be set to a function that returns headers to send to a - proxy during a CONNECT request. - In effect GetProxyConnectHeader is a dynamic - version of the existing field - ProxyConnectHeader; - if GetProxyConnectHeader is not nil, - then ProxyConnectHeader is ignored. -

- -

- The new http.FS - function converts an fs.FS - to an http.FileSystem. -

-
-
- -
net/http/httputil
-
-

- ReverseProxy - now flushes buffered data more aggressively when proxying - streamed responses with unknown body lengths. -

-
-
- -
net/smtp
-
-

- The Client's - Mail - method now sends the SMTPUTF8 directive to - servers that support it, signaling that addresses are encoded in UTF-8. -

-
-
- -
os
-
-

- Process.Signal now - returns ErrProcessDone - instead of the unexported errFinished when the process has - already finished. -

- -

- The package defines a new type - DirEntry - as an alias for fs.DirEntry. - The new ReadDir - function and the new - File.ReadDir - method can be used to read the contents of a directory into a - slice of DirEntry. - The File.Readdir - method (note the lower case d in dir) - still exists, returning a slice of - FileInfo, but for - most programs it will be more efficient to switch to - File.ReadDir. -

- -

- The package now defines - CreateTemp, - MkdirTemp, - ReadFile, and - WriteFile, - to be used instead of functions defined in the - io/ioutil package. -

- -

- The types FileInfo, - FileMode, and - PathError - are now aliases for types of the same name in the - io/fs package. - Function signatures in the os - package have been updated to refer to the names in the - io/fs package. - This should not affect any existing code. -

- -

- The new DirFS function - provides an implementation of - fs.FS backed by a tree - of operating system files. -

-
-
- -
os/signal
-
-

- The new - NotifyContext - function allows creating contexts that are canceled upon arrival of - specific signals. -

-
-
- -
path
-
-

- The Match function now - returns an error if the unmatched part of the pattern has a - syntax error. Previously, the function returned early on a failed - match, and thus did not report any later syntax error in the - pattern. -

-
-
- -
path/filepath
-
-

- The new function - WalkDir - is similar to - Walk, - but is typically more efficient. - The function passed to WalkDir receives a - fs.DirEntry - instead of a - fs.FileInfo. - (To clarify for those who recall the Walk function - as taking an os.FileInfo, - os.FileInfo is now an alias for fs.FileInfo.) -

- -

- The Match and - Glob functions now - return an error if the unmatched part of the pattern has a - syntax error. Previously, the functions returned early on a failed - match, and thus did not report any later syntax error in the - pattern. -

-
-
- -
reflect
-
-

- The Zero function has been optimized to avoid allocations. Code - which incorrectly compares the returned Value to another Value - using == or DeepEqual may get different results than those - obtained in previous Go versions. The documentation - for reflect.Value - describes how to compare two Values correctly. -

-
-
- -
runtime/debug
-
-

- The runtime.Error values - used when SetPanicOnFault is enabled may now have an - Addr method. If that method exists, it returns the memory - address that triggered the fault. -

-
-
- -
strconv
-
-

- ParseFloat now uses - the Eisel-Lemire - algorithm, improving performance by up to a factor of 2. This can - also speed up decoding textual formats like encoding/json. -

-
-
- -
syscall
-
-

- NewCallback - and - NewCallbackCDecl - now correctly support callback functions with multiple - sub-uintptr-sized arguments in a row. This may - require changing uses of these functions to eliminate manual - padding between small arguments. -

- -

- SysProcAttr on Windows has a new NoInheritHandles field that disables inheriting handles when creating a new process. -

- -

- DLLError on Windows now has an Unwrap method for unwrapping its underlying error. -

- -

- On Linux, - Setgid, - Setuid, - and related calls are now implemented. - Previously, they returned an syscall.EOPNOTSUPP error. -

- -

- On Linux, the new functions - AllThreadsSyscall - and AllThreadsSyscall6 - may be used to make a system call on all Go threads in the process. - These functions may only be used by programs that do not use cgo; - if a program uses cgo, they will always return - syscall.ENOTSUP. -

-
-
- -
testing/iotest
-
-

- The new - ErrReader - function returns an - io.Reader that always - returns an error. -

- -

- The new - TestReader - function tests that an io.Reader - behaves correctly. -

-
-
- -
text/template
-
-

- Newlines characters are now allowed inside action delimiters, - permitting actions to span multiple lines. -

- -

- The new template.ParseFS - function and template.Template.ParseFS - method are like template.ParseGlob - and template.Template.ParseGlob, - but read the templates from an fs.FS. -

-
-
- -
text/template/parse
-
-

- A new CommentNode - was added to the parse tree. The Mode - field in the parse.Tree enables access to it. -

-
-
- -
time/tzdata
-
-

- The slim timezone data format is now used for the timezone database in - $GOROOT/lib/time/zoneinfo.zip and the embedded copy in this - package. This reduces the size of the timezone database by about 350 KB. -

-
-
- -
unicode
-
-

- The unicode package and associated - support throughout the system has been upgraded from Unicode 12.0.0 to - Unicode 13.0.0, - which adds 5,930 new characters, including four new scripts, and 55 new emoji. - Unicode 13.0.0 also designates plane 3 (U+30000-U+3FFFF) as the tertiary - ideographic plane. -

-
-
diff --git a/_content/doc/go1.17.html b/_content/doc/go1.17.html deleted file mode 100644 index 81c66033bf..0000000000 --- a/_content/doc/go1.17.html +++ /dev/null @@ -1,1248 +0,0 @@ - - - - - - -

Introduction to Go 1.17

- -

- The latest Go release, version 1.17, arrives six months after Go 1.16. - 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. -

- -

Changes to the language

- -

- Go 1.17 includes three small enhancements to the language. -

- -
    -
  • - Conversions - from slice to array pointer: An expression s of - type []T may now be converted to array pointer type - *[N]T. If a is the result of such a - conversion, then corresponding indices that are in range refer to - the same underlying elements: &a[i] == &s[i] - for 0 <= i < N. The conversion panics if - len(s) is less than N. -
  • - -
  • - unsafe.Add: - unsafe.Add(ptr, len) adds len - to ptr and returns the updated pointer - unsafe.Pointer(uintptr(ptr) + uintptr(len)). -
  • - -
  • - unsafe.Slice: - For expression ptr of type *T, - unsafe.Slice(ptr, len) returns a slice of - type []T whose underlying array starts - at ptr and whose length and capacity - are len. -
  • -
- -

- The package unsafe enhancements were added to simplify writing code that conforms - to unsafe.Pointer's safety - rules, but the rules remain unchanged. In particular, existing - programs that correctly use unsafe.Pointer remain - valid, and new programs must still follow the rules when - using unsafe.Add or unsafe.Slice. -

- - -

- Note that the new conversion from slice to array pointer is the - first case in which a type conversion can panic at run time. - Analysis tools that assume type conversions can never panic - should be updated to consider this possibility. -

- -

Ports

- -

Darwin

- -

- As announced in the Go 1.16 release - notes, Go 1.17 requires macOS 10.13 High Sierra or later; support - for previous versions has been discontinued. -

- -

Windows

- -

- Go 1.17 adds support of 64-bit ARM architecture on Windows (the - windows/arm64 port). This port supports cgo. -

- -

OpenBSD

- -

- The 64-bit MIPS architecture on OpenBSD (the openbsd/mips64 - port) now supports cgo. -

- -

- In Go 1.16, on the 64-bit x86 and 64-bit ARM architectures on - OpenBSD (the openbsd/amd64 and openbsd/arm64 - ports) system calls are made through libc, instead - of directly using machine instructions. In Go 1.17, this is also - done on the 32-bit x86 and 32-bit ARM architectures on OpenBSD - (the openbsd/386 and openbsd/arm ports). - This ensures compatibility with OpenBSD 6.9 onwards, which require - system calls to be made through libc for non-static - Go binaries. -

- -

ARM64

- -

- Go programs now maintain stack frame pointers on the 64-bit ARM - architecture on all operating systems. Previously, stack frame - pointers were only enabled on Linux, macOS, and iOS. -

- -

loong64 GOARCH value reserved

- -

- The main Go compiler does not yet support the LoongArch - architecture, but we've reserved the GOARCH value - "loong64". - This means that Go files named *_loong64.go will now - be ignored by Go - tools except when that GOARCH value is being used. -

- -

Tools

- -

Go command

- - -

Pruned module graphs in go 1.17 modules

- -

- If a module specifies go 1.17 or higher, the module - graph includes only the immediate dependencies of - other go 1.17 modules, not their full transitive - dependencies. (See Module graph pruning - for more detail.) -

- -

- For the go command to correctly resolve transitive imports using - the pruned module graph, the go.mod file for each module needs to - include more detail about the transitive dependencies relevant to that module. - If a module specifies go 1.17 or higher in its - go.mod file, its go.mod file now contains an - explicit require - directive for every module that provides a transitively-imported package. - (In previous versions, the go.mod file typically only included - explicit requirements for directly-imported packages.) -

- -

- Since the expanded go.mod file needed for module graph pruning - includes all of the dependencies needed to load the imports of any package in - the main module, if the main module specifies - go 1.17 or higher the go tool no longer - reads (or even downloads) go.mod files for dependencies if they - are not needed in order to complete the requested command. - (See Lazy loading.) -

- -

- Because the number of explicit requirements may be substantially larger in an - expanded Go 1.17 go.mod file, the newly-added requirements - on indirect dependencies in a go 1.17 - module are maintained in a separate require block from the block - containing direct dependencies. -

- -

- To facilitate the upgrade to Go 1.17 pruned module graphs, the - go mod tidy - subcommand now supports a -go flag to set or change - the go version in the go.mod file. To convert - the go.mod file for an existing module to Go 1.17 without - changing the selected versions of its dependencies, run: -

- -
-  go mod tidy -go=1.17
-
- -

- By default, go mod tidy verifies that - the selected versions of dependencies relevant to the main module are the same - versions that would be used by the prior Go release (Go 1.16 for a module that - specifies go 1.17), and preserves - the go.sum entries needed by that release even for dependencies - that are not normally needed by other commands. -

- -

- The -compat flag allows that version to be overridden to support - older (or only newer) versions, up to the version specified by - the go directive in the go.mod file. To tidy - a go 1.17 module for Go 1.17 only, without saving - checksums for (or checking for consistency with) Go 1.16: -

- -
-  go mod tidy -compat=1.17
-
- -

- Note that even if the main module is tidied with -compat=1.17, - users who require the module from a - go 1.16 or earlier module will still be able to - use it, provided that the packages use only compatible language and library - features. -

- -

- The go mod graph - subcommand also supports the -go flag, which causes it to report - the graph as seen by the indicated Go version, showing dependencies that may - otherwise be pruned out. -

- -

Module deprecation comments

- -

- Module authors may deprecate a module by adding a - // Deprecated: - comment to go.mod, then tagging a new version. - go get now prints a warning if a module needed to - build packages named on the command line is deprecated. go - list -m -u prints deprecations for all - dependencies (use -f or -json to show the full - message). The go command considers different major versions to - be distinct modules, so this mechanism may be used, for example, to provide - users with migration instructions for a new major version. -

- -

go get

- -

- The go get -insecure flag is - deprecated and has been removed. To permit the use of insecure schemes - when fetching dependencies, please use the GOINSECURE - environment variable. The -insecure flag also bypassed module - sum validation, use GOPRIVATE or GONOSUMDB if - you need that functionality. See go help - environment for details. -

- -

- go get prints a deprecation warning when installing - commands outside the main module (without the -d flag). - go install cmd@version should be used - instead to install a command at a specific version, using a suffix like - @latest or @v1.2.3. In Go 1.18, the -d - flag will always be enabled, and go get will only - be used to change dependencies in go.mod. -

- -

go.mod files missing go directives

- -

- If the main module's go.mod file does not contain - a go directive and - the go command cannot update the go.mod file, the - go command now assumes go 1.11 instead of the - current release. (go mod init has added - go directives automatically since - Go 1.12.) -

- -

- If a module dependency lacks an explicit go.mod file, or - its go.mod file does not contain - a go directive, - the go command now assumes go 1.16 for that - dependency instead of the current release. (Dependencies developed in GOPATH - mode may lack a go.mod file, and - the vendor/modules.txt has to date never recorded - the go versions indicated by dependencies' go.mod - files.) -

- -

vendor contents

- -

- If the main module specifies go 1.17 or higher, - go mod vendor - now annotates - vendor/modules.txt with the go version indicated by - each vendored module in its own go.mod file. The annotated - version is used when building the module's packages from vendored source code. -

- -

- If the main module specifies go 1.17 or higher, - go mod vendor now omits go.mod - and go.sum files for vendored dependencies, which can otherwise - interfere with the ability of the go command to identify the correct - module root when invoked within the vendor tree. -

- -

Password prompts

- -

- The go command by default now suppresses SSH password prompts and - Git Credential Manager prompts when fetching Git repositories using SSH, as it - already did previously for other Git password prompts. Users authenticating to - private Git repos with password-protected SSH may configure - an ssh-agent to enable the go command to use - password-protected SSH keys. -

- -

go mod download

- -

- When go mod download is invoked without - arguments, it will no longer save sums for downloaded module content to - go.sum. It may still make changes to go.mod and - go.sum needed to load the build list. This is the same as the - behavior in Go 1.15. To save sums for all modules, use go - mod download all. -

- -

//go:build lines

- -

- The go command now understands //go:build lines - and prefers them over // +build lines. The new syntax uses - boolean expressions, just like Go, and should be less error-prone. - As of this release, the new syntax is fully supported, and all Go files - should be updated to have both forms with the same meaning. To aid in - migration, gofmt now automatically - synchronizes the two forms. For more details on the syntax and migration plan, - see - https://golang.org/design/draft-gobuild. -

- -

go run

- -

- go run now accepts arguments with version suffixes - (for example, go run - example.com/cmd@v1.0.0). This causes go - run to build and run packages in module-aware mode, ignoring the - go.mod file in the current directory or any parent directory, if - there is one. This is useful for running executables without installing them or - without changing dependencies of the current module. -

- -

Gofmt

- -

- gofmt (and go fmt) now synchronizes - //go:build lines with // +build lines. If a file - only has // +build lines, they will be moved to the appropriate - location in the file, and matching //go:build lines will be - added. Otherwise, // +build lines will be overwritten based on - any existing //go:build lines. For more information, see - https://golang.org/design/draft-gobuild. -

- -

Vet

- -

New warning for mismatched //go:build and // +build lines

- -

- The vet tool now verifies that //go:build and - // +build lines are in the correct part of the file and - synchronized with each other. If they aren't, - gofmt can be used to fix them. For more - information, see - https://golang.org/design/draft-gobuild. -

- -

New warning for calling signal.Notify on unbuffered channels

- -

- The vet tool now warns about calls to signal.Notify - with incoming signals being sent to an unbuffered channel. Using an unbuffered channel - risks missing signals sent on them as signal.Notify does not block when - sending to a channel. For example: -

- -
-c := make(chan os.Signal)
-// signals are sent on c before the channel is read from.
-// This signal may be dropped as c is unbuffered.
-signal.Notify(c, os.Interrupt)
-
- -

- Users of signal.Notify should use channels with sufficient buffer space to keep up with the - expected signal rate. -

- -

New warnings for Is, As and Unwrap methods

- -

- The vet tool now warns about methods named As, Is or Unwrap - on types implementing the error interface that have a different signature than the - one expected by the errors package. The errors.{As,Is,Unwrap} functions - expect such methods to implement either Is(error) bool, - As(interface{}) bool, or Unwrap() error - respectively. The functions errors.{As,Is,Unwrap} will ignore methods with the same - names but a different signature. For example: -

- -
-type MyError struct { hint string }
-func (m MyError) Error() string { ... } // MyError implements error.
-func (MyError) Is(target interface{}) bool { ... } // target is interface{} instead of error.
-func Foo() bool {
-	x, y := MyError{"A"}, MyError{"B"}
-	return errors.Is(x, y) // returns false as x != y and MyError does not have an `Is(error) bool` function.
-}
-
- -

Cover

- -

- The cover tool now uses an optimized parser - from golang.org/x/tools/cover, which may be noticeably faster - when parsing large coverage profiles. -

- -

Compiler

- -

- Go 1.17 implements a new way of passing function arguments and results using - registers instead of the stack. - Benchmarks for a representative set of Go packages and programs show - performance improvements of about 5%, and a typical reduction in - binary size of about 2%. - This is currently enabled for Linux, macOS, and Windows on the - 64-bit x86 architecture (the linux/amd64, - darwin/amd64, and windows/amd64 ports). -

- -

- This change does not affect the functionality of any safe Go code - and is designed to have no impact on most assembly code. - It may affect code that violates - the unsafe.Pointer - rules when accessing function arguments, or that depends on - undocumented behavior involving comparing function code pointers. - To maintain compatibility with existing assembly functions, the - compiler generates adapter functions that convert between the new - register-based calling convention and the previous stack-based - calling convention. - These adapters are typically invisible to users, except that taking - the address of a Go function in assembly code or taking the address - of an assembly function in Go code - using reflect.ValueOf(fn).Pointer() - or unsafe.Pointer will now return the address of the - adapter. - Code that depends on the value of these code pointers may no longer - behave as expected. - Adapters also may cause a very small performance overhead in two - cases: calling an assembly function indirectly from Go via - a func value, and calling Go functions from assembly. -

- -

- The format of stack traces from the runtime (printed when an uncaught panic - occurs, or when runtime.Stack is called) is improved. Previously, - the function arguments were printed as hexadecimal words based on the memory - layout. Now each argument in the source code is printed separately, separated - by commas. Aggregate-typed (struct, array, string, slice, interface, and complex) - arguments are delimited by curly braces. A caveat is that the value of an - argument that only lives in a register and is not stored to memory may be - inaccurate. Function return values (which were usually inaccurate) are no longer - printed. -

- -

- Functions containing closures can now be inlined. - One effect of this change is that a function with a closure may - produce a distinct closure code pointer for each place that the - function is inlined. - Go function values are not directly comparable, but this change - could reveal bugs in code that uses reflect - or unsafe.Pointer to bypass this language restriction - and compare functions by code pointer. -

- - - -

- When the linker uses external linking mode, which is the default - when linking a program that uses cgo, and the linker is invoked - with a -I option, the option will now be passed to the - external linker as a -Wl,--dynamic-linker option. -

- -

Core library

- -

Cgo

- -

- The runtime/cgo package now provides a - new facility that allows to turn any Go values to a safe representation - that can be used to pass values between C and Go safely. See - runtime/cgo.Handle for more information. -

- -

URL query parsing

- - -

- The net/url and net/http packages used to accept - ";" (semicolon) as a setting separator in URL queries, in - addition to "&" (ampersand). Now, settings with non-percent-encoded - semicolons are rejected and net/http servers will log a warning to - Server.ErrorLog - when encountering one in a request URL. -

- -

- For example, before Go 1.17 the Query - method of the URL example?a=1;b=2&c=3 would have returned - map[a:[1] b:[2] c:[3]], while now it returns map[c:[3]]. -

- -

- When encountering such a query string, - URL.Query - and - Request.FormValue - ignore any settings that contain a semicolon, - ParseQuery - returns the remaining settings and an error, and - Request.ParseForm - and - Request.ParseMultipartForm - return an error but still set Request fields based on the - remaining settings. -

- -

- net/http users can restore the original behavior by using the new - AllowQuerySemicolons - handler wrapper. This will also suppress the ErrorLog warning. - Note that accepting semicolons as query separators can lead to security issues - if different systems interpret cache keys differently. - See issue 25192 for more information. -

- -

TLS strict ALPN

- - -

- When Config.NextProtos - is set, servers now enforce that there is an overlap between the configured - protocols and the ALPN protocols advertised by the client, if any. If there is - no mutually supported protocol, the connection is closed with the - no_application_protocol alert, as required by RFC 7301. This - helps mitigate the ALPACA cross-protocol attack. -

- -

- As an exception, when the value "h2" is included in the server's - Config.NextProtos, HTTP/1.1 clients will be allowed to connect as - if they didn't support ALPN. - See issue 46310 for more information. -

- -

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/zip
-
-

- The new methods File.OpenRaw, Writer.CreateRaw, Writer.Copy provide support for cases where performance is a primary concern. -

-
-
- -
bufio
-
-

- The Writer.WriteRune method - now writes the replacement character U+FFFD for negative rune values, - as it does for other invalid runes. -

-
-
- -
bytes
-
-

- The Buffer.WriteRune method - now writes the replacement character U+FFFD for negative rune values, - as it does for other invalid runes. -

-
-
- -
compress/lzw
-
-

- The NewReader - function is guaranteed to return a value of the new - type Reader, - and similarly NewWriter - is guaranteed to return a value of the new - type Writer. - These new types both implement a Reset method - (Reader.Reset, - Writer.Reset) - that allows reuse of the Reader or Writer. -

-
-
- -
crypto/ed25519
-
-

- The crypto/ed25519 package has been rewritten, and all - operations are now approximately twice as fast on amd64 and arm64. - The observable behavior has not otherwise changed. -

-
-
- -
crypto/elliptic
-
-

- CurveParams - methods now automatically invoke faster and safer dedicated - implementations for known curves (P-224, P-256, and P-521) when - available. Note that this is a best-effort approach and applications - should avoid using the generic, not constant-time CurveParams - methods and instead use dedicated - Curve implementations - such as P256. -

- -

- The P521 curve - implementation has been rewritten using code generated by the - fiat-crypto project, - which is based on a formally-verified model of the arithmetic - operations. It is now constant-time and three times faster on amd64 and - arm64. The observable behavior has not otherwise changed. -

-
-
- -
crypto/rand
-
-

- The crypto/rand package now uses the getentropy - syscall on macOS and the getrandom syscall on Solaris, - Illumos, and DragonFlyBSD. -

-
-
- -
crypto/tls
-
-

- The new Conn.HandshakeContext - method allows the user to control cancellation of an in-progress TLS - handshake. The provided context is accessible from various callbacks through the new - ClientHelloInfo.Context and - CertificateRequestInfo.Context - methods. Canceling the context after the handshake has finished has no effect. -

- -

- Cipher suite ordering is now handled entirely by the - crypto/tls package. Currently, cipher suites are sorted based - on their security, performance, and hardware support taking into account - both the local and peer's hardware. The order of the - Config.CipherSuites - field is now ignored, as well as the - Config.PreferServerCipherSuites - field. Note that Config.CipherSuites still allows - applications to choose what TLS 1.0–1.2 cipher suites to enable. -

- -

- The 3DES cipher suites have been moved to - InsecureCipherSuites - due to fundamental block size-related - weakness. They are still enabled by default but only as a last resort, - thanks to the cipher suite ordering change above. -

- -

- Beginning in the next release, Go 1.18, the - Config.MinVersion - for crypto/tls clients will default to TLS 1.2, disabling TLS 1.0 - and TLS 1.1 by default. Applications will be able to override the change by - explicitly setting Config.MinVersion. - This will not affect crypto/tls servers. -

-
-
- -
crypto/x509
-
-

- CreateCertificate - now returns an error if the provided private key doesn't match the - parent's public key, if any. The resulting certificate would have failed - to verify. -

- -

- The temporary GODEBUG=x509ignoreCN=0 flag has been removed. -

- -

- ParseCertificate - has been rewritten, and now consumes ~70% fewer resources. The observable - behavior when processing WebPKI certificates has not otherwise changed, - except for error messages. -

- -

- On BSD systems, /etc/ssl/certs is now searched for trusted - roots. This adds support for the new system trusted certificate store in - FreeBSD 12.2+. -

- -

- Beginning in the next release, Go 1.18, crypto/x509 will - reject certificates signed with the SHA-1 hash function. This doesn't - apply to self-signed root certificates. Practical attacks against SHA-1 - have been demonstrated in 2017 and publicly - trusted Certificate Authorities have not issued SHA-1 certificates since 2015. -

-
-
- -
database/sql
-
-

- The DB.Close method now closes - the connector field if the type in this field implements the - io.Closer interface. -

- -

- The new - NullInt16 - and - NullByte - structs represent the int16 and byte values that may be null. These can be used as - destinations of the Scan method, - similar to NullString. -

-
-
- -
debug/elf
-
-

- The SHT_MIPS_ABIFLAGS - constant has been added. -

-
-
- -
encoding/binary
-
-

- binary.Uvarint will stop reading after 10 bytes to avoid - wasted computations. If more than 10 bytes are needed, the byte count returned is -11. -
- Previous Go versions could return larger negative counts when reading incorrectly encoded varints. -

-
-
- -
encoding/csv
-
-

- The new - Reader.FieldPos - method returns the line and column corresponding to the start of - a given field in the record most recently returned by - Read. -

-
-
- -
encoding/xml
-
-

- When a comment appears within a - Directive, it is now replaced - with a single space instead of being completely elided. -

- -

- Invalid element or attribute names with leading, trailing, or multiple - colons are now stored unmodified into the - Name.Local field. -

-
-
- -
flag
-
-

- Flag declarations now panic if an invalid name is specified. -

-
-
- -
go/build
-
-

- The new - Context.ToolTags - field holds the build tags appropriate to the current Go - toolchain configuration. -

-
-
- -
go/format
-
-

- The Source and - Node functions now - synchronize //go:build lines with // +build - lines. If a file only has // +build lines, they will be - moved to the appropriate location in the file, and matching - //go:build lines will be added. Otherwise, - // +build lines will be overwritten based on any existing - //go:build lines. For more information, see - https://golang.org/design/draft-gobuild. -

-
-
- -
go/parser
-
-

- The new SkipObjectResolution - Mode value instructs the parser not to resolve identifiers to - their declaration. This may improve parsing speed. -

-
-
- -
image
-
-

- The concrete image types (RGBA, Gray16 and so on) - now implement a new RGBA64Image - interface. The concrete types that previously implemented - draw.Image now also implement - draw.RGBA64Image, a - new interface in the image/draw package. -

-
-
- -
io/fs
-
-

- The new FileInfoToDirEntry function converts a FileInfo to a DirEntry. -

-
-
- -
math
-
-

- The math package now defines three more constants: MaxUint, MaxInt and MinInt. - For 32-bit systems their values are 2^32 - 1, 2^31 - 1 and -2^31, respectively. - For 64-bit systems their values are 2^64 - 1, 2^63 - 1 and -2^63, respectively. -

-
-
- -
mime
-
-

- On Unix systems, the table of MIME types is now read from the local system's - Shared MIME-info Database - when available. -

-
-
- -
mime/multipart
-
-

- Part.FileName - now applies - filepath.Base to the - return value. This mitigates potential path traversal vulnerabilities in - applications that accept multipart messages, such as net/http - servers that call - Request.FormFile. -

-
-
- -
net
-
-

- The new method IP.IsPrivate reports whether an address is - a private IPv4 address according to RFC 1918 - or a local IPv6 address according RFC 4193. -

- -

- The Go DNS resolver now only sends one DNS query when resolving an address for an IPv4-only or IPv6-only network, - rather than querying for both address families. -

- -

- The ErrClosed sentinel error and - ParseError error type now implement - the net.Error interface. -

- -

- The ParseIP and ParseCIDR - functions now reject IPv4 addresses which contain decimal components with leading zeros. - - These components were always interpreted as decimal, but some operating systems treat them as octal. - This mismatch could hypothetically lead to security issues if a Go application was used to validate IP addresses - which were then used in their original form with non-Go applications which interpreted components as octal. Generally, - it is advisable to always re-encode values after validation, which avoids this class of parser misalignment issues. -

-
-
- -
net/http
-
-

- The net/http package now uses the new - (*tls.Conn).HandshakeContext - with the Request context - when performing TLS handshakes in the client or server. -

- -

- Setting the Server - ReadTimeout or WriteTimeout fields to a negative value now indicates no timeout - rather than an immediate timeout. -

- -

- The ReadRequest function - now returns an error when the request has multiple Host headers. -

- -

- When producing a redirect to the cleaned version of a URL, - ServeMux now always - uses relative URLs in the Location header. Previously it - would echo the full URL of the request, which could lead to unintended - redirects if the client could be made to send an absolute request URL. -

- -

- When interpreting certain HTTP headers handled by net/http, - non-ASCII characters are now ignored or rejected. -

- -

- If - Request.ParseForm - returns an error when called by - Request.ParseMultipartForm, - the latter now continues populating - Request.MultipartForm - before returning it. -

-
-
- -
net/http/httptest
-
-

- ResponseRecorder.WriteHeader - now panics when the provided code is not a valid three-digit HTTP status code. - This matches the behavior of ResponseWriter - implementations in the net/http package. -

-
-
- -
net/url
-
-

- The new method Values.Has - reports whether a query parameter is set. -

-
-
- -
os
-
-

- The File.WriteString method - has been optimized to not make a copy of the input string. -

-
-
- -
reflect
-
-

- The new - Value.CanConvert - method reports whether a value can be converted to a type. - This may be used to avoid a panic when converting a slice to an - array pointer type if the slice is too short. - Previously it was sufficient to use - Type.ConvertibleTo - for this, but the newly permitted conversion from slice to array - pointer type can panic even if the types are convertible. -

- -

- The new - StructField.IsExported - and - Method.IsExported - methods report whether a struct field or type method is exported. - They provide a more readable alternative to checking whether PkgPath - is empty. -

- -

- The new VisibleFields function - returns all the visible fields in a struct type, including fields inside anonymous struct members. -

- -

- The ArrayOf function now panics when - called with a negative length. -

- -

- Checking the Type.ConvertibleTo method - is no longer sufficient to guarantee that a call to - Value.Convert will not panic. - It may panic when converting `[]T` to `*[N]T` if the slice's length is less than N. - See the language changes section above. -

- -

- The Value.Convert and - Type.ConvertibleTo methods - have been fixed to not treat types in different packages with the same name - as identical, to match what the language allows. -

-
-
- -
runtime/metrics
-
-

- New metrics were added that track total bytes and objects allocated and freed. - A new metric tracking the distribution of goroutine scheduling latencies was - also added. -

-
-
- -
runtime/pprof
-
-

- Block profiles are no longer biased to favor infrequent long events over - frequent short events. -

-
-
- -
strconv
-
-

- The strconv package now uses Ulf Adams's Ryū algorithm for formatting floating-point numbers. - This algorithm improves performance on most inputs and is more than 99% faster on worst-case inputs. -

- -

- The new QuotedPrefix function - returns the quoted string (as understood by - Unquote) - at the start of input. -

-
-
- -
strings
-
-

- The Builder.WriteRune method - now writes the replacement character U+FFFD for negative rune values, - as it does for other invalid runes. -

-
-
- -
sync/atomic
-
-

- atomic.Value now has Swap and - CompareAndSwap methods that provide - additional atomic operations. -

-
-
- -
syscall
-
-

-

- The GetQueuedCompletionStatus and - PostQueuedCompletionStatus - functions are now deprecated. These functions have incorrect signatures and are superseded by - equivalents in the golang.org/x/sys/windows package. -

- -

- On Unix-like systems, the process group of a child process is now set with signals blocked. - This avoids sending a SIGTTOU to the child when the parent is in a background process group. -

- -

- The Windows version of - SysProcAttr - has two new fields. AdditionalInheritedHandles is - a list of additional handles to be inherited by the new child - process. ParentProcess permits specifying the - parent process of the new process. - -

- The constant MSG_CMSG_CLOEXEC is now defined on - DragonFly and all OpenBSD systems (it was already defined on - some OpenBSD systems and all FreeBSD, NetBSD, and Linux systems). -

- -

- The constants SYS_WAIT6 and WEXITED - are now defined on NetBSD systems (SYS_WAIT6 was - already defined on DragonFly and FreeBSD systems; - WEXITED was already defined on Darwin, DragonFly, - FreeBSD, Linux, and Solaris systems). -

-
-
- -
testing
-
-

- Added a new testing flag -shuffle which controls the execution order of tests and benchmarks. -

-

- The new - T.Setenv - and B.Setenv - methods support setting an environment variable for the duration - of the test or benchmark. -

-
-
- -
text/template/parse
-
-

- The new SkipFuncCheck Mode - value changes the template parser to not verify that functions are defined. -

-
-
- -
time
-
-

- The Time type now has a - GoString method that - will return a more useful value for times when printed with the - %#v format specifier in the fmt package. -

- -

- The new Time.IsDST method can be used to check whether the time - is in Daylight Savings Time in its configured location. -

- -

- The new Time.UnixMilli and - Time.UnixMicro - methods return the number of milliseconds and microseconds elapsed since - January 1, 1970 UTC respectively. -
- The new UnixMilli and - UnixMicro functions - return the local Time corresponding to the given Unix time. -

- -

- The package now accepts comma "," as a separator for fractional seconds when parsing and formatting time. - For example, the following time layouts are now accepted: -

    -
  • 2006-01-02 15:04:05,999999999 -0700 MST
  • -
  • Mon Jan _2 15:04:05,000000 2006
  • -
  • Monday, January 2 15:04:05,000 2006
  • -
-

- -

- The new constant Layout - defines the reference time. -

-
-
- -
unicode
-
-

- The Is, - IsGraphic, - IsLetter, - IsLower, - IsMark, - IsNumber, - IsPrint, - IsPunct, - IsSpace, - IsSymbol, and - IsUpper functions - now return false on negative rune values, as they do for other invalid runes. -

-
-
diff --git a/_content/doc/go1.18.html b/_content/doc/go1.18.html deleted file mode 100644 index 6e2de13aa0..0000000000 --- a/_content/doc/go1.18.html +++ /dev/null @@ -1,1411 +0,0 @@ - - - - - - -

Introduction to Go 1.18

- -

- The latest Go release, version 1.18, - is a significant release, including changes to the language, - implementation of the toolchain, runtime, and libraries. - Go 1.18 arrives seven months after Go 1.17. - 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. -

- -

Changes to the language

- -

Generics

- -

- Go 1.18 includes an implementation of generic features as described by the - Type - Parameters Proposal. - This includes major - but fully backward-compatible - changes to the language. -

- -

- These new language changes required a large amount of new code that - has not had significant testing in production settings. That will - only happen as more people write and use generic code. We believe - that this feature is well implemented and high quality. However, - unlike most aspects of Go, we can't back up that belief with real - world experience. Therefore, while we encourage the use of generics - where it makes sense, please use appropriate caution when deploying - generic code in production. -

- -

- While we believe that the new language features are well designed - and clearly specified, it is possible that we have made mistakes. - We want to stress that the Go 1 - compatibility guarantee says "If it becomes necessary to address - an inconsistency or incompleteness in the specification, resolving - the issue could affect the meaning or legality of existing - programs. We reserve the right to address such issues, including - updating the implementations." It also says "If a compiler or - library has a bug that violates the specification, a program that - depends on the buggy behavior may break if the bug is fixed. We - reserve the right to fix such bugs." In other words, it is possible - that there will be code using generics that will work with the 1.18 - release but break in later releases. We do not plan or expect to - make any such change. However, breaking 1.18 programs in future - releases may become necessary for reasons that we cannot today - foresee. We will minimize any such breakage as much as possible, but - we can't guarantee that the breakage will be zero. -

- -

- The following is a list of the most visible changes. For a more comprehensive overview, see the - proposal. - For details see the language spec. -

- -
    -
  • - The syntax for - function and - type declarations - now accepts - type parameters. -
  • -
  • - Parameterized functions and types can be instantiated by following them with a list of - type arguments in square brackets. -
  • -
  • - The new token ~ has been added to the set of - operators and punctuation. -
  • -
  • - The syntax for - Interface types - now permits the embedding of arbitrary types (not just type names of interfaces) - as well as union and ~T type elements. Such interfaces may only be used - as type constraints. - An interface now defines a set of types as well as a set of methods. -
  • -
  • - The new - predeclared identifier - any is an alias for the empty interface. It may be used instead of - interface{}. -
  • -
  • - The new - predeclared identifier - comparable is an interface that denotes the set of all types which can be - compared using == or !=. It may only be used as (or embedded in) - a type constraint. -
  • -
- -

- There are three experimental packages using generics that may be - useful. - These packages are in x/exp repository; their API is not covered by - the Go 1 guarantee and may change as we gain more experience with - generics. -

-
golang.org/x/exp/constraints
-
-

- Constraints that are useful for generic code, such as - constraints.Ordered. -

-
- -
golang.org/x/exp/slices
-
-

- A collection of generic functions that operate on slices of - any element type. -

-
- -
golang.org/x/exp/maps
-
-

- A collection of generic functions that operate on maps of - any key or element type. -

-
-
-

- -

- The current generics implementation has the following known limitations: -

    -
  • - The Go compiler cannot handle type declarations inside generic functions - or methods. We hope to provide support for this feature in a - future release. -
  • -
  • - The Go compiler does not accept arguments of type parameter type with - the predeclared functions real, imag, and complex. - We hope to remove this restriction in a future release. -
  • -
  • - The Go compiler only supports calling a method m on a value - x of type parameter type P if m is explicitly - declared by P's constraint interface. - Similarly, method values x.m and method expressions - P.m also are only supported if m is explicitly - declared by P, even though m might be in the method set - of P by virtue of the fact that all types in P implement - m. We hope to remove this restriction in a future - release. -
  • -
  • - The Go compiler does not support accessing a struct field x.f - where x is of type parameter type even if all types in the - type parameter's type set have a field f. - We may remove this restriction in a future release. -
  • -
  • - Embedding a type parameter, or a pointer to a type parameter, as - an unnamed field in a struct type is not permitted. Similarly, - embedding a type parameter in an interface type is not permitted. - Whether these will ever be permitted is unclear at present. -
  • -
  • - A union element with more than one term may not contain an - interface type with a non-empty method set. Whether this will - ever be permitted is unclear at present. -
  • -
-

- -

- Generics also represent a large change for the Go ecosystem. While we have - updated several core tools with generics support, there is much more to do. - It will take time for remaining tools, documentation, and libraries to catch - up with these language changes. -

- -

Bug fixes

- -

- The Go 1.18 compiler now correctly reports declared but not used errors - for variables that are set inside a function literal but are never used. Before Go 1.18, - the compiler did not report an error in such cases. This fixes long-outstanding compiler - issue #8560. As a result of this change, - (possibly incorrect) programs may not compile anymore. The necessary fix is - straightforward: fix the program if it was in fact incorrect, or use the offending - variable, for instance by assigning it to the blank identifier _. - Since go vet always pointed out this error, the number of affected - programs is likely very small. -

- -

- The Go 1.18 compiler now reports an overflow when passing a rune constant expression - such as '1' << 32 as an argument to the predeclared functions - print and println, consistent with the behavior of - user-defined functions. Before Go 1.18, the compiler did not report an error - in such cases but silently accepted such constant arguments if they fit into an - int64. As a result of this change, (possibly incorrect) programs - may not compile anymore. The necessary fix is straightforward: fix the program if it - was in fact incorrect, or explicitly convert the offending argument to the correct type. - Since go vet always pointed out this error, the number of affected - programs is likely very small. -

- -

Ports

- -

AMD64

- -

- Go 1.18 introduces the new GOAMD64 environment variable, which selects at compile time - a minimum target version of the AMD64 architecture. Allowed values are v1, - v2, v3, or v4. Each higher level requires, - and takes advantage of, additional processor features. A detailed - description can be found - here. -

-

- The GOAMD64 environment variable defaults to v1. -

- -

RISC-V

- -

- The 64-bit RISC-V architecture on Linux (the linux/riscv64 port) - now supports the c-archive and c-shared build modes. -

- -

Linux

- -

- Go 1.18 requires Linux kernel version 2.6.32 or later. -

- -

Windows

- -

- The windows/arm and windows/arm64 ports now support - non-cooperative preemption, bringing that capability to all four Windows - ports, which should hopefully address subtle bugs encountered when calling - into Win32 functions that block for extended periods of time. -

- -

iOS

- -

- On iOS (the ios/arm64 port) - and iOS simulator running on AMD64-based macOS (the ios/amd64 port), - Go 1.18 now requires iOS 12 or later; support for previous versions has been discontinued. -

- -

FreeBSD

- -

- Go 1.18 is the last release that is supported on FreeBSD 11.x, which has - already reached end-of-life. Go 1.19 will require FreeBSD 12.2+ or FreeBSD - 13.0+. - FreeBSD 13.0+ will require a kernel with the COMPAT_FREEBSD12 option set (this is the default). -

- -

Tools

- -

Fuzzing

- -

- Go 1.18 includes an implementation of fuzzing as described by - the fuzzing proposal. -

- -

- See the fuzzing landing page to get - started. -

- -

- Please be aware that fuzzing can consume a lot of memory and may impact your - machine’s performance while it runs. Also be aware that the fuzzing engine - writes values that expand test coverage to a fuzz cache directory within - $GOCACHE/fuzz while it runs. There is currently no limit to the - number of files or total bytes that may be written to the fuzz cache, so it - may occupy a large amount of storage (possibly several GBs). -

- -

Go command

- -

go get

- -

- go get no longer builds or installs packages in - module-aware mode. go get is now dedicated to - adjusting dependencies in go.mod. Effectively, the - -d flag is always enabled. To install the latest version - of an executable outside the context of the current module, use - go - install example.com/cmd@latest. Any - version query - may be used instead of latest. This form of go - install was added in Go 1.16, so projects supporting older - versions may need to provide install instructions for both go - install and go get. go - get now reports an error when used outside a module, since there - is no go.mod file to update. In GOPATH mode (with - GO111MODULE=off), go get still builds - and installs packages, as before. -

- -

Automatic go.mod and go.sum updates

- -

- The go mod graph, - go mod vendor, - go mod verify, and - go mod why subcommands - no longer automatically update the go.mod and - go.sum files. - (Those files can be updated explicitly using go get, - go mod tidy, or - go mod download.) -

- -

go version

- -

- The go command now embeds version control information in - binaries. It includes the currently checked-out revision, commit time, and a - flag indicating whether edited or untracked files are present. Version - control information is embedded if the go command is invoked in - a directory within a Git, Mercurial, Fossil, or Bazaar repository, and the - main package and its containing main module are in the same - repository. This information may be omitted using the flag - -buildvcs=false. -

- -

- Additionally, the go command embeds information about the build, - including build and tool tags (set with -tags), compiler, - assembler, and linker flags (like -gcflags), whether cgo was - enabled, and if it was, the values of the cgo environment variables - (like CGO_CFLAGS). - Both VCS and build information may be read together with module - information using - go version -m file or - runtime/debug.ReadBuildInfo (for the currently running binary) - or the new debug/buildinfo - package. -

- -

- The underlying data format of the embedded build information can change with - new go releases, so an older version of go may not handle the - build information produced with a newer version of go. - To read the version information from a binary built with go 1.18, - use the go version command and the - debug/buildinfo package from go 1.18+. -

- -

go mod download

- -

- If the main module's go.mod file - specifies go 1.17 - or higher, go mod download without - arguments now downloads source code for only the modules - explicitly required in the main - module's go.mod file. (In a go 1.17 or - higher module, that set already includes all dependencies needed to build the - packages and tests in the main module.) - To also download source code for transitive dependencies, use - go mod download all. -

- -

go mod vendor

- -

- The go mod vendor subcommand now - supports a -o flag to set the output directory. - (Other go commands still read from the vendor - directory at the module root when loading packages - with -mod=vendor, so the main use for this flag is for - third-party tools that need to collect package source code.) -

- -

go mod tidy

- -

- The go mod tidy command now retains - additional checksums in the go.sum file for modules whose source - code is needed to verify that each imported package is provided by only one - module in the build list. Because this - condition is rare and failure to apply it results in a build error, this - change is not conditioned on the go version in the main - module's go.mod file. -

- -

go work

- -

- The go command now supports a "Workspace" mode. If a - go.work file is found in the working directory or a - parent directory, or one is specified using the GOWORK - environment variable, it will put the go command into workspace mode. - In workspace mode, the go.work file will be used to - determine the set of main modules used as the roots for module - resolution, instead of using the normally-found go.mod - file to specify the single main module. For more information see the - go work - documentation. -

- -

go build -asan

- -

- The go build command and related commands - now support an -asan flag that enables interoperation - with C (or C++) code compiled with the address sanitizer (C compiler - option -fsanitize=address). -

- -

go test

- -

- The go command now supports additional command line - options for the new fuzzing support described - above: -

    -
  • - go test supports - -fuzz, -fuzztime, and - -fuzzminimizetime options. - For documentation on these see - go help testflag. -
  • -
  • - go clean supports a -fuzzcache - option. - For documentation see - go help clean. -
  • -
-

- -

//go:build lines

- -

-Go 1.17 introduced //go:build lines as a more readable way to write build constraints, -instead of // +build lines. -As of Go 1.17, gofmt adds //go:build lines -to match existing +build lines and keeps them in sync, -while go vet diagnoses when they are out of sync. -

- -

Since the release of Go 1.18 marks the end of support for Go 1.16, -all supported versions of Go now understand //go:build lines. -In Go 1.18, go fix now removes the now-obsolete -// +build lines in modules declaring -go 1.18 or later in their go.mod files. -

- -

-For more information, see https://go.dev/design/draft-gobuild. -

- -

Gofmt

- -

- gofmt now reads and formats input files concurrently, with a - memory limit proportional to GOMAXPROCS. On a machine with - multiple CPUs, gofmt should now be significantly faster. -

- -

Vet

- -

Updates for Generics

- -

- The vet tool is updated to support generic code. In most cases, - it reports an error in generic code whenever it would report an error in the - equivalent non-generic code after substituting for type parameters with a - type from their - type set. - - For example, vet reports a format error in -

func Print[T ~int|~string](t T) {
-	fmt.Printf("%d", t)
-}
- because it would report a format error in the non-generic equivalent of - Print[string]: -
func PrintString(x string) {
-	fmt.Printf("%d", x)
-}
-

- -

Precision improvements for existing checkers

- -

- The cmd/vet checkers copylock, printf, - sortslice, testinggoroutine, and tests - have all had moderate precision improvements to handle additional code patterns. - This may lead to newly reported errors in existing packages. For example, the - printf checker now tracks formatting strings created by - concatenating string constants. So vet will report an error in: -

-  // fmt.Printf formatting directive %d is being passed to Println.
-  fmt.Println("%d"+` ≡ x (mod 2)`+"\n", x%2)
-
-

- -

Runtime

- -

- The garbage collector now includes non-heap sources of garbage collector work - (e.g., stack scanning) when determining how frequently to run. As a result, - garbage collector overhead is more predictable when these sources are - significant. For most applications these changes will be negligible; however, - some Go applications may now use less memory and spend more time on garbage - collection, or vice versa, than before. The intended workaround is to tweak - GOGC where necessary. -

- -

- The runtime now returns memory to the operating system more efficiently and has - been tuned to work more aggressively as a result. -

- -

- Go 1.17 generally improved the formatting of arguments in stack traces, - but could print inaccurate values for arguments passed in registers. - This is improved in Go 1.18 by printing a question mark (?) - after each value that may be inaccurate. -

- -

- The built-in function append now uses a slightly different formula - when deciding how much to grow a slice when it must allocate a new underlying array. - The new formula is less prone to sudden transitions in allocation behavior. -

- -

Compiler

- -

- Go 1.17 implemented a new way of passing - function arguments and results using registers instead of the stack - on 64-bit x86 architecture on selected operating systems. - Go 1.18 expands the supported platforms to include 64-bit ARM (GOARCH=arm64), - big- and little-endian 64-bit PowerPC (GOARCH=ppc64, ppc64le), - as well as 64-bit x86 architecture (GOARCH=amd64) - on all operating systems. - On 64-bit ARM and 64-bit PowerPC systems, benchmarking shows - typical performance improvements of 10% or more. -

- -

- As mentioned in the Go 1.17 release notes, - this change does not affect the functionality of any safe Go code and - is designed to have no impact on most assembly code. See the - Go 1.17 release notes for more details. -

- -

- The compiler now can inline functions that contain range loops or - labeled for loops. -

- -

- The new -asan compiler option supports the - new go command -asan option. -

- -

- Because the compiler's type checker was replaced in its entirety to - support generics, some error messages now may use different wording - than before. In some cases, pre-Go 1.18 error messages provided more - detail or were phrased in a more helpful way. - We intend to address these cases in Go 1.19. -

- -

- Because of changes in the compiler related to supporting generics, the - Go 1.18 compile speed can be roughly 15% slower than the Go 1.17 compile speed. - The execution time of the compiled code is not affected. We - intend to improve the speed of the compiler in future releases. -

- -

Linker

- -

- The linker emits far fewer relocations. - As a result, most codebases will link faster, require less memory to link, - and generate smaller binaries. - Tools that process Go binaries should use Go 1.18's debug/gosym package - to transparently handle both old and new binaries. -

- -

- The new -asan linker option supports the - new go command -asan option. -

- -

Bootstrap

- -

-When building a Go release from source and GOROOT_BOOTSTRAP -is not set, previous versions of Go looked for a Go 1.4 or later bootstrap toolchain -in the directory $HOME/go1.4 (%HOMEDRIVE%%HOMEPATH%\go1.4 on Windows). -Go now looks first for $HOME/go1.17 or $HOME/sdk/go1.17 -before falling back to $HOME/go1.4. -We intend for Go 1.19 to require Go 1.17 or later for bootstrap, -and this change should make the transition smoother. -For more details, see go.dev/issue/44505. -

- -

Core library

- -

New debug/buildinfo package

- -

- The new debug/buildinfo package - provides access to module versions, version control information, and build - flags embedded in executable files built by the go command. - The same information is also available via - runtime/debug.ReadBuildInfo - for the currently running binary and via go - version -m on the command line. -

- -

New net/netip package

- -

- The new net/netip - package defines a new IP address type, Addr. - Compared to the existing - net.IP type, the netip.Addr type takes less - memory, is immutable, and is comparable so it supports == - and can be used as a map key. -

-

- In addition to Addr, the package defines - AddrPort, representing - an IP and port, and - Prefix, representing - a network CIDR prefix. -

-

- The package also defines several functions to create and examine - these new types: - AddrFrom4, - AddrFrom16, - AddrFromSlice, - AddrPortFrom, - IPv4Unspecified, - IPv6LinkLocalAllNodes, - IPv6Unspecified, - MustParseAddr, - MustParseAddrPort, - MustParsePrefix, - ParseAddr, - ParseAddrPort, - ParsePrefix, - PrefixFrom. -

-

- The net package includes new - methods that parallel existing methods, but - return netip.AddrPort instead of the - heavier-weight net.IP or - *net.UDPAddr types: - Resolver.LookupNetIP, - UDPConn.ReadFromUDPAddrPort, - UDPConn.ReadMsgUDPAddrPort, - UDPConn.WriteToUDPAddrPort, - UDPConn.WriteMsgUDPAddrPort. - The new UDPConn methods support allocation-free I/O. -

-

- The net package also now includes functions and methods - to convert between the existing - TCPAddr/UDPAddr - types and netip.AddrPort: - TCPAddrFromAddrPort, - UDPAddrFromAddrPort, - TCPAddr.AddrPort, - UDPAddr.AddrPort. -

- -

TLS 1.0 and 1.1 disabled by default client-side

- -

- If Config.MinVersion - is not set, it now defaults to TLS 1.2 for client connections. Any safely - up-to-date server is expected to support TLS 1.2, and browsers have required - it since 2020. TLS 1.0 and 1.1 are still supported by setting - Config.MinVersion to VersionTLS10. - The server-side default is unchanged at TLS 1.0. -

- -

- The default can be temporarily reverted to TLS 1.0 by setting the - GODEBUG=tls10default=1 environment variable. - This option will be removed in Go 1.19. -

- -

Rejecting SHA-1 certificates

- -

- crypto/x509 will now - reject certificates signed with the SHA-1 hash function. This doesn't - apply to self-signed root certificates. Practical attacks against SHA-1 - have been demonstrated since 2017 and publicly - trusted Certificate Authorities have not issued SHA-1 certificates since 2015. -

- -

- This can be temporarily reverted by setting the - GODEBUG=x509sha1=1 environment variable. - This option will be removed in a future release. -

- -

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. -

- -
bufio
-
-

- The new Writer.AvailableBuffer - method returns an empty buffer with a possibly non-empty capacity for use - with append-like APIs. After appending, the buffer can be provided to a - succeeding Write call and possibly avoid any copying. -

- -

- The Reader.Reset and - Writer.Reset methods - now use the default buffer size when called on objects with a - nil buffer. -

-
-
- -
bytes
-
-

- The new Cut function - slices a []byte around a separator. It can replace - and simplify many common uses of - Index, - IndexByte, - IndexRune, - and SplitN. -

- -

- Trim, TrimLeft, - and TrimRight are now allocation free and, especially for - small ASCII cutsets, up to 10 times faster. -

- -

- The Title function is now deprecated. It doesn't - handle Unicode punctuation and language-specific capitalization rules, and is superseded by the - golang.org/x/text/cases package. -

-
-
- -
crypto/elliptic
-
-

- The P224, - P384, and - P521 curve - implementations are now all backed by code generated by the - addchain and - fiat-crypto - projects, the latter of which is based on a formally-verified model - of the arithmetic operations. They now use safer complete formulas - and internal APIs. P-224 and P-384 are now approximately four times - faster. All specific curve implementations are now constant-time. -

- -

- Operating on invalid curve points (those for which the - IsOnCurve method returns false, and which are never returned - by Unmarshal or - a Curve method operating on a valid point) has always been - undefined behavior, can lead to key recovery attacks, and is now - unsupported by the new backend. If an invalid point is supplied to a - P224, P384, or P521 method, that - method will now return a random point. The behavior might change to an - explicit panic in a future release. -

-
-
- -
crypto/tls
-
-

- The new Conn.NetConn - method allows access to the underlying - net.Conn. -

-
-
- -
crypto/x509
-
-

- Certificate.Verify - now uses platform APIs to verify certificate validity on macOS and iOS when it - is called with a nil - VerifyOpts.Roots - or when using the root pool returned from - SystemCertPool. -

- -

- SystemCertPool - is now available on Windows. -

- -

- On Windows, macOS, and iOS, when a - CertPool returned by - SystemCertPool - has additional certificates added to it, - Certificate.Verify - will do two verifications: one using the platform verifier APIs and the - system roots, and one using the Go verifier and the additional roots. - Chains returned by the platform verifier APIs will be prioritized. -

- -

- CertPool.Subjects - is deprecated. On Windows, macOS, and iOS the - CertPool returned by - SystemCertPool - will return a pool which does not include system roots in the slice - returned by Subjects, as a static list can't appropriately - represent the platform policies and might not be available at all from the - platform APIs. -

- -

- Support for signing certificates using signature algorithms that depend on the - MD5 hash (MD5WithRSA) may be removed in Go 1.19. -

-
-
- -
debug/dwarf
-
-

- The StructField - and BasicType - structs both now have a DataBitOffset field, which - holds the value of the DW_AT_data_bit_offset - attribute if present. -

-
- -
debug/elf
-
-

- The R_PPC64_RELATIVE - constant has been added. -

-
-
- -
debug/plan9obj
-
-

- The File.Symbols - method now returns the new exported error - value ErrNoSymbols - if the file has no symbol section. -

-
-
- -
embed
-
-

- A go:embed - directive may now start with all: to include files - whose names start with dot or underscore. -

-
-
- -
go/ast
-
-

- Per the proposal - - Additions to go/ast and go/token to support parameterized functions and types - - the following additions are made to the go/ast package: -

    -
  • - the FuncType - and TypeSpec - nodes have a new field TypeParams to hold type parameters, if any. -
  • -
  • - The new expression node IndexListExpr - represents index expressions with multiple indices, used for function and type instantiations - with more than one explicit type argument. -
  • -
-

-
-
- -
go/constant
-
-

- The new Kind.String - method returns a human-readable name for the receiver kind. -

-
-
- -
go/token
-
-

- The new constant TILDE - represents the ~ token per the proposal - - Additions to go/ast and go/token to support parameterized functions and types - . -

-
-
- -
go/types
-
-

- The new Config.GoVersion - field sets the accepted Go language version. -

- -

- Per the proposal - - Additions to go/types to support type parameters - - the following additions are made to the go/types package: -

-
    -
  • - The new type - TypeParam, factory function - NewTypeParam, - and associated methods are added to represent a type parameter. -
  • -
  • - The new type - TypeParamList holds a list of - type parameters. -
  • -
  • - The new type - TypeList holds a list of types. -
  • -
  • - The new factory function - NewSignatureType allocates a - Signature with - (receiver or function) type parameters. - To access those type parameters, the Signature type has two new methods - Signature.RecvTypeParams and - Signature.TypeParams. -
  • -
  • - Named types have four new methods: - Named.Origin to get the original - parameterized types of instantiated types, - Named.TypeArgs and - Named.TypeParams to get the - type arguments or type parameters of an instantiated or parameterized type, and - Named.SetTypeParams to set the - type parameters (for instance, when importing a named type where allocation of the named - type and setting of type parameters cannot be done simultaneously due to possible cycles). -
  • -
  • - The Interface type has four new methods: - Interface.IsComparable and - Interface.IsMethodSet to - query properties of the type set defined by the interface, and - Interface.MarkImplicit and - Interface.IsImplicit to set - and test whether the interface is an implicit interface around a type constraint literal. -
  • -
  • - The new types - Union and - Term, factory functions - NewUnion and - NewTerm, and associated - methods are added to represent type sets in interfaces. -
  • -
  • - The new function - Instantiate - instantiates a parameterized type. -
  • -
  • - The new Info.Instances - map records function and type instantiations through the new - Instance type. -
  • -
  • - The new type ArgumentError - and associated methods are added to represent an error related to a type argument. -
  • -
  • - The new type Context and factory function - NewContext - are added to facilitate sharing of identical type instances - across type-checked packages, via the new - Config.Context - field. -
  • -
-

- The predicates - AssignableTo, - ConvertibleTo, - Implements, - Identical, - IdenticalIgnoreTags, and - AssertableTo - now also work with arguments that are or contain generalized interfaces, - i.e. interfaces that may only be used as type constraints in Go code. - Note that the behavior of AssignableTo, - ConvertibleTo, Implements, and - AssertableTo is undefined with arguments that are - uninstantiated generic types, and AssertableTo is undefined - if the first argument is a generalized interface. -

-
-
- -
html/template
-
-

- Within a range pipeline the new - {{break}} command will end the loop early and the - new {{continue}} command will immediately start the - next loop iteration. -

- -

- The and function no longer always evaluates all arguments; it - stops evaluating arguments after the first argument that evaluates to - false. Similarly, the or function now stops evaluating - arguments after the first argument that evaluates to true. This makes a - difference if any of the arguments is a function call. -

-
-
- -
image/draw
-
-

- The Draw and DrawMask fallback implementations - (used when the arguments are not the most common image types) are now - faster when those arguments implement the optional - draw.RGBA64Image - and image.RGBA64Image - interfaces that were added in Go 1.17. -

-
-
- -
net
-
-

- net.Error.Temporary has been deprecated. -

-
-
- -
net/http
-
-

- On WebAssembly targets, the Dial, DialContext, - DialTLS and DialTLSContext method fields in - Transport - will now be correctly used, if specified, for making HTTP requests. -

- -

- The new - Cookie.Valid - method reports whether the cookie is valid. -

- -

- The new - MaxBytesHandler - function creates a Handler that wraps its - ResponseWriter and Request.Body with a - MaxBytesReader. -

- -

- When looking up a domain name containing non-ASCII characters, - the Unicode-to-ASCII conversion is now done in accordance with - Nontransitional Processing as defined in the - Unicode IDNA - Compatibility Processing standard (UTS #46). The - interpretation of four distinct runes are changed: ß, ς, - zero-width joiner U+200D, and zero-width non-joiner - U+200C. Nontransitional Processing is consistent with most - applications and web browsers. -

-
-
- -
os/user
-
-

- User.GroupIds - now uses a Go native implementation when cgo is not available. -

-
-
- -
reflect
-
-

- The new - Value.SetIterKey - and Value.SetIterValue - methods set a Value using a map iterator as the source. They are equivalent to - Value.Set(iter.Key()) and Value.Set(iter.Value()), but - do fewer allocations. -

- -

- The new - Value.UnsafePointer - method returns the Value's value as an unsafe.Pointer. - This allows callers to migrate from Value.UnsafeAddr - and Value.Pointer - to eliminate the need to perform uintptr to unsafe.Pointer conversions at the callsite (as unsafe.Pointer rules require). -

- -

- The new - MapIter.Reset - method changes its receiver to iterate over a - different map. The use of - MapIter.Reset - allows allocation-free iteration - over many maps. -

- -

- A number of methods ( - Value.CanInt, - Value.CanUint, - Value.CanFloat, - Value.CanComplex - ) - have been added to - Value - to test if a conversion is safe. -

- -

- Value.FieldByIndexErr - has been added to avoid the panic that occurs in - Value.FieldByIndex - when stepping through a nil pointer to an embedded struct. -

- -

- reflect.Ptr and - reflect.PtrTo - have been renamed to - reflect.Pointer and - reflect.PointerTo, - respectively, for consistency with the rest of the reflect package. - The old names will continue to work, but will be deprecated in a - future Go release. -

-
-
- -
regexp
-
-

- regexp - now treats each invalid byte of a UTF-8 string as U+FFFD. -

-
-
- -
runtime/debug
-
-

- The BuildInfo - struct has two new fields, containing additional information - about how the binary was built: -

    -
  • GoVersion - holds the version of Go used to build the binary. -
  • -
  • - Settings - is a slice of - BuildSettings - structs holding key/value pairs describing the build. -
  • -
-

-
-
- -
runtime/pprof
-
-

- The CPU profiler now uses per-thread timers on Linux. This increases the - maximum CPU usage that a profile can observe, and reduces some forms of - bias. -

-
-
- -
strconv
-
-

- strconv.Unquote - now rejects Unicode surrogate halves. -

-
-
- -
strings
-
-

- The new Cut function - slices a string around a separator. It can replace - and simplify many common uses of - Index, - IndexByte, - IndexRune, - and SplitN. -

- -

- The new Clone function copies the input - string without the returned cloned string referencing - the input string's memory. -

- -

- Trim, TrimLeft, - and TrimRight are now allocation free and, especially for - small ASCII cutsets, up to 10 times faster. -

- -

- The Title function is now deprecated. It doesn't - handle Unicode punctuation and language-specific capitalization rules, and is superseded by the - golang.org/x/text/cases package. -

-
-
- -
sync
-
-

- The new methods - Mutex.TryLock, - RWMutex.TryLock, and - RWMutex.TryRLock, - will acquire the lock if it is not currently held. -

-
-
- -
syscall
-
-

- The new function SyscallN - has been introduced for Windows, allowing for calls with arbitrary number - of arguments. As a result, - Syscall, - Syscall6, - Syscall9, - Syscall12, - Syscall15, and - Syscall18 are - deprecated in favor of SyscallN. -

- -

- SysProcAttr.Pdeathsig - is now supported in FreeBSD. -

-
-
- -
syscall/js
-
-

- The Wrapper interface has been removed. -

-
-
- -
testing
-
-

- The precedence of / in the argument for -run and - -bench has been increased. A/B|C/D used to be - treated as A/(B|C)/D and is now treated as - (A/B)|(C/D). -

- -

- If the -run option does not select any tests, the - -count option is ignored. This could change the behavior of - existing tests in the unlikely case that a test changes the set of subtests - that are run each time the test function itself is run. -

- -

- The new testing.F type - is used by the new fuzzing support described - above. Tests also now support the command line - options -test.fuzz, -test.fuzztime, and - -test.fuzzminimizetime. -

-
-
- -
text/template
-
-

- Within a range pipeline the new - {{break}} command will end the loop early and the - new {{continue}} command will immediately start the - next loop iteration. -

- -

- The and function no longer always evaluates all arguments; it - stops evaluating arguments after the first argument that evaluates to - false. Similarly, the or function now stops evaluating - arguments after the first argument that evaluates to true. This makes a - difference if any of the arguments is a function call. -

-
-
- -
text/template/parse
-
-

- The package supports the new - text/template and - html/template - {{break}} command via the new constant - NodeBreak - and the new type - BreakNode, - and similarly supports the new {{continue}} command - via the new constant - NodeContinue - and the new type - ContinueNode. -

-
-
- -
unicode/utf8
-
-

- The new AppendRune function appends the UTF-8 - encoding of a rune to a []byte. -

-
-
diff --git a/_content/doc/go1.19.html b/_content/doc/go1.19.html deleted file mode 100644 index 3c0d4d9b55..0000000000 --- a/_content/doc/go1.19.html +++ /dev/null @@ -1,1028 +0,0 @@ - - - -

Introduction to Go 1.19

-

- The latest Go release, version 1.19, arrives five months after Go 1.18. - 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. -

- -

Changes to the language

- -

- There is only one small change to the language, - a very small correction - to the scope of type parameters in method declarations. - Existing programs are unaffected. -

- -

Memory Model

- -

- The Go memory model has been - revised to align Go with - the memory model used by C, C++, Java, JavaScript, Rust, and Swift. - Go only provides sequentially consistent atomics, not any of the more relaxed forms found in other languages. - Along with the memory model update, - Go 1.19 introduces new types in the sync/atomic package - that make it easier to use atomic values, such as - atomic.Int64 - and - atomic.Pointer[T]. -

- -

Ports

- -

LoongArch 64-bit

-

- Go 1.19 adds support for the Loongson 64-bit architecture - LoongArch - on Linux (GOOS=linux, GOARCH=loong64). - The implemented ABI is LP64D. Minimum kernel version supported is 5.19. -

-

- Note that most existing commercial Linux distributions for LoongArch come - with older kernels, with a historical incompatible system call ABI. - Compiled binaries will not work on these systems, even if statically linked. - Users on such unsupported systems are limited to the distribution-provided - Go package. -

- -

RISC-V

-

- The riscv64 port now supports passing function arguments - and result using registers. Benchmarking shows typical performance - improvements of 10% or more on riscv64. -

- -

Tools

- -

Doc Comments

- -

-Go 1.19 adds support for links, lists, and clearer headings in doc comments. -As part of this change, gofmt -now reformats doc comments to make their rendered meaning clearer. -See “Go Doc Comments” -for syntax details and descriptions of common mistakes now highlighted by gofmt. -As another part of this change, the new package go/doc/comment -provides parsing and reformatting of doc comments -as well as support for rendering them to HTML, Markdown, and text. -

- -

New unix build constraint

- -

- The build constraint unix is now recognized - in //go:build lines. The constraint is satisfied - if the target operating system, also known as GOOS, is - a Unix or Unix-like system. For the 1.19 release it is satisfied - if GOOS is one of - aix, android, darwin, - dragonfly, freebsd, hurd, - illumos, ios, linux, - netbsd, openbsd, or solaris. - In future releases the unix constraint may match - additional newly supported operating systems. -

- -

Go command

- - -

- The -trimpath flag, if set, is now included in the build settings - stamped into Go binaries by go build, and can be - examined using - go version -m - or debug.ReadBuildInfo. -

-

- go generate now sets the GOROOT - environment variable explicitly in the generator's environment, so that - generators can locate the correct GOROOT even if built - with -trimpath. -

- -

- go test and go generate now place - GOROOT/bin at the beginning of the PATH used for the - subprocess, so tests and generators that execute the go command - will resolve it to same GOROOT. -

- -

- go env now quotes entries that contain spaces in - the CGO_CFLAGS, CGO_CPPFLAGS, CGO_CXXFLAGS, CGO_FFLAGS, CGO_LDFLAGS, - and GOGCCFLAGS variables it reports. -

- -

- go list -json now accepts a - comma-separated list of JSON fields to populate. If a list is specified, - the JSON output will include only those fields, and - go list may avoid work to compute fields that are - not included. In some cases, this may suppress errors that would otherwise - be reported. -

- -

- The go command now caches information necessary to load some modules, - which should result in a speed-up of some go list invocations. -

- -

Vet

- -

- The vet checker “errorsas” now reports when - errors.As is called - with a second argument of type *error, - a common mistake. -

- -

Runtime

- -

- The runtime now includes support for a soft memory limit. This memory limit - includes the Go heap and all other memory managed by the runtime, and - excludes external memory sources such as mappings of the binary itself, - memory managed in other languages, and memory held by the operating system on - behalf of the Go program. This limit may be managed via - runtime/debug.SetMemoryLimit - or the equivalent - GOMEMLIMIT - environment variable. The limit works in conjunction with - runtime/debug.SetGCPercent - / GOGC, - and will be respected even if GOGC=off, allowing Go programs to - always make maximal use of their memory limit, improving resource efficiency - in some cases. See the GC guide for - a detailed guide explaining the soft memory limit in more detail, as well as - a variety of common use-cases and scenarios. Please note that small memory - limits, on the order of tens of megabytes or less, are less likely to be - respected due to external latency factors, such as OS scheduling. See - issue 52433 for more details. Larger - memory limits, on the order of hundreds of megabytes or more, are stable and - production-ready. -

- -

- In order to limit the effects of GC thrashing when the program's live heap - size approaches the soft memory limit, the Go runtime also attempts to limit - total GC CPU utilization to 50%, excluding idle time, choosing to use more - memory over preventing application progress. In practice, we expect this limit - to only play a role in exceptional cases, and the new - runtime metric - /gc/limiter/last-enabled:gc-cycle reports when this last - occurred. -

- -

- The runtime now schedules many fewer GC worker goroutines on idle operating - system threads when the application is idle enough to force a periodic GC - cycle. -

- -

- The runtime will now allocate initial goroutine stacks based on the historic - average stack usage of goroutines. This avoids some of the early stack growth - and copying needed in the average case in exchange for at most 2x wasted - space on below-average goroutines. -

- -

- On Unix operating systems, Go programs that import package - os now automatically increase the open file limit - (RLIMIT_NOFILE) to the maximum allowed value; - that is, they change the soft limit to match the hard limit. - This corrects artificially low limits set on some systems for compatibility with very old C programs using the - select system call. - Go programs are not helped by that limit, and instead even simple programs like gofmt - often ran out of file descriptors on such systems when processing many files in parallel. - One impact of this change is that Go programs that in turn execute very old C programs in child processes - may run those programs with too high a limit. - This can be corrected by setting the hard limit before invoking the Go program. -

- -

- Unrecoverable fatal errors (such as concurrent map writes, or unlock of - unlocked mutexes) now print a simpler traceback excluding runtime metadata - (equivalent to a fatal panic) unless GOTRACEBACK=system or - crash. Runtime-internal fatal error tracebacks always include - full metadata regardless of the value of GOTRACEBACK -

- -

- Support for debugger-injected function calls has been added on ARM64, - enabling users to call functions from their binary in an interactive - debugging session when using a debugger that is updated to make use of this - functionality. -

- -

- The address sanitizer support added in Go 1.18 - now handles function arguments and global variables more precisely. -

- -

Compiler

- -

- The compiler now uses - a jump - table to implement large integer and string switch statements. - Performance improvements for the switch statement vary but can be - on the order of 20% faster. - (GOARCH=amd64 and GOARCH=arm64 only) -

-

- The Go compiler now requires the -p=importpath flag to - build a linkable object file. This is already supplied by - the go command and by Bazel. Any other build systems - that invoke the Go compiler directly will need to make sure they - pass this flag as well. -

-

- The Go compiler no longer accepts the -importmap - flag. Build systems that invoke the Go compiler directly must use - the -importcfg flag instead. -

- -

Assembler

-

- Like the compiler, the assembler now requires the - -p=importpath flag to build a linkable object file. - This is already supplied by the go command. Any other - build systems that invoke the Go assembler directly will need to - make sure they pass this flag as well. -

- -

Linker

-

- On ELF platforms, the linker now emits compressed DWARF sections in - the standard gABI format (SHF_COMPRESSED), instead of - the legacy .zdebug format. -

- -

Core library

- -

New atomic types

- -

- The sync/atomic package defines new atomic types - Bool, - Int32, - Int64, - Uint32, - Uint64, - Uintptr, and - Pointer. - These types hide the underlying values so that all accesses are forced to use - the atomic APIs. - Pointer also avoids - the need to convert to - unsafe.Pointer at call sites. - Int64 and - Uint64 are - automatically aligned to 64-bit boundaries in structs and allocated data, - even on 32-bit systems. -

- -

PATH lookups

- -

- - Command and - LookPath no longer - allow results from a PATH search to be found relative to the current directory. - This removes a common source of security problems - but may also break existing programs that depend on using, say, exec.Command("prog") - to run a binary named prog (or, on Windows, prog.exe) in the current directory. - See the os/exec package documentation for - information about how best to update such programs. -

- -

- On Windows, Command and LookPath now respect the - NoDefaultCurrentDirectoryInExePath - environment variable, making it possible to disable - the default implicit search of “.” in PATH lookups on Windows systems. -

- -

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. - There are also various performance improvements, not enumerated here. -

- -
archive/zip
-
-

- Reader - now ignores non-ZIP data at the start of a ZIP file, matching most other implementations. - This is necessary to read some Java JAR files, among other uses. -

-
-
- -
crypto/elliptic
-
-

- Operating on invalid curve points (those for which the - IsOnCurve method returns false, and which are never returned - by Unmarshal or by a Curve method operating on a - valid point) has always been undefined behavior and can lead to key - recovery attacks. If an invalid point is supplied to - Marshal, - MarshalCompressed, - Add, - Double, or - ScalarMult, - they will now panic. -

- -

- ScalarBaseMult operations on the P224, - P384, and P521 curves are now up to three - times faster, leading to similar speedups in some ECDSA operations. The - generic (not platform optimized) P256 implementation was - replaced with one derived from a formally verified model; this might - lead to significant slowdowns on 32-bit platforms. -

-
-
- -
crypto/rand
-
-

- Read no longer buffers - random data obtained from the operating system between calls. Applications - that perform many small reads at high frequency might choose to wrap - Reader in a - bufio.Reader for performance - reasons, taking care to use - io.ReadFull - to ensure no partial reads occur. -

- -

- On Plan 9, Read has been reimplemented, replacing the ANSI - X9.31 algorithm with a fast key erasure generator. -

- -

- The Prime - implementation was changed to use only rejection sampling, - which removes a bias when generating small primes in non-cryptographic contexts, - removes one possible minor timing leak, - and better aligns the behavior with BoringSSL, - all while simplifying the implementation. - The change does produce different outputs for a given random source - stream compared to the previous implementation, - which can break tests written expecting specific results from - specific deterministic random sources. - To help prevent such problems in the future, - the implementation is now intentionally non-deterministic with respect to the input stream. -

-
-
- -
crypto/tls
-
-

- The GODEBUG option tls10default=1 has been - removed. It is still possible to enable TLS 1.0 client-side by setting - Config.MinVersion. -

- -

- The TLS server and client now reject duplicate extensions in TLS - handshakes, as required by RFC 5246, Section 7.4.1.4 and RFC 8446, Section - 4.2. -

-
-
- -
crypto/x509
-
-

- CreateCertificate - no longer supports creating certificates with SignatureAlgorithm - set to MD5WithRSA. -

- -

- CreateCertificate no longer accepts negative serial numbers. -

- -

- CreateCertificate will not emit an empty SEQUENCE anymore - when the produced certificate has no extensions. -

- -

- Removal of the GODEBUG optionx509sha1=1, - originally planned for Go 1.19, has been rescheduled to a future release. - Applications using it should work on migrating. Practical attacks against - SHA-1 have been demonstrated since 2017 and publicly trusted Certificate - Authorities have not issued SHA-1 certificates since 2015. -

- -

- ParseCertificate - and ParseCertificateRequest - now reject certificates and CSRs which contain duplicate extensions. -

- -

- The new CertPool.Clone - and CertPool.Equal - methods allow cloning a CertPool and checking the equivalence of two - CertPools respectively. -

- -

- The new function ParseRevocationList - provides a faster, safer to use CRL parser which returns a - RevocationList. - Parsing a CRL also populates the new RevocationList fields - RawIssuer, Signature, - AuthorityKeyId, and Extensions, which are ignored by - CreateRevocationList. -

- The new method RevocationList.CheckSignatureFrom - checks that the signature on a CRL is a valid signature from a - Certificate. -

- The ParseCRL and - ParseDERCRL functions - are now deprecated in favor of ParseRevocationList. - The Certificate.CheckCRLSignature - method is deprecated in favor of RevocationList.CheckSignatureFrom. -

- -

- The path builder of Certificate.Verify - was overhauled and should now produce better chains and/or be more efficient in complicated scenarios. - Name constraints are now also enforced on non-leaf certificates. -

-
-
- -
crypto/x509/pkix
-
-

- The types CertificateList and - TBSCertificateList - have been deprecated. The new crypto/x509 CRL functionality - should be used instead. -

-
-
- -
debug/elf
-
-

- The new EM_LOONGARCH and R_LARCH_* constants - support the loong64 port. -

-
-
- -
debug/pe
-
-

- The new File.COFFSymbolReadSectionDefAux - method, which returns a COFFSymbolAuxFormat5, - provides access to COMDAT information in PE file sections. - These are supported by new IMAGE_COMDAT_* and IMAGE_SCN_* constants. -

-
-
- -
encoding/binary
-
-

- The new interface - AppendByteOrder - provides efficient methods for appending a uint16, uint32, or uint64 - to a byte slice. - BigEndian and - LittleEndian now implement this interface. -

-

- Similarly, the new functions - AppendUvarint and - AppendVarint - are efficient appending versions of - PutUvarint and - PutVarint. -

-
-
- -
encoding/csv
-
-

- The new method - Reader.InputOffset - reports the reader's current input position as a byte offset, - analogous to encoding/json's - Decoder.InputOffset. -

-
-
- -
encoding/xml
-
-

- The new method - Decoder.InputPos - reports the reader's current input position as a line and column, - analogous to encoding/csv's - Decoder.FieldPos. -

-
-
- -
flag
-
-

- The new function - TextVar - defines a flag with a value implementing - encoding.TextUnmarshaler, - allowing command-line flag variables to have types such as - big.Int, - netip.Addr, and - time.Time. -

-
-
- -
fmt
-
-

- The new functions - Append, - Appendf, and - Appendln - append formatted data to byte slices. -

-
-
- -
go/parser
-
-

- The parser now recognizes ~x as a unary expression with operator - token.TILDE, - allowing better error recovery when a type constraint such as ~int is used in an incorrect context. -

-
-
- -
go/types
-
-

- The new methods Func.Origin - and Var.Origin return the - corresponding Object of the - generic type for synthetic Func - and Var objects created during type - instantiation. -

-

- It is no longer possible to produce an infinite number of distinct-but-identical - Named type instantiations via - recursive calls to - Named.Underlying or - Named.Method. -

-
-
- - -
hash/maphash
-
-

- The new functions - Bytes - and - String - provide an efficient way hash a single byte slice or string. - They are equivalent to using the more general - Hash - with a single write, but they avoid setup overhead for small inputs. -

-
-
- -
html/template
-
-

- The type FuncMap - is now an alias for - text/template's FuncMap - instead of its own named type. - This allows writing code that operates on a FuncMap from either setting. -

-

- Go 1.19.8 and later - disallow actions in ECMAScript 6 template literals. - This behavior can be reverted by the GODEBUG=jstmpllitinterp=1 setting. -

-
-
- -
image/draw
-
-

- Draw with the - Src operator preserves - non-premultiplied-alpha colors when destination and source images are - both image.NRGBA - or both image.NRGBA64. - This reverts a behavior change accidentally introduced by a Go 1.18 - library optimization; the code now matches the behavior in Go 1.17 and earlier. -

-
-
- -
io
-
-

- NopCloser's result now implements - WriterTo - whenever its input does. -

- -

- MultiReader's result now implements - WriterTo unconditionally. - If any underlying reader does not implement WriterTo, - it is simulated appropriately. -

-
-
- -
mime
-
-

- On Windows only, the mime package now ignores a registry entry - recording that the extension .js should have MIME - type text/plain. This is a common unintentional - misconfiguration on Windows systems. The effect is - that .js will have the default MIME - type text/javascript; charset=utf-8. - Applications that expect text/plain on Windows must - now explicitly call - AddExtensionType. -

-
-
- -
mime/multipart
-
-

- In Go 1.19.8 and later, this package sets limits the size - of the MIME data it processes to protect against malicious inputs. - Reader.NextPart and Reader.NextRawPart limit the - number of headers in a part to 10000 and Reader.ReadForm limits - the total number of headers in all FileHeaders to 10000. - These limits may be adjusted with the GODEBUG=multipartmaxheaders - setting. - Reader.ReadForm further limits the number of parts in a form to 1000. - This limit may be adjusted with the GODEBUG=multipartmaxparts - setting. -

-
-
- -
net
-
-

- The pure Go resolver will now use EDNS(0) to include a suggested - maximum reply packet length, permitting reply packets to contain - up to 1232 bytes (the previous maximum was 512). - In the unlikely event that this causes problems with a local DNS - resolver, setting the environment variable - GODEBUG=netdns=cgo to use the cgo-based resolver - should work. - Please report any such problems on the - issue tracker. -

- -

- When a net package function or method returns an "I/O timeout" - error, the error will now satisfy errors.Is(err, - context.DeadlineExceeded). When a net package function - returns an "operation was canceled" error, the error will now - satisfy errors.Is(err, context.Canceled). - These changes are intended to make it easier for code to test - for cases in which a context cancellation or timeout causes a net - package function or method to return an error, while preserving - backward compatibility for error messages. -

- -

- Resolver.PreferGo - is now implemented on Windows and Plan 9. It previously only worked on Unix - platforms. Combined with - Dialer.Resolver and - Resolver.Dial, it's now - possible to write portable programs and be in control of all DNS name lookups - when dialing. -

- -

- The net package now has initial support for the netgo - build tag on Windows. When used, the package uses the Go DNS client (as used - by Resolver.PreferGo) instead of asking Windows for - DNS results. The upstream DNS server it discovers from Windows - may not yet be correct with complex system network configurations, however. -

-
-
- -
net/http
-
-

- ResponseWriter.WriteHeader - now supports sending user-defined 1xx informational headers. -

- -

- The io.ReadCloser returned by - MaxBytesReader - will now return the defined error type - MaxBytesError - when its read limit is exceeded. -

- -

- The HTTP client will handle a 3xx response without a - Location header by returning it to the caller, - rather than treating it as an error. -

-
-
- -
net/url
-
-

- The new - JoinPath - function and - URL.JoinPath - method create a new URL by joining a list of path - elements. -

-

- The URL type now distinguishes between URLs with no - authority and URLs with an empty authority. For example, - http:///path has an empty authority (host), - while http:/path has none. -

-

- The new URL field - OmitHost is set to true when a - URL has an empty authority. -

- -
-
- -
os/exec
-
-

- A Cmd with a non-empty Dir field - and nil Env now implicitly sets the PWD environment - variable for the subprocess to match Dir. -

-

- The new method Cmd.Environ reports the - environment that would be used to run the command, including the - implicitly set PWD variable. -

-
-
- -
reflect
-
-

- The method Value.Bytes - now accepts addressable arrays in addition to slices. -

-

- The methods Value.Len - and Value.Cap - now successfully operate on a pointer to an array and return the length of that array, - to match what the builtin - len and cap functions do. -

-
-
- -
regexp/syntax
-
-

- Go 1.18 release candidate 1, Go 1.17.8, and Go 1.16.15 included a security fix - to the regular expression parser, making it reject very deeply nested expressions. - Because Go patch releases do not introduce new API, - the parser returned syntax.ErrInternalError in this case. - Go 1.19 adds a more specific error, syntax.ErrNestingDepth, - which the parser now returns instead. -

-
-
- -
runtime
-
-

- The GOROOT function now returns the empty string - (instead of "go") when the binary was built with - the -trimpath flag set and the GOROOT - variable is not set in the process environment. -

-
-
- -
runtime/metrics
-
-

- The new /sched/gomaxprocs:threads - metric reports - the current - runtime.GOMAXPROCS - value. -

- -

- The new /cgo/go-to-c-calls:calls - metric - reports the total number of calls made from Go to C. This metric is - identical to the - runtime.NumCgoCall - function. -

- -

- The new /gc/limiter/last-enabled:gc-cycle - metric - reports the last GC cycle when the GC CPU limiter was enabled. See the - runtime notes for details about the GC CPU limiter. -

-
-
- -
runtime/pprof
-
-

- Stop-the-world pause times have been significantly reduced when - collecting goroutine profiles, reducing the overall latency impact to the - application. -

- -

- MaxRSS is now reported in heap profiles for all Unix - operating systems (it was previously only reported for - GOOS=android, darwin, ios, and - linux). -

-
-
- -
runtime/race
-
-

- The race detector has been upgraded to use thread sanitizer - version v3 on all supported platforms - except windows/amd64 - and openbsd/amd64, which remain on v2. - Compared to v2, it is now typically 1.5x to 2x faster, uses half - as much memory, and it supports an unlimited number of - goroutines. - On Linux, the race detector now requires at least glibc version - 2.17 and GNU binutils 2.26. -

- -

- The race detector is now supported on GOARCH=s390x. -

- -

- Race detector support for openbsd/amd64 has been - removed from thread sanitizer upstream, so it is unlikely to - ever be updated from v2. -

-
-
- -
runtime/trace
-
-

- When tracing and the - CPU profiler are - enabled simultaneously, the execution trace includes CPU profile - samples as instantaneous events. -

-
-
- -
sort
-
-

- The sorting algorithm has been rewritten to use - pattern-defeating quicksort, which - is faster for several common scenarios. -

-

- The new function - Find - is like - Search - but often easier to use: it returns an additional boolean reporting whether an equal value was found. -

-
-
- -
strconv
-
-

- Quote - and related functions now quote the rune U+007F as \x7f, - not \u007f, - for consistency with other ASCII values. -

-
-
- -
syscall
-
-

- On PowerPC (GOARCH=ppc64, ppc64le), - Syscall, - Syscall6, - RawSyscall, and - RawSyscall6 - now always return 0 for return value r2 instead of an - undefined value. -

- -

- On AIX and Solaris, Getrusage is now defined. -

-
-
- -
time
-
-

- The new method - Duration.Abs - provides a convenient and safe way to take the absolute value of a duration, - converting −2⁶³ to 2⁶³−1. - (This boundary case can happen as the result of subtracting a recent time from the zero time.) -

-

- The new method - Time.ZoneBounds - returns the start and end times of the time zone in effect at a given time. - It can be used in a loop to enumerate all the known time zone transitions at a given location. -

-
-
- - - - - - - - - - - - - - - - - - - - - diff --git a/_content/doc/go1.2.html b/_content/doc/go1.2.html deleted file mode 100644 index 2a544b877d..0000000000 --- a/_content/doc/go1.2.html +++ /dev/null @@ -1,977 +0,0 @@ - - -

Introduction to Go 1.2

- -

-Since the release of Go version 1.1 in April, 2013, -the release schedule has been shortened to make the release process more efficient. -This release, Go version 1.2 or Go 1.2 for short, arrives roughly six months after 1.1, -while 1.1 took over a year to appear after 1.0. -Because of the shorter time scale, 1.2 is a smaller delta than the step from 1.0 to 1.1, -but it still has some significant developments, including -a better scheduler and one new language feature. -Of course, Go 1.2 keeps the promise -of compatibility. -The overwhelming majority of programs built with Go 1.1 (or 1.0 for that matter) -will run without any changes whatsoever when moved to 1.2, -although the introduction of one restriction -to a corner of the language may expose already-incorrect code -(see the discussion of the use of nil). -

- -

Changes to the language

- -

-In the interest of firming up the specification, one corner case has been clarified, -with consequences for programs. -There is also one new language feature. -

- -

Use of nil

- -

-The language now specifies that, for safety reasons, -certain uses of nil pointers are guaranteed to trigger a run-time panic. -For instance, in Go 1.0, given code like -

- -
-type T struct {
-    X [1<<24]byte
-    Field int32
-}
-
-func main() {
-    var x *T
-    ...
-}
-
- -

-the nil pointer x could be used to access memory incorrectly: -the expression x.Field could access memory at address 1<<24. -To prevent such unsafe behavior, in Go 1.2 the compilers now guarantee that any indirection through -a nil pointer, such as illustrated here but also in nil pointers to arrays, nil interface values, -nil slices, and so on, will either panic or return a correct, safe non-nil value. -In short, any expression that explicitly or implicitly requires evaluation of a nil address is an error. -The implementation may inject extra tests into the compiled program to enforce this behavior. -

- -

-Further details are in the -design document. -

- -

-Updating: -Most code that depended on the old behavior is erroneous and will fail when run. -Such programs will need to be updated by hand. -

- -

Three-index slices

- -

-Go 1.2 adds the ability to specify the capacity as well as the length when using a slicing operation -on an existing array or slice. -A slicing operation creates a new slice by describing a contiguous section of an already-created array or slice: -

- -
-var array [10]int
-slice := array[2:4]
-
- -

-The capacity of the slice is the maximum number of elements that the slice may hold, even after reslicing; -it reflects the size of the underlying array. -In this example, the capacity of the slice variable is 8. -

- -

-Go 1.2 adds new syntax to allow a slicing operation to specify the capacity as well as the length. -A second -colon introduces the capacity value, which must be less than or equal to the capacity of the -source slice or array, adjusted for the origin. For instance, -

- -
-slice = array[2:4:7]
-
- -

-sets the slice to have the same length as in the earlier example but its capacity is now only 5 elements (7-2). -It is impossible to use this new slice value to access the last three elements of the original array. -

- -

-In this three-index notation, a missing first index ([:i:j]) defaults to zero but the other -two indices must always be specified explicitly. -It is possible that future releases of Go may introduce default values for these indices. -

- -

-Further details are in the -design document. -

- -

-Updating: -This is a backwards-compatible change that affects no existing programs. -

- -

Changes to the implementations and tools

- -

Pre-emption in the scheduler

- -

-In prior releases, a goroutine that was looping forever could starve out other -goroutines on the same thread, a serious problem when GOMAXPROCS -provided only one user thread. -In Go 1.2, this is partially addressed: The scheduler is invoked occasionally -upon entry to a function. -This means that any loop that includes a (non-inlined) function call can -be pre-empted, allowing other goroutines to run on the same thread. -

- -

Limit on the number of threads

- -

-Go 1.2 introduces a configurable limit (default 10,000) to the total number of threads -a single program may have in its address space, to avoid resource starvation -issues in some environments. -Note that goroutines are multiplexed onto threads so this limit does not directly -limit the number of goroutines, only the number that may be simultaneously blocked -in a system call. -In practice, the limit is hard to reach. -

- -

-The new SetMaxThreads function in the -runtime/debug package controls the thread count limit. -

- -

-Updating: -Few functions will be affected by the limit, but if a program dies because it hits the -limit, it could be modified to call SetMaxThreads to set a higher count. -Even better would be to refactor the program to need fewer threads, reducing consumption -of kernel resources. -

- -

Stack size

- -

-In Go 1.2, the minimum size of the stack when a goroutine is created has been lifted from 4KB to 8KB. -Many programs were suffering performance problems with the old size, which had a tendency -to introduce expensive stack-segment switching in performance-critical sections. -The new number was determined by empirical testing. -

- -

-At the other end, the new function SetMaxStack -in the runtime/debug package controls -the maximum size of a single goroutine's stack. -The default is 1GB on 64-bit systems and 250MB on 32-bit systems. -Before Go 1.2, it was too easy for a runaway recursion to consume all the memory on a machine. -

- -

-Updating: -The increased minimum stack size may cause programs with many goroutines to use -more memory. There is no workaround, but plans for future releases -include new stack management technology that should address the problem better. -

- -

Cgo and C++

- -

-The cgo command will now invoke the C++ -compiler to build any pieces of the linked-to library that are written in C++; -the documentation has more detail. -

- -

Godoc and vet moved to the go.tools subrepository

- -

-Both binaries are still included with the distribution, but the source code for the -godoc and vet commands has moved to the -go.tools subrepository. -

- -

-Also, the core of the godoc program has been split into a -library, -while the command itself is in a separate -directory. -The move allows the code to be updated easily and the separation into a library and command -makes it easier to construct custom binaries for local sites and different deployment methods. -

- -

-Updating: -Since godoc and vet are not part of the library, -no client Go code depends on their source and no updating is required. -

- -

-The binary distributions available from golang.org -include these binaries, so users of these distributions are unaffected. -

- -

-When building from source, users must use "go get" to install godoc and vet. -(The binaries will continue to be installed in their usual locations, not -$GOPATH/bin.) -

- -
-$ go get code.google.com/p/go.tools/cmd/godoc
-$ go get code.google.com/p/go.tools/cmd/vet
-
- -

Status of gccgo

- -

-We expect the future GCC 4.9 release to include gccgo with full -support for Go 1.2. -In the current (4.8.2) release of GCC, gccgo implements Go 1.1.2. -

- -

Changes to the gc compiler and linker

- -

-Go 1.2 has several semantic changes to the workings of the gc compiler suite. -Most users will be unaffected by them. -

- -

-The cgo command now -works when C++ is included in the library being linked against. -See the cgo documentation -for details. -

- -

-The gc compiler displayed a vestigial detail of its origins when -a program had no package clause: it assumed -the file was in package main. -The past has been erased, and a missing package clause -is now an error. -

- -

-On the ARM, the toolchain supports "external linking", which -is a step towards being able to build shared libraries with the gc -toolchain and to provide dynamic linking support for environments -in which that is necessary. -

- -

-In the runtime for the ARM, with 5a, it used to be possible to refer -to the runtime-internal m (machine) and g -(goroutine) variables using R9 and R10 directly. -It is now necessary to refer to them by their proper names. -

- -

-Also on the ARM, the 5l linker (sic) now defines the -MOVBS and MOVHS instructions -as synonyms of MOVB and MOVH, -to make clearer the separation between signed and unsigned -sub-word moves; the unsigned versions already existed with a -U suffix. -

- -

Test coverage

- -

-One major new feature of go test is -that it can now compute and, with help from a new, separately installed -"go tool cover" program, display test coverage results. -

- -

-The cover tool is part of the -go.tools -subrepository. -It can be installed by running -

- -
-$ go get code.google.com/p/go.tools/cmd/cover
-
- -

-The cover tool does two things. -First, when "go test" is given the -cover flag, it is run automatically -to rewrite the source for the package and insert instrumentation statements. -The test is then compiled and run as usual, and basic coverage statistics are reported: -

- -
-$ go test -cover fmt
-ok  	fmt	0.060s	coverage: 91.4% of statements
-$
-
- -

-Second, for more detailed reports, different flags to "go test" can create a coverage profile file, -which the cover program, invoked with "go tool cover", can then analyze. -

- -

-Details on how to generate and analyze coverage statistics can be found by running the commands -

- -
-$ go help testflag
-$ go tool cover -help
-
- -

The go doc command is deleted

- -

-The "go doc" command is deleted. -Note that the godoc tool itself is not deleted, -just the wrapping of it by the go command. -All it did was show the documents for a package by package path, -which godoc itself already does with more flexibility. -It has therefore been deleted to reduce the number of documentation tools and, -as part of the restructuring of godoc, encourage better options in future. -

- -

-Updating: For those who still need the precise functionality of running -

- -
-$ go doc
-
- -

-in a directory, the behavior is identical to running -

- -
-$ godoc .
-
- -

Changes to the go command

- -

-The go get command -now has a -t flag that causes it to download the dependencies -of the tests run by the package, not just those of the package itself. -By default, as before, dependencies of the tests are not downloaded. -

- -

Performance

- -

-There are a number of significant performance improvements in the standard library; here are a few of them. -

- -
    - -
  • -The compress/bzip2 -decompresses about 30% faster. -
  • - -
  • -The crypto/des package -is about five times faster. -
  • - -
  • -The encoding/json package -encodes about 30% faster. -
  • - -
  • -Networking performance on Windows and BSD systems is about 30% faster through the use -of an integrated network poller in the runtime, similar to what was done for Linux and OS X -in Go 1.1. -
  • - -
- -

Changes to the standard library

- - -

The archive/tar and archive/zip packages

- -

-The -archive/tar -and -archive/zip -packages have had a change to their semantics that may break existing programs. -The issue is that they both provided an implementation of the -os.FileInfo -interface that was not compliant with the specification for that interface. -In particular, their Name method returned the full -path name of the entry, but the interface specification requires that -the method return only the base name (final path element). -

- -

-Updating: Since this behavior was newly implemented and -a bit obscure, it is possible that no code depends on the broken behavior. -If there are programs that do depend on it, they will need to be identified -and fixed manually. -

- -

The new encoding package

- -

-There is a new package, encoding, -that defines a set of standard encoding interfaces that may be used to -build custom marshalers and unmarshalers for packages such as -encoding/xml, -encoding/json, -and -encoding/binary. -These new interfaces have been used to tidy up some implementations in -the standard library. -

- -

-The new interfaces are called -BinaryMarshaler, -BinaryUnmarshaler, -TextMarshaler, -and -TextUnmarshaler. -Full details are in the documentation for the package -and a separate design document. -

- -

The fmt package

- -

-The fmt package's formatted print -routines such as Printf -now allow the data items to be printed to be accessed in arbitrary order -by using an indexing operation in the formatting specifications. -Wherever an argument is to be fetched from the argument list for formatting, -either as the value to be formatted or as a width or specification integer, -a new optional indexing notation [n] -fetches argument n instead. -The value of n is 1-indexed. -After such an indexing operating, the next argument to be fetched by normal -processing will be n+1. -

- -

-For example, the normal Printf call -

- -
-fmt.Sprintf("%c %c %c\n", 'a', 'b', 'c')
-
- -

-would create the string "a b c", but with indexing operations like this, -

- -
-fmt.Sprintf("%[3]c %[1]c %c\n", 'a', 'b', 'c')
-
- -

-the result is ""c a b". The [3] index accesses the third formatting -argument, which is 'c', [1] accesses the first, 'a', -and then the next fetch accesses the argument following that one, 'b'. -

- -

-The motivation for this feature is programmable format statements to access -the arguments in different order for localization, but it has other uses: -

- -
-log.Printf("trace: value %v of type %[1]T\n", expensiveFunction(a.b[c]))
-
- -

-Updating: The change to the syntax of format specifications -is strictly backwards compatible, so it affects no working programs. -

- -

The text/template and html/template packages

- -

-The -text/template package -has a couple of changes in Go 1.2, both of which are also mirrored in the -html/template package. -

- -

-First, there are new default functions for comparing basic types. -The functions are listed in this table, which shows their names and -the associated familiar comparison operator. -

- - - - - - - - - - - - - - - - - - - - - - - -
Name Operator
eq ==
ne !=
lt <
le <=
gt >
ge >=
- -

-These functions behave slightly differently from the corresponding Go operators. -First, they operate only on basic types (bool, int, -float64, string, etc.). -(Go allows comparison of arrays and structs as well, under some circumstances.) -Second, values can be compared as long as they are the same sort of value: -any signed integer value can be compared to any other signed integer value for example. (Go -does not permit comparing an int8 and an int16). -Finally, the eq function (only) allows comparison of the first -argument with one or more following arguments. The template in this example, -

- -
-{{if eq .A 1 2 3}} equal {{else}} not equal {{end}}
-
- -

-reports "equal" if .A is equal to any of 1, 2, or 3. -

- -

-The second change is that a small addition to the grammar makes "if else if" chains easier to write. -Instead of writing, -

- -
-{{if eq .A 1}} X {{else}} {{if eq .A 2}} Y {{end}} {{end}}
-
- -

-one can fold the second "if" into the "else" and have only one "end", like this: -

- -
-{{if eq .A 1}} X {{else if eq .A 2}} Y {{end}}
-
- -

-The two forms are identical in effect; the difference is just in the syntax. -

- -

-Updating: Neither the "else if" change nor the comparison functions -affect existing programs. Those that -already define functions called eq and so on through a function -map are unaffected because the associated function map will override the new -default function definitions. -

- -

New packages

- -

-There are two new packages. -

- - - -

Minor changes to the library

- -

-The following list summarizes a number of minor changes to the library, mostly additions. -See the relevant package documentation for more information about each change. -

- -
    - -
  • -The archive/zip package -adds the -DataOffset accessor -to return the offset of a file's (possibly compressed) data within the archive. -
  • - -
  • -The bufio package -adds Reset -methods to Reader and -Writer. -These methods allow the Readers -and Writers -to be re-used on new input and output readers and writers, saving -allocation overhead. -
  • - -
  • -The compress/bzip2 -can now decompress concatenated archives. -
  • - -
  • -The compress/flate -package adds a Reset -method on the Writer, -to make it possible to reduce allocation when, for instance, constructing an -archive to hold multiple compressed files. -
  • - -
  • -The compress/gzip package's -Writer type adds a -Reset -so it may be reused. -
  • - -
  • -The compress/zlib package's -Writer type adds a -Reset -so it may be reused. -
  • - -
  • -The container/heap package -adds a Fix -method to provide a more efficient way to update an item's position in the heap. -
  • - -
  • -The container/list package -adds the MoveBefore -and -MoveAfter -methods, which implement the obvious rearrangement. -
  • - -
  • -The crypto/cipher package -adds the new GCM mode (Galois Counter Mode), which is almost always -used with AES encryption. -
  • - -
  • -The -crypto/md5 package -adds a new Sum function -to simplify hashing without sacrificing performance. -
  • - -
  • -Similarly, the -crypto/sha1 package -adds a new Sum function. -
  • - -
  • -Also, the -crypto/sha256 package -adds Sum256 -and Sum224 functions. -
  • - -
  • -Finally, the crypto/sha512 package -adds Sum512 and -Sum384 functions. -
  • - -
  • -The crypto/x509 package -adds support for reading and writing arbitrary extensions. -
  • - -
  • -The crypto/tls package adds -support for TLS 1.1, 1.2 and AES-GCM. -
  • - -
  • -The database/sql package adds a -SetMaxOpenConns -method on DB to limit the -number of open connections to the database. -
  • - -
  • -The encoding/csv package -now always allows trailing commas on fields. -
  • - -
  • -The encoding/gob package -now treats channel and function fields of structures as if they were unexported, -even if they are not. That is, it ignores them completely. Previously they would -trigger an error, which could cause unexpected compatibility problems if an -embedded structure added such a field. -The package also now supports the generic BinaryMarshaler and -BinaryUnmarshaler interfaces of the -encoding package -described above. -
  • - -
  • -The encoding/json package -now will always escape ampersands as "\u0026" when printing strings. -It will now accept but correct invalid UTF-8 in -Marshal -(such input was previously rejected). -Finally, it now supports the generic encoding interfaces of the -encoding package -described above. -
  • - -
  • -The encoding/xml package -now allows attributes stored in pointers to be marshaled. -It also supports the generic encoding interfaces of the -encoding package -described above through the new -Marshaler, -Unmarshaler, -and related -MarshalerAttr and -UnmarshalerAttr -interfaces. -The package also adds a -Flush method -to the -Encoder -type for use by custom encoders. See the documentation for -EncodeToken -to see how to use it. -
  • - -
  • -The flag package now -has a Getter interface -to allow the value of a flag to be retrieved. Due to the -Go 1 compatibility guidelines, this method cannot be added to the existing -Value -interface, but all the existing standard flag types implement it. -The package also now exports the CommandLine -flag set, which holds the flags from the command line. -
  • - -
  • -The go/ast package's -SliceExpr struct -has a new boolean field, Slice3, which is set to true -when representing a slice expression with three indices (two colons). -The default is false, representing the usual two-index form. -
  • - -
  • -The go/build package adds -the AllTags field -to the Package type, -to make it easier to process build tags. -
  • - -
  • -The image/draw package now -exports an interface, Drawer, -that wraps the standard Draw method. -The Porter-Duff operators now implement this interface, in effect binding an operation to -the draw operator rather than providing it explicitly. -Given a paletted image as its destination, the new -FloydSteinberg -implementation of the -Drawer -interface will use the Floyd-Steinberg error diffusion algorithm to draw the image. -To create palettes suitable for such processing, the new -Quantizer interface -represents implementations of quantization algorithms that choose a palette -given a full-color image. -There are no implementations of this interface in the library. -
  • - -
  • -The image/gif package -can now create GIF files using the new -Encode -and EncodeAll -functions. -Their options argument allows specification of an image -Quantizer to use; -if it is nil, the generated GIF will use the -Plan9 -color map (palette) defined in the new -image/color/palette package. -The options also specify a -Drawer -to use to create the output image; -if it is nil, Floyd-Steinberg error diffusion is used. -
  • - -
  • -The Copy method of the -io package now prioritizes its -arguments differently. -If one argument implements WriterTo -and the other implements ReaderFrom, -Copy will now invoke -WriterTo to do the work, -so that less intermediate buffering is required in general. -
  • - -
  • -The net package requires cgo by default -because the host operating system must in general mediate network call setup. -On some systems, though, it is possible to use the network without cgo, and useful -to do so, for instance to avoid dynamic linking. -The new build tag netgo (off by default) allows the construction of a -net package in pure Go on those systems where it is possible. -
  • - -
  • -The net package adds a new field -DualStack to the Dialer -struct for TCP connection setup using a dual IP stack as described in -RFC 6555. -
  • - -
  • -The net/http package will no longer -transmit cookies that are incorrect according to -RFC 6265. -It just logs an error and sends nothing. -Also, -the net/http package's -ReadResponse -function now permits the *Request parameter to be nil, -whereupon it assumes a GET request. -Finally, an HTTP server will now serve HEAD -requests transparently, without the need for special casing in handler code. -While serving a HEAD request, writes to a -Handler's -ResponseWriter -are absorbed by the -Server -and the client receives an empty body as required by the HTTP specification. -
  • - -
  • -The os/exec package's -Cmd.StdinPipe method -returns an io.WriteCloser, but has changed its concrete -implementation from *os.File to an unexported type that embeds -*os.File, and it is now safe to close the returned value. -Before Go 1.2, there was an unavoidable race that this change fixes. -Code that needs access to the methods of *os.File can use an -interface type assertion, such as wc.(interface{ Sync() error }). -
  • - -
  • -The runtime package relaxes -the constraints on finalizer functions in -SetFinalizer: the -actual argument can now be any type that is assignable to the formal type of -the function, as is the case for any normal function call in Go. -
  • - -
  • -The sort package has a new -Stable function that implements -stable sorting. It is less efficient than the normal sort algorithm, however. -
  • - -
  • -The strings package adds -an IndexByte -function for consistency with the bytes package. -
  • - -
  • -The sync/atomic package -adds a new set of swap functions that atomically exchange the argument with the -value stored in the pointer, returning the old value. -The functions are -SwapInt32, -SwapInt64, -SwapUint32, -SwapUint64, -SwapUintptr, -and -SwapPointer, -which swaps an unsafe.Pointer. -
  • - -
  • -The syscall package now implements -Sendfile for Darwin. -
  • - -
  • -The testing package -now exports the TB interface. -It records the methods in common with the -T -and -B types, -to make it easier to share code between tests and benchmarks. -Also, the -AllocsPerRun -function now quantizes the return value to an integer (although it -still has type float64), to round off any error caused by -initialization and make the result more repeatable. -
  • - -
  • -The text/template package -now automatically dereferences pointer values when evaluating the arguments -to "escape" functions such as "html", to bring the behavior of such functions -in agreement with that of other printing functions such as "printf". -
  • - -
  • -In the time package, the -Parse function -and -Format -method -now handle time zone offsets with seconds, such as in the historical -date "1871-01-01T05:33:02+00:34:08". -Also, pattern matching in the formats for those routines is stricter: a non-lowercase letter -must now follow the standard words such as "Jan" and "Mon". -
  • - -
  • -The unicode package -adds In, -a nicer-to-use but equivalent version of the original -IsOneOf, -to see whether a character is a member of a Unicode category. -
  • - -
diff --git a/_content/doc/go1.20.html b/_content/doc/go1.20.html deleted file mode 100644 index b6bb805ba7..0000000000 --- a/_content/doc/go1.20.html +++ /dev/null @@ -1,1291 +0,0 @@ - - - - - - -

Introduction to Go 1.20

- -

- The latest Go release, version 1.20, arrives six months after Go 1.19. - 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. -

- -

Changes to the language

- -

- Go 1.20 includes four changes to the language. -

- -

- Go 1.17 added conversions from slice to an array pointer. - Go 1.20 extends this to allow conversions from a slice to an array: - given a slice x, [4]byte(x) can now be written - instead of *(*[4]byte)(x). -

- -

- The unsafe package defines - three new functions SliceData, String, and StringData. - Along with Go 1.17's Slice, these functions now provide the complete ability to - construct and deconstruct slice and string values, without depending on their exact representation. -

- -

- The specification now defines that struct values are compared one field at a time, - considering fields in the order they appear in the struct type definition, - and stopping at the first mismatch. - The specification could previously have been read as if - all fields needed to be compared beyond the first mismatch. - Similarly, the specification now defines that array values are compared - one element at a time, in increasing index order. - In both cases, the difference affects whether certain comparisons must panic. - Existing programs are unchanged: the new spec wording describes - what the implementations have always done. -

- -

- Comparable types (such as ordinary interfaces) - may now satisfy comparable constraints, even if the type arguments - are not strictly comparable (comparison may panic at runtime). - This makes it possible to instantiate a type parameter constrained by comparable - (e.g., a type parameter for a user-defined generic map key) with a non-strictly comparable type argument - such as an interface type, or a composite type containing an interface type. -

- -

Ports

- -

Windows

- -

- Go 1.20 is the last release that will run on any release of Windows 7, 8, Server 2008 and Server 2012. - Go 1.21 will require at least Windows 10 or Server 2016. -

- -

Darwin and iOS

- -

- Go 1.20 is the last release that will run on macOS 10.13 High Sierra or 10.14 Mojave. - Go 1.21 will require macOS 10.15 Catalina or later. -

- -

FreeBSD/RISC-V

- -

- Go 1.20 adds experimental support for FreeBSD on RISC-V (GOOS=freebsd, GOARCH=riscv64). -

- -

Tools

- -

Go command

- -

- The directory $GOROOT/pkg no longer stores - pre-compiled package archives for the standard library: - go install no longer writes them, - the go build no longer checks for them, - and the Go distribution no longer ships them. - Instead, packages in the standard library are built as needed - and cached in the build cache, just like packages outside GOROOT. - This change reduces the size of the Go distribution and also - avoids C toolchain skew for packages that use cgo. -

- -

- The implementation of go test -json - has been improved to make it more robust. - Programs that run go test -json - do not need any updates. - Programs that invoke go tool test2json - directly should now run the test binary with -v=test2json - (for example, go test -v=test2json - or ./pkg.test -test.v=test2json) - instead of plain -v. -

- -

- A related change to go test -json - is the addition of an event with Action set to start - at the beginning of each test program's execution. - When running multiple tests using the go command, - these start events are guaranteed to be emitted in the same order as - the packages named on the command line. -

- -

- The go command now defines - architecture feature build tags, such as amd64.v2, - to allow selecting a package implementation file based on the presence - or absence of a particular architecture feature. - See go help buildconstraint for details. -

- -

- The go subcommands now accept - -C <dir> to change directory to <dir> - before performing the command, which may be useful for scripts that need to - execute commands in multiple different modules. -

- -

- The go build and go test - commands no longer accept the -i flag, - which has been deprecated since Go 1.16. -

- -

- The go generate command now accepts - -skip <pattern> to skip //go:generate directives - matching <pattern>. -

- -

- The go test command now accepts - -skip <pattern> to skip tests, subtests, or examples - matching <pattern>. -

- -

- When the main module is located within GOPATH/src, - go install no longer installs libraries for - non-main packages to GOPATH/pkg, - and go list no longer reports a Target - field for such packages. (In module mode, compiled packages are stored in the - build cache - only, but a bug had caused - the GOPATH install targets to unexpectedly remain in effect.) -

- -

- The go build, go install, - and other build-related commands now support a -pgo flag that enables - profile-guided optimization, which is described in more detail in the - Compiler section below. - The -pgo flag specifies the file path of the profile. - Specifying -pgo=auto causes the go command to search - for a file named default.pgo in the main package's directory and - use it if present. - This mode currently requires a single main package to be specified on the - command line, but we plan to lift this restriction in a future release. - Specifying -pgo=off turns off profile-guided optimization. -

- -

- The go build, go install, - and other build-related commands now support a -cover - flag that builds the specified target with code coverage instrumentation. - This is described in more detail in the - Cover section below. -

- -

go version

- -

- The go version -m command - now supports reading more types of Go binaries, most notably, Windows DLLs - built with go build -buildmode=c-shared - and Linux binaries without execute permission. -

- -

Cgo

- -

- The go command now disables cgo by default - on systems without a C toolchain. - More specifically, when the CGO_ENABLED environment variable is unset, - the CC environment variable is unset, - and the default C compiler (typically clang or gcc) - is not found in the path, - CGO_ENABLED defaults to 0. - As always, you can override the default by setting CGO_ENABLED explicitly. -

- -

- The most important effect of the default change is that when Go is installed - on a system without a C compiler, it will now use pure Go builds for packages - in the standard library that use cgo, instead of using pre-distributed package archives - (which have been removed, as noted above) - or attempting to use cgo and failing. - This makes Go work better in some minimal container environments - as well as on macOS, where pre-distributed package archives have - not been used for cgo-based packages since Go 1.16. -

- -

- The packages in the standard library that use cgo are net, - os/user, and - plugin. - On macOS, the net and os/user packages have been rewritten not to use cgo: - the same code is now used for cgo and non-cgo builds as well as cross-compiled builds. - On Windows, the net and os/user packages have never used cgo. - On other systems, builds with cgo disabled will use a pure Go version of these packages. -

- -

- A consequence is that, on macOS, if Go code that uses - the net package is built - with -buildmode=c-archive, linking the resulting - archive into a C program requires passing -lresolv when - linking the C code. -

- -

- On macOS, the race detector has been rewritten not to use cgo: - race-detector-enabled programs can be built and run without Xcode. - On Linux and other Unix systems, and on Windows, a host C toolchain - is required to use the race detector. -

- -

Cover

- -

- Go 1.20 supports collecting code coverage profiles for programs - (applications and integration tests), as opposed to just unit tests. -

- -

- To collect coverage data for a program, build it with go - build's -cover flag, then run the resulting - binary with the environment variable GOCOVERDIR set - to an output directory for coverage profiles. - See the - 'coverage for integration tests' landing page for more on how to get started. - For details on the design and implementation, see the - proposal. -

- -

Vet

- -

Improved detection of loop variable capture by nested functions

- -

- The vet tool now reports references to loop variables following - a call to T.Parallel() - within subtest function bodies. Such references may observe the value of the - variable from a different iteration (typically causing test cases to be - skipped) or an invalid state due to unsynchronized concurrent access. -

- -

- The tool also detects reference mistakes in more places. Previously it would - only consider the last statement of the loop body, but now it recursively - inspects the last statements within if, switch, and select statements. -

- -

New diagnostic for incorrect time formats

- -

- The vet tool now reports use of the time format 2006-02-01 (yyyy-dd-mm) - with Time.Format and - time.Parse. - This format does not appear in common date standards, but is frequently - used by mistake when attempting to use the ISO 8601 date format - (yyyy-mm-dd). -

- -

Runtime

- -

- Some of the garbage collector's internal data structures were reorganized to - be both more space and CPU efficient. - This change reduces memory overheads and improves overall CPU performance by - up to 2%. -

- -

- The garbage collector behaves less erratically with respect to goroutine - assists in some circumstances. -

- -

- Go 1.20 adds a new runtime/coverage package - containing APIs for writing coverage profile data at - runtime from long-running and/or server programs that - do not terminate via os.Exit(). -

- -

Compiler

- -

- Go 1.20 adds preview support for profile-guided optimization (PGO). - PGO enables the toolchain to perform application- and workload-specific - optimizations based on run-time profile information. - Currently, the compiler supports pprof CPU profiles, which can be collected - through usual means, such as the runtime/pprof or - net/http/pprof packages. - To enable PGO, pass the path of a pprof profile file via the - -pgo flag to go build, - as mentioned above. - Go 1.20 uses PGO to more aggressively inline functions at hot call sites. - Benchmarks for a representative set of Go programs show enabling - profile-guided inlining optimization improves performance about 3–4%. - See the PGO user guide for detailed documentation. - We plan to add more profile-guided optimizations in future releases. - Note that profile-guided optimization is a preview, so please use it - with appropriate caution. -

- -

- The Go 1.20 compiler upgraded its front-end to use a new way of handling the - compiler's internal data, which fixes several generic-types issues and enables - type declarations within generic functions and methods. -

- -

- The compiler now rejects anonymous interface cycles - with a compiler error by default. - These arise from tricky uses of embedded interfaces - and have always had subtle correctness issues, - yet we have no evidence that they're actually used in practice. - Assuming no reports from users adversely affected by this change, - we plan to update the language specification for Go 1.22 to formally disallow them - so tools authors can stop supporting them too. -

- -

- Go 1.18 and 1.19 saw regressions in build speed, largely due to the addition - of support for generics and follow-on work. Go 1.20 improves build speeds by - up to 10%, bringing it back in line with Go 1.17. - Relative to Go 1.19, generated code performance is also generally slightly improved. -

- -

Linker

- -

- On Linux, the linker now selects the dynamic interpreter for glibc - or musl at link time. -

- -

- On Windows, the Go linker now supports modern LLVM-based C toolchains. -

- -

- Go 1.20 uses go: and type: prefixes for compiler-generated - symbols rather than go. and type.. - This avoids confusion for user packages whose name starts with go.. - The debug/gosym package understands - this new naming convention for binaries built with Go 1.20 and newer. -

- -

Bootstrap

- -

- When building a Go release from source and GOROOT_BOOTSTRAP is not set, - previous versions of Go looked for a Go 1.4 or later bootstrap toolchain in the directory - $HOME/go1.4 (%HOMEDRIVE%%HOMEPATH%\go1.4 on Windows). - Go 1.18 and Go 1.19 looked first for $HOME/go1.17 or $HOME/sdk/go1.17 - before falling back to $HOME/go1.4, - in anticipation of requiring Go 1.17 for use when bootstrapping Go 1.20. - Go 1.20 does require a Go 1.17 release for bootstrapping, but we realized that we should - adopt the latest point release of the bootstrap toolchain, so it requires Go 1.17.13. - Go 1.20 looks for $HOME/go1.17.13 or $HOME/sdk/go1.17.13 - before falling back to $HOME/go1.4 - (to support systems that hard-coded the path $HOME/go1.4 but have installed - a newer Go toolchain there). - In the future, we plan to move the bootstrap toolchain forward approximately once a year, - and in particular we expect that Go 1.22 will require the final point release of Go 1.20 for bootstrap. -

- -

Core library

- -

New crypto/ecdh package

- -

- Go 1.20 adds a new crypto/ecdh package - to provide explicit support for Elliptic Curve Diffie-Hellman key exchanges - over NIST curves and Curve25519. -

-

- Programs should use crypto/ecdh instead of the lower-level functionality in - crypto/elliptic for ECDH, and - third-party modules for more advanced use cases. -

- -

Wrapping multiple errors

- -

- Go 1.20 expands support for error wrapping to permit an error to - wrap multiple other errors. -

-

- An error e can wrap more than one error by providing - an Unwrap method that returns a []error. -

-

- The errors.Is and - errors.As functions - have been updated to inspect multiply wrapped errors. -

-

- The fmt.Errorf function - now supports multiple occurrences of the %w format verb, - which will cause it to return an error that wraps all of those error operands. -

-

- The new function errors.Join - returns an error wrapping a list of errors. -

- -

HTTP ResponseController

- -

- The new - "net/http".ResponseController - type provides access to extended per-request functionality not handled by the - "net/http".ResponseWriter interface. -

- -

- Previously, we have added new per-request functionality by defining optional - interfaces which a ResponseWriter can implement, such as - Flusher. These interfaces - are not discoverable and clumsy to use. -

- -

- The ResponseController type provides a clearer, more discoverable way - to add per-handler controls. Two such controls also added in Go 1.20 are - SetReadDeadline and SetWriteDeadline, which allow setting - per-request read and write deadlines. For example: -

- -
-func RequestHandler(w ResponseWriter, r *Request) {
-  rc := http.NewResponseController(w)
-  rc.SetWriteDeadline(time.Time{}) // disable Server.WriteTimeout when sending a large response
-  io.Copy(w, bigData)
-}
-
- -

New ReverseProxy Rewrite hook

- -

- The httputil.ReverseProxy - forwarding proxy includes a new - Rewrite - hook function, superseding the - previous Director hook. -

- -

- The Rewrite hook accepts a - ProxyRequest parameter, - which includes both the inbound request received by the proxy and the outbound - request that it will send. - Unlike Director hooks, which only operate on the outbound request, - this permits Rewrite hooks to avoid certain scenarios where - a malicious inbound request may cause headers added by the hook - to be removed before forwarding. - See issue #50580. -

- -

- The ProxyRequest.SetURL - method routes the outbound request to a provided destination - and supersedes the NewSingleHostReverseProxy function. - Unlike NewSingleHostReverseProxy, SetURL - also sets the Host header of the outbound request. -

- -

- The - ProxyRequest.SetXForwarded - method sets the X-Forwarded-For, X-Forwarded-Host, - and X-Forwarded-Proto headers of the outbound request. - When using a Rewrite, these headers are not added by default. -

- -

- An example of a Rewrite hook using these features is: -

- -
-proxyHandler := &httputil.ReverseProxy{
-  Rewrite: func(r *httputil.ProxyRequest) {
-    r.SetURL(outboundURL) // Forward request to outboundURL.
-    r.SetXForwarded()     // Set X-Forwarded-* headers.
-    r.Out.Header.Set("X-Additional-Header", "header set by the proxy")
-  },
-}
-
- -

- ReverseProxy no longer adds a User-Agent header - to forwarded requests when the incoming request does not have one. -

- -

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. - There are also various performance improvements, not enumerated here. -

- -
archive/tar
-
-

- When the GODEBUG=tarinsecurepath=0 environment variable is set, - Reader.Next method - will now return the error ErrInsecurePath - for an entry with a file name that is an absolute path, - refers to a location outside the current directory, contains invalid - characters, or (on Windows) is a reserved name such as NUL. - A future version of Go may disable insecure paths by default. -

-
-
- -
archive/zip
-
-

- When the GODEBUG=zipinsecurepath=0 environment variable is set, - NewReader will now return the error - ErrInsecurePath - when opening an archive which contains any file name that is an absolute path, - refers to a location outside the current directory, contains invalid - characters, or (on Windows) is a reserved names such as NUL. - A future version of Go may disable insecure paths by default. -

-

- Reading from a directory file that contains file data will now return an error. - The zip specification does not permit directory files to contain file data, - so this change only affects reading from invalid archives. -

-
-
- -
bytes
-
-

- The new - CutPrefix and - CutSuffix functions - are like TrimPrefix - and TrimSuffix - but also report whether the string was trimmed. -

- -

- The new Clone function - allocates a copy of a byte slice. -

-
-
- -
context
-
-

- The new WithCancelCause function - provides a way to cancel a context with a given error. - That error can be retrieved by calling the new Cause function. -

-
-
- -
crypto/ecdsa
-
-

- When using supported curves, all operations are now implemented in constant time. - This led to an increase in CPU time between 5% and 30%, mostly affecting P-384 and P-521. -

- -

- The new PrivateKey.ECDH method - converts an ecdsa.PrivateKey to an ecdh.PrivateKey. -

-
-
- -
crypto/ed25519
-
-

- The PrivateKey.Sign method - and the - VerifyWithOptions function - now support signing pre-hashed messages with Ed25519ph, - indicated by an - Options.HashFunc - that returns - crypto.SHA512. - They also now support Ed25519ctx and Ed25519ph with context, - indicated by setting the new - Options.Context - field. -

-
-
- -
crypto/rsa
-
-

- The new field OAEPOptions.MGFHash - allows configuring the MGF1 hash separately for OAEP decryption. -

- -

- crypto/rsa now uses a new, safer, constant-time backend. This causes a CPU - runtime increase for decryption operations between approximately 15% - (RSA-2048 on amd64) and 45% (RSA-4096 on arm64), and more on 32-bit architectures. - Encryption operations are approximately 20x slower than before (but still 5-10x faster than decryption). - Performance is expected to improve in future releases. - Programs must not modify or manually generate the fields of - PrecomputedValues. -

-
-
- -
crypto/subtle
-
-

- The new function XORBytes - XORs two byte slices together. -

-
-
- -
crypto/tls
-
-

- Parsed certificates are now shared across all clients actively using that certificate. - The memory savings can be significant in programs that make many concurrent connections to a - server or collection of servers sharing any part of their certificate chains. -

- -

- For a handshake failure due to a certificate verification failure, - the TLS client and server now return an error of the new type - CertificateVerificationError, - which includes the presented certificates. -

-
-
- -
crypto/x509
-
-

- ParsePKCS8PrivateKey - and - MarshalPKCS8PrivateKey - now support keys of type *crypto/ecdh.PrivateKey. - ParsePKIXPublicKey - and - MarshalPKIXPublicKey - now support keys of type *crypto/ecdh.PublicKey. - Parsing NIST curve keys still returns values of type - *ecdsa.PublicKey and *ecdsa.PrivateKey. - Use their new ECDH methods to convert to the crypto/ecdh types. -

-

- The new SetFallbackRoots - function allows a program to define a set of fallback root certificates in case an - operating system verifier or standard platform root bundle is unavailable at runtime. - It will most commonly be used with a new package, golang.org/x/crypto/x509roots/fallback, - which will provide an up to date root bundle. -

-
-
- -
debug/elf
-
-

- Attempts to read from a SHT_NOBITS section using - Section.Data - or the reader returned by Section.Open - now return an error. -

-

- Additional R_LARCH_* constants are defined for use with LoongArch systems. -

-

- Additional R_PPC64_* constants are defined for use with PPC64 ELFv2 relocations. -

-

- The constant value for R_PPC64_SECTOFF_LO_DS is corrected, from 61 to 62. -

-
-
- -
debug/gosym
-
-

- Due to a change of Go's symbol naming conventions, tools that - process Go binaries should use Go 1.20's debug/gosym package to - transparently handle both old and new binaries. -

-
-
- -
debug/pe
-
-

- Additional IMAGE_FILE_MACHINE_RISCV* constants are defined for use with RISC-V systems. -

-
-
- -
encoding/binary
-
-

- The ReadVarint and - ReadUvarint - functions will now return io.ErrUnexpectedEOF after reading a partial value, - rather than io.EOF. -

-
-
- -
encoding/xml
-
-

- The new Encoder.Close method - can be used to check for unclosed elements when finished encoding. -

- -

- The decoder now rejects element and attribute names with more than one colon, - such as <a:b:c>, - as well as namespaces that resolve to an empty string, such as xmlns:a="". -

- -

- The decoder now rejects elements that use different namespace prefixes in the opening and closing tag, - even if those prefixes both denote the same namespace. -

-
-
- -
errors
-
-

- The new Join function returns an error wrapping a list of errors. -

-
-
- -
fmt
-
-

- The Errorf function supports multiple occurrences of - the %w format verb, returning an error that unwraps to the list of all arguments to %w. -

-

- The new FormatString function recovers the - formatting directive corresponding to a State, - which can be useful in Formatter. - implementations. -

-
-
- -
go/ast
-
-

- The new RangeStmt.Range field - records the position of the range keyword in a range statement. -

-

- The new File.FileStart - and File.FileEnd fields - record the position of the start and end of the entire source file. -

-
-
- -
go/token
-
-

- The new FileSet.RemoveFile method - removes a file from a FileSet. - Long-running programs can use this to release memory associated - with files they no longer need. -

-
-
- -
go/types
-
-

- The new Satisfies function reports - whether a type satisfies a constraint. - This change aligns with the new language semantics - that distinguish satisfying a constraint from implementing an interface. -

-
-
- -
html/template
-
-

- Go 1.20.3 and later - disallow actions in ECMAScript 6 template literals. - This behavior can be reverted by the GODEBUG=jstmpllitinterp=1 setting. -

-
-
- -
io
-
-

- The new OffsetWriter wraps an underlying - WriterAt - and provides Seek, Write, and WriteAt methods - that adjust their effective file offset position by a fixed amount. -

-
-
- -
io/fs
-
-

- The new error SkipAll - terminates a WalkDir - immediately but successfully. -

-
-
- -
math/big
-
-

- The math/big package's wide scope and - input-dependent timing make it ill-suited for implementing cryptography. - The cryptography packages in the standard library no longer call non-trivial - Int methods on attacker-controlled inputs. - In the future, the determination of whether a bug in math/big is - considered a security vulnerability will depend on its wider impact on the - standard library. -

-
-
- -
math/rand
-
-

- The math/rand package now automatically seeds - the global random number generator - (used by top-level functions like Float64 and Int) with a random value, - and the top-level Seed function has been deprecated. - Programs that need a reproducible sequence of random numbers - should prefer to allocate their own random source, using rand.New(rand.NewSource(seed)). -

-

- Programs that need the earlier consistent global seeding behavior can set - GODEBUG=randautoseed=0 in their environment. -

-

- The top-level Read function has been deprecated. - In almost all cases, crypto/rand.Read is more appropriate. -

-
-
- -
mime
-
-

- The ParseMediaType function now allows duplicate parameter names, - so long as the values of the names are the same. -

-
-
- -
mime/multipart
-
-

- Methods of the Reader type now wrap errors - returned by the underlying io.Reader. -

-

- In Go 1.19.8 and later, this package sets limits the size - of the MIME data it processes to protect against malicious inputs. - Reader.NextPart and Reader.NextRawPart limit the - number of headers in a part to 10000 and Reader.ReadForm limits - the total number of headers in all FileHeaders to 10000. - These limits may be adjusted with the GODEBUG=multipartmaxheaders - setting. - Reader.ReadForm further limits the number of parts in a form to 1000. - This limit may be adjusted with the GODEBUG=multipartmaxparts - setting. -

-
-
- -
net
-
-

- The LookupCNAME - function now consistently returns the contents - of a CNAME record when one exists. Previously on Unix systems and - when using the pure Go resolver, LookupCNAME would return an error - if a CNAME record referred to a name that with no A, - AAAA, or CNAME record. This change modifies - LookupCNAME to match the previous behavior on Windows, - allowing LookupCNAME to succeed whenever a - CNAME exists. -

- -

- Interface.Flags now includes the new flag FlagRunning, - indicating an operationally active interface. An interface which is administratively - configured but not active (for example, because the network cable is not connected) - will have FlagUp set but not FlagRunning. -

- -

- The new Dialer.ControlContext field contains a callback function - similar to the existing Dialer.Control hook, that additionally - accepts the dial context as a parameter. - Control is ignored when ControlContext is not nil. -

- -

- The Go DNS resolver recognizes the trust-ad resolver option. - When options trust-ad is set in resolv.conf, - the Go resolver will set the AD bit in DNS queries. The resolver does not - make use of the AD bit in responses. -

- -

- DNS resolution will detect changes to /etc/nsswitch.conf - and reload the file when it changes. Checks are made at most once every - five seconds, matching the previous handling of /etc/hosts - and /etc/resolv.conf. -

-
-
- -
net/http
-
-

- The ResponseWriter.WriteHeader function now supports sending - 1xx status codes. -

- -

- The new Server.DisableGeneralOptionsHandler configuration setting - allows disabling the default OPTIONS * handler. -

- -

- The new Transport.OnProxyConnectResponse hook is called - when a Transport receives an HTTP response from a proxy - for a CONNECT request. -

- -

- The HTTP server now accepts HEAD requests containing a body, - rather than rejecting them as invalid. -

- -

- HTTP/2 stream errors returned by net/http functions may be converted - to a golang.org/x/net/http2.StreamError using - errors.As. -

- -

- Leading and trailing spaces are trimmed from cookie names, - rather than being rejected as invalid. - For example, a cookie setting of "name =value" - is now accepted as setting the cookie "name". -

- -

- A Cookie with an empty Expires field is now considered valid. - Cookie.Valid only checks Expires when it is set. -

-
-
- -
net/netip
-
-

- The new IPv6LinkLocalAllRouters - and IPv6Loopback functions - are the net/netip equivalents of - net.IPv6loopback and - net.IPv6linklocalallrouters. -

-
-
- -
os
-
-

- On Windows, the name NUL is no longer treated as a special case in - Mkdir and - Stat. -

-

- On Windows, File.Stat - now uses the file handle to retrieve attributes when the file is a directory. - Previously it would use the path passed to - Open, which may no longer be the file - represented by the file handle if the file has been moved or replaced. - This change modifies Open to open directories without the - FILE_SHARE_DELETE access, which match the behavior of regular files. -

-

- On Windows, File.Seek now supports - seeking to the beginning of a directory. -

-
-
- -
os/exec
-
-

- The new Cmd fields - Cancel and - WaitDelay - specify the behavior of the Cmd when its associated - Context is canceled or its process exits with I/O pipes still - held open by a child process. -

-
-
- -
path/filepath
-
-

- The new error SkipAll - terminates a Walk - immediately but successfully. -

-

- The new IsLocal function reports whether a path is - lexically local to a directory. - For example, if IsLocal(p) is true, - then Open(p) will refer to a file that is lexically - within the subtree rooted at the current directory. -

-
-
- -
reflect
-
-

- The new Value.Comparable and - Value.Equal methods - can be used to compare two Values for equality. - Comparable reports whether Equal is a valid operation for a given Value receiver. -

- -

- The new Value.Grow method - extends a slice to guarantee space for another n elements. -

- -

- The new Value.SetZero method - sets a value to be the zero value for its type. -

- -

- Go 1.18 introduced Value.SetIterKey - and Value.SetIterValue methods. - These are optimizations: v.SetIterKey(it) is meant to be equivalent to v.Set(it.Key()). - The implementations incorrectly omitted a check for use of unexported fields that was present in the unoptimized forms. - Go 1.20 corrects these methods to include the unexported field check. -

-
-
- -
regexp
-
-

- Go 1.19.2 and Go 1.18.7 included a security fix to the regular expression parser, - making it reject very large expressions that would consume too much memory. - Because Go patch releases do not introduce new API, - the parser returned syntax.ErrInternalError in this case. - Go 1.20 adds a more specific error, syntax.ErrLarge, - which the parser now returns instead. -

-
-
- -
runtime/cgo
-
-

- Go 1.20 adds new Incomplete marker type. - Code generated by cgo will use cgo.Incomplete to mark an incomplete C type. -

-
-
- -
runtime/metrics
-
-

- Go 1.20 adds new supported metrics, - including the current GOMAXPROCS setting (/sched/gomaxprocs:threads), - the number of cgo calls executed (/cgo/go-to-c-calls:calls), - total mutex block time (/sync/mutex/wait/total:seconds), and various measures of time - spent in garbage collection. -

- -

- Time-based histogram metrics are now less precise, but take up much less memory. -

-
-
- -
runtime/pprof
-
-

- Mutex profile samples are now pre-scaled, fixing an issue where old mutex profile - samples would be scaled incorrectly if the sampling rate changed during execution. -

- -

- Profiles collected on Windows now include memory mapping information that fixes - symbolization issues for position-independent binaries. -

-
-
- -
runtime/trace
-
-

- The garbage collector's background sweeper now yields less frequently, - resulting in many fewer extraneous events in execution traces. -

-
-
- -
strings
-
-

- The new - CutPrefix and - CutSuffix functions - are like TrimPrefix - and TrimSuffix - but also report whether the string was trimmed. -

-
-
- -
sync
-
-

- The new Map methods Swap, - CompareAndSwap, and - CompareAndDelete - allow existing map entries to be updated atomically. -

-
-
- -
syscall
-
-

- On FreeBSD, compatibility shims needed for FreeBSD 11 and earlier have been removed. -

-

- On Linux, additional CLONE_* constants - are defined for use with the SysProcAttr.Cloneflags field. -

-

- On Linux, the new SysProcAttr.CgroupFD - and SysProcAttr.UseCgroupFD fields - provide a way to place a child process into a specific cgroup. -

-
-
- -
testing
-
-

- The new method B.Elapsed - reports the current elapsed time of the benchmark, which may be useful for - calculating rates to report with ReportMetric. -

- -

- Calling T.Run - from a function passed - to T.Cleanup - was never well-defined, and will now panic. -

-
-
- -
time
-
-

- The new time layout constants DateTime, - DateOnly, and - TimeOnly - provide names for three of the most common layout strings used in a survey of public Go source code. -

- -

- The new Time.Compare method - compares two times. -

- -

- Parse - now ignores sub-nanosecond precision in its input, - instead of reporting those digits as an error. -

- -

- The Time.MarshalJSON method - is now more strict about adherence to RFC 3339. -

-
-
- -
unicode/utf16
-
-

- The new AppendRune - function appends the UTF-16 encoding of a given rune to a uint16 slice, - analogous to utf8.AppendRune. -

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/_content/doc/go1.21.html b/_content/doc/go1.21.html deleted file mode 100644 index b190c7134f..0000000000 --- a/_content/doc/go1.21.html +++ /dev/null @@ -1,1357 +0,0 @@ - - - - - - -

Introduction to Go 1.21

- -

- The latest Go release, version 1.21, arrives six months after Go 1.20. - 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; - in fact, Go 1.21 improves upon that promise. - We expect almost all Go programs to continue to compile and run as before. -

- -

- Go 1.21 introduces a small change to the numbering of releases. - In the past, we used Go 1.N to refer to both the overall Go language version and release family - as well as the first release in that family. - Starting in Go 1.21, the first release is now Go 1.N.0. - Today we are releasing both the Go 1.21 language and its initial implementation, the Go 1.21.0 release. - These notes refer to “Go 1.21”; tools like go version will report “go1.21.0” - (until you upgrade to Go 1.21.1). - See “Go versions” in the “Go Toolchains” documentation for details - about the new version numbering. -

- -

Changes to the language

- -

- Go 1.21 adds three new built-ins to the language. - -

    -
  • - The new functions min and max compute the - smallest (or largest, for max) value of a fixed number - of given arguments. - See the language spec for - details. -
  • -
  • - The new function clear deletes all elements from a - map or zeroes all elements of a slice. - See the language spec for - details. -
  • -
-

- -

- Package initialization order is now specified more precisely. The - new algorithm is: -

    -
  • - Sort all packages by import path. -
  • -
  • Repeat until the list of packages is empty: -
      -
    • - Find the first package in the list for which all imports are - already initialized. -
    • -
    • - Initialize that package and remove it from the list. -
    • -
    -
  • -
- This may change the behavior of some programs that rely on a - specific initialization ordering that was not expressed by explicit - imports. The behavior of such programs was not well defined by the - spec in past releases. The new rule provides an unambiguous definition. -

- -

- Multiple improvements that increase the power and precision of type inference have been made. -

-
    -
  • - A (possibly partially instantiated generic) function may now be called with arguments that are - themselves (possibly partially instantiated) generic functions. - The compiler will attempt to infer the missing type arguments of the callee (as before) and, - for each argument that is a generic function that is not fully instantiated, - its missing type arguments (new). - Typical use cases are calls to generic functions operating on containers - (such as slices.IndexFunc) where a function argument - may also be generic, and where the type argument of the called function and its arguments - are inferred from the container type. - More generally, a generic function may now be used without explicit instantiation when - it is assigned to a variable or returned as a result value if the type arguments can - be inferred from the assignment. -
  • -
  • - Type inference now also considers methods when a value is assigned to an interface: - type arguments for type parameters used in method signatures may be inferred from - the corresponding parameter types of matching methods. -
  • -
  • - Similarly, since a type argument must implement all the methods of its corresponding constraint, - the methods of the type argument and constraint are matched which may lead to the inference of - additional type arguments. -
  • -
  • - If multiple untyped constant arguments of different kinds (such as an untyped int and - an untyped floating-point constant) are passed to parameters with the same (not otherwise - specified) type parameter type, instead of an error, now type inference determines the - type using the same approach as an operator with untyped constant operands. - This change brings the types inferred from untyped constant arguments in line with the - types of constant expressions. -
  • -
  • - Type inference is now precise when matching corresponding types in assignments: - component types (such as the elements of slices, or the parameter types in function signatures) - must be identical (given suitable type arguments) to match, otherwise inference fails. - This change produces more accurate error messages: - where in the past type inference may have succeeded incorrectly and lead to an invalid assignment, - the compiler now reports an inference error if two types can't possibly match. -
  • -
- -

- More generally, the description of - type inference - in the language spec has been clarified. - Together, all these changes make type inference more powerful and inference failures less surprising. -

- - -

- Go 1.21 includes a preview of a language change we are considering for a future version of Go: - making for loop variables per-iteration instead of per-loop, to avoid accidental sharing bugs. - For details about how to try that language change, see the LoopvarExperiment wiki page. -

- - -

- Go 1.21 now defines that if a goroutine is panicking and recover was called directly by a deferred - function, the return value of recover is guaranteed not to be nil. To ensure this, calling panic - with a nil interface value (or an untyped nil) causes a run-time panic of type - *runtime.PanicNilError. -

-

- To support programs written for older versions of Go, nil panics can be re-enabled by setting - GODEBUG=panicnil=1. - This setting is enabled automatically when compiling a program whose main package - is in a module that declares go 1.20 or earlier. -

- -

Tools

-

- Go 1.21 adds improved support for backwards compatibility and forwards compatibility - in the Go toolchain. -

- -

- To improve backwards compatibility, Go 1.21 formalizes - Go's use of the GODEBUG environment variable to control - the default behavior for changes that are non-breaking according to the - compatibility policy - but nonetheless may cause existing programs to break. - (For example, programs that depend on buggy behavior may break - when a bug is fixed, but bug fixes are not considered breaking changes.) - When Go must make this kind of behavior change, - it now chooses between the old and new behavior based on the - go line in the workspace's go.work file - or else the main module's go.mod file. - Upgrading to a new Go toolchain but leaving the go line - set to its original (older) Go version preserves the behavior of the older - toolchain. - With this compatibility support, the latest Go toolchain should always - be the best, most secure, implementation of an older version of Go. - See “Go, Backwards Compatibility, and GODEBUG” for details. -

- -

- To improve forwards compatibility, Go 1.21 now reads the go line - in a go.work or go.mod file as a strict - minimum requirement: go 1.21.0 means - that the workspace or module cannot be used with Go 1.20 or with Go 1.21rc1. - This allows projects that depend on fixes made in later versions of Go - to ensure that they are not used with earlier versions. - It also gives better error reporting for projects that make use of new Go features: - when the problem is that a newer Go version is needed, - that problem is reported clearly, instead of attempting to build the code - and printing errors about unresolved imports or syntax errors. -

- -

- To make these new stricter version requirements easier to manage, - the go command can now invoke not just the toolchain - bundled in its own release but also other Go toolchain versions found in the PATH - or downloaded on demand. - If a go.mod or go.work go line - declares a minimum requirement on a newer version of Go, the go - command will find and run that version automatically. - The new toolchain directive sets a suggested minimum toolchain to use, - which may be newer than the strict go minimum. - See “Go Toolchains” for details. -

- -

Go command

- -

- The -pgo build flag now defaults to -pgo=auto, - and the restriction of specifying a single main package on the command - line is now removed. If a file named default.pgo is present - in the main package's directory, the go command will use - it to enable profile-guided optimization for building the corresponding - program. -

- -

- The -C dir flag must now be the first - flag on the command-line when used. -

- -

- The new go test option - -fullpath prints full path names in test log messages, - rather than just base names. -

- -

- The go test -c flag now - supports writing test binaries for multiple packages, each to - pkg.test where pkg is the package name. - It is an error if more than one test package being compiled has a given package name. -

- -

- The go test -o flag now - accepts a directory argument, in which case test binaries are written to that - directory instead of the current directory. -

- -

Cgo

- -

- In files that import "C", the Go toolchain now - correctly reports errors for attempts to declare Go methods on C types. -

- -

Runtime

- -

- When printing very deep stacks, the runtime now prints the first 50 - (innermost) frames followed by the bottom 50 (outermost) frames, - rather than just printing the first 100 frames. This makes it easier - to see how deeply recursive stacks started, and is especially - valuable for debugging stack overflows. -

- -

- On Linux platforms that support transparent huge pages, the Go runtime - now manages which parts of the heap may be backed by huge pages more - explicitly. This leads to better utilization of memory: small heaps - should see less memory used (up to 50% in pathological cases) while - large heaps should see fewer broken huge pages for dense parts of the - heap, improving CPU usage and latency by up to 1%. -

- -

- As a result of runtime-internal garbage collection tuning, - applications may see up to a 40% reduction in application tail latency - and a small decrease in memory use. Some applications may also observe - a small loss in throughput. - - The memory use decrease should be proportional to the loss in - throughput, such that the previous release's throughput/memory - tradeoff may be recovered (with little change to latency) by - increasing GOGC and/or GOMEMLIMIT slightly. -

- -

- Calls from C to Go on threads created in C require some setup to prepare for - Go execution. On Unix platforms, this setup is now preserved across multiple - calls from the same thread. This significantly reduces the overhead of - subsequent C to Go calls from ~1-3 microseconds per call to ~100-200 - nanoseconds per call. -

- -

Compiler

- -

- Profile-guide optimization (PGO), added as a preview in Go 1.20, is now ready - for general use. PGO enables additional optimizations on code identified as - hot by profiles of production workloads. As mentioned in the - Go command section, PGO is enabled by default for - binaries that contain a default.pgo profile in the main - package directory. Performance improvements vary depending on application - behavior, with most programs from a representative set of Go programs seeing - between 2 and 7% improvement from enabling PGO. See the - PGO user guide for detailed documentation. -

- - -

- PGO builds can now devirtualize some interface method calls, adding a - concrete call to the most common callee. This enables further optimization, - such as inlining the callee. -

- - -

- Go 1.21 improves build speed by up to 6%, largely thanks to building the - compiler itself with PGO. -

- -

Assembler

- - -

- On amd64, frameless nosplit assembly functions are no longer automatically marked as NOFRAME. - Instead, the NOFRAME attribute must be explicitly specified if desired, - which is already the behavior on other architectures supporting frame pointers. - With this, the runtime now maintains the frame pointers for stack transitions. -

- - -

- The verifier that checks for incorrect uses of R15 when dynamic linking on amd64 has been improved. -

- -

Linker

- -

- On windows/amd64, the linker (with help from the compiler) now emits - SEH unwinding data by default, which improves the integration - of Go applications with Windows debuggers and other tools. -

- - -

- In Go 1.21 the linker (with help from the compiler) is now capable of - deleting dead (unreferenced) global map variables, if the number of - entries in the variable initializer is sufficiently large, and if the - initializer expressions are side-effect free. -

- -

Core library

- -

New log/slog package

- -

- The new log/slog package provides structured logging with levels. - Structured logging emits key-value pairs - to enable fast, accurate processing of large amounts of log data. - The package supports integration with popular log analysis tools and services. -

- -

New testing/slogtest package

- -

- The new testing/slogtest package can help - to validate slog.Handler implementations. -

- -

New slices package

- -

- - - - - - The new slices package provides many common - operations on slices, using generic functions that work with slices - of any element type. -

- -

New maps package

- -

- The new maps package provides several - common operations on maps, using generic functions that work with - maps of any key or element type. -

- -

New cmp package

- -

- The new cmp package defines the type - constraint Ordered and - two new generic functions - Less - and Compare that are - useful with ordered - types. -

- -

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. - There are also various performance improvements, not enumerated here. -

- -
archive/tar
-
-

- The implementation of the - io/fs.FileInfo - interface returned by - Header.FileInfo - now implements a String method that calls - io/fs.FormatFileInfo. -

-
-
- -
archive/zip
-
-

- The implementation of the - io/fs.FileInfo - interface returned by - FileHeader.FileInfo - now implements a String method that calls - io/fs.FormatFileInfo. -

- -

- The implementation of the - io/fs.DirEntry - interface returned by the - io/fs.ReadDirFile.ReadDir - method of the - io/fs.File - returned by - Reader.Open - now implements a String method that calls - io/fs.FormatDirEntry. -

-
-
- -
bytes
-
-

- The Buffer type - has two new methods: - Available - and AvailableBuffer. - These may be used along with the - Write - method to append directly to the Buffer. -

-
-
- -
context
-
-

- The new WithoutCancel - function returns a copy of a context that is not canceled when the original - context is canceled. -

-

- The new WithDeadlineCause - and WithTimeoutCause - functions provide a way to set a context cancellation cause when a deadline or - timer expires. The cause may be retrieved with the - Cause function. -

-

- The new AfterFunc - function registers a function to run after a context has been cancelled. -

- -

- An optimization means that the results of calling - Background - and TODO and - converting them to a shared type can be considered equal. - In previous releases they were always different. Comparing - Context values - for equality has never been well-defined, so this is not - considered to be an incompatible change. -

-
-
- - -
crypto/ecdsa
-
-

- PublicKey.Equal and - PrivateKey.Equal - now execute in constant time. -

-
-
- -
crypto/elliptic
-
-

- All of the Curve methods have been deprecated, along with GenerateKey, Marshal, and Unmarshal. For ECDH operations, the new crypto/ecdh package should be used instead. For lower-level operations, use third-party modules such as filippo.io/nistec. -

-
-
- -
crypto/rand
-
-

- The crypto/rand package now uses the getrandom system call on NetBSD 10.0 and later. -

-
-
- -
crypto/rsa
-
-

- The performance of private RSA operations (decryption and signing) is now better than Go 1.19 for GOARCH=amd64 and GOARCH=arm64. It had regressed in Go 1.20. -

-

- Due to the addition of private fields to PrecomputedValues, PrivateKey.Precompute must be called for optimal performance even if deserializing (for example from JSON) a previously-precomputed private key. -

-

- PublicKey.Equal and - PrivateKey.Equal - now execute in constant time. -

-

- The GenerateMultiPrimeKey function and the PrecomputedValues.CRTValues field have been deprecated. PrecomputedValues.CRTValues will still be populated when PrivateKey.Precompute is called, but the values will not be used during decryption operations. -

-
-
- - - -
crypto/sha256
-
-

- SHA-224 and SHA-256 operations now use native instructions when available when GOARCH=amd64, providing a performance improvement on the order of 3-4x. -

-
-
- - - - -
crypto/tls
-
-

- Servers now skip verifying client certificates (including not running - Config.VerifyPeerCertificate) - for resumed connections, besides checking the expiration time. This makes - session tickets larger when client certificates are in use. Clients were - already skipping verification on resumption, but now check the expiration - time even if Config.InsecureSkipVerify - is set. -

- -

- Applications can now control the content of session tickets. -

-

- -

- To reduce the potential for session tickets to be used as a tracking - mechanism across connections, the server now issues new tickets on every - resumption (if they are supported and not disabled) and tickets don't bear - an identifier for the key that encrypted them anymore. If passing a large - number of keys to Conn.SetSessionTicketKeys, - this might lead to a noticeable performance cost. -

- -

- Both clients and servers now implement the Extended Master Secret extension (RFC 7627). - The deprecation of ConnectionState.TLSUnique - has been reverted, and is now set for resumed connections that support Extended Master Secret. -

- -

- The new QUICConn type - provides support for QUIC implementations, including 0-RTT support. Note - that this is not itself a QUIC implementation, and 0-RTT is still not - supported in TLS. -

- -

- The new VersionName function - returns the name for a TLS version number. -

- -

- The TLS alert codes sent from the server for client authentication failures have - been improved. Previously, these failures always resulted in a "bad certificate" alert. - Now, certain failures will result in more appropriate alert codes, - as defined by RFC 5246 and RFC 8446: -

    -
  • - For TLS 1.3 connections, if the server is configured to require client authentication using - RequireAnyClientCert or - RequireAndVerifyClientCert, - and the client does not provide any certificate, the server will now return the "certificate required" alert. -
  • -
  • - If the client provides a certificate that is not signed by the set of trusted certificate authorities - configured on the server, the server will return the "unknown certificate authority" alert. -
  • -
  • - If the client provides a certificate that is either expired or not yet valid, - the server will return the "expired certificate" alert. -
  • -
  • - In all other scenarios related to client authentication failures, the server still returns "bad certificate". -
  • -
-

-
-
- -
crypto/x509
-
-

- RevocationList.RevokedCertificates has been deprecated and replaced with the new RevokedCertificateEntries field, which is a slice of RevocationListEntry. RevocationListEntry contains all of the fields in pkix.RevokedCertificate, as well as the revocation reason code. -

- -

- Name constraints are now correctly enforced on non-leaf certificates, and - not on the certificates where they are expressed. -

-
-
- -
debug/elf
-
-

- The new - File.DynValue - method may be used to retrieve the numeric values listed with a - given dynamic tag. -

- -

- The constant flags permitted in a DT_FLAGS_1 - dynamic tag are now defined with type - DynFlag1. These - tags have names starting with DF_1. -

- -

- The package now defines the constant - COMPRESS_ZSTD. -

- -

- The package now defines the constant - R_PPC64_REL24_P9NOTOC. -

-
-
- -
debug/pe
-
-

- Attempts to read from a section containing uninitialized data - using - Section.Data - or the reader returned by Section.Open - now return an error. -

-
-
- -
embed
-
-

- The io/fs.File - returned by - FS.Open now - has a ReadAt method that - implements io.ReaderAt. -

- -

- Calling FS.Open.Stat - will return a type that now implements a String - method that calls - io/fs.FormatFileInfo. -

-
-
- -
encoding/binary
-
-

- The new - NativeEndian - variable may be used to convert between byte slices and integers - using the current machine's native endianness. -

-
-
- -
errors
-
-

- The new - ErrUnsupported - error provides a standardized way to indicate that a requested - operation may not be performed because it is unsupported. - For example, a call to - os.Link when using a - file system that does not support hard links. -

-
-
- -
flag
-
-

- The new BoolFunc - function and - FlagSet.BoolFunc - method define a flag that does not require an argument and calls - a function when the flag is used. This is similar to - Func but for a - boolean flag. -

- -

- A flag definition - (via Bool, - BoolVar, - Int, - IntVar, etc.) - will panic if Set has - already been called on a flag with the same name. This change is - intended to detect cases where changes in - initialization order cause flag operations to occur in a - different order than expected. In many cases the fix to this - problem is to introduce a explicit package dependence to - correctly order the definition before any - Set operations. -

-
-
- -
go/ast
-
-

- The new IsGenerated predicate - reports whether a file syntax tree contains the - special comment - that conventionally indicates that the file was generated by a tool. -

-
- -
-

- The new - File.GoVersion - field records the minimum Go version required by - any //go:build or // +build - directives. -

-
-
- -
go/build
-
-

- The package now parses build directives (comments that start - with //go:) in file headers (before - the package declaration). These directives are - available in the new - Package fields - Directives, - TestDirectives, - and - XTestDirectives. -

-
-
- -
go/build/constraint
-
-

- The new - GoVersion - function returns the minimum Go version implied by a build - expression. -

-
-
- -
go/token
-
-

- The new File.Lines method - returns the file's line-number table in the same form as accepted by - File.SetLines. -

-
-
- -
go/types
-
-

- The new Package.GoVersion - method returns the Go language version used to check the package. -

-
-
- -
hash/maphash
-
-

- The hash/maphash package now has a pure Go implementation, selectable with the purego build tag. -

-
-
- -
html/template
-
-

- The new error - ErrJSTemplate - is returned when an action appears in a JavaScript template - literal. Previously an unexported error was returned. -

-
-
- -
io/fs
-
-

- The new - FormatFileInfo - function returns a formatted version of a - FileInfo. - The new - FormatDirEntry - function returns a formatted version of a - DirEntry. - The implementation of - DirEntry - returned by - ReadDir now - implements a String method that calls - FormatDirEntry, - and the same is true for - the DirEntry - value passed to - WalkDirFunc. -

-
-
- - - - - -
math/big
-
-

- The new Int.Float64 - method returns the nearest floating-point value to a - multi-precision integer, along with an indication of any - rounding that occurred. -

-
-
- -
net
-
-

- - - On Linux, the net package can now use - Multipath TCP when the kernel supports it. It is not used by - default. To use Multipath TCP when available on a client, call - the - Dialer.SetMultipathTCP - method before calling the - Dialer.Dial or - Dialer.DialContext - methods. To use Multipath TCP when available on a server, call - the - ListenConfig.SetMultipathTCP - method before calling the - ListenConfig.Listen - method. Specify the network as "tcp" or - "tcp4" or "tcp6" as usual. If - Multipath TCP is not supported by the kernel or the remote host, - the connection will silently fall back to TCP. To test whether a - particular connection is using Multipath TCP, use the - TCPConn.MultipathTCP - method. -

-

- In a future Go release we may enable Multipath TCP by default on - systems that support it. -

-
-
- -
net/http
-
-

- The new ResponseController.EnableFullDuplex - method allows server handlers to concurrently read from an HTTP/1 - request body while writing the response. Normally, the HTTP/1 server - automatically consumes any remaining request body before starting to - write the response, to avoid deadlocking clients which attempt to - write a complete request before reading the response. The - EnableFullDuplex method disables this behavior. -

- -

- The new ErrSchemeMismatch error is returned by Client and Transport when the server responds to an HTTPS request with an HTTP response. -

- -

- The net/http package now supports - errors.ErrUnsupported, - in that the expression - errors.Is(http.ErrNotSupported, errors.ErrUnsupported) - will return true. -

-
-
- -
os
-
-

- Programs may now pass an empty time.Time value to - the Chtimes function - to leave either the access time or the modification time unchanged. -

- -

- On Windows the - File.Chdir method - now changes the current directory to the file, rather than - always returning an error. -

- -

- On Unix systems, if a non-blocking descriptor is passed - to NewFile, calling - the File.Fd method - will now return a non-blocking descriptor. Previously the - descriptor was converted to blocking mode. -

- -

- On Windows calling - Truncate on a - non-existent file used to create an empty file. It now returns - an error indicating that the file does not exist. -

- -

- On Windows calling - TempDir now uses - GetTempPath2W when available, instead of GetTempPathW. The - new behavior is a security hardening measure that prevents - temporary files created by processes running as SYSTEM to - be accessed by non-SYSTEM processes. -

- -

- On Windows the os package now supports working with files whose - names, stored as UTF-16, can't be represented as valid UTF-8. -

- -

- On Windows Lstat now resolves - symbolic links for paths ending with a path separator, consistent with its - behavior on POSIX platforms. -

- -

- The implementation of the - io/fs.DirEntry - interface returned by the - ReadDir function and - the File.ReadDir - method now implements a String method that calls - io/fs.FormatDirEntry. -

- -

- The implementation of the - io/fs.FS interface returned by - the DirFS function now implements - the io/fs.ReadFileFS and - the io/fs.ReadDirFS - interfaces. -

-
-
- -
path/filepath
-
-

- The implementation of the - io/fs.DirEntry - interface passed to the function argument of - WalkDir - now implements a String method that calls - io/fs.FormatDirEntry. -

-
-
- - - -
reflect
-
-

- In Go 1.21, ValueOf - no longer forces its argument to be allocated on the heap, allowing - a Value's content to be allocated on the stack. Most - operations on a Value also allow the underlying value - to be stack allocated. -

- -

- The new Value - method Value.Clear - clears the contents of a map or zeros the contents of a slice. - This corresponds to the new clear built-in - added to the language. -

- -

- The SliceHeader - and StringHeader - types are now deprecated. In new code - prefer unsafe.Slice, - unsafe.SliceData, - unsafe.String, - or unsafe.StringData. -

-
-
- -
regexp
-
-

- Regexp now defines - MarshalText - and UnmarshalText - methods. These implement - encoding.TextMarshaler - and - encoding.TextUnmarshaler - and will be used by packages such as - encoding/json. -

-
-
- -
runtime
-
-

- Textual stack traces produced by Go programs, such as those - produced when crashing, calling runtime.Stack, or - collecting a goroutine profile with debug=2, now - include the IDs of the goroutines that created each goroutine in - the stack trace. -

- -

- Crashing Go applications can now opt-in to Windows Error Reporting (WER) by setting the environment variable - GOTRACEBACK=wer or calling debug.SetTraceback("wer") - before the crash. Other than enabling WER, the runtime will behave as with GOTRACEBACK=crash. - On non-Windows systems, GOTRACEBACK=wer is ignored. -

- -

- GODEBUG=cgocheck=2, a thorough checker of cgo pointer passing rules, - is no longer available as a debug option. - Instead, it is available as an experiment using GOEXPERIMENT=cgocheck2. - In particular this means that this mode has to be selected at build time instead of startup time. -

- -

- GODEBUG=cgocheck=1 is still available (and is still the default). -

- -

- A new type Pinner has been added to the runtime - package. Pinners may be used to "pin" Go memory - such that it may be used more freely by non-Go code. For instance, - passing Go values that reference pinned Go memory to C code is - now allowed. Previously, passing any such nested reference was - disallowed by the - cgo pointer passing rules. - - See the docs for more details. -

- - -
-
- -
runtime/metrics
-
-

- A few previously-internal GC metrics, such as live heap size, are - now available. - - GOGC and GOMEMLIMIT are also now - available as metrics. -

-
-
- -
runtime/trace
-
-

- Collecting traces on amd64 and arm64 now incurs a substantially - smaller CPU cost: up to a 10x improvement over the previous release. -

- -

- Traces now contain explicit stop-the-world events for every reason - the Go runtime might stop-the-world, not just garbage collection. -

-
-
- -
sync
-
-

- The new OnceFunc, - OnceValue, and - OnceValues - functions capture a common use of Once to - lazily initialize a value on first use. -

-
-
- -
syscall
-
-

- On Windows the - Fchdir function - now changes the current directory to its argument, rather than - always returning an error. -

- -

- On FreeBSD - SysProcAttr - has a new field Jail that may be used to put the - newly created process in a jailed environment. -

- -

- On Windows the syscall package now supports working with files whose - names, stored as UTF-16, can't be represented as valid UTF-8. - The UTF16ToString - and UTF16FromString - functions now convert between UTF-16 data and - WTF-8 strings. - This is backward compatible as WTF-8 is a superset of the UTF-8 - format that was used in earlier releases. -

- -

- Several error values match the new - errors.ErrUnsupported, - such that errors.Is(err, errors.ErrUnsupported) - returns true. -

    -
  • ENOSYS
  • -
  • ENOTSUP
  • -
  • EOPNOTSUPP
  • -
  • EPLAN9 (Plan 9 only)
  • -
  • ERROR_CALL_NOT_IMPLEMENTED (Windows only)
  • -
  • ERROR_NOT_SUPPORTED (Windows only)
  • -
  • EWINDOWS (Windows only)
  • -
-

-
-
- -
testing
-
-

- The new -test.fullpath option will print full path - names in test log messages, rather than just base names. -

- -

- The new Testing function reports whether the program is a test created by go test. -

-
-
- -
testing/fstest
-
-

- Calling Open.Stat - will return a type that now implements a String - method that calls - io/fs.FormatFileInfo. -

-
-
- -
unicode
-
-

- The unicode package and - associated support throughout the system has been upgraded to - Unicode 15.0.0. -

-
-
- -

Ports

- -

Darwin

- -

- As announced in the Go 1.20 release notes, - Go 1.21 requires macOS 10.15 Catalina or later; - support for previous versions has been discontinued. -

- -

Windows

- -

- As announced in the Go 1.20 release notes, - Go 1.21 requires at least Windows 10 or Windows Server 2016; - support for previous versions has been discontinued. -

- - -

- -

- -

WebAssembly

- -

- The new go:wasmimport directive can now be used in Go programs - to import functions from the WebAssembly host. -

- - -

- The Go scheduler now interacts much more efficiently with the - JavaScript event loop, especially in applications that block - frequently on asynchronous events. -

- - -

WebAssembly System Interface

- -

- Go 1.21 adds an experimental port to the - WebAssembly System Interface (WASI), Preview 1 - (GOOS=wasip1, GOARCH=wasm). -

- -

- As a result of the addition of the new GOOS value - "wasip1", Go files named *_wasip1.go - will now be ignored - by Go tools except when that GOOS value is being - used. - If you have existing filenames matching that pattern, you will - need to rename them. -

- -

ppc64/ppc64le

- -

- On Linux, GOPPC64=power10 now generates PC-relative instructions, prefixed - instructions, and other new Power10 instructions. On AIX, GOPPC64=power10 - generates Power10 instructions, but does not generate PC-relative instructions. -

- -

- When building position-independent binaries for GOPPC64=power10 - GOOS=linux GOARCH=ppc64le, users can expect reduced binary - sizes in most cases, in some cases 3.5%. Position-independent binaries are built for - ppc64le with the following -buildmode values: - c-archive, c-shared, shared, pie, plugin. -

- -

loong64

- -

- The linux/loong64 port now supports -buildmode=c-archive, - -buildmode=c-shared and -buildmode=pie. -

- - - - - - - - - - - - - - - - - - diff --git a/_content/doc/go1.3.html b/_content/doc/go1.3.html deleted file mode 100644 index 507227ebf5..0000000000 --- a/_content/doc/go1.3.html +++ /dev/null @@ -1,606 +0,0 @@ - - -

Introduction to Go 1.3

- -

-The latest Go release, version 1.3, arrives six months after 1.2, -and contains no language changes. -It focuses primarily on implementation work, providing -precise garbage collection, -a major refactoring of the compiler toolchain that results in -faster builds, especially for large projects, -significant performance improvements across the board, -and support for DragonFly BSD, Solaris, Plan 9 and Google's Native Client architecture (NaCl). -It also has an important refinement to the memory model regarding synchronization. -As always, Go 1.3 keeps the promise -of compatibility, -and almost everything -will continue to compile and run without change when moved to 1.3. -

- -

Changes to the supported operating systems and architectures

- -

Removal of support for Windows 2000

- -

-Microsoft stopped supporting Windows 2000 in 2010. -Since it has implementation difficulties -regarding exception handling (signals in Unix terminology), -as of Go 1.3 it is not supported by Go either. -

- -

Support for DragonFly BSD

- -

-Go 1.3 now includes experimental support for DragonFly BSD on the amd64 (64-bit x86) and 386 (32-bit x86) architectures. -It uses DragonFly BSD 3.6 or above. -

- -

Support for FreeBSD

- -

-It was not announced at the time, but since the release of Go 1.2, support for Go on FreeBSD -requires FreeBSD 8 or above. -

- -

-As of Go 1.3, support for Go on FreeBSD requires that the kernel be compiled with the -COMPAT_FREEBSD32 flag configured. -

- -

-In concert with the switch to EABI syscalls for ARM platforms, Go 1.3 will run only on FreeBSD 10. -The x86 platforms, 386 and amd64, are unaffected. -

- -

Support for Native Client

- -

-Support for the Native Client virtual machine architecture has returned to Go with the 1.3 release. -It runs on the 32-bit Intel architectures (GOARCH=386) and also on 64-bit Intel, but using -32-bit pointers (GOARCH=amd64p32). -There is not yet support for Native Client on ARM. -Note that this is Native Client (NaCl), not Portable Native Client (PNaCl). -Details about Native Client are here; -how to set up the Go version is described here. -

- -

Support for NetBSD

- -

-As of Go 1.3, support for Go on NetBSD requires NetBSD 6.0 or above. -

- -

Support for OpenBSD

- -

-As of Go 1.3, support for Go on OpenBSD requires OpenBSD 5.5 or above. -

- -

Support for Plan 9

- -

-Go 1.3 now includes experimental support for Plan 9 on the 386 (32-bit x86) architecture. -It requires the Tsemacquire syscall, which has been in Plan 9 since June, 2012. -

- -

Support for Solaris

- -

-Go 1.3 now includes experimental support for Solaris on the amd64 (64-bit x86) architecture. -It requires illumos, Solaris 11 or above. -

- -

Changes to the memory model

- -

-The Go 1.3 memory model adds a new rule -concerning sending and receiving on buffered channels, -to make explicit that a buffered channel can be used as a simple -semaphore, using a send into the -channel to acquire and a receive from the channel to release. -This is not a language change, just a clarification about an expected property of communication. -

- -

Changes to the implementations and tools

- -

Stack

- -

-Go 1.3 has changed the implementation of goroutine stacks away from the old, -"segmented" model to a contiguous model. -When a goroutine needs more stack -than is available, its stack is transferred to a larger single block of memory. -The overhead of this transfer operation amortizes well and eliminates the old "hot spot" -problem when a calculation repeatedly steps across a segment boundary. -Details including performance numbers are in this -design document. -

- -

Changes to the garbage collector

- -

-For a while now, the garbage collector has been precise when examining -values in the heap; the Go 1.3 release adds equivalent precision to values on the stack. -This means that a non-pointer Go value such as an integer will never be mistaken for a -pointer and prevent unused memory from being reclaimed. -

- -

-Starting with Go 1.3, the runtime assumes that values with pointer type -contain pointers and other values do not. -This assumption is fundamental to the precise behavior of both stack expansion -and garbage collection. -Programs that use package unsafe -to store integers in pointer-typed values are illegal and will crash if the runtime detects the behavior. -Programs that use package unsafe to store pointers -in integer-typed values are also illegal but more difficult to diagnose during execution. -Because the pointers are hidden from the runtime, a stack expansion or garbage collection -may reclaim the memory they point at, creating -dangling pointers. -

- -

-Updating: Code that uses unsafe.Pointer to convert -an integer-typed value held in memory into a pointer is illegal and must be rewritten. -Such code can be identified by go vet. -

- -

Map iteration

- -

-Iterations over small maps no longer happen in a consistent order. -Go 1 defines that “The iteration order over maps -is not specified and is not guaranteed to be the same from one iteration to the next.” -To keep code from depending on map iteration order, -Go 1.0 started each map iteration at a random index in the map. -A new map implementation introduced in Go 1.1 neglected to randomize -iteration for maps with eight or fewer entries, although the iteration order -can still vary from system to system. -This has allowed people to write Go 1.1 and Go 1.2 programs that -depend on small map iteration order and therefore only work reliably on certain systems. -Go 1.3 reintroduces random iteration for small maps in order to flush out these bugs. -

- -

-Updating: If code assumes a fixed iteration order for small maps, -it will break and must be rewritten not to make that assumption. -Because only small maps are affected, the problem arises most often in tests. -

- - - -

-As part of the general overhaul to -the Go linker, the compilers and linkers have been refactored. -The linker is still a C program, but now the instruction selection phase that -was part of the linker has been moved to the compiler through the creation of a new -library called liblink. -By doing instruction selection only once, when the package is first compiled, -this can speed up compilation of large projects significantly. -

- -

-Updating: Although this is a major internal change, it should have no -effect on programs. -

- -

Status of gccgo

- -

-GCC release 4.9 will contain the Go 1.2 (not 1.3) version of gccgo. -The release schedules for the GCC and Go projects do not coincide, -which means that 1.3 will be available in the development branch but -that the next GCC release, 4.10, will likely have the Go 1.4 version of gccgo. -

- -

Changes to the go command

- -

-The cmd/go command has several new -features. -The go run and -go test subcommands -support a new -exec option to specify an alternate -way to run the resulting binary. -Its immediate purpose is to support NaCl. -

- -

-The test coverage support of the go test -subcommand now automatically sets the coverage mode to -atomic -when the race detector is enabled, to eliminate false reports about unsafe -access to coverage counters. -

- -

-The go test subcommand -now always builds the package, even if it has no test files. -Previously, it would do nothing if no test files were present. -

- -

-The go build subcommand -supports a new -i option to install dependencies -of the specified target, but not the target itself. -

- -

-Cross compiling with cgo enabled -is now supported. -The CC_FOR_TARGET and CXX_FOR_TARGET environment -variables are used when running all.bash to specify the cross compilers -for C and C++ code, respectively. -

- -

-Finally, the go command now supports packages that import Objective-C -files (suffixed .m) through cgo. -

- -

Changes to cgo

- -

-The cmd/cgo command, -which processes import "C" declarations in Go packages, -has corrected a serious bug that may cause some packages to stop compiling. -Previously, all pointers to incomplete struct types translated to the Go type *[0]byte, -with the effect that the Go compiler could not diagnose passing one kind of struct pointer -to a function expecting another. -Go 1.3 corrects this mistake by translating each different -incomplete struct to a different named type. -

- -

-Given the C declaration typedef struct S T for an incomplete struct S, -some Go code used this bug to refer to the types C.struct_S and C.T interchangeably. -Cgo now explicitly allows this use, even for completed struct types. -However, some Go code also used this bug to pass (for example) a *C.FILE -from one package to another. -This is not legal and no longer works: in general Go packages -should avoid exposing C types and names in their APIs. -

- -

-Updating: Code confusing pointers to incomplete types or -passing them across package boundaries will no longer compile -and must be rewritten. -If the conversion is correct and must be preserved, -use an explicit conversion via unsafe.Pointer. -

- -

SWIG 3.0 required for programs that use SWIG

- -

-For Go programs that use SWIG, SWIG version 3.0 is now required. -The cmd/go command will now link the -SWIG generated object files directly into the binary, rather than -building and linking with a shared library. -

- -

Command-line flag parsing

- -

-In the gc toolchain, the assemblers now use the -same command-line flag parsing rules as the Go flag package, a departure -from the traditional Unix flag parsing. -This may affect scripts that invoke the tool directly. -For example, -go tool 6a -SDfoo must now be written -go tool 6a -S -D foo. -(The same change was made to the compilers and linkers in Go 1.1.) -

- -

Changes to godoc

-

-When invoked with the -analysis flag, -godoc -now performs sophisticated static -analysis of the code it indexes. -The results of analysis are presented in both the source view and the -package documentation view, and include the call graph of each package -and the relationships between -definitions and references, -types and their methods, -interfaces and their implementations, -send and receive operations on channels, -functions and their callers, and -call sites and their callees. -

- -

Miscellany

- -

-The program misc/benchcmp that compares -performance across benchmarking runs has been rewritten. -Once a shell and awk script in the main repository, it is now a Go program in the go.tools repo. -Documentation is here. -

- -

-For the few of us that build Go distributions, the tool misc/dist has been -moved and renamed; it now lives in misc/makerelease, still in the main repository. -

- -

Performance

- -

-The performance of Go binaries for this release has improved in many cases due to changes -in the runtime and garbage collection, plus some changes to libraries. -Significant instances include: -

- -
    - -
  • -The runtime handles defers more efficiently, reducing the memory footprint by about two kilobytes -per goroutine that calls defer. -
  • - -
  • -The garbage collector has been sped up, using a concurrent sweep algorithm, -better parallelization, and larger pages. -The cumulative effect can be a 50-70% reduction in collector pause time. -
  • - -
  • -The race detector (see this guide) -is now about 40% faster. -
  • - -
  • -The regular expression package regexp -is now significantly faster for certain simple expressions due to the implementation of -a second, one-pass execution engine. -The choice of which engine to use is automatic; -the details are hidden from the user. -
  • - -
- -

-Also, the runtime now includes in stack dumps how long a goroutine has been blocked, -which can be useful information when debugging deadlocks or performance issues. -

- -

Changes to the standard library

- -

New packages

- -

-A new package debug/plan9obj was added to the standard library. -It implements access to Plan 9 a.out object files. -

- -

Major changes to the library

- -

-A previous bug in crypto/tls -made it possible to skip verification in TLS inadvertently. -In Go 1.3, the bug is fixed: one must specify either ServerName or -InsecureSkipVerify, and if ServerName is specified it is enforced. -This may break existing code that incorrectly depended on insecure -behavior. -

- -

-There is an important new type added to the standard library: sync.Pool. -It provides an efficient mechanism for implementing certain types of caches whose memory -can be reclaimed automatically by the system. -

- -

-The testing package's benchmarking helper, -B, now has a -RunParallel method -to make it easier to run benchmarks that exercise multiple CPUs. -

- -

-Updating: The crypto/tls fix may break existing code, but such -code was erroneous and should be updated. -

- -

Minor changes to the library

- -

-The following list summarizes a number of minor changes to the library, mostly additions. -See the relevant package documentation for more information about each change. -

- -
    - -
  • In the crypto/tls package, -a new DialWithDialer -function lets one establish a TLS connection using an existing dialer, making it easier -to control dial options such as timeouts. -The package also now reports the TLS version used by the connection in the -ConnectionState -struct. -
  • - -
  • The CreateCertificate -function of the crypto/tls package -now supports parsing (and elsewhere, serialization) of PKCS #10 certificate -signature requests. -
  • - -
  • -The formatted print functions of the fmt package now define %F -as a synonym for %f when printing floating-point values. -
  • - -
  • -The math/big package's -Int and -Rat types -now implement -encoding.TextMarshaler and -encoding.TextUnmarshaler. -
  • - -
  • -The complex power function, Pow, -now specifies the behavior when the first argument is zero. -It was undefined before. -The details are in the documentation for the function. -
  • - -
  • -The net/http package now exposes the -properties of a TLS connection used to make a client request in the new -Response.TLS field. -
  • - -
  • -The net/http package now -allows setting an optional server error logger -with Server.ErrorLog. -The default is still that all errors go to stderr. -
  • - -
  • -The net/http package now -supports disabling HTTP keep-alive connections on the server -with Server.SetKeepAlivesEnabled. -The default continues to be that the server does keep-alive (reuses -connections for multiple requests) by default. -Only resource-constrained servers or those in the process of graceful -shutdown will want to disable them. -
  • - -
  • -The net/http package adds an optional -Transport.TLSHandshakeTimeout -setting to cap the amount of time HTTP client requests will wait for -TLS handshakes to complete. -It's now also set by default -on DefaultTransport. -
  • - -
  • -The net/http package's -DefaultTransport, -used by the HTTP client code, now -enables TCP -keep-alives by default. -Other Transport -values with a nil Dial field continue to function the same -as before: no TCP keep-alives are used. -
  • - -
  • -The net/http package -now enables TCP -keep-alives for incoming server requests when -ListenAndServe -or -ListenAndServeTLS -are used. -When a server is started otherwise, TCP keep-alives are not enabled. -
  • - -
  • -The net/http package now -provides an -optional Server.ConnState -callback to hook various phases of a server connection's lifecycle -(see ConnState). -This can be used to implement rate limiting or graceful shutdown. -
  • - -
  • -The net/http package's HTTP -client now has an -optional Client.Timeout -field to specify an end-to-end timeout on requests made using the -client. -
  • - -
  • -The net/http package's -Request.ParseMultipartForm -method will now return an error if the body's Content-Type -is not multipart/form-data. -Prior to Go 1.3 it would silently fail and return nil. -Code that relies on the previous behavior should be updated. -
  • - -
  • In the net package, -the Dialer struct now -has a KeepAlive option to specify a keep-alive period for the connection. -
  • - -
  • -The net/http package's -Transport -now closes Request.Body -consistently, even on error. -
  • - -
  • -The os/exec package now implements -what the documentation has always said with regard to relative paths for the binary. -In particular, it only calls LookPath -when the binary's file name contains no path separators. -
  • - -
  • -The SetMapIndex -function in the reflect package -no longer panics when deleting from a nil map. -
  • - -
  • -If the main goroutine calls -runtime.Goexit -and all other goroutines finish execution, the program now always crashes, -reporting a detected deadlock. -Earlier versions of Go handled this situation inconsistently: most instances -were reported as deadlocks, but some trivial cases exited cleanly instead. -
  • - -
  • -The runtime/debug package now has a new function -debug.WriteHeapDump -that writes out a description of the heap. -
  • - -
  • -The CanBackquote -function in the strconv package -now considers the DEL character, U+007F, to be -non-printing. -
  • - -
  • -The syscall package now provides -SendmsgN -as an alternate version of -Sendmsg -that returns the number of bytes written. -
  • - -
  • -On Windows, the syscall package now -supports the cdecl calling convention through the addition of a new function -NewCallbackCDecl -alongside the existing function -NewCallback. -
  • - -
  • -The testing package now -diagnoses tests that call panic(nil), which are almost always erroneous. -Also, tests now write profiles (if invoked with profiling flags) even on failure. -
  • - -
  • -The unicode package and associated -support throughout the system has been upgraded from -Unicode 6.2.0 to Unicode 6.3.0. -
  • - -
diff --git a/_content/doc/go1.4.html b/_content/doc/go1.4.html deleted file mode 100644 index 32b16b8824..0000000000 --- a/_content/doc/go1.4.html +++ /dev/null @@ -1,894 +0,0 @@ - - -

Introduction to Go 1.4

- -

-The latest Go release, version 1.4, arrives as scheduled six months after 1.3. -

- -

-It contains only one tiny language change, -in the form of a backwards-compatible simple variant of for-range loop, -and a possibly breaking change to the compiler involving methods on pointers-to-pointers. -

- -

-The release focuses primarily on implementation work, improving the garbage collector -and preparing the ground for a fully concurrent collector to be rolled out in the -next few releases. -Stacks are now contiguous, reallocated when necessary rather than linking on new -"segments"; -this release therefore eliminates the notorious "hot stack split" problem. -There are some new tools available including support in the go command -for build-time source code generation. -The release also adds support for ARM processors on Android and Native Client (NaCl) -and for AMD64 on Plan 9. -

- -

-As always, Go 1.4 keeps the promise -of compatibility, -and almost everything -will continue to compile and run without change when moved to 1.4. -

- -

Changes to the language

- -

For-range loops

-

-Up until Go 1.3, for-range loop had two forms -

- -
-for i, v := range x {
-	...
-}
-
- -

-and -

- -
-for i := range x {
-	...
-}
-
- -

-If one was not interested in the loop values, only the iteration itself, it was still -necessary to mention a variable (probably the blank identifier, as in -for _ = range x), because -the form -

- -
-for range x {
-	...
-}
-
- -

-was not syntactically permitted. -

- -

-This situation seemed awkward, so as of Go 1.4 the variable-free form is now legal. -The pattern arises rarely but the code can be cleaner when it does. -

- -

-Updating: The change is strictly backwards compatible to existing Go -programs, but tools that analyze Go parse trees may need to be modified to accept -this new form as the -Key field of RangeStmt -may now be nil. -

- -

Method calls on **T

- -

-Given these declarations, -

- -
-type T int
-func (T) M() {}
-var x **T
-
- -

-both gc and gccgo accepted the method call -

- -
-x.M()
-
- -

-which is a double dereference of the pointer-to-pointer x. -The Go specification allows a single dereference to be inserted automatically, -but not two, so this call is erroneous according to the language definition. -It has therefore been disallowed in Go 1.4, which is a breaking change, -although very few programs will be affected. -

- -

-Updating: Code that depends on the old, erroneous behavior will no longer -compile but is easy to fix by adding an explicit dereference. -

- -

Changes to the supported operating systems and architectures

- -

Android

- -

-Go 1.4 can build binaries for ARM processors running the Android operating system. -It can also build a .so library that can be loaded by an Android application -using the supporting packages in the mobile subrepository. -A brief description of the plans for this experimental port are available -here. -

- -

NaCl on ARM

- -

-The previous release introduced Native Client (NaCl) support for the 32-bit x86 -(GOARCH=386) -and 64-bit x86 using 32-bit pointers (GOARCH=amd64p32). -The 1.4 release adds NaCl support for ARM (GOARCH=arm). -

- -

Plan9 on AMD64

- -

-This release adds support for the Plan 9 operating system on AMD64 processors, -provided the kernel supports the nsec system call and uses 4K pages. -

- -

Changes to the compatibility guidelines

- -

-The unsafe package allows one -to defeat Go's type system by exploiting internal details of the implementation -or machine representation of data. -It was never explicitly specified what use of unsafe meant -with respect to compatibility as specified in the -Go compatibility guidelines. -The answer, of course, is that we can make no promise of compatibility -for code that does unsafe things. -

- -

-We have clarified this situation in the documentation included in the release. -The Go compatibility guidelines and the -docs for the unsafe package -are now explicit that unsafe code is not guaranteed to remain compatible. -

- -

-Updating: Nothing technical has changed; this is just a clarification -of the documentation. -

- - -

Changes to the implementations and tools

- -

Changes to the runtime

- -

-Prior to Go 1.4, the runtime (garbage collector, concurrency support, interface management, -maps, slices, strings, ...) was mostly written in C, with some assembler support. -In 1.4, much of the code has been translated to Go so that the garbage collector can scan -the stacks of programs in the runtime and get accurate information about what variables -are active. -This change was large but should have no semantic effect on programs. -

- -

-This rewrite allows the garbage collector in 1.4 to be fully precise, -meaning that it is aware of the location of all active pointers in the program. -This means the heap will be smaller as there will be no false positives keeping non-pointers alive. -Other related changes also reduce the heap size, which is smaller by 10%-30% overall -relative to the previous release. -

- -

-A consequence is that stacks are no longer segmented, eliminating the "hot split" problem. -When a stack limit is reached, a new, larger stack is allocated, all active frames for -the goroutine are copied there, and any pointers into the stack are updated. -Performance can be noticeably better in some cases and is always more predictable. -Details are available in the design document. -

- -

-The use of contiguous stacks means that stacks can start smaller without triggering performance issues, -so the default starting size for a goroutine's stack in 1.4 has been reduced from 8192 bytes to 2048 bytes. -

- -

-As preparation for the concurrent garbage collector scheduled for the 1.5 release, -writes to pointer values in the heap are now done by a function call, -called a write barrier, rather than directly from the function updating the value. -In this next release, this will permit the garbage collector to mediate writes to the heap while it is running. -This change has no semantic effect on programs in 1.4, but was -included in the release to test the compiler and the resulting performance. -

- -

-The implementation of interface values has been modified. -In earlier releases, the interface contained a word that was either a pointer or a one-word -scalar value, depending on the type of the concrete object stored. -This implementation was problematical for the garbage collector, -so as of 1.4 interface values always hold a pointer. -In running programs, most interface values were pointers anyway, -so the effect is minimal, but programs that store integers (for example) in -interfaces will see more allocations. -

- -

-As of Go 1.3, the runtime crashes if it finds a memory word that should contain -a valid pointer but instead contains an obviously invalid pointer (for example, the value 3). -Programs that store integers in pointer values may run afoul of this check and crash. -In Go 1.4, setting the GODEBUG variable -invalidptr=0 disables -the crash as a workaround, but we cannot guarantee that future releases will be -able to avoid the crash; the correct fix is to rewrite code not to alias integers and pointers. -

- -

Assembly

- -

-The language accepted by the assemblers cmd/5a, cmd/6a -and cmd/8a has had several changes, -mostly to make it easier to deliver type information to the runtime. -

- -

-First, the textflag.h file that defines flags for TEXT directives -has been copied from the linker source directory to a standard location so it can be -included with the simple directive -

- -
-#include "textflag.h"
-
- -

-The more important changes are in how assembler source can define the necessary -type information. -For most programs it will suffice to move data -definitions (DATA and GLOBL directives) -out of assembly into Go files -and to write a Go declaration for each assembly function. -The assembly document describes what to do. -

- -

-Updating: -Assembly files that include textflag.h from its old -location will still work, but should be updated. -For the type information, most assembly routines will need no change, -but all should be examined. -Assembly source files that define data, -functions with non-empty stack frames, or functions that return pointers -need particular attention. -A description of the necessary (but simple) changes -is in the assembly document. -

- -

-More information about these changes is in the assembly document. -

- -

Status of gccgo

- -

-The release schedules for the GCC and Go projects do not coincide. -GCC release 4.9 contains the Go 1.2 version of gccgo. -The next release, GCC 5, will likely have the Go 1.4 version of gccgo. -

- -

Internal packages

- -

-Go's package system makes it easy to structure programs into components with clean boundaries, -but there are only two forms of access: local (unexported) and global (exported). -Sometimes one wishes to have components that are not exported, -for instance to avoid acquiring clients of interfaces to code that is part of a public repository -but not intended for use outside the program to which it belongs. -

- -

-The Go language does not have the power to enforce this distinction, but as of Go 1.4 the -go command introduces -a mechanism to define "internal" packages that may not be imported by packages outside -the source subtree in which they reside. -

- -

-To create such a package, place it in a directory named internal or in a subdirectory of a directory -named internal. -When the go command sees an import of a package with internal in its path, -it verifies that the package doing the import -is within the tree rooted at the parent of the internal directory. -For example, a package .../a/b/c/internal/d/e/f -can be imported only by code in the directory tree rooted at .../a/b/c. -It cannot be imported by code in .../a/b/g or in any other repository. -

- -

-For Go 1.4, the internal package mechanism is enforced for the main Go repository; -from 1.5 and onward it will be enforced for any repository. -

- -

-Full details of the mechanism are in -the design document. -

- -

Canonical import paths

- -

-Code often lives in repositories hosted by public services such as github.com, -meaning that the import paths for packages begin with the name of the hosting service, -github.com/rsc/pdf for example. -One can use -an existing mechanism -to provide a "custom" or "vanity" import path such as -rsc.io/pdf, but -that creates two valid import paths for the package. -That is a problem: one may inadvertently import the package through the two -distinct paths in a single program, which is wasteful; -miss an update to a package because the path being used is not recognized to be -out of date; -or break clients using the old path by moving the package to a different hosting service. -

- -

-Go 1.4 introduces an annotation for package clauses in Go source that identify a canonical -import path for the package. -If an import is attempted using a path that is not canonical, -the go command -will refuse to compile the importing package. -

- -

-The syntax is simple: put an identifying comment on the package line. -For our example, the package clause would read: -

- -
-package pdf // import "rsc.io/pdf"
-
- -

-With this in place, -the go command will -refuse to compile a package that imports github.com/rsc/pdf, -ensuring that the code can be moved without breaking users. -

- -

-The check is at build time, not download time, so if go get -fails because of this check, the mis-imported package has been copied to the local machine -and should be removed manually. -

- -

-To complement this new feature, a check has been added at update time to verify -that the local package's remote repository matches that of its custom import. -The go get -u command will fail to -update a package if its remote repository has changed since it was first -downloaded. -The new -f flag overrides this check. -

- -

-Further information is in -the design document. -

- -

Import paths for the subrepositories

- -

-The Go project subrepositories (code.google.com/p/go.tools and so on) -are now available under custom import paths replacing code.google.com/p/go. with golang.org/x/, -as in golang.org/x/tools. -We will add canonical import comments to the code around June 1, 2015, -at which point Go 1.4 and later will stop accepting the old code.google.com paths. -

- -

-Updating: All code that imports from subrepositories should change -to use the new golang.org paths. -Go 1.0 and later can resolve and import the new paths, so updating will not break -compatibility with older releases. -Code that has not updated will stop compiling with Go 1.4 around June 1, 2015. -

- -

The go generate subcommand

- -

-The go command has a new subcommand, -go generate, -to automate the running of tools to generate source code before compilation. -For example, it can be used to run the yacc -compiler-compiler on a .y file to produce the Go source file implementing the grammar, -or to automate the generation of String methods for typed constants using the new -stringer -tool in the golang.org/x/tools subrepository. -

- -

-For more information, see the -design document. -

- -

Change to file name handling

- -

-Build constraints, also known as build tags, control compilation by including or excluding files -(see the documentation /go/build). -Compilation can also be controlled by the name of the file itself by "tagging" the file with -a suffix (before the .go or .s extension) with an underscore -and the name of the architecture or operating system. -For instance, the file gopher_arm.go will only be compiled if the target -processor is an ARM. -

- -

-Before Go 1.4, a file called just arm.go was similarly tagged, but this behavior -can break sources when new architectures are added, causing files to suddenly become tagged. -In 1.4, therefore, a file will be tagged in this manner only if the tag (architecture or operating -system name) is preceded by an underscore. -

- -

-Updating: Packages that depend on the old behavior will no longer compile correctly. -Files with names like windows.go or amd64.go should either -have explicit build tags added to the source or be renamed to something like -os_windows.go or support_amd64.go. -

- -

Other changes to the go command

- -

-There were a number of minor changes to the -cmd/go -command worth noting. -

- -
    - -
  • -Unless cgo is being used to build the package, -the go command now refuses to compile C source files, -since the relevant C compilers -(6c etc.) -are intended to be removed from the installation in some future release. -(They are used today only to build part of the runtime.) -It is difficult to use them correctly in any case, so any extant uses are likely incorrect, -so we have disabled them. -
  • - -
  • -The go test -subcommand has a new flag, -o, to set the name of the resulting binary, -corresponding to the same flag in other subcommands. -The non-functional -file flag has been removed. -
  • - -
  • -The go test -subcommand will compile and link all *_test.go files in the package, -even when there are no Test functions in them. -It previously ignored such files. -
  • - -
  • -The behavior of the -go build -subcommand's --a flag has been changed for non-development installations. -For installations running a released distribution, the -a flag will no longer -rebuild the standard library and commands, to avoid overwriting the installation's files. -
  • - -
- -

Changes to package source layout

- -

-In the main Go source repository, the source code for the packages was kept in -the directory src/pkg, which made sense but differed from -other repositories, including the Go subrepositories. -In Go 1.4, the pkg level of the source tree is now gone, so for example -the fmt package's source, once kept in -directory src/pkg/fmt, now lives one level higher in src/fmt. -

- -

-Updating: Tools like godoc that discover source code -need to know about the new location. All tools and services maintained by the Go team -have been updated. -

- - -

SWIG

- -

-Due to runtime changes in this release, Go 1.4 requires SWIG 3.0.3. -

- -

Miscellany

- -

-The standard repository's top-level misc directory used to contain -Go support for editors and IDEs: plugins, initialization scripts and so on. -Maintaining these was becoming time-consuming -and needed external help because many of the editors listed were not used by -members of the core team. -It also required us to make decisions about which plugin was best for a given -editor, even for editors we do not use. -

- -

-The Go community at large is much better suited to managing this information. -In Go 1.4, therefore, this support has been removed from the repository. -Instead, there is a curated, informative list of what's available on -a wiki page. -

- -

Performance

- -

-Most programs will run about the same speed or slightly faster in 1.4 than in 1.3; -some will be slightly slower. -There are many changes, making it hard to be precise about what to expect. -

- -

-As mentioned above, much of the runtime was translated to Go from C, -which led to some reduction in heap sizes. -It also improved performance slightly because the Go compiler is better -at optimization, due to things like inlining, than the C compiler used to build -the runtime. -

- -

-The garbage collector was sped up, leading to measurable improvements for -garbage-heavy programs. -On the other hand, the new write barriers slow things down again, typically -by about the same amount but, depending on their behavior, some programs -may be somewhat slower or faster. -

- -

-Library changes that affect performance are documented below. -

- -

Changes to the standard library

- -

New packages

- -

-There are no new packages in this release. -

- -

Major changes to the library

- -

bufio.Scanner

- -

-The Scanner type in the -bufio package -has had a bug fixed that may require changes to custom -split functions. -The bug made it impossible to generate an empty token at EOF; the fix -changes the end conditions seen by the split function. -Previously, scanning stopped at EOF if there was no more data. -As of 1.4, the split function will be called once at EOF after input is exhausted, -so the split function can generate a final empty token -as the documentation already promised. -

- -

-Updating: Custom split functions may need to be modified to -handle empty tokens at EOF as desired. -

- -

syscall

- -

-The syscall package is now frozen except -for changes needed to maintain the core repository. -In particular, it will no longer be extended to support new or different system calls -that are not used by the core. -The reasons are described at length in a -separate document. -

- -

-A new subrepository, golang.org/x/sys, -has been created to serve as the location for new developments to support system -calls on all kernels. -It has a nicer structure, with three packages that each hold the implementation of -system calls for one of -Unix, -Windows and -Plan 9. -These packages will be curated more generously, accepting all reasonable changes -that reflect kernel interfaces in those operating systems. -See the documentation and the article mentioned above for more information. -

- -

-Updating: Existing programs are not affected as the syscall -package is largely unchanged from the 1.3 release. -Future development that requires system calls not in the syscall package -should build on golang.org/x/sys instead. -

- -

Minor changes to the library

- -

-The following list summarizes a number of minor changes to the library, mostly additions. -See the relevant package documentation for more information about each change. -

- -
    - -
  • -The archive/zip package's -Writer now supports a -Flush method. -
  • - -
  • -The compress/flate, -compress/gzip, -and compress/zlib -packages now support a Reset method -for the decompressors, allowing them to reuse buffers and improve performance. -The compress/gzip package also has a -Multistream method to control support -for multistream files. -
  • - -
  • -The crypto package now has a -Signer interface, implemented by the -PrivateKey types in -crypto/ecdsa and -crypto/rsa. -
  • - -
  • -The crypto/tls package -now supports ALPN as defined in RFC 7301. -
  • - -
  • -The crypto/tls package -now supports programmatic selection of server certificates -through the new CertificateForName function -of the Config struct. -
  • - -
  • -Also in the crypto/tls package, the server now supports -TLS_FALLBACK_SCSV -to help clients detect fallback attacks. -(The Go client does not support fallback at all, so it is not vulnerable to -those attacks.) -
  • - -
  • -The database/sql package can now list all registered -Drivers. -
  • - -
  • -The debug/dwarf package now supports -UnspecifiedTypes. -
  • - -
  • -In the encoding/asn1 package, -optional elements with a default value will now only be omitted if they have that value. -
  • - -
  • -The encoding/csv package no longer -quotes empty strings but does quote the end-of-data marker \. (backslash dot). -This is permitted by the definition of CSV and allows it to work better with Postgres. -
  • - -
  • -The encoding/gob package has been rewritten to eliminate -the use of unsafe operations, allowing it to be used in environments that do not permit use of the -unsafe package. -For typical uses it will be 10-30% slower, but the delta is dependent on the type of the data and -in some cases, especially involving arrays, it can be faster. -There is no functional change. -
  • - -
  • -The encoding/xml package's -Decoder can now report its input offset. -
  • - -
  • -In the fmt package, -formatting of pointers to maps has changed to be consistent with that of pointers -to structs, arrays, and so on. -For instance, &map[string]int{"one": 1} now prints by default as -&map[one: 1] rather than as a hexadecimal pointer value. -
  • - -
  • -The image package's -Image -implementations like -RGBA and -Gray have specialized -RGBAAt and -GrayAt methods alongside the general -At method. -
  • - -
  • -The image/png package now has an -Encoder -type to control the compression level used for encoding. -
  • - -
  • -The math package now has a -Nextafter32 function. -
  • - -
  • -The net/http package's -Request type -has a new BasicAuth method -that returns the username and password from authenticated requests using the -HTTP Basic Authentication -Scheme. -
  • - -
  • The net/http package's -Transport type -has a new DialTLS hook -that allows customizing the behavior of outbound TLS connections. -
  • - -
  • -The net/http/httputil package's -ReverseProxy type -has a new field, -ErrorLog, that -provides user control of logging. -
  • - -
  • -The os package -now implements symbolic links on the Windows operating system -through the Symlink function. -Other operating systems already have this functionality. -There is also a new Unsetenv function. -
  • - -
  • -The reflect package's -Type interface -has a new method, Comparable, -that reports whether the type implements general comparisons. -
  • - -
  • -Also in the reflect package, the -Value interface is now three instead of four words -because of changes to the implementation of interfaces in the runtime. -This saves memory but has no semantic effect. -
  • - -
  • -The runtime package -now implements monotonic clocks on Windows, -as it already did for the other systems. -
  • - -
  • -The runtime package's -Mallocs counter -now counts very small allocations that were missed in Go 1.3. -This may break tests using ReadMemStats -or AllocsPerRun -due to the more accurate answer. -
  • - -
  • -In the runtime package, -an array PauseEnd -has been added to the -MemStats -and GCStats structs. -This array is a circular buffer of times when garbage collection pauses ended. -The corresponding pause durations are already recorded in -PauseNs -
  • - -
  • -The runtime/race package -now supports FreeBSD, which means the -go command's -race -flag now works on FreeBSD. -
  • - -
  • -The sync/atomic package -has a new type, Value. -Value provides an efficient mechanism for atomic loads and -stores of values of arbitrary type. -
  • - -
  • -In the syscall package's -implementation on Linux, the -Setuid -and Setgid have been disabled -because those system calls operate on the calling thread, not the whole process, which is -different from other platforms and not the expected result. -
  • - -
  • -The testing package -has a new facility to provide more control over running a set of tests. -If the test code contains a function -
    -func TestMain(m *testing.M)
    -
    - -that function will be called instead of running the tests directly. -The M struct contains methods to access and run the tests. -
  • - -
  • -Also in the testing package, -a new Coverage -function reports the current test coverage fraction, -enabling individual tests to report how much they are contributing to the -overall coverage. -
  • - -
  • -The text/scanner package's -Scanner type -has a new function, -IsIdentRune, -allowing one to control the definition of an identifier when scanning. -
  • - -
  • -The text/template package's boolean -functions eq, lt, and so on have been generalized to allow comparison -of signed and unsigned integers, simplifying their use in practice. -(Previously one could only compare values of the same signedness.) -All negative values compare less than all unsigned values. -
  • - -
  • -The time package now uses the standard symbol for the micro prefix, -the micro symbol (U+00B5 'µ'), to print microsecond durations. -ParseDuration still accepts us -but the package no longer prints microseconds as us. -
    -Updating: Code that depends on the output format of durations -but does not use ParseDuration will need to be updated. -
  • - -
diff --git a/_content/doc/go1.5.html b/_content/doc/go1.5.html deleted file mode 100644 index 3514b55fed..0000000000 --- a/_content/doc/go1.5.html +++ /dev/null @@ -1,1308 +0,0 @@ - - - -

Introduction to Go 1.5

- -

-The latest Go release, version 1.5, -is a significant release, including major architectural changes to the implementation. -Despite that, we expect almost all Go programs to continue to compile and run as before, -because the release still maintains the Go 1 promise -of compatibility. -

- -

-The biggest developments in the implementation are: -

- -
    - -
  • -The compiler and runtime are now written entirely in Go (with a little assembler). -C is no longer involved in the implementation, and so the C compiler that was -once necessary for building the distribution is gone. -
  • - -
  • -The garbage collector is now concurrent and provides dramatically lower -pause times by running, when possible, in parallel with other goroutines. -
  • - -
  • -By default, Go programs run with GOMAXPROCS set to the -number of cores available; in prior releases it defaulted to 1. -
  • - -
  • -Support for internal packages -is now provided for all repositories, not just the Go core. -
  • - -
  • -The go command now provides experimental -support for "vendoring" external dependencies. -
  • - -
  • -A new go tool trace command supports fine-grained -tracing of program execution. -
  • - -
  • -A new go doc command (distinct from godoc) -is customized for command-line use. -
  • - -
- -

-These and a number of other changes to the implementation and tools -are discussed below. -

- -

-The release also contains one small language change involving map literals. -

- -

-Finally, the timing of the release -strays from the usual six-month interval, -both to provide more time to prepare this major release and to shift the schedule thereafter to -time the release dates more conveniently. -

- -

Changes to the language

- -

Map literals

- -

-Due to an oversight, the rule that allowed the element type to be elided from slice literals was not -applied to map keys. -This has been corrected in Go 1.5. -An example will make this clear. -As of Go 1.5, this map literal, -

- -
-m := map[Point]string{
-    Point{29.935523, 52.891566}:   "Persepolis",
-    Point{-25.352594, 131.034361}: "Uluru",
-    Point{37.422455, -122.084306}: "Googleplex",
-}
-
- -

-may be written as follows, without the Point type listed explicitly: -

- -
-m := map[Point]string{
-    {29.935523, 52.891566}:   "Persepolis",
-    {-25.352594, 131.034361}: "Uluru",
-    {37.422455, -122.084306}: "Googleplex",
-}
-
- -

The Implementation

- -

No more C

- -

-The compiler and runtime are now implemented in Go and assembler, without C. -The only C source left in the tree is related to testing or to cgo. -There was a C compiler in the tree in 1.4 and earlier. -It was used to build the runtime; a custom compiler was necessary in part to -guarantee the C code would work with the stack management of goroutines. -Since the runtime is in Go now, there is no need for this C compiler and it is gone. -Details of the process to eliminate C are discussed elsewhere. -

- -

-The conversion from C was done with the help of custom tools created for the job. -Most important, the compiler was actually moved by automatic translation of -the C code into Go. -It is in effect the same program in a different language. -It is not a new implementation -of the compiler so we expect the process will not have introduced new compiler -bugs. -An overview of this process is available in the slides for -this presentation. -

- -

Compiler and tools

- -

-Independent of but encouraged by the move to Go, the names of the tools have changed. -The old names 6g, 8g and so on are gone; instead there -is just one binary, accessible as go tool compile, -that compiles Go source into binaries suitable for the architecture and operating system -specified by $GOARCH and $GOOS. -Similarly, there is now one linker (go tool link) -and one assembler (go tool asm). -The linker was translated automatically from the old C implementation, -but the assembler is a new native Go implementation discussed -in more detail below. -

- -

-Similar to the drop of the names 6g, 8g, and so on, -the output of the compiler and assembler are now given a plain .o suffix -rather than .8, .6, etc. -

- - -

Garbage collector

- -

-The garbage collector has been re-engineered for 1.5 as part of the development -outlined in the design document. -Expected latencies are much lower than with the collector -in prior releases, through a combination of advanced algorithms, -better scheduling of the collector, -and running more of the collection in parallel with the user program. -The "stop the world" phase of the collector -will almost always be under 10 milliseconds and usually much less. -

- -

-For systems that benefit from low latency, such as user-responsive web sites, -the drop in expected latency with the new collector may be important. -

- -

-Details of the new collector were presented in a -talk at GopherCon 2015. -

- -

Runtime

- -

-In Go 1.5, the order in which goroutines are scheduled has been changed. -The properties of the scheduler were never defined by the language, -but programs that depend on the scheduling order may be broken -by this change. -We have seen a few (erroneous) programs affected by this change. -If you have programs that implicitly depend on the scheduling -order, you will need to update them. -

- -

-Another potentially breaking change is that the runtime now -sets the default number of threads to run simultaneously, -defined by GOMAXPROCS, to the number -of cores available on the CPU. -In prior releases the default was 1. -Programs that do not expect to run with multiple cores may -break inadvertently. -They can be updated by removing the restriction or by setting -GOMAXPROCS explicitly. -For a more detailed discussion of this change, see -the design document. -

- -

Build

- -

-Now that the Go compiler and runtime are implemented in Go, a Go compiler -must be available to compile the distribution from source. -Thus, to build the Go core, a working Go distribution must already be in place. -(Go programmers who do not work on the core are unaffected by this change.) -Any Go 1.4 or later distribution (including gccgo) will serve. -For details, see the design document. -

- -

Ports

- -

-Due mostly to the industry's move away from the 32-bit x86 architecture, -the set of binary downloads provided is reduced in 1.5. -A distribution for the OS X operating system is provided only for the -amd64 architecture, not 386. -Similarly, the ports for Snow Leopard (Apple OS X 10.6) still work but are no -longer released as a download or maintained since Apple no longer maintains that version -of the operating system. -Also, the dragonfly/386 port is no longer supported at all -because DragonflyBSD itself no longer supports the 32-bit 386 architecture. -

- -

-There are however several new ports available to be built from source. -These include darwin/arm and darwin/arm64. -The new port linux/arm64 is mostly in place, but cgo -is only supported using external linking. -

- -

-Also available as experiments are ppc64 -and ppc64le (64-bit PowerPC, big- and little-endian). -Both these ports support cgo but -only with internal linking. -

- -

-On FreeBSD, Go 1.5 requires FreeBSD 8-STABLE+ because of its new use of the SYSCALL instruction. -

- -

-On NaCl, Go 1.5 requires SDK version pepper-41. Later pepper versions are not -compatible due to the removal of the sRPC subsystem from the NaCl runtime. -

- -

-On Darwin, the use of the system X.509 certificate interface can be disabled -with the ios build tag. -

- -

-The Solaris port now has full support for cgo and the packages -net and -crypto/x509, -as well as a number of other fixes and improvements. -

- -

Tools

- -

Translating

- -

-As part of the process to eliminate C from the tree, the compiler and -linker were translated from C to Go. -It was a genuine (machine assisted) translation, so the new programs are essentially -the old programs translated rather than new ones with new bugs. -We are confident the translation process has introduced few if any new bugs, -and in fact uncovered a number of previously unknown bugs, now fixed. -

- -

-The assembler is a new program, however; it is described below. -

- -

Renaming

- -

-The suites of programs that were the compilers (6g, 8g, etc.), -the assemblers (6a, 8a, etc.), -and the linkers (6l, 8l, etc.) -have each been consolidated into a single tool that is configured -by the environment variables GOOS and GOARCH. -The old names are gone; the new tools are available through the go tool -mechanism as go tool compile, -go tool asm, -and go tool link. -Also, the file suffixes .6, .8, etc. for the -intermediate object files are also gone; now they are just plain .o files. -

- -

-For example, to build and link a program on amd64 for Darwin -using the tools directly, rather than through go build, -one would run: -

- -
-$ export GOOS=darwin GOARCH=amd64
-$ go tool compile program.go
-$ go tool link program.o
-
- -

Moving

- -

-Because the go/types package -has now moved into the main repository (see below), -the vet and -cover -tools have also been moved. -They are no longer maintained in the external golang.org/x/tools repository, -although (deprecated) source still resides there for compatibility with old releases. -

- -

Compiler

- -

-As described above, the compiler in Go 1.5 is a single Go program, -translated from the old C source, that replaces 6g, 8g, -and so on. -Its target is configured by the environment variables GOOS and GOARCH. -

- -

-The 1.5 compiler is mostly equivalent to the old, -but some internal details have changed. -One significant change is that evaluation of constants now uses -the math/big package -rather than a custom (and less well tested) implementation of high precision -arithmetic. -We do not expect this to affect the results. -

- -

-For the amd64 architecture only, the compiler has a new option, -dynlink, -that assists dynamic linking by supporting references to Go symbols -defined in external shared libraries. -

- -

Assembler

- -

-Like the compiler and linker, the assembler in Go 1.5 is a single program -that replaces the suite of assemblers (6a, -8a, etc.) and the environment variables -GOARCH and GOOS -configure the architecture and operating system. -Unlike the other programs, the assembler is a wholly new program -written in Go. -

- -

-The new assembler is very nearly compatible with the previous -ones, but there are a few changes that may affect some -assembler source files. -See the updated assembler guide -for more specific information about these changes. In summary: - -

- -

-First, the expression evaluation used for constants is a little -different. -It now uses unsigned 64-bit arithmetic and the precedence -of operators (+, -, <<, etc.) -comes from Go, not C. -We expect these changes to affect very few programs but -manual verification may be required. -

- -

-Perhaps more important is that on machines where -SP or PC is only an alias -for a numbered register, -such as R13 for the stack pointer and -R15 for the hardware program counter -on ARM, -a reference to such a register that does not include a symbol -is now illegal. -For example, SP and 4(SP) are -illegal but sym+4(SP) is fine. -On such machines, to refer to the hardware register use its -true R name. -

- -

-One minor change is that some of the old assemblers -permitted the notation -

- -
-constant=value
-
- -

-to define a named constant. -Since this is always possible to do with the traditional -C-like #define notation, which is still -supported (the assembler includes an implementation -of a simplified C preprocessor), the feature was removed. -

- - - -

-The linker in Go 1.5 is now one Go program, -that replaces 6l, 8l, etc. -Its operating system and instruction set are specified -by the environment variables GOOS and GOARCH. -

- -

-There are several other changes. -The most significant is the addition of a -buildmode option that -expands the style of linking; it now supports -situations such as building shared libraries and allowing other languages -to call into Go libraries. -Some of these were outlined in a design document. -For a list of the available build modes and their use, run -

- -
-$ go help buildmode
-
- -

-Another minor change is that the linker no longer records build time stamps in -the header of Windows executables. -Also, although this may be fixed, Windows cgo executables are missing some -DWARF information. -

- -

-Finally, the -X flag, which takes two arguments, -as in -

- -
--X importpath.name value
-
- -

-now also accepts a more common Go flag style with a single argument -that is itself a name=value pair: -

- -
--X importpath.name=value
-
- -

-Although the old syntax still works, it is recommended that uses of this -flag in scripts and the like be updated to the new form. -

- -

Go command

- -

-The go command's basic operation -is unchanged, but there are a number of changes worth noting. -

- -

-The previous release introduced the idea of a directory internal to a package -being unimportable through the go command. -In 1.4, it was tested with the introduction of some internal elements -in the core repository. -As suggested in the design document, -that change is now being made available to all repositories. -The rules are explained in the design document, but in summary any -package in or under a directory named internal may -be imported by packages rooted in the same subtree. -Existing packages with directory elements named internal may be -inadvertently broken by this change, which was why it was advertised -in the last release. -

- -

-Another change in how packages are handled is the experimental -addition of support for "vendoring". -For details, see the documentation for the go command -and the design document. -

- -

-There have also been several minor changes. -Read the documentation for full details. -

- -
    - -
  • -SWIG support has been updated such that -.swig and .swigcxx -now require SWIG 3.0.6 or later. -
  • - -
  • -The install subcommand now removes the -binary created by the build subcommand -in the source directory, if present, -to avoid problems having two binaries present in the tree. -
  • - -
  • -The std (standard library) wildcard package name -now excludes commands. -A new cmd wildcard covers the commands. -
  • - -
  • -A new -asmflags build option -sets flags to pass to the assembler. -However, -the -ccflags build option has been dropped; -it was specific to the old, now deleted C compiler . -
  • - -
  • -A new -buildmode build option -sets the build mode, described above. -
  • - -
  • -A new -pkgdir build option -sets the location of installed package archives, -to help isolate custom builds. -
  • - -
  • -A new -toolexec build option -allows substitution of a different command to invoke -the compiler and so on. -This acts as a custom replacement for go tool. -
  • - -
  • -The test subcommand now has a -count -flag to specify how many times to run each test and benchmark. -The testing package -does the work here, through the -test.count flag. -
  • - -
  • -The generate subcommand has a couple of new features. -The -run option specifies a regular expression to select which directives -to execute; this was proposed but never implemented in 1.4. -The executing pattern now has access to two new environment variables: -$GOLINE returns the source line number of the directive -and $DOLLAR expands to a dollar sign. -
  • - -
  • -The get subcommand now has a -insecure -flag that must be enabled if fetching from an insecure repository, one that -does not encrypt the connection. -
  • - -
- -

Go vet command

- -

-The go tool vet command now does -more thorough validation of struct tags. -

- -

Trace command

- -

-A new tool is available for dynamic execution tracing of Go programs. -The usage is analogous to how the test coverage tool works. -Generation of traces is integrated into go test, -and then a separate execution of the tracing tool itself analyzes the results: -

- -
-$ go test -trace=trace.out path/to/package
-$ go tool trace [flags] pkg.test trace.out
-
- -

-The flags enable the output to be displayed in a browser window. -For details, run go tool trace -help. -There is also a description of the tracing facility in this -talk -from GopherCon 2015. -

- -

Go doc command

- -

-A few releases back, the go doc -command was deleted as being unnecessary. -One could always run "godoc ." instead. -The 1.5 release introduces a new go doc -command with a more convenient command-line interface than -godoc's. -It is designed for command-line usage specifically, and provides a more -compact and focused presentation of the documentation for a package -or its elements, according to the invocation. -It also provides case-insensitive matching and -support for showing the documentation for unexported symbols. -For details run "go help doc". -

- -

Cgo

- -

-When parsing #cgo lines, -the invocation ${SRCDIR} is now -expanded into the path to the source directory. -This allows options to be passed to the -compiler and linker that involve file paths relative to the -source code directory. Without the expansion the paths would be -invalid when the current working directory changes. -

- -

-Solaris now has full cgo support. -

- -

-On Windows, cgo now uses external linking by default. -

- -

-When a C struct ends with a zero-sized field, but the struct itself is -not zero-sized, Go code can no longer refer to the zero-sized field. -Any such references will have to be rewritten. -

- -

Performance

- -

-As always, the changes are so general and varied that precise statements -about performance are difficult to make. -The changes are even broader ranging than usual in this release, which -includes a new garbage collector and a conversion of the runtime to Go. -Some programs may run faster, some slower. -On average the programs in the Go 1 benchmark suite run a few percent faster in Go 1.5 -than they did in Go 1.4, -while as mentioned above the garbage collector's pauses are -dramatically shorter, and almost always under 10 milliseconds. -

- -

-Builds in Go 1.5 will be slower by a factor of about two. -The automatic translation of the compiler and linker from C to Go resulted in -unidiomatic Go code that performs poorly compared to well-written Go. -Analysis tools and refactoring helped to improve the code, but much remains to be done. -Further profiling and optimization will continue in Go 1.6 and future releases. -For more details, see these slides -and associated video. -

- -

Core library

- -

Flag

- -

-The flag package's -PrintDefaults -function, and method on FlagSet, -have been modified to create nicer usage messages. -The format has been changed to be more human-friendly and in the usage -messages a word quoted with `backquotes` is taken to be the name of the -flag's operand to display in the usage message. -For instance, a flag created with the invocation, -

- -
-cpuFlag = flag.Int("cpu", 1, "run `N` processes in parallel")
-
- -

-will show the help message, -

- -
--cpu N
-    	run N processes in parallel (default 1)
-
- -

-Also, the default is now listed only when it is not the zero value for the type. -

- -

Floats in math/big

- -

-The math/big package -has a new, fundamental data type, -Float, -which implements arbitrary-precision floating-point numbers. -A Float value is represented by a boolean sign, -a variable-length mantissa, and a 32-bit fixed-size signed exponent. -The precision of a Float (the mantissa size in bits) -can be specified explicitly or is otherwise determined by the first -operation that creates the value. -Once created, the size of a Float's mantissa may be modified with the -SetPrec method. -Floats support the concept of infinities, such as are created by -overflow, but values that would lead to the equivalent of IEEE 754 NaNs -trigger a panic. -Float operations support all IEEE-754 rounding modes. -When the precision is set to 24 (53) bits, -operations that stay within the range of normalized float32 -(float64) -values produce the same results as the corresponding IEEE-754 -arithmetic on those values. -

- -

Go types

- -

-The go/types package -up to now has been maintained in the golang.org/x -repository; as of Go 1.5 it has been relocated to the main repository. -The code at the old location is now deprecated. -There is also a modest API change in the package, discussed below. -

- -

-Associated with this move, the -go/constant -package also moved to the main repository; -it was golang.org/x/tools/exact before. -The go/importer package -also moved to the main repository, -as well as some tools described above. -

- -

Net

- -

-The DNS resolver in the net package has almost always used cgo to access -the system interface. -A change in Go 1.5 means that on most Unix systems DNS resolution -will no longer require cgo, which simplifies execution -on those platforms. -Now, if the system's networking configuration permits, the native Go resolver -will suffice. -The important effect of this change is that each DNS resolution occupies a goroutine -rather than a thread, -so a program with multiple outstanding DNS requests will consume fewer operating -system resources. -

- -

-The decision of how to run the resolver applies at run time, not build time. -The netgo build tag that has been used to enforce the use -of the Go resolver is no longer necessary, although it still works. -A new netcgo build tag forces the use of the cgo resolver at -build time. -To force cgo resolution at run time set -GODEBUG=netdns=cgo in the environment. -More debug options are documented here. -

- -

-This change applies to Unix systems only. -Windows, Mac OS X, and Plan 9 systems behave as before. -

- -

Reflect

- -

-The reflect package -has two new functions: ArrayOf -and FuncOf. -These functions, analogous to the extant -SliceOf function, -create new types at runtime to describe arrays and functions. -

- -

Hardening

- -

-Several dozen bugs were found in the standard library -through randomized testing with the -go-fuzz tool. -Bugs were fixed in the -archive/tar, -archive/zip, -compress/flate, -encoding/gob, -fmt, -html/template, -image/gif, -image/jpeg, -image/png, and -text/template, -packages. -The fixes harden the implementation against incorrect and malicious inputs. -

- -

Minor changes to the library

- -
    - -
  • -The archive/zip package's -Writer type now has a -SetOffset -method to specify the location within the output stream at which to write the archive. -
  • - -
  • -The Reader in the -bufio package now has a -Discard -method to discard data from the input. -
  • - -
  • -In the bytes package, -the Buffer type -now has a Cap method -that reports the number of bytes allocated within the buffer. -Similarly, in both the bytes -and strings packages, -the Reader -type now has a Size -method that reports the original length of the underlying slice or string. -
  • - -
  • -Both the bytes and -strings packages -also now have a LastIndexByte -function that locates the rightmost byte with that value in the argument. -
  • - -
  • -The crypto package -has a new interface, Decrypter, -that abstracts the behavior of a private key used in asymmetric decryption. -
  • - -
  • -In the crypto/cipher package, -the documentation for the Stream -interface has been clarified regarding the behavior when the source and destination are -different lengths. -If the destination is shorter than the source, the method will panic. -This is not a change in the implementation, only the documentation. -
  • - -
  • -Also in the crypto/cipher package, -there is now support for nonce lengths other than 96 bytes in AES's Galois/Counter mode (GCM), -which some protocols require. -
  • - -
  • -In the crypto/elliptic package, -there is now a Name field in the -CurveParams struct, -and the curves implemented in the package have been given names. -These names provide a safer way to select a curve, as opposed to -selecting its bit size, for cryptographic systems that are curve-dependent. -
  • - -
  • -Also in the crypto/elliptic package, -the Unmarshal function -now verifies that the point is actually on the curve. -(If it is not, the function returns nils). -This change guards against certain attacks. -
  • - -
  • -The crypto/sha512 -package now has support for the two truncated versions of -the SHA-512 hash algorithm, SHA-512/224 and SHA-512/256. -
  • - -
  • -The crypto/tls package -minimum protocol version now defaults to TLS 1.0. -The old default, SSLv3, is still available through Config if needed. -
  • - -
  • -The crypto/tls package -now supports Signed Certificate Timestamps (SCTs) as specified in RFC 6962. -The server serves them if they are listed in the -Certificate struct, -and the client requests them and exposes them, if present, -in its ConnectionState struct. - -
  • -The stapled OCSP response to a crypto/tls client connection, -previously only available via the -OCSPResponse method, -is now exposed in the ConnectionState struct. -
  • - -
  • -The crypto/tls server implementation -will now always call the -GetCertificate function in -the Config struct -to select a certificate for the connection when none is supplied. -
  • - -
  • -Finally, the session ticket keys in the -crypto/tls package -can now be changed while the server is running. -This is done through the new -SetSessionTicketKeys -method of the -Config type. -
  • - -
  • -In the crypto/x509 package, -wildcards are now accepted only in the leftmost label as defined in -the specification. -
  • - -
  • -Also in the crypto/x509 package, -the handling of unknown critical extensions has been changed. -They used to cause parse errors but now they are parsed and caused errors only -in Verify. -The new field UnhandledCriticalExtensions of -Certificate records these extensions. -
  • - -
  • -The DB type of the -database/sql package -now has a Stats method -to retrieve database statistics. -
  • - -
  • -The debug/dwarf -package has extensive additions to better support DWARF version 4. -See for example the definition of the new type -Class. -
  • - -
  • -The debug/dwarf package -also now supports decoding of DWARF line tables. -
  • - -
  • -The debug/elf -package now has support for the 64-bit PowerPC architecture. -
  • - -
  • -The encoding/base64 package -now supports unpadded encodings through two new encoding variables, -RawStdEncoding and -RawURLEncoding. -
  • - -
  • -The encoding/json package -now returns an UnmarshalTypeError -if a JSON value is not appropriate for the target variable or component -to which it is being unmarshaled. -
  • - -
  • -The encoding/json's -Decoder -type has a new method that provides a streaming interface for decoding -a JSON document: -Token. -It also interoperates with the existing functionality of Decode, -which will continue a decode operation already started with Decoder.Token. -
  • - -
  • -The flag package -has a new function, UnquoteUsage, -to assist in the creation of usage messages using the new convention -described above. -
  • - -
  • -In the fmt package, -a value of type Value now -prints what it holds, rather than use the reflect.Value's Stringer -method, which produces things like <int Value>. -
  • - -
  • -The EmptyStmt type -in the go/ast package now -has a boolean Implicit field that records whether the -semicolon was implicitly added or was present in the source. -
  • - -
  • -For forward compatibility the go/build package -reserves GOARCH values for a number of architectures that Go might support one day. -This is not a promise that it will. -Also, the Package struct -now has a PkgTargetRoot field that stores the -architecture-dependent root directory in which to install, if known. -
  • - -
  • -The (newly migrated) go/types -package allows one to control the prefix attached to package-level names using -the new Qualifier -function type as an argument to several functions. This is an API change for -the package, but since it is new to the core, it is not breaking the Go 1 compatibility -rules since code that uses the package must explicitly ask for it at its new location. -To update, run -go fix on your package. -
  • - -
  • -In the image package, -the Rectangle type -now implements the Image interface, -so a Rectangle can serve as a mask when drawing. -
  • - -
  • -Also in the image package, -to assist in the handling of some JPEG images, -there is now support for 4:1:1 and 4:1:0 YCbCr subsampling and basic -CMYK support, represented by the new image.CMYK struct. -
  • - -
  • -The image/color package -adds basic CMYK support, through the new -CMYK struct, -the CMYKModel color model, and the -CMYKToRGB function, as -needed by some JPEG images. -
  • - -
  • -Also in the image/color package, -the conversion of a YCbCr -value to RGBA has become more precise. -Previously, the low 8 bits were just an echo of the high 8 bits; -now they contain more accurate information. -Because of the echo property of the old code, the operation -uint8(r) to extract an 8-bit red value worked, but is incorrect. -In Go 1.5, that operation may yield a different value. -The correct code is, and always was, to select the high 8 bits: -uint8(r>>8). -Incidentally, the image/draw package -provides better support for such conversions; see -this blog post -for more information. -
  • - -
  • -Finally, as of Go 1.5 the closest match check in -Index -now honors the alpha channel. -
  • - -
  • -The image/gif package -includes a couple of generalizations. -A multiple-frame GIF file can now have an overall bounds different -from all the contained single frames' bounds. -Also, the GIF struct -now has a Disposal field -that specifies the disposal method for each frame. -
  • - -
  • -The io package -adds a CopyBuffer function -that is like Copy but -uses a caller-provided buffer, permitting control of allocation and buffer size. -
  • - -
  • -The log package -has a new LUTC flag -that causes time stamps to be printed in the UTC time zone. -It also adds a SetOutput method -for user-created loggers. -
  • - -
  • -In Go 1.4, Max was not detecting all possible NaN bit patterns. -This is fixed in Go 1.5, so programs that use math.Max on data including NaNs may behave differently, -but now correctly according to the IEEE754 definition of NaNs. -
  • - -
  • -The math/big package -adds a new Jacobi -function for integers and a new -ModSqrt -method for the Int type. -
  • - -
  • -The mime package -adds a new WordDecoder type -to decode MIME headers containing RFC 204-encoded words. -It also provides BEncoding and -QEncoding -as implementations of the encoding schemes of RFC 2045 and RFC 2047. -
  • - -
  • -The mime package also adds an -ExtensionsByType -function that returns the MIME extensions know to be associated with a given MIME type. -
  • - -
  • -There is a new mime/quotedprintable -package that implements the quoted-printable encoding defined by RFC 2045. -
  • - -
  • -The net package will now -Dial hostnames by trying each -IP address in order until one succeeds. -The Dialer.DualStack -mode now implements Happy Eyeballs -(RFC 6555) by giving the -first address family a 300ms head start; this value can be overridden by -the new Dialer.FallbackDelay. -
  • - -
  • -A number of inconsistencies in the types returned by errors in the -net package have been -tidied up. -Most now return an -OpError value -with more information than before. -Also, the OpError -type now includes a Source field that holds the local -network address. -
  • - -
  • -The net/http package now -has support for setting trailers from a server Handler. -For details, see the documentation for -ResponseWriter. -
  • - -
  • -There is a new method to cancel a net/http -Request by setting the new -Request.Cancel -field. -It is supported by http.Transport. -The Cancel field's type is compatible with the -context.Context.Done -return value. -
  • - -
  • -Also in the net/http package, -there is code to ignore the zero Time value -in the ServeContent function. -As of Go 1.5, it now also ignores a time value equal to the Unix epoch. -
  • - -
  • -The net/http/fcgi package -exports two new errors, -ErrConnClosed and -ErrRequestAborted, -to report the corresponding error conditions. -
  • - -
  • -The net/http/cgi package -had a bug that mishandled the values of the environment variables -REMOTE_ADDR and REMOTE_HOST. -This has been fixed. -Also, starting with Go 1.5 the package sets the REMOTE_PORT -variable. -
  • - -
  • -The net/mail package -adds an AddressParser -type that can parse mail addresses. -
  • - -
  • -The net/smtp package -now has a TLSConnectionState -accessor to the Client -type that returns the client's TLS state. -
  • - -
  • -The os package -has a new LookupEnv function -that is similar to Getenv -but can distinguish between an empty environment variable and a missing one. -
  • - -
  • -The os/signal package -adds new Ignore and -Reset functions. -
  • - -
  • -The runtime, -runtime/trace, -and net/http/pprof packages -each have new functions to support the tracing facilities described above: -ReadTrace, -StartTrace, -StopTrace, -Start, -Stop, and -Trace. -See the respective documentation for details. -
  • - -
  • -The runtime/pprof package -by default now includes overall memory statistics in all memory profiles. -
  • - -
  • -The strings package -has a new Compare function. -This is present to provide symmetry with the bytes package -but is otherwise unnecessary as strings support comparison natively. -
  • - -
  • -The WaitGroup implementation in -package sync -now diagnoses code that races a call to Add -against a return from Wait. -If it detects this condition, the implementation panics. -
  • - -
  • -In the syscall package, -the Linux SysProcAttr struct now has a -GidMappingsEnableSetgroups field, made necessary -by security changes in Linux 3.19. -On all Unix systems, the struct also has new Foreground and Pgid fields -to provide more control when exec'ing. -On Darwin, there is now a Syscall9 function -to support calls with too many arguments. -
  • - -
  • -The testing/quick will now -generate nil values for pointer types, -making it possible to use with recursive data structures. -Also, the package now supports generation of array types. -
  • - -
  • -In the text/template and -html/template packages, -integer constants too large to be represented as a Go integer now trigger a -parse error. Before, they were silently converted to floating point, losing -precision. -
  • - -
  • -Also in the text/template and -html/template packages, -a new Option method -allows customization of the behavior of the template during execution. -The sole implemented option allows control over how a missing key is -handled when indexing a map. -The default, which can now be overridden, is as before: to continue with an invalid value. -
  • - -
  • -The time package's -Time type has a new method -AppendFormat, -which can be used to avoid allocation when printing a time value. -
  • - -
  • -The unicode package and associated -support throughout the system has been upgraded from version 7.0 to -Unicode 8.0. -
  • - -
diff --git a/_content/doc/go1.6.html b/_content/doc/go1.6.html deleted file mode 100644 index 1bcfe4687e..0000000000 --- a/_content/doc/go1.6.html +++ /dev/null @@ -1,920 +0,0 @@ - - - - - - -

Introduction to Go 1.6

- -

-The latest Go release, version 1.6, arrives six months after 1.5. -Most of its changes are in the implementation of the language, runtime, and libraries. -There are no changes to the language specification. -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. -

- -

-The release adds new ports to Linux on 64-bit MIPS and Android on 32-bit x86; -defined and enforced rules for sharing Go pointers with C; -transparent, automatic support for HTTP/2; -and a new mechanism for template reuse. -

- -

Changes to the language

- -

-There are no language changes in this release. -

- -

Ports

- -

-Go 1.6 adds experimental ports to -Linux on 64-bit MIPS (linux/mips64 and linux/mips64le). -These ports support cgo but only with internal linking. -

- -

-Go 1.6 also adds an experimental port to Android on 32-bit x86 (android/386). -

- -

-On FreeBSD, Go 1.6 defaults to using clang, not gcc, as the external C compiler. -

- -

-On Linux on little-endian 64-bit PowerPC (linux/ppc64le), -Go 1.6 now supports cgo with external linking and -is roughly feature complete. -

- -

-On NaCl, Go 1.5 required SDK version pepper-41. -Go 1.6 adds support for later SDK versions. -

- -

-On 32-bit x86 systems using the -dynlink or -shared compilation modes, -the register CX is now overwritten by certain memory references and should -be avoided in hand-written assembly. -See the assembly documentation for details. -

- -

Tools

- -

Cgo

- -

-There is one major change to cgo, along with one minor change. -

- -

-The major change is the definition of rules for sharing Go pointers with C code, -to ensure that such C code can coexist with Go's garbage collector. -Briefly, Go and C may share memory allocated by Go -when a pointer to that memory is passed to C as part of a cgo call, -provided that the memory itself contains no pointers to Go-allocated memory, -and provided that C does not retain the pointer after the call returns. -These rules are checked by the runtime during program execution: -if the runtime detects a violation, it prints a diagnosis and crashes the program. -The checks can be disabled by setting the environment variable -GODEBUG=cgocheck=0, but note that the vast majority of -code identified by the checks is subtly incompatible with garbage collection -in one way or another. -Disabling the checks will typically only lead to more mysterious failure modes. -Fixing the code in question should be strongly preferred -over turning off the checks. -See the cgo documentation for more details. -

- -

-The minor change is -the addition of explicit C.complexfloat and C.complexdouble types, -separate from Go's complex64 and complex128. -Matching the other numeric types, C's complex types and Go's complex type are -no longer interchangeable. -

- -

Compiler Toolchain

- -

-The compiler toolchain is mostly unchanged. -Internally, the most significant change is that the parser is now hand-written -instead of generated from yacc. -

- -

-The compiler, linker, and go command have a new flag -msan, -analogous to -race and only available on linux/amd64, -that enables interoperation with the Clang MemorySanitizer. -Such interoperation is useful mainly for testing a program containing suspect C or C++ code. -

- -

-The linker has a new option -libgcc to set the expected location -of the C compiler support library when linking cgo code. -The option is only consulted when using -linkmode=internal, -and it may be set to none to disable the use of a support library. -

- -

-The implementation of build modes started in Go 1.5 has been expanded to more systems. -This release adds support for the c-shared mode on android/386, android/amd64, -android/arm64, linux/386, and linux/arm64; -for the shared mode on linux/386, linux/arm, linux/amd64, and linux/ppc64le; -and for the new pie mode (generating position-independent executables) on -android/386, android/amd64, android/arm, android/arm64, linux/386, -linux/amd64, linux/arm, linux/arm64, and linux/ppc64le. -See the design document for details. -

- -

-As a reminder, the linker's -X flag changed in Go 1.5. -In Go 1.4 and earlier, it took two arguments, as in -

- -
--X importpath.name value
-
- -

-Go 1.5 added an alternative syntax using a single argument -that is itself a name=value pair: -

- -
--X importpath.name=value
-
- -

-In Go 1.5 the old syntax was still accepted, after printing a warning -suggesting use of the new syntax instead. -Go 1.6 continues to accept the old syntax and print the warning. -Go 1.7 will remove support for the old syntax. -

- -

Gccgo

- -

-The release schedules for the GCC and Go projects do not coincide. -GCC release 5 contains the Go 1.4 version of gccgo. -The next release, GCC 6, will have the Go 1.6.1 version of gccgo. -

- -

Go command

- -

-The go command's basic operation -is unchanged, but there are a number of changes worth noting. -

- -

-Go 1.5 introduced experimental support for vendoring, -enabled by setting the GO15VENDOREXPERIMENT environment variable to 1. -Go 1.6 keeps the vendoring support, no longer considered experimental, -and enables it by default. -It can be disabled explicitly by setting -the GO15VENDOREXPERIMENT environment variable to 0. -Go 1.7 will remove support for the environment variable. -

- -

-The most likely problem caused by enabling vendoring by default happens -in source trees containing an existing directory named vendor that -does not expect to be interpreted according to new vendoring semantics. -In this case, the simplest fix is to rename the directory to anything other -than vendor and update any affected import paths. -

- -

-For details about vendoring, -see the documentation for the go command -and the design document. -

- -

-There is a new build flag, -msan, -that compiles Go with support for the LLVM memory sanitizer. -This is intended mainly for use when linking against C or C++ code -that is being checked with the memory sanitizer. -

- -

Go doc command

- -

-Go 1.5 introduced the -go doc command, -which allows references to packages using only the package name, as in -go doc http. -In the event of ambiguity, the Go 1.5 behavior was to use the package -with the lexicographically earliest import path. -In Go 1.6, ambiguity is resolved by preferring import paths with -fewer elements, breaking ties using lexicographic comparison. -An important effect of this change is that original copies of packages -are now preferred over vendored copies. -Successful searches also tend to run faster. -

- -

Go vet command

- -

-The go vet command now diagnoses -passing function or method values as arguments to Printf, -such as when passing f where f() was intended. -

- -

Performance

- -

-As always, the changes are so general and varied that precise statements -about performance are difficult to make. -Some programs may run faster, some slower. -On average the programs in the Go 1 benchmark suite run a few percent faster in Go 1.6 -than they did in Go 1.5. -The garbage collector's pauses are even lower than in Go 1.5, -especially for programs using -a large amount of memory. -

- -

-There have been significant optimizations bringing more than 10% improvements -to implementations of the -compress/bzip2, -compress/gzip, -crypto/aes, -crypto/elliptic, -crypto/ecdsa, and -sort packages. -

- -

Core library

- -

HTTP/2

- -

-Go 1.6 adds transparent support in the -net/http package -for the new HTTP/2 protocol. -Go clients and servers will automatically use HTTP/2 as appropriate when using HTTPS. -There is no exported API specific to details of the HTTP/2 protocol handling, -just as there is no exported API specific to HTTP/1.1. -

- -

-Programs that must disable HTTP/2 can do so by setting -Transport.TLSNextProto (for clients) -or -Server.TLSNextProto (for servers) -to a non-nil, empty map. -

- -

-Programs that must adjust HTTP/2 protocol-specific details can import and use -golang.org/x/net/http2, -in particular its -ConfigureServer -and -ConfigureTransport -functions. -

- -

Runtime

- -

-The runtime has added lightweight, best-effort detection of concurrent misuse of maps. -As always, if one goroutine is writing to a map, no other goroutine should be -reading or writing the map concurrently. -If the runtime detects this condition, it prints a diagnosis and crashes the program. -The best way to find out more about the problem is to run the program -under the -race detector, -which will more reliably identify the race -and give more detail. -

- -

-For program-ending panics, the runtime now by default -prints only the stack of the running goroutine, -not all existing goroutines. -Usually only the current goroutine is relevant to a panic, -so omitting the others significantly reduces irrelevant output -in a crash message. -To see the stacks from all goroutines in crash messages, set the environment variable -GOTRACEBACK to all -or call -debug.SetTraceback -before the crash, and rerun the program. -See the runtime documentation for details. -

- -

-Updating: -Uncaught panics intended to dump the state of the entire program, -such as when a timeout is detected or when explicitly handling a received signal, -should now call debug.SetTraceback("all") before panicking. -Searching for uses of -signal.Notify may help identify such code. -

- -

-On Windows, Go programs in Go 1.5 and earlier forced -the global Windows timer resolution to 1ms at startup -by calling timeBeginPeriod(1). -Go no longer needs this for good scheduler performance, -and changing the global timer resolution caused problems on some systems, -so the call has been removed. -

- -

-When using -buildmode=c-archive or --buildmode=c-shared to build an archive or a shared -library, the handling of signals has changed. -In Go 1.5 the archive or shared library would install a signal handler -for most signals. -In Go 1.6 it will only install a signal handler for the -synchronous signals needed to handle run-time panics in Go code: -SIGBUS, SIGFPE, SIGSEGV. -See the os/signal package for more -details. -

- -

Reflect

- -

-The -reflect package has -resolved a long-standing incompatibility -between the gc and gccgo toolchains -regarding embedded unexported struct types containing exported fields. -Code that walks data structures using reflection, especially to implement -serialization in the spirit -of the -encoding/json and -encoding/xml packages, -may need to be updated. -

- -

-The problem arises when using reflection to walk through -an embedded unexported struct-typed field -into an exported field of that struct. -In this case, reflect had incorrectly reported -the embedded field as exported, by returning an empty Field.PkgPath. -Now it correctly reports the field as unexported -but ignores that fact when evaluating access to exported fields -contained within the struct. -

- -

-Updating: -Typically, code that previously walked over structs and used -

- -
-f.PkgPath != ""
-
- -

-to exclude inaccessible fields -should now use -

- -
-f.PkgPath != "" && !f.Anonymous
-
- -

-For example, see the changes to the implementations of -encoding/json and -encoding/xml. -

- -

Sorting

- -

-In the -sort -package, -the implementation of -Sort -has been rewritten to make about 10% fewer calls to the -Interface's -Less and Swap -methods, with a corresponding overall time savings. -The new algorithm does choose a different ordering than before -for values that compare equal (those pairs for which Less(i, j) and Less(j, i) are false). -

- -

-Updating: -The definition of Sort makes no guarantee about the final order of equal values, -but the new behavior may still break programs that expect a specific order. -Such programs should either refine their Less implementations -to report the desired order -or should switch to -Stable, -which preserves the original input order -of equal values. -

- -

Templates

- -

-In the -text/template package, -there are two significant new features to make writing templates easier. -

- -

-First, it is now possible to trim spaces around template actions, -which can make template definitions more readable. -A minus sign at the beginning of an action says to trim space before the action, -and a minus sign at the end of an action says to trim space after the action. -For example, the template -

- -
-{{23 -}}
-   <
-{{- 45}}
-
- -

-formats as 23<45. -

- -

-Second, the new {{block}} action, -combined with allowing redefinition of named templates, -provides a simple way to define pieces of a template that -can be replaced in different instantiations. -There is an example -in the text/template package that demonstrates this new feature. -

- -

Minor changes to the library

- -
    - -
  • -The archive/tar package's -implementation corrects many bugs in rare corner cases of the file format. -One visible change is that the -Reader type's -Read method -now presents the content of special file types as being empty, -returning io.EOF immediately. -
  • - -
  • -In the archive/zip package, the -Reader type now has a -RegisterDecompressor method, -and the -Writer type now has a -RegisterCompressor method, -enabling control over compression options for individual zip files. -These take precedence over the pre-existing global -RegisterDecompressor and -RegisterCompressor functions. -
  • - -
  • -The bufio package's -Scanner type now has a -Buffer method, -to specify an initial buffer and maximum buffer size to use during scanning. -This makes it possible, when needed, to scan tokens larger than -MaxScanTokenSize. -Also for the Scanner, the package now defines the -ErrFinalToken error value, for use by -split functions to abort processing or to return a final empty token. -
  • - -
  • -The compress/flate package -has deprecated its -ReadError and -WriteError error implementations. -In Go 1.5 they were only rarely returned when an error was encountered; -now they are never returned, although they remain defined for compatibility. -
  • - -
  • -The compress/flate, -compress/gzip, and -compress/zlib packages -now report -io.ErrUnexpectedEOF for truncated input streams, instead of -io.EOF. -
  • - -
  • -The crypto/cipher package now -overwrites the destination buffer in the event of a GCM decryption failure. -This is to allow the AESNI code to avoid using a temporary buffer. -
  • - -
  • -The crypto/tls package -has a variety of minor changes. -It now allows -Listen -to succeed when the -Config -has a nil Certificates, as long as the GetCertificate callback is set, -it adds support for RSA with AES-GCM cipher suites, -and -it adds a -RecordHeaderError -to allow clients (in particular, the net/http package) -to report a better error when attempting a TLS connection to a non-TLS server. -
  • - -
  • -The crypto/x509 package -now permits certificates to contain negative serial numbers -(technically an error, but unfortunately common in practice), -and it defines a new -InsecureAlgorithmError -to give a better error message when rejecting a certificate -signed with an insecure algorithm like MD5. -
  • - -
  • -The debug/dwarf and -debug/elf packages -together add support for compressed DWARF sections. -User code needs no updating: the sections are decompressed automatically when read. -
  • - -
  • -The debug/elf package -adds support for general compressed ELF sections. -User code needs no updating: the sections are decompressed automatically when read. -However, compressed -Sections do not support random access: -they have a nil ReaderAt field. -
  • - -
  • -The encoding/asn1 package -now exports -tag and class constants -useful for advanced parsing of ASN.1 structures. -
  • - -
  • -Also in the encoding/asn1 package, -Unmarshal now rejects various non-standard integer and length encodings. -
  • - -
  • -The encoding/base64 package's -Decoder has been fixed -to process the final bytes of its input. Previously it processed as many four-byte tokens as -possible but ignored the remainder, up to three bytes. -The Decoder therefore now handles inputs in unpadded encodings (like -RawURLEncoding) correctly, -but it also rejects inputs in padded encodings that are truncated or end with invalid bytes, -such as trailing spaces. -
  • - -
  • -The encoding/json package -now checks the syntax of a -Number -before marshaling it, requiring that it conforms to the JSON specification for numeric values. -As in previous releases, the zero Number (an empty string) is marshaled as a literal 0 (zero). -
  • - -
  • -The encoding/xml package's -Marshal -function now supports a cdata attribute, such as chardata -but encoding its argument in one or more <![CDATA[ ... ]]> tags. -
  • - -
  • -Also in the encoding/xml package, -Decoder's -Token method -now reports an error when encountering EOF before seeing all open tags closed, -consistent with its general requirement that tags in the input be properly matched. -To avoid that requirement, use -RawToken. -
  • - -
  • -The fmt package now allows -any integer type as an argument to -Printf's * width and precision specification. -In previous releases, the argument to * was required to have type int. -
  • - -
  • -Also in the fmt package, -Scanf can now scan hexadecimal strings using %X, as an alias for %x. -Both formats accept any mix of upper- and lower-case hexadecimal. -
  • - -
  • -The image -and -image/color packages -add -NYCbCrA -and -NYCbCrA -types, to support Y'CbCr images with non-premultiplied alpha. -
  • - -
  • -The io package's -MultiWriter -implementation now implements a WriteString method, -for use by -WriteString. -
  • - -
  • -In the math/big package, -Int adds -Append -and -Text -methods to give more control over printing. -
  • - -
  • -Also in the math/big package, -Float now implements -encoding.TextMarshaler and -encoding.TextUnmarshaler, -allowing it to be serialized in a natural form by the -encoding/json and -encoding/xml packages. -
  • - -
  • -Also in the math/big package, -Float's -Append method now supports the special precision argument -1. -As in -strconv.ParseFloat, -precision -1 means to use the smallest number of digits necessary such that -Parse -reading the result into a Float of the same precision -will yield the original value. -
  • - -
  • -The math/rand package -adds a -Read -function, and likewise -Rand adds a -Read method. -These make it easier to generate pseudorandom test data. -Note that, like the rest of the package, -these should not be used in cryptographic settings; -for such purposes, use the crypto/rand package instead. -
  • - -
  • -The net package's -ParseMAC function now accepts 20-byte IP-over-InfiniBand (IPoIB) link-layer addresses. -
  • - - -
  • -Also in the net package, -there have been a few changes to DNS lookups. -First, the -DNSError error implementation now implements -Error, -and in particular its new -IsTemporary -method returns true for DNS server errors. -Second, DNS lookup functions such as -LookupAddr -now return rooted domain names (with a trailing dot) -on Plan 9 and Windows, to match the behavior of Go on Unix systems. -
  • - -
  • -The net/http package has -a number of minor additions beyond the HTTP/2 support already discussed. -First, the -FileServer now sorts its generated directory listings by file name. -Second, the -ServeFile function now refuses to serve a result -if the request's URL path contains “..” (dot-dot) as a path element. -Programs should typically use FileServer and -Dir -instead of calling ServeFile directly. -Programs that need to serve file content in response to requests for URLs containing dot-dot can -still call ServeContent. -Third, the -Client now allows user code to set the -Expect: 100-continue header (see -Transport.ExpectContinueTimeout). -Fourth, there are -five new error codes: -StatusPreconditionRequired (428), -StatusTooManyRequests (429), -StatusRequestHeaderFieldsTooLarge (431), and -StatusNetworkAuthenticationRequired (511) from RFC 6585, -as well as the recently-approved -StatusUnavailableForLegalReasons (451). -Fifth, the implementation and documentation of -CloseNotifier -has been substantially changed. -The Hijacker -interface now works correctly on connections that have previously -been used with CloseNotifier. -The documentation now describes when CloseNotifier -is expected to work. -
  • - -
  • -Also in the net/http package, -there are a few changes related to the handling of a -Request data structure with its Method field set to the empty string. -An empty Method field has always been documented as an alias for "GET" -and it remains so. -However, Go 1.6 fixes a few routines that did not treat an empty -Method the same as an explicit "GET". -Most notably, in previous releases -Client followed redirects only with -Method set explicitly to "GET"; -in Go 1.6 Client also follows redirects for the empty Method. -Finally, -NewRequest accepts a method argument that has not been -documented as allowed to be empty. -In past releases, passing an empty method argument resulted -in a Request with an empty Method field. -In Go 1.6, the resulting Request always has an initialized -Method field: if its argument is an empty string, NewRequest -sets the Method field in the returned Request to "GET". -
  • - -
  • -The net/http/httptest package's -ResponseRecorder now initializes a default Content-Type header -using the same content-sniffing algorithm as in -http.Server. -
  • - -
  • -The net/url package's -Parse is now stricter and more spec-compliant regarding the parsing -of host names. -For example, spaces in the host name are no longer accepted. -
  • - -
  • -Also in the net/url package, -the Error type now implements -net.Error. -
  • - -
  • -The os package's -IsExist, -IsNotExist, -and -IsPermission -now return correct results when inquiring about an -SyscallError. -
  • - -
  • -On Unix-like systems, when a write -to os.Stdout -or os.Stderr (more precisely, an os.File -opened for file descriptor 1 or 2) fails due to a broken pipe error, -the program will raise a SIGPIPE signal. -By default this will cause the program to exit; this may be changed by -calling the -os/signal -Notify function -for syscall.SIGPIPE. -A write to a broken pipe on a file descriptor other 1 or 2 will simply -return syscall.EPIPE (possibly wrapped in -os.PathError -and/or os.SyscallError) -to the caller. -The old behavior of raising an uncatchable SIGPIPE signal -after 10 consecutive writes to a broken pipe no longer occurs. -
  • - -
  • -In the os/exec package, -Cmd's -Output method continues to return an -ExitError when a command exits with an unsuccessful status. -If standard error would otherwise have been discarded, -the returned ExitError now holds a prefix and suffix -(currently 32 kB) of the failed command's standard error output, -for debugging or for inclusion in error messages. -The ExitError's -String -method does not show the captured standard error; -programs must retrieve it from the data structure -separately. -
  • - -
  • -On Windows, the path/filepath package's -Join function now correctly handles the case when the base is a relative drive path. -For example, Join(`c:`, `a`) now -returns `c:a` instead of `c:\a` as in past releases. -This may affect code that expects the incorrect result. -
  • - -
  • -In the regexp package, -the -Regexp type has always been safe for use by -concurrent goroutines. -It uses a sync.Mutex to protect -a cache of scratch spaces used during regular expression searches. -Some high-concurrency servers using the same Regexp from many goroutines -have seen degraded performance due to contention on that mutex. -To help such servers, Regexp now has a -Copy method, -which makes a copy of a Regexp that shares most of the structure -of the original but has its own scratch space cache. -Two goroutines can use different copies of a Regexp -without mutex contention. -A copy does have additional space overhead, so Copy -should only be used when contention has been observed. -
  • - -
  • -The strconv package adds -IsGraphic, -similar to IsPrint. -It also adds -QuoteToGraphic, -QuoteRuneToGraphic, -AppendQuoteToGraphic, -and -AppendQuoteRuneToGraphic, -analogous to -QuoteToASCII, -QuoteRuneToASCII, -and so on. -The ASCII family escapes all space characters except ASCII space (U+0020). -In contrast, the Graphic family does not escape any Unicode space characters (category Zs). -
  • - -
  • -In the testing package, -when a test calls -t.Parallel, -that test is paused until all non-parallel tests complete, and then -that test continues execution with all other parallel tests. -Go 1.6 changes the time reported for such a test: -previously the time counted only the parallel execution, -but now it also counts the time from the start of testing -until the call to t.Parallel. -
  • - -
  • -The text/template package -contains two minor changes, in addition to the major changes -described above. -First, it adds a new -ExecError type -returned for any error during -Execute -that does not originate in a Write to the underlying writer. -Callers can distinguish template usage errors from I/O errors by checking for -ExecError. -Second, the -Funcs method -now checks that the names used as keys in the -FuncMap -are identifiers that can appear in a template function invocation. -If not, Funcs panics. -
  • - -
  • -The time package's -Parse function has always rejected any day of month larger than 31, -such as January 32. -In Go 1.6, Parse now also rejects February 29 in non-leap years, -February 30, February 31, April 31, June 31, September 31, and November 31. -
  • - -
diff --git a/_content/doc/go1.7.html b/_content/doc/go1.7.html deleted file mode 100644 index 1f777fed13..0000000000 --- a/_content/doc/go1.7.html +++ /dev/null @@ -1,1279 +0,0 @@ - - - - - - - - -

Introduction to Go 1.7

- -

-The latest Go release, version 1.7, arrives six months after 1.6. -Most of its changes are in the implementation of the toolchain, runtime, and libraries. -There is one minor change to the language specification. -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. -

- -

-The release adds a port to IBM LinuxOne; -updates the x86-64 compiler back end to generate more efficient code; -includes the context package, promoted from the -x/net subrepository -and now used in the standard library; -and adds support in the testing package for -creating hierarchies of tests and benchmarks. -The release also finalizes the vendoring support -started in Go 1.5, making it a standard feature. -

- -

Changes to the language

- -

-There is one tiny language change in this release. -The section on terminating statements -clarifies that to determine whether a statement list ends in a terminating statement, -the “final non-empty statement” is considered the end, -matching the existing behavior of the gc and gccgo compiler toolchains. -In earlier releases the definition referred only to the “final statement,” -leaving the effect of trailing empty statements at the least unclear. -The go/types -package has been updated to match the gc and gccgo compiler toolchains -in this respect. -This change has no effect on the correctness of existing programs. -

- -

Ports

- -

-Go 1.7 adds support for macOS 10.12 Sierra. -Binaries built with versions of Go before 1.7 will not work -correctly on Sierra. -

- -

-Go 1.7 adds an experimental port to Linux on z Systems (linux/s390x) -and the beginning of a port to Plan 9 on ARM (plan9/arm). -

- -

-The experimental ports to Linux on 64-bit MIPS (linux/mips64 and linux/mips64le) -added in Go 1.6 now have full support for cgo and external linking. -

- -

-The experimental port to Linux on little-endian 64-bit PowerPC (linux/ppc64le) -now requires the POWER8 architecture or later. -Big-endian 64-bit PowerPC (linux/ppc64) only requires the -POWER5 architecture. -

- -

-The OpenBSD port now requires OpenBSD 5.6 or later, for access to the getentropy(2) system call. -

- -

Known Issues

- -

-There are some instabilities on FreeBSD that are known but not understood. -These can lead to program crashes in rare cases. -See issue 16136, -issue 15658, -and issue 16396. -Any help in solving these FreeBSD-specific issues would be appreciated. -

- -

Tools

- -

Assembler

- -

-For 64-bit ARM systems, the vector register names have been -corrected to V0 through V31; -previous releases incorrectly referred to them as V32 through V63. -

- -

-For 64-bit x86 systems, the following instructions have been added: -PCMPESTRI, -RORXL, -RORXQ, -VINSERTI128, -VPADDD, -VPADDQ, -VPALIGNR, -VPBLENDD, -VPERM2F128, -VPERM2I128, -VPOR, -VPSHUFB, -VPSHUFD, -VPSLLD, -VPSLLDQ, -VPSLLQ, -VPSRLD, -VPSRLDQ, -and -VPSRLQ. -

- -

Compiler Toolchain

- -

-This release includes a new code generation back end for 64-bit x86 systems, -following a proposal from 2015 -that has been under development since then. -The new back end, based on -SSA, -generates more compact, more efficient code -and provides a better platform for optimizations -such as bounds check elimination. -The new back end reduces the CPU time required by -our benchmark programs by 5-35%. -

- -

-For this release, the new back end can be disabled by passing --ssa=0 to the compiler. -If you find that your program compiles or runs successfully -only with the new back end disabled, please -file a bug report. -

- -

-The format of exported metadata written by the compiler in package archives has changed: -the old textual format has been replaced by a more compact binary format. -This results in somewhat smaller package archives and fixes a few -long-standing corner case bugs. -

- -

-For this release, the new export format can be disabled by passing --newexport=0 to the compiler. -If you find that your program compiles or runs successfully -only with the new export format disabled, please -file a bug report. -

- -

-The linker's -X option no longer supports the unusual two-argument form --X name value, -as announced in the Go 1.6 release -and in warnings printed by the linker. -Use -X name=value instead. -

- -

-The compiler and linker have been optimized and run significantly faster in this release than in Go 1.6, -although they are still slower than we would like and will continue to be optimized in future releases. -

- -

-Due to changes across the compiler toolchain and standard library, -binaries built with this release should typically be smaller than binaries -built with Go 1.6, -sometimes by as much as 20-30%. -

- -

-On x86-64 systems, Go programs now maintain stack frame pointers -as expected by profiling tools like Linux's perf and Intel's VTune, -making it easier to analyze and optimize Go programs using these tools. -The frame pointer maintenance has a small run-time overhead that varies -but averages around 2%. We hope to reduce this cost in future releases. -To build a toolchain that does not use frame pointers, set -GOEXPERIMENT=noframepointer when running -make.bash, make.bat, or make.rc. -

- -

Cgo

- -

-Packages using cgo may now include -Fortran source files (in addition to C, C++, Objective C, and SWIG), -although the Go bindings must still use C language APIs. -

- -

-Go bindings may now use a new helper function C.CBytes. -In contrast to C.CString, which takes a Go string -and returns a *C.byte (a C char*), -C.CBytes takes a Go []byte -and returns an unsafe.Pointer (a C void*). -

- -

-Packages and binaries built using cgo have in past releases -produced different output on each build, -due to the embedding of temporary directory names. -When using this release with -new enough versions of GCC or Clang -(those that support the -fdebug-prefix-map option), -those builds should finally be deterministic. -

- -

Gccgo

- -

-Due to the alignment of Go's semiannual release schedule with GCC's annual release schedule, -GCC release 6 contains the Go 1.6.1 version of gccgo. -The next release, GCC 7, will likely have the Go 1.8 version of gccgo. -

- -

Go command

- -

-The go command's basic operation -is unchanged, but there are a number of changes worth noting. -

- -

-This release removes support for the GO15VENDOREXPERIMENT environment variable, -as announced in the Go 1.6 release. -Vendoring support -is now a standard feature of the go command and toolchain. -

- -

-The Package data structure made available to -“go list” now includes a -StaleReason field explaining why a particular package -is or is not considered stale (in need of rebuilding). -This field is available to the -f or -json -options and is useful for understanding why a target is being rebuilt. -

- -

-The “go get” command now supports -import paths referring to git.openstack.org. -

- -

-This release adds experimental, minimal support for building programs using -binary-only packages, -packages distributed in binary form -without the corresponding source code. -This feature is needed in some commercial settings -but is not intended to be fully integrated into the rest of the toolchain. -For example, tools that assume access to complete source code -will not work with such packages, and there are no plans to support -such packages in the “go get” command. -

- -

Go doc

- -

-The “go doc” command -now groups constructors with the type they construct, -following godoc. -

- -

Go vet

- -

-The “go vet” command -has more accurate analysis in its -copylock and -printf checks, -and a new -tests check that checks the name and signature of likely test functions. -To avoid confusion with the new -tests check, the old, unadvertised --test option has been removed; it was equivalent to -all -shadow. -

- -

-The vet command also has a new check, --lostcancel, which detects failure to call the -cancellation function returned by the WithCancel, -WithTimeout, and WithDeadline functions in -Go 1.7's new context package (see below). -Failure to call the function prevents the new Context -from being reclaimed until its parent is canceled. -(The background context is never canceled.) -

- -

Go tool dist

- -

-The new subcommand “go tool dist list” -prints all supported operating system/architecture pairs. -

- -

Go tool trace

- -

-The “go tool trace” command, -introduced in Go 1.5, -has been refined in various ways. -

- -

-First, collecting traces is significantly more efficient than in past releases. -In this release, the typical execution-time overhead of collecting a trace is about 25%; -in past releases it was at least 400%. -Second, trace files now include file and line number information, -making them more self-contained and making the -original executable optional when running the trace tool. -Third, the trace tool now breaks up large traces to avoid limits -in the browser-based viewer. -

- -

-Although the trace file format has changed in this release, -the Go 1.7 tools can still read traces from earlier releases. -

- -

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 and -optimizations in the core library. -On x86-64 systems, many programs will run significantly faster, -due to improvements in generated code brought by the -new compiler back end. -As noted above, in our own benchmarks, -the code generation changes alone typically reduce program CPU time by 5-35%. -

- -

- -There have been significant optimizations bringing more than 10% improvements -to implementations in the -crypto/sha1, -crypto/sha256, -encoding/binary, -fmt, -hash/adler32, -hash/crc32, -hash/crc64, -image/color, -math/big, -strconv, -strings, -unicode, -and -unicode/utf16 -packages. -

- -

-Garbage collection pauses should be significantly shorter than they -were in Go 1.6 for programs with large numbers of idle goroutines, -substantial stack size fluctuation, or large package-level variables. -

- -

Core library

- -

Context

- -

-Go 1.7 moves the golang.org/x/net/context package -into the standard library as context. -This allows the use of contexts for cancellation, timeouts, and passing -request-scoped data in other standard library packages, -including -net, -net/http, -and -os/exec, -as noted below. -

- -

-For more information about contexts, see the -package documentation -and the Go blog post -“Go Concurrent Patterns: Context.” -

- -

HTTP Tracing

- -

-Go 1.7 introduces net/http/httptrace, -a package that provides mechanisms for tracing events within HTTP requests. -

- -

Testing

- -

-The testing package now supports the definition -of tests with subtests and benchmarks with sub-benchmarks. -This support makes it easy to write table-driven benchmarks -and to create hierarchical tests. -It also provides a way to share common setup and tear-down code. -See the package documentation for details. -

- -

Runtime

- -

-All panics started by the runtime now use panic values -that implement both the -builtin error, -and -runtime.Error, -as -required by the language specification. -

- -

-During panics, if a signal's name is known, it will be printed in the stack trace. -Otherwise, the signal's number will be used, as it was before Go1.7. -

- -

-The new function -KeepAlive -provides an explicit mechanism for declaring -that an allocated object must be considered reachable -at a particular point in a program, -typically to delay the execution of an associated finalizer. -

- -

-The new function -CallersFrames -translates a PC slice obtained from -Callers -into a sequence of frames corresponding to the call stack. -This new API should be preferred instead of direct use of -FuncForPC, -because the frame sequence can more accurately describe -call stacks with inlined function calls. -

- -

-The new function -SetCgoTraceback -facilitates tighter integration between Go and C code executing -in the same process called using cgo. -

- -

-On 32-bit systems, the runtime can now use memory allocated -by the operating system anywhere in the address space, -eliminating the -“memory allocated by OS not in usable range” failure -common in some environments. -

- -

-The runtime can now return unused memory to the operating system on -all architectures. -In Go 1.6 and earlier, the runtime could not -release memory on ARM64, 64-bit PowerPC, or MIPS. -

- -

-On Windows, Go programs in Go 1.5 and earlier forced -the global Windows timer resolution to 1ms at startup -by calling timeBeginPeriod(1). -Changing the global timer resolution caused problems on some systems, -and testing suggested that the call was not needed for good scheduler performance, -so Go 1.6 removed the call. -Go 1.7 brings the call back: under some workloads the call -is still needed for good scheduler performance. -

- - -

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. -

- -
bufio
- -
-

-In previous releases of Go, if -Reader's -Peek method -were asked for more bytes than fit in the underlying buffer, -it would return an empty slice and the error ErrBufferFull. -Now it returns the entire underlying buffer, still accompanied by the error ErrBufferFull. -

-
-
- -
bytes
- -
-

-The new functions -ContainsAny and -ContainsRune -have been added for symmetry with -the strings package. -

- -

-In previous releases of Go, if -Reader's -Read method -were asked for zero bytes with no data remaining, it would -return a count of 0 and no error. -Now it returns a count of 0 and the error -io.EOF. -

- -

-The -Reader type has a new method -Reset to allow reuse of a Reader. -

-
-
- -
compress/flate
- -
-

-There are many performance optimizations throughout the package. -Decompression speed is improved by about 10%, -while compression for DefaultCompression is twice as fast. -

- -

-In addition to those general improvements, -the -BestSpeed -compressor has been replaced entirely and uses an -algorithm similar to Snappy, -resulting in about a 2.5X speed increase, -although the output can be 5-10% larger than with the previous algorithm. -

- -

-There is also a new compression level -HuffmanOnly -that applies Huffman but not Lempel-Ziv encoding. -Forgoing Lempel-Ziv encoding means that -HuffmanOnly runs about 3X faster than the new BestSpeed -but at the cost of producing compressed outputs that are 20-40% larger than those -generated by the new BestSpeed. -

- -

-It is important to note that both -BestSpeed and HuffmanOnly produce a compressed output that is -RFC 1951 compliant. -In other words, any valid DEFLATE decompressor will continue to be able to decompress these outputs. -

- -

-Lastly, there is a minor change to the decompressor's implementation of -io.Reader. In previous versions, -the decompressor deferred reporting -io.EOF until exactly no more bytes could be read. -Now, it reports -io.EOF more eagerly when reading the last set of bytes. -

-
-
- -
crypto/tls
- -
-

-The TLS implementation sends the first few data packets on each connection -using small record sizes, gradually increasing to the TLS maximum record size. -This heuristic reduces the amount of data that must be received before -the first packet can be decrypted, improving communication latency over -low-bandwidth networks. -Setting -Config's -DynamicRecordSizingDisabled field to true -forces the behavior of Go 1.6 and earlier, where packets are -as large as possible from the start of the connection. -

- -

-The TLS client now has optional, limited support for server-initiated renegotiation, -enabled by setting the -Config's -Renegotiation field. -This is needed for connecting to many Microsoft Azure servers. -

- -

-The errors returned by the package now consistently begin with a -tls: prefix. -In past releases, some errors used a crypto/tls: prefix, -some used a tls: prefix, and some had no prefix at all. -

- -

-When generating self-signed certificates, the package no longer sets the -“Authority Key Identifier” field by default. -

-
-
- -
crypto/x509
- -
-

-The new function -SystemCertPool -provides access to the entire system certificate pool if available. -There is also a new associated error type -SystemRootsError. -

-
-
- -
debug/dwarf
- -
-

-The -Reader type's new -SeekPC method and the -Data type's new -Ranges method -help to find the compilation unit to pass to a -LineReader -and to identify the specific function for a given program counter. -

-
-
- -
debug/elf
- -
-

-The new -R_390 relocation type -and its many predefined constants -support the S390 port. -

-
-
- -
encoding/asn1
- -
-

-The ASN.1 decoder now rejects non-minimal integer encodings. -This may cause the package to reject some invalid but formerly accepted ASN.1 data. -

-
-
- -
encoding/json
- -
-

-The -Encoder's new -SetIndent method -sets the indentation parameters for JSON encoding, -like in the top-level -Indent function. -

- -

-The -Encoder's new -SetEscapeHTML method -controls whether the -&, <, and > -characters in quoted strings should be escaped as -\u0026, \u003c, and \u003e, -respectively. -As in previous releases, the encoder defaults to applying this escaping, -to avoid certain problems that can arise when embedding JSON in HTML. -

- -

-In earlier versions of Go, this package only supported encoding and decoding -maps using keys with string types. -Go 1.7 adds support for maps using keys with integer types: -the encoding uses a quoted decimal representation as the JSON key. -Go 1.7 also adds support for encoding maps using non-string keys that implement -the MarshalText -(see -encoding.TextMarshaler) -method, -as well as support for decoding maps using non-string keys that implement -the UnmarshalText -(see -encoding.TextUnmarshaler) -method. -These methods are ignored for keys with string types in order to preserve -the encoding and decoding used in earlier versions of Go. -

- -

-When encoding a slice of typed bytes, -Marshal -now generates an array of elements encoded using -that byte type's -MarshalJSON -or -MarshalText -method if present, -only falling back to the default base64-encoded string data if neither method is available. -Earlier versions of Go accept both the original base64-encoded string encoding -and the array encoding (assuming the byte type also implements -UnmarshalJSON -or -UnmarshalText -as appropriate), -so this change should be semantically backwards compatible with earlier versions of Go, -even though it does change the chosen encoding. -

-
-
- -
go/build
- -
-

-To implement the go command's new support for binary-only packages -and for Fortran code in cgo-based packages, -the -Package type -adds new fields BinaryOnly, CgoFFLAGS, and FFiles. -

-
-
- -
go/doc
- -
-

-To support the corresponding change in go test described above, -Example struct adds an Unordered field -indicating whether the example may generate its output lines in any order. -

-
-
- -
io
- -
-

-The package adds new constants -SeekStart, SeekCurrent, and SeekEnd, -for use with -Seeker -implementations. -These constants are preferred over os.SEEK_SET, os.SEEK_CUR, and os.SEEK_END, -but the latter will be preserved for compatibility. -

-
-
- -
math/big
- -
-

-The -Float type adds -GobEncode and -GobDecode methods, -so that values of type Float can now be encoded and decoded using the -encoding/gob -package. -

-
-
- -
math/rand
- -
-

-The -Read function and -Rand's -Read method -now produce a pseudo-random stream of bytes that is consistent and not -dependent on the size of the input buffer. -

- -

-The documentation clarifies that -Rand's Seed -and Read methods -are not safe to call concurrently, though the global -functions Seed -and Read are (and have -always been) safe. -

-
-
- -
mime/multipart
- -
-

-The -Writer -implementation now emits each multipart section's header sorted by key. -Previously, iteration over a map caused the section header to use a -non-deterministic order. -

-
-
- -
net
- -
-

-As part of the introduction of context, the -Dialer type has a new method -DialContext, like -Dial but adding the -context.Context -for the dial operation. -The context is intended to obsolete the Dialer's -Cancel and Deadline fields, -but the implementation continues to respect them, -for backwards compatibility. -

- -

-The -IP type's -String method has changed its result for invalid IP addresses. -In past releases, if an IP byte slice had length other than 0, 4, or 16, String -returned "?". -Go 1.7 adds the hexadecimal encoding of the bytes, as in "?12ab". -

- -

-The pure Go name resolution -implementation now respects nsswitch.conf's -stated preference for the priority of DNS lookups compared to -local file (that is, /etc/hosts) lookups. -

-
-
- -
net/http
- -
-

-ResponseWriter's -documentation now makes clear that beginning to write the response -may prevent future reads on the request body. -For maximal compatibility, implementations are encouraged to -read the request body completely before writing any part of the response. -

- -

-As part of the introduction of context, the -Request has a new methods -Context, to retrieve the associated context, and -WithContext, to construct a copy of Request -with a modified context. -

- -

-In the -Server implementation, -Serve records in the request context -both the underlying *Server using the key ServerContextKey -and the local address on which the request was received (a -Addr) using the key LocalAddrContextKey. -For example, the address on which a request received is -req.Context().Value(http.LocalAddrContextKey).(net.Addr). -

- -

-The server's Serve method -now only enables HTTP/2 support if the Server.TLSConfig field is nil -or includes "h2" in its TLSConfig.NextProtos. -

- -

-The server implementation now -pads response codes less than 100 to three digits -as required by the protocol, -so that w.WriteHeader(5) uses the HTTP response -status 005, not just 5. -

- -

-The server implementation now correctly sends only one "Transfer-Encoding" header when "chunked" -is set explicitly, following RFC 7230. -

- -

-The server implementation is now stricter about rejecting requests with invalid HTTP versions. -Invalid requests claiming to be HTTP/0.x are now rejected (HTTP/0.9 was never fully supported), -and plaintext HTTP/2 requests other than the "PRI * HTTP/2.0" upgrade request are now rejected as well. -The server continues to handle encrypted HTTP/2 requests. -

- -

-In the server, a 200 status code is sent back by the timeout handler on an empty -response body, instead of sending back 0 as the status code. -

- -

-In the client, the -Transport implementation passes the request context -to any dial operation connecting to the remote server. -If a custom dialer is needed, the new Transport field -DialContext is preferred over the existing Dial field, -to allow the transport to supply a context. -

- -

-The -Transport also adds fields -IdleConnTimeout, -MaxIdleConns, -and -MaxResponseHeaderBytes -to help control client resources consumed -by idle or chatty servers. -

- -

-A -Client's configured CheckRedirect function can now -return ErrUseLastResponse to indicate that the -most recent redirect response should be returned as the -result of the HTTP request. -That response is now available to the CheckRedirect function -as req.Response. -

- -

-Since Go 1, the default behavior of the HTTP client is -to request server-side compression -using the Accept-Encoding request header -and then to decompress the response body transparently, -and this behavior is adjustable using the -Transport's DisableCompression field. -In Go 1.7, to aid the implementation of HTTP proxies, the -Response's new -Uncompressed field reports whether -this transparent decompression took place. -

- -

-DetectContentType -adds support for a few new audio and video content types. -

-
-
- -
net/http/cgi
- -
-

-The -Handler -adds a new field -Stderr -that allows redirection of the child process's -standard error away from the host process's -standard error. -

-
-
- -
net/http/httptest
- -
-

-The new function -NewRequest -prepares a new -http.Request -suitable for passing to an -http.Handler during a test. -

- -

-The -ResponseRecorder's new -Result method -returns the recorded -http.Response. -Tests that need to check the response's headers or trailers -should call Result and inspect the response fields -instead of accessing -ResponseRecorder's HeaderMap directly. -

-
-
- -
net/http/httputil
- -
-

-The -ReverseProxy implementation now responds with “502 Bad Gateway” -when it cannot reach a back end; in earlier releases it responded with “500 Internal Server Error.” -

- -

-Both -ClientConn and -ServerConn have been documented as deprecated. -They are low-level, old, and unused by Go's current HTTP stack -and will no longer be updated. -Programs should use -http.Client, -http.Transport, -and -http.Server -instead. -

-
-
- -
net/http/pprof
- -
-

-The runtime trace HTTP handler, installed to handle the path /debug/pprof/trace, -now accepts a fractional number in its seconds query parameter, -allowing collection of traces for intervals smaller than one second. -This is especially useful on busy servers. -

-
-
- -
net/mail
- -
-

-The address parser now allows unescaped UTF-8 text in addresses -following RFC 6532, -but it does not apply any normalization to the result. -For compatibility with older mail parsers, -the address encoder, namely -Address's -String method, -continues to escape all UTF-8 text following RFC 5322. -

- -

-The ParseAddress -function and -the AddressParser.Parse -method are stricter. -They used to ignore any characters following an e-mail address, but -will now return an error for anything other than whitespace. -

-
-
- -
net/url
- -
-

-The -URL's -new ForceQuery field -records whether the URL must have a query string, -in order to distinguish URLs without query strings (like /search) -from URLs with empty query strings (like /search?). -

-
-
- -
os
- -
-

-IsExist now returns true for syscall.ENOTEMPTY, -on systems where that error exists. -

- -

-On Windows, -Remove now removes read-only files when possible, -making the implementation behave as on -non-Windows systems. -

-
-
- -
os/exec
- -
-

-As part of the introduction of context, -the new constructor -CommandContext -is like -Command but includes a context that can be used to cancel the command execution. -

-
-
- -
os/user
- -
-

-The -Current -function is now implemented even when cgo is not available. -

- -

-The new -Group type, -along with the lookup functions -LookupGroup and -LookupGroupId -and the new field GroupIds in the User struct, -provides access to system-specific user group information. -

-
-
- -
reflect
- -
-

-Although -Value's -Field method has always been documented to panic -if the given field number i is out of range, it has instead -silently returned a zero -Value. -Go 1.7 changes the method to behave as documented. -

- -

-The new -StructOf -function constructs a struct type at run time. -It completes the set of type constructors, joining -ArrayOf, -ChanOf, -FuncOf, -MapOf, -PtrTo, -and -SliceOf. -

- -

-StructTag's -new method -Lookup -is like -Get -but distinguishes the tag not containing the given key -from the tag associating an empty string with the given key. -

- -

-The -Method and -NumMethod -methods of -Type and -Value -no longer return or count unexported methods. -

-
-
- -
strings
- -
-

-In previous releases of Go, if -Reader's -Read method -were asked for zero bytes with no data remaining, it would -return a count of 0 and no error. -Now it returns a count of 0 and the error -io.EOF. -

- -

-The -Reader type has a new method -Reset to allow reuse of a Reader. -

-
-
- -
time
- -
-

-Duration's -time.Duration.String method now reports the zero duration as "0s", not "0". -ParseDuration continues to accept both forms. -

- -

-The method call time.Local.String() now returns "Local" on all systems; -in earlier releases, it returned an empty string on Windows. -

- -

-The time zone database in -$GOROOT/lib/time has been updated -to IANA release 2016d. -This fallback database is only used when the system time zone database -cannot be found, for example on Windows. -The Windows time zone abbreviation list has also been updated. -

-
-
- -
syscall
- -
-

-On Linux, the -SysProcAttr struct -(as used in -os/exec.Cmd's SysProcAttr field) -has a new Unshareflags field. -If the field is nonzero, the child process created by -ForkExec -(as used in exec.Cmd's Run method) -will call the -unshare(2) -system call before executing the new program. -

-
-
- - -
unicode
- -
-

-The unicode package and associated -support throughout the system has been upgraded from version 8.0 to -Unicode 9.0. -

-
-
diff --git a/_content/doc/go1.8.html b/_content/doc/go1.8.html deleted file mode 100644 index 7e6dbfad78..0000000000 --- a/_content/doc/go1.8.html +++ /dev/null @@ -1,1668 +0,0 @@ - - - - - - -

Introduction to Go 1.8

- -

-The latest Go release, version 1.8, arrives six months after Go 1.7. -Most of its changes are in the implementation of the toolchain, runtime, and libraries. -There are two minor changes to the language specification. -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. -

- -

-The release adds support for 32-bit MIPS, -updates the compiler back end to generate more efficient code, -reduces GC pauses by eliminating stop-the-world stack rescanning, -adds HTTP/2 Push support, -adds HTTP graceful shutdown, -adds more context support, -enables profiling mutexes, -and simplifies sorting slices. -

- -

Changes to the language

- -

- When explicitly converting a value from one struct type to another, - as of Go 1.8 the tags are ignored. Thus two structs that differ - only in their tags may be converted from one to the other: -

- -
-func example() {
-	type T1 struct {
-		X int `json:"foo"`
-	}
-	type T2 struct {
-		X int `json:"bar"`
-	}
-	var v1 T1
-	var v2 T2
-	v1 = T1(v2) // now legal
-}
-
- - -

- The language specification now only requires that implementations - support up to 16-bit exponents in floating-point constants. This does not affect - either the “gc” or - gccgo compilers, both of - which still support 32-bit exponents. -

- -

Ports

- -

-Go now supports 32-bit MIPS on Linux for both big-endian -(linux/mips) and little-endian machines -(linux/mipsle) that implement the MIPS32r1 instruction set with FPU -or kernel FPU emulation. Note that many common MIPS-based routers lack an FPU and -have firmware that doesn't enable kernel FPU emulation; Go won't run on such machines. -

- -

-On DragonFly BSD, Go now requires DragonFly 4.4.4 or later. -

- -

-On OpenBSD, Go now requires OpenBSD 5.9 or later. -

- -

-The Plan 9 port's networking support is now much more complete -and matches the behavior of Unix and Windows with respect to deadlines -and cancellation. For Plan 9 kernel requirements, see the -Plan 9 wiki page. -

- -

- Go 1.8 now only supports OS X 10.8 or later. This is likely the last - Go release to support 10.8. Compiling Go or running - binaries on older OS X versions is untested. -

- -

- Go 1.8 will be the last release to support Linux on ARMv5E and ARMv6 processors: - Go 1.9 will likely require the ARMv6K (as found in the Raspberry Pi 1) or later. - To identify whether a Linux system is ARMv6K or later, run - “go tool dist -check-armv6k” - (to facilitate testing, it is also possible to just copy the dist command to the - system without installing a full copy of Go 1.8) - and if the program terminates with output "ARMv6K supported." then the system - implements ARMv6K or later. - Go on non-Linux ARM systems already requires ARMv6K or later. -

- -

- zos is now a recognized value for GOOS, - reserved for the z/OS operating system. -

- -

Known Issues

- -

-There are some instabilities on FreeBSD and NetBSD that are known but not understood. -These can lead to program crashes in rare cases. -See -issue 15658 and -issue 16511. -Any help in solving these issues would be appreciated. -

- -

Tools

- -

Assembler

- -

-For 64-bit x86 systems, the following instructions have been added: -VBROADCASTSD, -BROADCASTSS, -MOVDDUP, -MOVSHDUP, -MOVSLDUP, -VMOVDDUP, -VMOVSHDUP, and -VMOVSLDUP. -

- -

-For 64-bit PPC systems, the common vector scalar instructions have been -added: -LXS, -LXSDX, -LXSI, -LXSIWAX, -LXSIWZX, -LXV, -LXVD2X, -LXVDSX, -LXVW4X, -MFVSR, -MFVSRD, -MFVSRWZ, -MTVSR, -MTVSRD, -MTVSRWA, -MTVSRWZ, -STXS, -STXSDX, -STXSI, -STXSIWX, -STXV, -STXVD2X, -STXVW4X, -XSCV, -XSCVDPSP, -XSCVDPSPN, -XSCVDPSXDS, -XSCVDPSXWS, -XSCVDPUXDS, -XSCVDPUXWS, -XSCVSPDP, -XSCVSPDPN, -XSCVSXDDP, -XSCVSXDSP, -XSCVUXDDP, -XSCVUXDSP, -XSCVX, -XSCVXP, -XVCV, -XVCVDPSP, -XVCVDPSXDS, -XVCVDPSXWS, -XVCVDPUXDS, -XVCVDPUXWS, -XVCVSPDP, -XVCVSPSXDS, -XVCVSPSXWS, -XVCVSPUXDS, -XVCVSPUXWS, -XVCVSXDDP, -XVCVSXDSP, -XVCVSXWDP, -XVCVSXWSP, -XVCVUXDDP, -XVCVUXDSP, -XVCVUXWDP, -XVCVUXWSP, -XVCVX, -XVCVXP, -XXLAND, -XXLANDC, -XXLANDQ, -XXLEQV, -XXLNAND, -XXLNOR, -XXLOR, -XXLORC, -XXLORQ, -XXLXOR, -XXMRG, -XXMRGHW, -XXMRGLW, -XXPERM, -XXPERMDI, -XXSEL, -XXSI, -XXSLDWI, -XXSPLT, and -XXSPLTW. -

- -

Yacc

- -

-The yacc tool (previously available by running -“go tool yacc”) has been removed. -As of Go 1.7 it was no longer used by the Go compiler. -It has moved to the “tools” repository and is now available at -golang.org/x/tools/cmd/goyacc. -

- -

Fix

- -

- The fix tool has a new “context” - fix to change imports from “golang.org/x/net/context” - to “context”. -

- -

Pprof

- -

- The pprof tool can now profile TLS servers - and skip certificate validation by using the “https+insecure” - URL scheme. -

- -

- The callgrind output now has instruction-level granularity. -

- -

Trace

- -

- The trace tool has a new -pprof flag for - producing pprof-compatible blocking and latency profiles from an - execution trace. -

- -

- Garbage collection events are now shown more clearly in the - execution trace viewer. Garbage collection activity is shown on its - own row and GC helper goroutines are annotated with their roles. -

- -

Vet

- -

Vet is stricter in some ways and looser where it - previously caused false positives.

- -

Vet now checks for copying an array of locks, - duplicate JSON and XML struct field tags, - non-space-separated struct tags, - deferred calls to HTTP Response.Body.Close - before checking errors, and - indexed arguments in Printf. - It also improves existing checks.

-

- -

Compiler Toolchain

- -

-Go 1.7 introduced a new compiler back end for 64-bit x86 systems. -In Go 1.8, that back end has been developed further and is now used for -all architectures. -

- -

-The new back end, based on -static single assignment form (SSA), -generates more compact, more efficient code -and provides a better platform for optimizations -such as bounds check elimination. -The new back end reduces the CPU time required by -our benchmark programs by 20-30% -on 32-bit ARM systems. For 64-bit x86 systems, which already used the SSA back end in -Go 1.7, the gains are a more modest 0-10%. Other architectures will likely -see improvements closer to the 32-bit ARM numbers. -

- -

- The temporary -ssa=0 compiler flag introduced in Go 1.7 - to disable the new back end has been removed in Go 1.8. -

- -

- In addition to enabling the new compiler back end for all systems, - Go 1.8 also introduces a new compiler front end. The new compiler - front end should not be noticeable to users but is the foundation for - future performance work. -

- -

- The compiler and linker have been optimized and run faster in this - release than in Go 1.7, although they are still slower than we would - like and will continue to be optimized in future releases. - Compared to the previous release, Go 1.8 is - about 15% faster. -

- -

Cgo

- -

-The Go tool now remembers the value of the CGO_ENABLED environment -variable set during make.bash and applies it to all future compilations -by default to fix issue #12808. -When doing native compilation, it is rarely necessary to explicitly set -the CGO_ENABLED environment variable as make.bash -will detect the correct setting automatically. The main reason to explicitly -set the CGO_ENABLED environment variable is when your environment -supports cgo, but you explicitly do not want cgo support, in which case, set -CGO_ENABLED=0 during make.bash or all.bash. -

- -

-The environment variable PKG_CONFIG may now be used to -set the program to run to handle #cgo pkg-config -directives. The default is pkg-config, the program -always used by earlier releases. This is intended to make it easier -to cross-compile -cgo code. -

- -

-The cgo tool now supports a -srcdir -option, which is used by the go command. -

- -

-If cgo code calls C.malloc, and -malloc returns NULL, the program will now -crash with an out of memory error. -C.malloc will never return nil. -Unlike most C functions, C.malloc may not be used in a -two-result form returning an errno value. -

- -

-If cgo is used to call a C function passing a -pointer to a C union, and if the C union can contain any pointer -values, and if cgo pointer -checking is enabled (as it is by default), the union value is now -checked for Go pointers. -

- -

Gccgo

- -

-Due to the alignment of Go's semiannual release schedule with GCC's -annual release schedule, -GCC release 6 contains the Go 1.6.1 version of gccgo. -We expect that the next release, GCC 7, will contain the Go 1.8 -version of gccgo. -

- -

Default GOPATH

- -

- The - GOPATH - environment variable now has a default value if it - is unset. It defaults to - $HOME/go on Unix and - %USERPROFILE%/go on Windows. -

- -

Go get

- -

- The “go get” command now always respects - HTTP proxy environment variables, regardless of whether - the -insecure flag is used. In previous releases, the - -insecure flag had the side effect of not using proxies. -

- -

Go bug

- -

- The new - “go bug” - command starts a bug report on GitHub, prefilled - with information about the current system. -

- -

Go doc

- -

- The - “go doc” - command now groups constants and variables with their type, - following the behavior of - godoc. -

- -

- In order to improve the readability of doc's - output, each summary of the first-level items is guaranteed to - occupy a single line. -

- -

- Documentation for a specific method in an interface definition can - now be requested, as in - “go doc net.Conn.SetDeadline”. -

- -

Plugins

- -

- Go now provides early support for plugins with a “plugin” - build mode for generating plugins written in Go, and a - new plugin package for - loading such plugins at run time. Plugin support is currently only - available on Linux. Please report any issues. -

- -

Runtime

- -

Argument Liveness

- -

- The garbage collector no longer considers - arguments live throughout the entirety of a function. For more - information, and for how to force a variable to remain live, see - the runtime.KeepAlive - function added in Go 1.7. -

- -

- Updating: - Code that sets a finalizer on an allocated object may need to add - calls to runtime.KeepAlive in functions or methods - using that object. - Read the - KeepAlive - documentation and its example for more details. -

- -

Concurrent Map Misuse

- -

-In Go 1.6, the runtime -added lightweight, -best-effort detection of concurrent misuse of maps. This release -improves that detector with support for detecting programs that -concurrently write to and iterate over a map. -

-

-As always, if one goroutine is writing to a map, no other goroutine should be -reading (which includes iterating) or writing the map concurrently. -If the runtime detects this condition, it prints a diagnosis and crashes the program. -The best way to find out more about the problem is to run the program -under the -race detector, -which will more reliably identify the race -and give more detail. -

- -

MemStats Documentation

- -

- The runtime.MemStats - type has been more thoroughly documented. -

- -

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 and -optimizations in the standard library. -

- -

-There have been optimizations to implementations in the -bytes, -crypto/aes, -crypto/cipher, -crypto/elliptic, -crypto/sha256, -crypto/sha512, -encoding/asn1, -encoding/csv, -encoding/hex, -encoding/json, -hash/crc32, -image/color, -image/draw, -math, -math/big, -reflect, -regexp, -runtime, -strconv, -strings, -syscall, -text/template, and -unicode/utf8 -packages. -

- -

Garbage Collector

- -

- Garbage collection pauses should be significantly shorter than they - were in Go 1.7, usually under 100 microseconds and often as low as - 10 microseconds. - See the - document on eliminating stop-the-world stack re-scanning - for details. More work remains for Go 1.9. -

- -

Defer

- - -

- The overhead of deferred - function calls has been reduced by about half. -

- -

Cgo

- -

The overhead of calls from Go into C has been reduced by about half.

- -

Standard library

- -

Examples

- -

-Examples have been added to the documentation across many packages. -

- -

Sort

- -

-The sort package -now includes a convenience function -Slice to sort a -slice given a less function. - -In many cases this means that writing a new sorter type is not -necessary. -

- -

-Also new are -SliceStable and -SliceIsSorted. -

- -

HTTP/2 Push

- -

-The net/http package now includes a -mechanism to -send HTTP/2 server pushes from a -Handler. -Similar to the existing Flusher and Hijacker -interfaces, an HTTP/2 -ResponseWriter -now implements the new -Pusher interface. -

- -

HTTP Server Graceful Shutdown

- -

- The HTTP Server now has support for graceful shutdown using the new - Server.Shutdown - method and abrupt shutdown using the new - Server.Close - method. -

- -

More Context Support

- -

- Continuing Go 1.7's adoption - of context.Context - into the standard library, Go 1.8 adds more context support - to existing packages: -

- - - -

Mutex Contention Profiling

- -

- The runtime and tools now support profiling contended mutexes. -

- -

- Most users will want to use the new -mutexprofile - flag with “go test”, - and then use pprof on the resultant file. -

- -

- Lower-level support is also available via the new - MutexProfile - and - SetMutexProfileFraction. -

- -

- A known limitation for Go 1.8 is that the profile only reports contention for - sync.Mutex, - not - sync.RWMutex. -

- -

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. The following sections list the user visible changes and additions. -Optimizations and minor bug fixes are not listed. -

- -
archive/tar
-
- -

- The tar implementation corrects many bugs in corner cases of the file format. - The Reader - is now able to process tar files in the PAX format with entries larger than 8GB. - The Writer - no longer produces invalid tar files in some situations involving long pathnames. -

- -
-
- -
compress/flate
-
- -

- There have been some minor fixes to the encoder to improve the - compression ratio in certain situations. As a result, the exact - encoded output of DEFLATE may be different from Go 1.7. Since - DEFLATE is the underlying compression of gzip, png, zlib, and zip, - those formats may have changed outputs. -

- -

- The encoder, when operating in - NoCompression - mode, now produces a consistent output that is not dependent on - the size of the slices passed to the - Write - method. -

- -

- The decoder, upon encountering an error, now returns any - buffered data it had uncompressed along with the error. -

- -
-
- - -
compress/gzip
-
- -

- The Writer - now encodes a zero MTIME field when - the Header.ModTime - field is the zero value. - - In previous releases of Go, the Writer would encode - a nonsensical value. - - Similarly, - the Reader - now reports a zero encoded MTIME field as a zero - Header.ModTime. -

- -
-
- -
context
-
-

- The DeadlineExceeded - error now implements - net.Error - and reports true for both the Timeout and - Temporary methods. -

-
-
- -
crypto/tls
-
-

- The new method - Conn.CloseWrite - allows TLS connections to be half closed. -

- -

- The new method - Config.Clone - clones a TLS configuration. -

- -

- - The new Config.GetConfigForClient - callback allows selecting a configuration for a client dynamically, based - on the client's - ClientHelloInfo. - - - The ClientHelloInfo - struct now has new - fields Conn, SignatureSchemes (using - the new - type SignatureScheme), - SupportedProtos, and SupportedVersions. -

- -

- The new Config.GetClientCertificate - callback allows selecting a client certificate based on the server's - TLS CertificateRequest message, represented by the new - CertificateRequestInfo. -

- -

- The new - Config.KeyLogWriter - allows debugging TLS connections - in WireShark and - similar tools. -

- -

- The new - Config.VerifyPeerCertificate - callback allows additional validation of a peer's presented certificate. -

- -

- The crypto/tls package now implements basic - countermeasures against CBC padding oracles. There should be - no explicit secret-dependent timings, but it does not attempt to - normalize memory accesses to prevent cache timing leaks. -

- -

- The crypto/tls package now supports - X25519 and - ChaCha20-Poly1305. - ChaCha20-Poly1305 is now prioritized unless - hardware support for AES-GCM is present. -

- -

- AES-128-CBC cipher suites with SHA-256 are also - now supported, but disabled by default. -

- -
-
- -
crypto/x509
-
-

- PSS signatures are now supported. -

- -

- UnknownAuthorityError - now has a Cert field, reporting the untrusted - certificate. -

- -

- Certificate validation is more permissive in a few cases and - stricter in a few other cases. - -

- -

- Root certificates will now also be looked for - at /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem - on Linux, to support RHEL and CentOS. -

- -
-
- -
database/sql
-
-

- The package now supports context.Context. There are new methods - ending in Context such as - DB.QueryContext and - DB.PrepareContext - that take context arguments. Using the new Context methods ensures that - connections are closed and returned to the connection pool when the - request is done; enables canceling in-progress queries - should the driver support that; and allows the database - pool to cancel waiting for the next available connection. -

-

- The IsolationLevel - can now be set when starting a transaction by setting the isolation level - on TxOptions.Isolation and passing - it to DB.BeginTx. - An error will be returned if an isolation level is selected that the driver - does not support. A read-only attribute may also be set on the transaction - by setting TxOptions.ReadOnly - to true. -

-

- Queries now expose the SQL column type information for drivers that support it. - Rows can return ColumnTypes - which can include SQL type information, column type lengths, and the Go type. -

-

- A Rows - can now represent multiple result sets. After - Rows.Next returns false, - Rows.NextResultSet - may be called to advance to the next result set. The existing Rows - should continue to be used after it advances to the next result set. -

-

- NamedArg may be used - as query arguments. The new function Named - helps create a NamedArg - more succinctly. -

- If a driver supports the new - Pinger - interface, the - DB.Ping - and - DB.PingContext - methods will use that interface to check whether a - database connection is still valid. -

-

- The new Context query methods work for all drivers, but - Context cancellation is not responsive unless the driver has been - updated to use them. The other features require driver support in - database/sql/driver. - Driver authors should review the new interfaces. Users of existing - driver should review the driver documentation to see what - it supports and any system specific documentation on each feature. -

-
-
- -
debug/pe
-
-

- The package has been extended and is now used by - the Go linker to read gcc-generated object files. - The new - File.StringTable - and - Section.Relocs - fields provide access to the COFF string table and COFF relocations. - The new - File.COFFSymbols - allows low-level access to the COFF symbol table. -

-
-
- -
encoding/base64
-
-

- The new - Encoding.Strict - method returns an Encoding that causes the decoder - to return an error when the trailing padding bits are not zero. -

-
-
- -
encoding/binary
-
-

- Read - and - Write - now support booleans. -

-
-
- -
encoding/json
-
- -

- UnmarshalTypeError - now includes the struct and field name. -

- -

- A nil Marshaler - now marshals as a JSON null value. -

- -

- A RawMessage value now - marshals the same as its pointer type. -

- -

- Marshal - encodes floating-point numbers using the same format as in ES6, - preferring decimal (not exponential) notation for a wider range of values. - In particular, all floating-point integers up to 264 format the - same as the equivalent int64 representation. -

- -

- In previous versions of Go, unmarshaling a JSON null into an - Unmarshaler - was considered a no-op; now the Unmarshaler's - UnmarshalJSON method is called with the JSON literal - null and can define the semantics of that case. -

- -
-
- -
encoding/pem
-
-

- Decode - is now strict about the format of the ending line. -

-
-
- -
encoding/xml
-
-

- Unmarshal - now has wildcard support for collecting all attributes using - the new ",any,attr" struct tag. -

-
-
- -
expvar
-
-

- The new methods - Int.Value, - String.Value, - Float.Value, and - Func.Value - report the current value of an exported variable. -

- -

- The new - function Handler - returns the package's HTTP handler, to enable installing it in - non-standard locations. -

-
-
- -
fmt
-
-

- Scanf, - Fscanf, and - Sscanf now - handle spaces differently and more consistently than - previous releases. See the - scanning documentation - for details. -

-
-
- -
go/doc
-
-

- The new IsPredeclared - function reports whether a string is a predeclared identifier. -

-
-
- -
go/types
-
-

- The new function - Default - returns the default "typed" type for an "untyped" type. -

- -

- The alignment of complex64 now matches - the Go compiler. -

-
-
- -
html/template
-
-

- The package now validates - the "type" attribute on - a <script> tag. -

-
-
- -
image/png
-
-

- Decode - (and DecodeConfig) - now supports True Color and grayscale transparency. -

-

- Encoder - is now faster and creates smaller output - when encoding paletted images. -

-
-
- -
math/big
-
-

- The new method - Int.Sqrt - calculates ⌊√x⌋. -

- -

- The new method - Float.Scan - is a support routine for - fmt.Scanner. -

- -

- Int.ModInverse - now supports negative numbers. -

- -
-
- -
math/rand
-
- -

- The new Rand.Uint64 - method returns uint64 values. The - new Source64 - interface describes sources capable of generating such values - directly; otherwise the Rand.Uint64 method - constructs a uint64 from two calls - to Source's - Int63 method. -

- -
-
- -
mime
-
-

- ParseMediaType - now preserves unnecessary backslash escapes as literals, - in order to support MSIE. - When MSIE sends a full file path (in “intranet mode”), it does not - escape backslashes: “C:\dev\go\foo.txt”, not - “C:\\dev\\go\\foo.txt”. - If we see an unnecessary backslash escape, we now assume it is from MSIE - and intended as a literal backslash. - No known MIME generators emit unnecessary backslash escapes - for simple token characters like numbers and letters. -

-
-
- -
mime/quotedprintable
-
- -

- The - Reader's - parsing has been relaxed in two ways to accept - more input seen in the wild. - - - First, it accepts an equals sign (=) not followed - by two hex digits as a literal equal sign. - - - Second, it silently ignores a trailing equals sign at the end of - an encoded input. -

- -
-
- -
net
-
- -

- The Conn documentation - has been updated to clarify expectations of an interface - implementation. Updates in the net/http packages - depend on implementations obeying the documentation. -

-

Updating: implementations of the Conn interface should verify - they implement the documented semantics. The - golang.org/x/net/nettest - package will exercise a Conn and validate it behaves properly. -

- -

- The new method - UnixListener.SetUnlinkOnClose - sets whether the underlying socket file should be removed from the file system when - the listener is closed. -

- -

- The new Buffers type permits - writing to the network more efficiently from multiple discontiguous buffers - in memory. On certain machines, for certain types of connections, - this is optimized into an OS-specific batch write operation (such as writev). -

- -

- The new Resolver looks up names and numbers - and supports context.Context. - The Dialer now has an optional - Resolver field. -

- -

- Interfaces is now supported on Solaris. -

- -

- The Go DNS resolver now supports resolv.conf's “rotate” - and “option ndots:0” options. The “ndots” option is - now respected in the same way as libresolve. -

- -
-
- -
net/http
-
- -

Server changes:

-
    -
  • The server now supports graceful shutdown support, mentioned above.
  • - -
  • - The Server - adds configuration options - ReadHeaderTimeout and IdleTimeout - and documents WriteTimeout. -
  • - -
  • - FileServer - and - ServeContent - now support HTTP If-Match conditional requests, - in addition to the previous If-None-Match - support for ETags properly formatted according to RFC 7232, section 2.3. -
  • -
- -

- There are several additions to what a server's Handler can do: -

- -
    -
  • - The Context - returned - by Request.Context - is canceled if the underlying net.Conn - closes. For instance, if the user closes their browser in the - middle of a slow request, the Handler can now - detect that the user is gone. This complements the - existing CloseNotifier - support. This functionality requires that the underlying - net.Conn implements - recently clarified interface documentation. -
  • - -
  • - To serve trailers produced after the header has already been written, - see the new - TrailerPrefix - mechanism. -
  • - -
  • - A Handler can now abort a response by panicking - with the error - ErrAbortHandler. -
  • - -
  • - A Write of zero bytes to a - ResponseWriter - is now defined as a - way to test whether a ResponseWriter has been hijacked: - if so, the Write returns - ErrHijacked - without printing an error - to the server's error log. -
  • - -
- -

Client & Transport changes:

-
    -
  • - The Client - now copies most request headers on redirect. See - the documentation - on the Client type for details. -
  • - -
  • - The Transport - now supports international domain names. Consequently, so do - Get and other helpers. -
  • - -
  • - The Client now supports 301, 307, and 308 redirects. - - For example, Client.Post now follows 301 - redirects, converting them to GET requests - without bodies, like it did for 302 and 303 redirect responses - previously. - - The Client now also follows 307 and 308 - redirects, preserving the original request method and body, if - any. If the redirect requires resending the request body, the - request must have the new - Request.GetBody - field defined. - NewRequest - sets Request.GetBody automatically for common - body types. -
  • - -
  • - The Transport now rejects requests for URLs with - ports containing non-digit characters. -
  • - -
  • - The Transport will now retry non-idempotent - requests if no bytes were written before a network failure - and the request has no body. -
  • - -
  • - The - new Transport.ProxyConnectHeader - allows configuration of header values to send to a proxy - during a CONNECT request. -
  • - -
  • - The DefaultTransport.Dialer - now enables DualStack ("Happy Eyeballs") support, - allowing the use of IPv4 as a backup if it looks like IPv6 might be - failing. -
  • - -
  • - The Transport - no longer reads a byte of a non-nil - Request.Body - when the - Request.ContentLength - is zero to determine whether the ContentLength - is actually zero or just undefined. - To explicitly signal that a body has zero length, - either set it to nil, or set it to the new value - NoBody. - The new NoBody value is intended for use by Request - constructor functions; it is used by - NewRequest. -
  • -
- -
-
- -
net/http/httptrace
-
-

- There is now support for tracing a client request's TLS handshakes with - the new - ClientTrace.TLSHandshakeStart - and - ClientTrace.TLSHandshakeDone. -

-
-
- -
net/http/httputil
-
-

- The ReverseProxy - has a new optional hook, - ModifyResponse, - for modifying the response from the back end before proxying it to the client. -

- -
-
- -
net/mail
-
- -

- Empty quoted strings are once again allowed in the name part of - an address. That is, Go 1.4 and earlier accepted - "" <gopher@example.com>, - but Go 1.5 introduced a bug that rejected this address. - The address is recognized again. -

- -

- The - Header.Date - method has always provided a way to parse - the Date: header. - A new function - ParseDate - allows parsing dates found in other - header lines, such as the Resent-Date: header. -

- -
-
- -
net/smtp
-
- -

- If an implementation of the - Auth.Start - method returns an empty toServer value, - the package no longer sends - trailing whitespace in the SMTP AUTH command, - which some servers rejected. -

- -
-
- -
net/url
-
- -

- The new functions - PathEscape - and - PathUnescape - are similar to the query escaping and unescaping functions but - for path elements. -

- -

- The new methods - URL.Hostname - and - URL.Port - return the hostname and port fields of a URL, - correctly handling the case where the port may not be present. -

- -

- The existing method - URL.ResolveReference - now properly handles paths with escaped bytes without losing - the escaping. -

- -

- The URL type now implements - encoding.BinaryMarshaler and - encoding.BinaryUnmarshaler, - making it possible to process URLs in gob data. -

- -

- Following RFC 3986, - Parse - now rejects URLs like this_that:other/thing instead of - interpreting them as relative paths (this_that is not a valid scheme). - To force interpretation as a relative path, - such URLs should be prefixed with “./”. - The URL.String method now inserts this prefix as needed. -

- -
-
- -
os
-
-

- The new function - Executable returns - the path name of the running executable. -

- -

- An attempt to call a method on - an os.File that has - already been closed will now return the new error - value os.ErrClosed. - Previously it returned a system-specific error such - as syscall.EBADF. -

- -

- On Unix systems, os.Rename - will now return an error when used to rename a directory to an - existing empty directory. - Previously it would fail when renaming to a non-empty directory - but succeed when renaming to an empty directory. - This makes the behavior on Unix correspond to that of other systems. -

- -

- On Windows, long absolute paths are now transparently converted to - extended-length paths (paths that start with “\\?\”). - This permits the package to work with files whose path names are - longer than 260 characters. -

- -

- On Windows, os.IsExist - will now return true for the system - error ERROR_DIR_NOT_EMPTY. - This roughly corresponds to the existing handling of the Unix - error ENOTEMPTY. -

- -

- On Plan 9, files that are not served by #M will now - have ModeDevice set in - the value returned - by FileInfo.Mode. -

-
-
- -
path/filepath
-
-

- A number of bugs and corner cases on Windows were fixed: - Abs now calls Clean as documented, - Glob now matches - “\\?\c:\*”, - EvalSymlinks now - correctly handles “C:.”, and - Clean now properly - handles a leading “..” in the path. -

-
-
- -
reflect
-
-

- The new function - Swapper was - added to support sort.Slice. -

-
-
- -
strconv
-
-

- The Unquote - function now strips carriage returns (\r) in - backquoted raw strings, following the - Go language semantics. -

-
-
- -
syscall
-
-

- The Getpagesize - now returns the system's size, rather than a constant value. - Previously it always returned 4KB. -

- -

- The signature - of Utimes has - changed on Solaris to match all the other Unix systems' - signature. Portable code should continue to use - os.Chtimes instead. -

- -

- The X__cmsg_data field has been removed from - Cmsghdr. -

-
-
- -
text/template
-
-

- Template.Execute - can now take a - reflect.Value as its data - argument, and - FuncMap - functions can also accept and return reflect.Value. -

- -
-
- -
time
-
- -

The new function - Until complements - the analogous Since function. -

- -

- ParseDuration - now accepts long fractional parts. -

- -

- Parse - now rejects dates before the start of a month, such as June 0; - it already rejected dates beyond the end of the month, such as - June 31 and July 32. -

- -

- The tzdata database has been updated to version - 2016j for systems that don't already have a local time zone - database. -

- -

-

-
- -
testing
-
-

- The new method - T.Name - (and B.Name) returns the name of the current - test or benchmark. -

- -

- The new function - CoverMode - reports the test coverage mode. -

- -

- Tests and benchmarks are now marked as failed if the race - detector is enabled and a data race occurs during execution. - Previously, individual test cases would appear to pass, - and only the overall execution of the test binary would fail. -

- -

- The signature of the - MainStart - function has changed, as allowed by the documentation. It is an - internal detail and not part of the Go 1 compatibility promise. - If you're not calling MainStart directly but see - errors, that likely means you set the - normally-empty GOROOT environment variable and it - doesn't match the version of your go command's binary. -

- -
-
- -
unicode
-
-

- SimpleFold - now returns its argument unchanged if the provided input was an invalid rune. - Previously, the implementation failed with an index bounds check panic. -

-
-
diff --git a/_content/doc/go1.9.html b/_content/doc/go1.9.html deleted file mode 100644 index ae1ac23d7c..0000000000 --- a/_content/doc/go1.9.html +++ /dev/null @@ -1,1022 +0,0 @@ - - - - - - -

Introduction to Go 1.9

- -

- The latest Go release, version 1.9, arrives six months - after Go 1.8 and is the tenth release in - the Go 1.x - series. - There are two changes to the language: - adding support for type aliases and defining when implementations - may fuse floating point operations. - Most of the 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. -

- -

- The release - adds transparent monotonic time support, - parallelizes compilation of functions within a package, - better supports test helper functions, - includes a new bit manipulation package, - and has a new concurrent map type. -

- -

Changes to the language

- -

- There are two changes to the language. -

-

- Go now supports type aliases to support gradual code repair while - moving a type between packages. - The type alias - design document - and an - article on refactoring cover the problem in detail. - In short, a type alias declaration has the form: -

- -
-type T1 = T2
-
- -

- This declaration introduces an alias name T1—an - alternate spelling—for the type denoted by T2; that is, - both T1 and T2 denote the same type. -

- -

- A smaller language change is that the - language specification - now states when implementations are allowed to fuse floating - point operations together, such as by using an architecture's "fused - multiply and add" (FMA) instruction to compute x*y + z - without rounding the intermediate result x*y. - To force the intermediate rounding, write float64(x*y) + z. -

- -

Ports

- -

- There are no new supported operating systems or processor - architectures in this release. -

- -

ppc64x requires POWER8

- -

- Both GOARCH=ppc64 and GOARCH=ppc64le now - require at least POWER8 support. In previous releases, - only GOARCH=ppc64le required POWER8 and the big - endian ppc64 architecture supported older - hardware. -

- -

FreeBSD

- -

- Go 1.9 is the last release that will run on FreeBSD 9.3, - which is already - unsupported by FreeBSD. - Go 1.10 will require FreeBSD 10.3+. -

- -

OpenBSD 6.0

- -

- Go 1.9 now enables PT_TLS generation for cgo binaries and thus - requires OpenBSD 6.0 or newer. Go 1.9 no longer supports - OpenBSD 5.9. -

- -

Known Issues

- -

- There are some instabilities on FreeBSD that are known but not understood. - These can lead to program crashes in rare cases. - See issue 15658. - Any help in solving this FreeBSD-specific issue would be appreciated. -

- -

- Go stopped running NetBSD builders during the Go 1.9 development - cycle due to NetBSD kernel crashes, up to and including NetBSD 7.1. - As Go 1.9 is being released, NetBSD 7.1.1 is being released with a fix. - However, at this time we have no NetBSD builders passing our test suite. - Any help investigating the - various NetBSD issues - would be appreciated. -

- -

Tools

- -

Parallel Compilation

- -

- The Go compiler now supports compiling a package's functions in parallel, taking - advantage of multiple cores. This is in addition to the go command's - existing support for parallel compilation of separate packages. - Parallel compilation is on by default, but it can be disabled by setting the - environment variable GO19CONCURRENTCOMPILATION to 0. -

- -

Vendor matching with ./...

- -

- By popular request, ./... no longer matches packages - in vendor directories in tools accepting package names, - such as go test. To match vendor - directories, write ./vendor/.... -

- -

Moved GOROOT

- -

- The go tool will now use the path from which it - was invoked to attempt to locate the root of the Go install tree. - This means that if the entire Go installation is moved to a new - location, the go tool should continue to work as usual. - This may be overridden by setting GOROOT in the environment, - which should only be done in unusual circumstances. - Note that this does not affect the result of - the runtime.GOROOT function, which - will continue to report the original installation location; - this may be fixed in later releases. -

- -

Compiler Toolchain

- -

- Complex division is now C99-compatible. This has always been the - case in gccgo and is now fixed in the gc toolchain. -

- -

- The linker will now generate DWARF information for cgo executables on Windows. -

- -

- The compiler now includes lexical scopes in the generated DWARF if the - -N -l flags are provided, allowing - debuggers to hide variables that are not in scope. The .debug_info - section is now DWARF version 4. -

- -

- The values of GOARM and GO386 now affect a - compiled package's build ID, as used by the go tool's - dependency caching. -

- -

Assembler

- -

- The four-operand ARM MULA instruction is now assembled correctly, - with the addend register as the third argument and the result - register as the fourth and final argument. - In previous releases, the two meanings were reversed. - The three-operand form, in which the fourth argument is implicitly - the same as the third, is unaffected. - Code using four-operand MULA instructions - will need to be updated, but we believe this form is very rarely used. - MULAWT and MULAWB were already - using the correct order in all forms and are unchanged. -

- -

- The assembler now supports ADDSUBPS/PD, completing the - two missing x86 SSE3 instructions. -

- -

Doc

- -

- Long lists of arguments are now truncated. This improves the readability - of go doc on some generated code. -

- -

- Viewing documentation on struct fields is now supported. - For example, go doc http.Client.Jar. -

- -

Env

- -

- The new go env -json flag - enables JSON output, instead of the default OS-specific output - format. -

- -

Test

- -

- The go test - command accepts a new -list flag, which takes a regular - expression as an argument and prints to stdout the name of any - tests, benchmarks, or examples that match it, without running them. -

- - -

Pprof

- -

- 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. -

- -

- The go tool pprof command now - uses the HTTP proxy information defined in the environment, using - http.ProxyFromEnvironment. -

- -

Vet

- - -

- The vet command - has been better integrated into the - go tool, - so go vet now supports all standard build - flags while vet's own flags are now available - from go vet as well as - from go tool vet. -

- -

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

- -

Call stacks with inlined frames

- -

- Users of - runtime.Callers - should avoid directly inspecting the resulting PC slice and instead use - runtime.CallersFrames - to get a complete view of the call stack, or - runtime.Caller - to get information about a single caller. - This is because an individual element of the PC slice cannot account - for inlined frames or other nuances of the call stack. -

- -

- Specifically, code that directly iterates over the PC slice and uses - functions such as - runtime.FuncForPC - to resolve each PC individually will miss inlined frames. - To get a complete view of the stack, such code should instead use - CallersFrames. - Likewise, code should not assume that the length returned by - Callers is any indication of the call depth. - It should instead count the number of frames returned by - CallersFrames. -

- -

- Code that queries a single caller at a specific depth should use - Caller rather than passing a slice of length 1 to - Callers. -

- -

- runtime.CallersFrames - has been available since Go 1.7, so code can be updated prior to - upgrading to Go 1.9. -

- -

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

- -

- Library functions that used to trigger stop-the-world garbage - collection now trigger concurrent garbage collection. - - Specifically, runtime.GC, - debug.SetGCPercent, - and - debug.FreeOSMemory, - now trigger concurrent garbage collection, blocking only the calling - goroutine until the garbage collection is done. -

- -

- The - debug.SetGCPercent - function only triggers a garbage collection if one is immediately - necessary because of the new GOGC value. - This makes it possible to adjust GOGC on-the-fly. -

- -

- Large object allocation performance is significantly improved in - applications using large (>50GB) heaps containing many large - objects. -

- -

- The runtime.ReadMemStats - function now takes less than 100µs even for very large heaps. -

- -

Core library

- -

Transparent Monotonic Time support

- -

- The time package now transparently - tracks monotonic time in each Time - value, making computing durations between two Time values - a safe operation in the presence of wall clock adjustments. - See the package docs and - design document - for details. -

- -

New bit manipulation package

- -

- Go 1.9 includes a new package, - math/bits, with optimized - implementations for manipulating bits. On most architectures, - functions in this package are additionally recognized by the - compiler and treated as intrinsics for additional performance. -

- -

Test Helper Functions

- -

- The - new (*T).Helper - and (*B).Helper - methods mark the calling function as a test helper function. When - printing file and line information, that function will be skipped. - This permits writing test helper functions while still having useful - line numbers for users. -

- -

Concurrent Map

- -

- The new Map type - in the sync package - is a concurrent map with amortized-constant-time loads, stores, and - deletes. It is safe for multiple goroutines to call a Map's methods - concurrently. -

- -

Profiler Labels

- -

- The runtime/pprof package - now supports adding labels to pprof profiler records. - Labels form a key-value map that is used to distinguish calls of the - same function in different contexts when looking at profiles - with the pprof command. - The pprof package's - new Do function - runs code associated with some provided labels. Other new functions - in the package help work with labels. -

- - - - -

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/zip
-
-

- The - ZIP Writer - now sets the UTF-8 bit in - the FileHeader.Flags - when appropriate. -

- -
- -
crypto/rand
-
-

- On Linux, Go now calls the getrandom system call - without the GRND_NONBLOCK flag; it will now block - until the kernel has sufficient randomness. On kernels predating - the getrandom system call, Go continues to read - from /dev/urandom. -

- -
- -
crypto/x509
-
-

- - On Unix systems the environment - variables SSL_CERT_FILE - and SSL_CERT_DIR can now be used to override the - system default locations for the SSL certificate file and SSL - certificate files directory, respectively. -

- -

The FreeBSD file /usr/local/etc/ssl/cert.pem is - now included in the certificate search path. -

- -

- - The package now supports excluded domains in name constraints. - In addition to enforcing such constraints, - CreateCertificate - will create certificates with excluded name constraints - if the provided template certificate has the new - field - ExcludedDNSDomains - populated. -

- -

- - If any SAN extension, including with no DNS names, is present - in the certificate, then the Common Name from - Subject is ignored. - In previous releases, the code tested only whether DNS-name SANs were - present in a certificate. -

- -
- -
database/sql
-
-

- The package will now use a cached Stmt if - available in Tx.Stmt. - This prevents statements from being re-prepared each time - Tx.Stmt is called. -

- -

- The package now allows drivers to implement their own argument checkers by implementing - driver.NamedValueChecker. - This also allows drivers to support OUTPUT and INOUT parameter types. - Out should be used to return output parameters - when supported by the driver. -

- -

- Rows.Scan can now scan user-defined string types. - Previously the package supported scanning into numeric types like type Int int64. It now also supports - scanning into string types like type String string. -

- -

- The new DB.Conn method returns the new - Conn type representing an - exclusive connection to the database from the connection pool. All queries run on - a Conn will use the same underlying - connection until Conn.Close is called - to return the connection to the connection pool. -

- -
- -
encoding/asn1
-
-

- The new - NullBytes - and - NullRawValue - represent the ASN.1 NULL type. -

- -
- -
encoding/base32
-
-

- The new Encoding.WithPadding - method adds support for custom padding characters and disabling padding. -

- -
- -
encoding/csv
-
-

- The new field - Reader.ReuseRecord - controls whether calls to - Read - may return a slice sharing the backing array of the previous - call's returned slice for improved performance. -

- -
- -
fmt
-
-

- The sharp flag ('#') is now supported when printing - floating point and complex numbers. It will always print a - decimal point - for %e, %E, %f, %F, %g - and %G; it will not remove trailing zeros - for %g and %G. -

- -
- -
hash/fnv
-
-

- The package now includes 128-bit FNV-1 and FNV-1a hash support with - New128 and - New128a, respectively. -

- -
- -
html/template
-
-

- The package now reports an error if a predefined escaper (one of - "html", "urlquery" and "js") is found in a pipeline and does not match - what the auto-escaper would have decided on its own. - This avoids certain security or correctness issues. - Now use of one of these escapers is always either a no-op or an error. - (The no-op case eases migration from text/template.) -

- -
- -
image
-
-

- The Rectangle.Intersect - method now returns a zero Rectangle when called on - adjacent but non-overlapping rectangles, as documented. In - earlier releases it would incorrectly return an empty but - non-zero Rectangle. -

- -
- -
image/color
-
-

- The YCbCr to RGBA conversion formula has been tweaked to ensure - that rounding adjustments span the complete [0, 0xffff] RGBA - range. -

- -
- -
image/png
-
-

- The new Encoder.BufferPool - field allows specifying an EncoderBufferPool, - that will be used by the encoder to get temporary EncoderBuffer - buffers when encoding a PNG image. - - The use of a BufferPool reduces the number of - memory allocations performed while encoding multiple images. -

- -

- The package now supports the decoding of transparent 8-bit - grayscale ("Gray8") images. -

- -
- -
math/big
-
-

- The new - IsInt64 - and - IsUint64 - methods report whether an Int - may be represented as an int64 or uint64 - value. -

- -
- -
mime/multipart
-
-

- The new - FileHeader.Size - field describes the size of a file in a multipart message. -

- -
- -
net
-
-

- The new - Resolver.StrictErrors - provides control over how Go's built-in DNS resolver handles - temporary errors during queries composed of multiple sub-queries, - such as an A+AAAA address lookup. -

- -

- The new - Resolver.Dial - allows a Resolver to use a custom dial function. -

- -

- JoinHostPort now only places an address in square brackets if the host contains a colon. - In previous releases it would also wrap addresses in square brackets if they contained a percent ('%') sign. -

- -

- The new methods - TCPConn.SyscallConn, - IPConn.SyscallConn, - UDPConn.SyscallConn, - and - UnixConn.SyscallConn - provide access to the connections' underlying file descriptors. -

- -

- It is now safe to call Dial with the address obtained from - (*TCPListener).String() after creating the listener with - Listen("tcp", ":0"). - Previously it failed on some machines with half-configured IPv6 stacks. -

- -
- -
net/http
-
- -

- The Cookie.String method, used for - Cookie and Set-Cookie headers, now encloses values in double quotes - if the value contains either a space or a comma. -

- -

Server changes:

-
    -
  • - ServeMux now ignores ports in the host - header when matching handlers. The host is matched unmodified for CONNECT requests. -
  • - -
  • - The new Server.ServeTLS method wraps - Server.Serve with added TLS support. -
  • - -
  • - Server.WriteTimeout - now applies to HTTP/2 connections and is enforced per-stream. -
  • - -
  • - HTTP/2 now uses the priority write scheduler by default. - Frames are scheduled by following HTTP/2 priorities as described in - RFC 7540 Section 5.3. -
  • - -
  • - The HTTP handler returned by StripPrefix - now calls its provided handler with a modified clone of the original *http.Request. - Any code storing per-request state in maps keyed by *http.Request should - use - Request.Context, - Request.WithContext, - and - context.WithValue instead. -
  • - -
  • - LocalAddrContextKey now contains - the connection's actual network address instead of the interface address used by the listener. -
  • -
- -

Client & Transport changes:

-
    -
  • - The Transport - now supports making requests via SOCKS5 proxy when the URL returned by - Transport.Proxy - has the scheme socks5. -
  • -
- -
- -
net/http/fcgi
-
-

- The new - ProcessEnv - function returns FastCGI environment variables associated with an HTTP request - for which there are no appropriate - http.Request - fields, such as REMOTE_USER. -

- -
- -
net/http/httptest
-
-

- The new - Server.Client - method returns an HTTP client configured for making requests to the test server. -

- -

- The new - Server.Certificate - method returns the test server's TLS certificate, if any. -

- -
- -
net/http/httputil
-
-

- The ReverseProxy - now proxies all HTTP/2 response trailers, even those not declared in the initial response - header. Such undeclared trailers are used by the gRPC protocol. -

- -
- -
os
-
-

- The os package now uses the internal runtime poller - for file I/O. - This reduces the number of threads required for read/write - operations on pipes, and it eliminates races when one goroutine - closes a file while another is using the file for I/O. -

- -
-

- On Windows, - Args - is now populated without shell32.dll, improving process start-up time by 1-7 ms. -

- -
- -
os/exec
-
-

- The os/exec package now prevents child processes from being created with - any duplicate environment variables. - If Cmd.Env - contains duplicate environment keys, only the last - value in the slice for each duplicate key is used. -

- -
- -
os/user
-
-

- Lookup and - LookupId now - work on Unix systems when CGO_ENABLED=0 by reading - the /etc/passwd file. -

- -

- LookupGroup and - LookupGroupId now - work on Unix systems when CGO_ENABLED=0 by reading - the /etc/group file. -

- -
- -
reflect
-
-

- The new - MakeMapWithSize - function creates a map with a capacity hint. -

- -
- -
runtime
-
-

- Tracebacks generated by the runtime and recorded in profiles are - now accurate in the presence of inlining. - To retrieve tracebacks programmatically, applications should use - runtime.CallersFrames - rather than directly iterating over the results of - runtime.Callers. -

- -

- On Windows, Go no longer forces the system timer to run at high - resolution when the program is idle. - This should reduce the impact of Go programs on battery life. -

- -

- On FreeBSD, GOMAXPROCS and - runtime.NumCPU - are now based on the process' CPU mask, rather than the total - number of CPUs. -

- -

- The runtime has preliminary support for Android O. -

- -
- -
runtime/debug
-
-

- Calling - SetGCPercent - with a negative value no longer runs an immediate garbage collection. -

- -
- -
runtime/trace
-
-

- The execution trace now displays mark assist events, which - indicate when an application goroutine is forced to assist - garbage collection because it is allocating too quickly. -

- -

- "Sweep" events now encompass the entire process of finding free - space for an allocation, rather than recording each individual - span that is swept. - This reduces allocation latency when tracing allocation-heavy - programs. - The sweep event shows how many bytes were swept and how many - were reclaimed. -

- -
- -
sync
-
-

- Mutex is now more fair. -

- -
- -
syscall
-
-

- The new field - Credential.NoSetGroups - controls whether Unix systems make a setgroups system call - to set supplementary groups when starting a new process. -

- -

- The new field - SysProcAttr.AmbientCaps - allows setting ambient capabilities on Linux 4.3+ when creating - a new process. -

- -

- On 64-bit x86 Linux, process creation latency has been optimized with - use of CLONE_VFORK and CLONE_VM. -

- -

- The new - Conn - interface describes some types in the - net - package that can provide access to their underlying file descriptor - using the new - RawConn - interface. -

- -
- - -
testing/quick
-
-

- The package now chooses values in the full range when - generating int64 and uint64 random - numbers; in earlier releases generated values were always - limited to the [-262, 262) range. -

- -

- In previous releases, using a nil - Config.Rand - value caused a fixed deterministic random number generator to be used. - It now uses a random number generator seeded with the current time. - For the old behavior, set Config.Rand to rand.New(rand.NewSource(0)). -

- -
- -
text/template
-
-

- The handling of empty blocks, which was broken by a Go 1.8 - change that made the result dependent on the order of templates, - has been fixed, restoring the old Go 1.7 behavior. -

- -
- -
time
-
-

- The new methods - Duration.Round - and - Duration.Truncate - handle rounding and truncating durations to multiples of a given duration. -

- -

- Retrieving the time and sleeping now work correctly under Wine. -

- -

- If a Time value has a monotonic clock reading, its - string representation (as returned by String) now includes a - final field "m=±value", where value is the - monotonic clock reading formatted as a decimal number of seconds. -

- -

- The included tzdata timezone database has been - updated to version 2017b. As always, it is only used if the - system does not already have the database available. -

- -
diff --git a/_content/doc/go1.html b/_content/doc/go1.html deleted file mode 100644 index e63807140d..0000000000 --- a/_content/doc/go1.html +++ /dev/null @@ -1,2038 +0,0 @@ - - -

Introduction to Go 1

- -

-Go version 1, Go 1 for short, defines a language and a set of core libraries -that provide a stable foundation for creating reliable products, projects, and -publications. -

- -

-The driving motivation for Go 1 is stability for its users. People should be able to -write Go programs and expect that they will continue to compile and run without -change, on a time scale of years, including in production environments such as -Google App Engine. Similarly, people should be able to write books about Go, be -able to say which version of Go the book is describing, and have that version -number still be meaningful much later. -

- -

-Code that compiles in Go 1 should, with few exceptions, continue to compile and -run throughout the lifetime of that version, even as we issue updates and bug -fixes such as Go version 1.1, 1.2, and so on. Other than critical fixes, changes -made to the language and library for subsequent releases of Go 1 may -add functionality but will not break existing Go 1 programs. -The Go 1 compatibility document -explains the compatibility guidelines in more detail. -

- -

-Go 1 is a representation of Go as it used today, not a wholesale rethinking of -the language. We avoided designing new features and instead focused on cleaning -up problems and inconsistencies and improving portability. There are a number -changes to the Go language and packages that we had considered for some time and -prototyped but not released primarily because they are significant and -backwards-incompatible. Go 1 was an opportunity to get them out, which is -helpful for the long term, but also means that Go 1 introduces incompatibilities -for old programs. Fortunately, the go fix tool can -automate much of the work needed to bring programs up to the Go 1 standard. -

- -

-This document outlines the major changes in Go 1 that will affect programmers -updating existing code; its reference point is the prior release, r60 (tagged as -r60.3). It also explains how to update code from r60 to run under Go 1. -

- -

Changes to the language

- -

Append

- -

-The append predeclared variadic function makes it easy to grow a slice -by adding elements to the end. -A common use is to add bytes to the end of a byte slice when generating output. -However, append did not provide a way to append a string to a []byte, -which is another common case. -

- -{{code "/doc/progs/go1.go" `/greeting := ..byte/` `/append.*hello/`}} - -

-By analogy with the similar property of copy, Go 1 -permits a string to be appended (byte-wise) directly to a byte -slice, reducing the friction between strings and byte slices. -The conversion is no longer necessary: -

- -{{code "/doc/progs/go1.go" `/append.*world/`}} - -

-Updating: -This is a new feature, so existing code needs no changes. -

- -

Close

- -

-The close predeclared function provides a mechanism -for a sender to signal that no more values will be sent. -It is important to the implementation of for range -loops over channels and is helpful in other situations. -Partly by design and partly because of race conditions that can occur otherwise, -it is intended for use only by the goroutine sending on the channel, -not by the goroutine receiving data. -However, before Go 1 there was no compile-time checking that close -was being used correctly. -

- -

-To close this gap, at least in part, Go 1 disallows close on receive-only channels. -Attempting to close such a channel is a compile-time error. -

- -
-    var c chan int
-    var csend chan<- int = c
-    var crecv <-chan int = c
-    close(c)     // legal
-    close(csend) // legal
-    close(crecv) // illegal
-
- -

-Updating: -Existing code that attempts to close a receive-only channel was -erroneous even before Go 1 and should be fixed. The compiler will -now reject such code. -

- -

Composite literals

- -

-In Go 1, a composite literal of array, slice, or map type can elide the -type specification for the elements' initializers if they are of pointer type. -All four of the initializations in this example are legal; the last one was illegal before Go 1. -

- -{{code "/doc/progs/go1.go" `/type Date struct/` `/STOP/`}} - -

-Updating: -This change has no effect on existing code, but the command -gofmt -s applied to existing source -will, among other things, elide explicit element types wherever permitted. -

- - -

Goroutines during init

- -

-The old language defined that go statements executed during initialization created goroutines but that they did not begin to run until initialization of the entire program was complete. -This introduced clumsiness in many places and, in effect, limited the utility -of the init construct: -if it was possible for another package to use the library during initialization, the library -was forced to avoid goroutines. -This design was done for reasons of simplicity and safety but, -as our confidence in the language grew, it seemed unnecessary. -Running goroutines during initialization is no more complex or unsafe than running them during normal execution. -

- -

-In Go 1, code that uses goroutines can be called from -init routines and global initialization expressions -without introducing a deadlock. -

- -{{code "/doc/progs/go1.go" `/PackageGlobal/` `/^}/`}} - -

-Updating: -This is a new feature, so existing code needs no changes, -although it's possible that code that depends on goroutines not starting before main will break. -There was no such code in the standard repository. -

- -

The rune type

- -

-The language spec allows the int type to be 32 or 64 bits wide, but current implementations set int to 32 bits even on 64-bit platforms. -It would be preferable to have int be 64 bits on 64-bit platforms. -(There are important consequences for indexing large slices.) -However, this change would waste space when processing Unicode characters with -the old language because the int type was also used to hold Unicode code points: each code point would waste an extra 32 bits of storage if int grew from 32 bits to 64. -

- -

-To make changing to 64-bit int feasible, -Go 1 introduces a new basic type, rune, to represent -individual Unicode code points. -It is an alias for int32, analogous to byte -as an alias for uint8. -

- -

-Character literals such as 'a', '語', and '\u0345' -now have default type rune, -analogous to 1.0 having default type float64. -A variable initialized to a character constant will therefore -have type rune unless otherwise specified. -

- -

-Libraries have been updated to use rune rather than int -when appropriate. For instance, the functions unicode.ToLower and -relatives now take and return a rune. -

- -{{code "/doc/progs/go1.go" `/STARTRUNE/` `/ENDRUNE/`}} - -

-Updating: -Most source code will be unaffected by this because the type inference from -:= initializers introduces the new type silently, and it propagates -from there. -Some code may get type errors that a trivial conversion will resolve. -

- -

The error type

- -

-Go 1 introduces a new built-in type, error, which has the following definition: -

- -
-    type error interface {
-        Error() string
-    }
-
- -

-Since the consequences of this type are all in the package library, -it is discussed below. -

- -

Deleting from maps

- -

-In the old language, to delete the entry with key k from map m, one wrote the statement, -

- -
-    m[k] = value, false
-
- -

-This syntax was a peculiar special case, the only two-to-one assignment. -It required passing a value (usually ignored) that is evaluated but discarded, -plus a boolean that was nearly always the constant false. -It did the job but was odd and a point of contention. -

- -

-In Go 1, that syntax has gone; instead there is a new built-in -function, delete. The call -

- -{{code "/doc/progs/go1.go" `/delete\(m, k\)/`}} - -

-will delete the map entry retrieved by the expression m[k]. -There is no return value. Deleting a non-existent entry is a no-op. -

- -

-Updating: -Running go fix will convert expressions of the form m[k] = value, -false into delete(m, k) when it is clear that -the ignored value can be safely discarded from the program and -false refers to the predefined boolean constant. -The fix tool -will flag other uses of the syntax for inspection by the programmer. -

- -

Iterating in maps

- -

-The old language specification did not define the order of iteration for maps, -and in practice it differed across hardware platforms. -This caused tests that iterated over maps to be fragile and non-portable, with the -unpleasant property that a test might always pass on one machine but break on another. -

- -

-In Go 1, the order in which elements are visited when iterating -over a map using a for range statement -is defined to be unpredictable, even if the same loop is run multiple -times with the same map. -Code should not assume that the elements are visited in any particular order. -

- -

-This change means that code that depends on iteration order is very likely to break early and be fixed long before it becomes a problem. -Just as important, it allows the map implementation to ensure better map balancing even when programs are using range loops to select an element from a map. -

- -{{code "/doc/progs/go1.go" `/Sunday/` `/^ }/`}} - -

-Updating: -This is one change where tools cannot help. Most existing code -will be unaffected, but some programs may break or misbehave; we -recommend manual checking of all range statements over maps to -verify they do not depend on iteration order. There were a few such -examples in the standard repository; they have been fixed. -Note that it was already incorrect to depend on the iteration order, which -was unspecified. This change codifies the unpredictability. -

- -

Multiple assignment

- -

-The language specification has long guaranteed that in assignments -the right-hand-side expressions are all evaluated before any left-hand-side expressions are assigned. -To guarantee predictable behavior, -Go 1 refines the specification further. -

- -

-If the left-hand side of the assignment -statement contains expressions that require evaluation, such as -function calls or array indexing operations, these will all be done -using the usual left-to-right rule before any variables are assigned -their value. Once everything is evaluated, the actual assignments -proceed in left-to-right order. -

- -

-These examples illustrate the behavior. -

- -{{code "/doc/progs/go1.go" `/sa :=/` `/then sc.0. = 2/`}} - -

-Updating: -This is one change where tools cannot help, but breakage is unlikely. -No code in the standard repository was broken by this change, and code -that depended on the previous unspecified behavior was already incorrect. -

- -

Returns and shadowed variables

- -

-A common mistake is to use return (without arguments) after an assignment to a variable that has the same name as a result variable but is not the same variable. -This situation is called shadowing: the result variable has been shadowed by another variable with the same name declared in an inner scope. -

- -

-In functions with named return values, -the Go 1 compilers disallow return statements without arguments if any of the named return values is shadowed at the point of the return statement. -(It isn't part of the specification, because this is one area we are still exploring; -the situation is analogous to the compilers rejecting functions that do not end with an explicit return statement.) -

- -

-This function implicitly returns a shadowed return value and will be rejected by the compiler: -

- -
-    func Bug() (i, j, k int) {
-        for i = 0; i < 5; i++ {
-            for j := 0; j < 5; j++ { // Redeclares j.
-                k += i*j
-                if k > 100 {
-                    return // Rejected: j is shadowed here.
-                }
-            }
-        }
-        return // OK: j is not shadowed here.
-    }
-
- -

-Updating: -Code that shadows return values in this way will be rejected by the compiler and will need to be fixed by hand. -The few cases that arose in the standard repository were mostly bugs. -

- -

Copying structs with unexported fields

- -

-The old language did not allow a package to make a copy of a struct value containing unexported fields belonging to a different package. -There was, however, a required exception for a method receiver; -also, the implementations of copy and append have never honored the restriction. -

- -

-Go 1 will allow packages to copy struct values containing unexported fields from other packages. -Besides resolving the inconsistency, -this change admits a new kind of API: a package can return an opaque value without resorting to a pointer or interface. -The new implementations of time.Time and -reflect.Value are examples of types taking advantage of this new property. -

- -

-As an example, if package p includes the definitions, -

- -
-    type Struct struct {
-        Public int
-        secret int
-    }
-    func NewStruct(a int) Struct {  // Note: not a pointer.
-        return Struct{a, f(a)}
-    }
-    func (s Struct) String() string {
-        return fmt.Sprintf("{%d (secret %d)}", s.Public, s.secret)
-    }
-
- -

-a package that imports p can assign and copy values of type -p.Struct at will. -Behind the scenes the unexported fields will be assigned and copied just -as if they were exported, -but the client code will never be aware of them. The code -

- -
-    import "p"
-
-    myStruct := p.NewStruct(23)
-    copyOfMyStruct := myStruct
-    fmt.Println(myStruct, copyOfMyStruct)
-
- -

-will show that the secret field of the struct has been copied to the new value. -

- -

-Updating: -This is a new feature, so existing code needs no changes. -

- -

Equality

- -

-Before Go 1, the language did not define equality on struct and array values. -This meant, -among other things, that structs and arrays could not be used as map keys. -On the other hand, Go did define equality on function and map values. -Function equality was problematic in the presence of closures -(when are two closures equal?) -while map equality compared pointers, not the maps' content, which was usually -not what the user would want. -

- -

-Go 1 addressed these issues. -First, structs and arrays can be compared for equality and inequality -(== and !=), -and therefore be used as map keys, -provided they are composed from elements for which equality is also defined, -using element-wise comparison. -

- -{{code "/doc/progs/go1.go" `/type Day struct/` `/Printf/`}} - -

-Second, Go 1 removes the definition of equality for function values, -except for comparison with nil. -Finally, map equality is gone too, also except for comparison with nil. -

- -

-Note that equality is still undefined for slices, for which the -calculation is in general infeasible. Also note that the ordered -comparison operators (< <= -> >=) are still undefined for -structs and arrays. - -

-Updating: -Struct and array equality is a new feature, so existing code needs no changes. -Existing code that depends on function or map equality will be -rejected by the compiler and will need to be fixed by hand. -Few programs will be affected, but the fix may require some -redesign. -

- -

The package hierarchy

- -

-Go 1 addresses many deficiencies in the old standard library and -cleans up a number of packages, making them more internally consistent -and portable. -

- -

-This section describes how the packages have been rearranged in Go 1. -Some have moved, some have been renamed, some have been deleted. -New packages are described in later sections. -

- -

The package hierarchy

- -

-Go 1 has a rearranged package hierarchy that groups related items -into subdirectories. For instance, utf8 and -utf16 now occupy subdirectories of unicode. -Also, some packages have moved into -subrepositories of -code.google.com/p/go -while others have been deleted outright. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Old pathNew path

asn1 encoding/asn1
csv encoding/csv
gob encoding/gob
json encoding/json
xml encoding/xml

exp/template/html html/template

big math/big
cmath math/cmplx
rand math/rand

http net/http
http/cgi net/http/cgi
http/fcgi net/http/fcgi
http/httptest net/http/httptest
http/pprof net/http/pprof
mail net/mail
rpc net/rpc
rpc/jsonrpc net/rpc/jsonrpc
smtp net/smtp
url net/url

exec os/exec

scanner text/scanner
tabwriter text/tabwriter
template text/template
template/parse text/template/parse

utf8 unicode/utf8
utf16 unicode/utf16
- -

-Note that the package names for the old cmath and -exp/template/html packages have changed to cmplx -and template. -

- -

-Updating: -Running go fix will update all imports and package renames for packages that -remain inside the standard repository. Programs that import packages -that are no longer in the standard repository will need to be edited -by hand. -

- -

The package tree exp

- -

-Because they are not standardized, the packages under the exp directory will not be available in the -standard Go 1 release distributions, although they will be available in source code form -in the repository for -developers who wish to use them. -

- -

-Several packages have moved under exp at the time of Go 1's release: -

- -
    -
  • ebnf
  • -
  • html
  • -
  • go/types
  • -
- -

-(The EscapeString and UnescapeString types remain -in package html.) -

- -

-All these packages are available under the same names, with the prefix exp/: exp/ebnf etc. -

- -

-Also, the utf8.String type has been moved to its own package, exp/utf8string. -

- -

-Finally, the gotype command now resides in exp/gotype, while -ebnflint is now in exp/ebnflint. -If they are installed, they now reside in $GOROOT/bin/tool. -

- -

-Updating: -Code that uses packages in exp will need to be updated by hand, -or else compiled from an installation that has exp available. -The go fix tool or the compiler will complain about such uses. -

- -

The package tree old

- -

-Because they are deprecated, the packages under the old directory will not be available in the -standard Go 1 release distributions, although they will be available in source code form for -developers who wish to use them. -

- -

-The packages in their new locations are: -

- -
    -
  • old/netchan
  • -
- -

-Updating: -Code that uses packages now in old will need to be updated by hand, -or else compiled from an installation that has old available. -The go fix tool will warn about such uses. -

- -

Deleted packages

- -

-Go 1 deletes several packages outright: -

- -
    -
  • container/vector
  • -
  • exp/datafmt
  • -
  • go/typechecker
  • -
  • old/regexp
  • -
  • old/template
  • -
  • try
  • -
- -

-and also the command gotry. -

- -

-Updating: -Code that uses container/vector should be updated to use -slices directly. See -the Go -Language Community Wiki for some suggestions. -Code that uses the other packages (there should be almost zero) will need to be rethought. -

- -

Packages moving to subrepositories

- -

-Go 1 has moved a number of packages into other repositories, usually sub-repositories of -the main Go repository. -This table lists the old and new import paths: -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OldNew

crypto/bcrypt code.google.com/p/go.crypto/bcrypt
crypto/blowfish code.google.com/p/go.crypto/blowfish
crypto/cast5 code.google.com/p/go.crypto/cast5
crypto/md4 code.google.com/p/go.crypto/md4
crypto/ocsp code.google.com/p/go.crypto/ocsp
crypto/openpgp code.google.com/p/go.crypto/openpgp
crypto/openpgp/armor code.google.com/p/go.crypto/openpgp/armor
crypto/openpgp/elgamal code.google.com/p/go.crypto/openpgp/elgamal
crypto/openpgp/errors code.google.com/p/go.crypto/openpgp/errors
crypto/openpgp/packet code.google.com/p/go.crypto/openpgp/packet
crypto/openpgp/s2k code.google.com/p/go.crypto/openpgp/s2k
crypto/ripemd160 code.google.com/p/go.crypto/ripemd160
crypto/twofish code.google.com/p/go.crypto/twofish
crypto/xtea code.google.com/p/go.crypto/xtea
exp/ssh code.google.com/p/go.crypto/ssh

image/bmp code.google.com/p/go.image/bmp
image/tiff code.google.com/p/go.image/tiff

net/dict code.google.com/p/go.net/dict
net/websocket code.google.com/p/go.net/websocket
exp/spdy code.google.com/p/go.net/spdy

encoding/git85 code.google.com/p/go.codereview/git85
patch code.google.com/p/go.codereview/patch

exp/wingui code.google.com/p/gowingui
- -

-Updating: -Running go fix will update imports of these packages to use the new import paths. -Installations that depend on these packages will need to install them using -a go get command. -

- -

Major changes to the library

- -

-This section describes significant changes to the core libraries, the ones that -affect the most programs. -

- -

The error type and errors package

- -

-The placement of os.Error in package os is mostly historical: errors first came up when implementing package os, and they seemed system-related at the time. -Since then it has become clear that errors are more fundamental than the operating system. For example, it would be nice to use Errors in packages that os depends on, like syscall. -Also, having Error in os introduces many dependencies on os that would otherwise not exist. -

- -

-Go 1 solves these problems by introducing a built-in error interface type and a separate errors package (analogous to bytes and strings) that contains utility functions. -It replaces os.NewError with -errors.New, -giving errors a more central place in the environment. -

- -

-So the widely-used String method does not cause accidental satisfaction -of the error interface, the error interface uses instead -the name Error for that method: -

- -
-    type error interface {
-        Error() string
-    }
-
- -

-The fmt library automatically invokes Error, as it already -does for String, for easy printing of error values. -

- -{{code "/doc/progs/go1.go" `/START ERROR EXAMPLE/` `/END ERROR EXAMPLE/`}} - -

-All standard packages have been updated to use the new interface; the old os.Error is gone. -

- -

-A new package, errors, contains the function -

- -
-func New(text string) error
-
- -

-to turn a string into an error. It replaces the old os.NewError. -

- -{{code "/doc/progs/go1.go" `/ErrSyntax/`}} - -

-Updating: -Running go fix will update almost all code affected by the change. -Code that defines error types with a String method will need to be updated -by hand to rename the methods to Error. -

- -

System call errors

- -

-The old syscall package, which predated os.Error -(and just about everything else), -returned errors as int values. -In turn, the os package forwarded many of these errors, such -as EINVAL, but using a different set of errors on each platform. -This behavior was unpleasant and unportable. -

- -

-In Go 1, the -syscall -package instead returns an error for system call errors. -On Unix, the implementation is done by a -syscall.Errno type -that satisfies error and replaces the old os.Errno. -

- -

-The changes affecting os.EINVAL and relatives are -described elsewhere. - -

-Updating: -Running go fix will update almost all code affected by the change. -Regardless, most code should use the os package -rather than syscall and so will be unaffected. -

- -

Time

- -

-Time is always a challenge to support well in a programming language. -The old Go time package had int64 units, no -real type safety, -and no distinction between absolute times and durations. -

- -

-One of the most sweeping changes in the Go 1 library is therefore a -complete redesign of the -time package. -Instead of an integer number of nanoseconds as an int64, -and a separate *time.Time type to deal with human -units such as hours and years, -there are now two fundamental types: -time.Time -(a value, so the * is gone), which represents a moment in time; -and time.Duration, -which represents an interval. -Both have nanosecond resolution. -A Time can represent any time into the ancient -past and remote future, while a Duration can -span plus or minus only about 290 years. -There are methods on these types, plus a number of helpful -predefined constant durations such as time.Second. -

- -

-Among the new methods are things like -Time.Add, -which adds a Duration to a Time, and -Time.Sub, -which subtracts two Times to yield a Duration. -

- -

-The most important semantic change is that the Unix epoch (Jan 1, 1970) is now -relevant only for those functions and methods that mention Unix: -time.Unix -and the Unix -and UnixNano methods -of the Time type. -In particular, -time.Now -returns a time.Time value rather than, in the old -API, an integer nanosecond count since the Unix epoch. -

- -{{code "/doc/progs/go1.go" `/sleepUntil/` `/^}/`}} - -

-The new types, methods, and constants have been propagated through -all the standard packages that use time, such as os and -its representation of file time stamps. -

- -

-Updating: -The go fix tool will update many uses of the old time package to use the new -types and methods, although it does not replace values such as 1e9 -representing nanoseconds per second. -Also, because of type changes in some of the values that arise, -some of the expressions rewritten by the fix tool may require -further hand editing; in such cases the rewrite will include -the correct function or method for the old functionality, but -may have the wrong type or require further analysis. -

- -

Minor changes to the library

- -

-This section describes smaller changes, such as those to less commonly -used packages or that affect -few programs beyond the need to run go fix. -This category includes packages that are new in Go 1. -Collectively they improve portability, regularize behavior, and -make the interfaces more modern and Go-like. -

- -

The archive/zip package

- -

-In Go 1, *zip.Writer no -longer has a Write method. Its presence was a mistake. -

- -

-Updating: -What little code is affected will be caught by the compiler and must be updated by hand. -

- -

The bufio package

- -

-In Go 1, bufio.NewReaderSize -and -bufio.NewWriterSize -functions no longer return an error for invalid sizes. -If the argument size is too small or invalid, it is adjusted. -

- -

-Updating: -Running go fix will update calls that assign the error to _. -Calls that aren't fixed will be caught by the compiler and must be updated by hand. -

- -

The compress/flate, compress/gzip and compress/zlib packages

- -

-In Go 1, the NewWriterXxx functions in -compress/flate, -compress/gzip and -compress/zlib -all return (*Writer, error) if they take a compression level, -and *Writer otherwise. Package gzip's -Compressor and Decompressor types have been renamed -to Writer and Reader. Package flate's -WrongValueError type has been removed. -

- -

-Updating -Running go fix will update old names and calls that assign the error to _. -Calls that aren't fixed will be caught by the compiler and must be updated by hand. -

- -

The crypto/aes and crypto/des packages

- -

-In Go 1, the Reset method has been removed. Go does not guarantee -that memory is not copied and therefore this method was misleading. -

- -

-The cipher-specific types *aes.Cipher, *des.Cipher, -and *des.TripleDESCipher have been removed in favor of -cipher.Block. -

- -

-Updating: -Remove the calls to Reset. Replace uses of the specific cipher types with -cipher.Block. -

- -

The crypto/elliptic package

- -

-In Go 1, elliptic.Curve -has been made an interface to permit alternative implementations. The curve -parameters have been moved to the -elliptic.CurveParams -structure. -

- -

-Updating: -Existing users of *elliptic.Curve will need to change to -simply elliptic.Curve. Calls to Marshal, -Unmarshal and GenerateKey are now functions -in crypto/elliptic that take an elliptic.Curve -as their first argument. -

- -

The crypto/hmac package

- -

-In Go 1, the hash-specific functions, such as hmac.NewMD5, have -been removed from crypto/hmac. Instead, hmac.New takes -a function that returns a hash.Hash, such as md5.New. -

- -

-Updating: -Running go fix will perform the needed changes. -

- -

The crypto/x509 package

- -

-In Go 1, the -CreateCertificate -function and -CreateCRL -method in crypto/x509 have been altered to take an -interface{} where they previously took a *rsa.PublicKey -or *rsa.PrivateKey. This will allow other public key algorithms -to be implemented in the future. -

- -

-Updating: -No changes will be needed. -

- -

The encoding/binary package

- -

-In Go 1, the binary.TotalSize function has been replaced by -Size, -which takes an interface{} argument rather than -a reflect.Value. -

- -

-Updating: -What little code is affected will be caught by the compiler and must be updated by hand. -

- -

The encoding/xml package

- -

-In Go 1, the xml package -has been brought closer in design to the other marshaling packages such -as encoding/gob. -

- -

-The old Parser type is renamed -Decoder and has a new -Decode method. An -Encoder type was also introduced. -

- -

-The functions Marshal -and Unmarshal -work with []byte values now. To work with streams, -use the new Encoder -and Decoder types. -

- -

-When marshaling or unmarshaling values, the format of supported flags in -field tags has changed to be closer to the -json package -(`xml:"name,flag"`). The matching done between field tags, field -names, and the XML attribute and element names is now case-sensitive. -The XMLName field tag, if present, must also match the name -of the XML element being marshaled. -

- -

-Updating: -Running go fix will update most uses of the package except for some calls to -Unmarshal. Special care must be taken with field tags, -since the fix tool will not update them and if not fixed by hand they will -misbehave silently in some cases. For example, the old -"attr" is now written ",attr" while plain -"attr" remains valid but with a different meaning. -

- -

The expvar package

- -

-In Go 1, the RemoveAll function has been removed. -The Iter function and Iter method on *Map have -been replaced by -Do -and -(*Map).Do. -

- -

-Updating: -Most code using expvar will not need changing. The rare code that used -Iter can be updated to pass a closure to Do to achieve the same effect. -

- -

The flag package

- -

-In Go 1, the interface flag.Value has changed slightly. -The Set method now returns an error instead of -a bool to indicate success or failure. -

- -

-There is also a new kind of flag, Duration, to support argument -values specifying time intervals. -Values for such flags must be given units, just as time.Duration -formats them: 10s, 1h30m, etc. -

- -{{code "/doc/progs/go1.go" `/timeout/`}} - -

-Updating: -Programs that implement their own flags will need minor manual fixes to update their -Set methods. -The Duration flag is new and affects no existing code. -

- - -

The go/* packages

- -

-Several packages under go have slightly revised APIs. -

- -

-A concrete Mode type was introduced for configuration mode flags -in the packages -go/scanner, -go/parser, -go/printer, and -go/doc. -

- -

-The modes AllowIllegalChars and InsertSemis have been removed -from the go/scanner package. They were mostly -useful for scanning text other then Go source files. Instead, the -text/scanner package should be used -for that purpose. -

- -

-The ErrorHandler provided -to the scanner's Init method is -now simply a function rather than an interface. The ErrorVector type has -been removed in favor of the (existing) ErrorList -type, and the ErrorVector methods have been migrated. Instead of embedding -an ErrorVector in a client of the scanner, now a client should maintain -an ErrorList. -

- -

-The set of parse functions provided by the go/parser -package has been reduced to the primary parse function -ParseFile, and a couple of -convenience functions ParseDir -and ParseExpr. -

- -

-The go/printer package supports an additional -configuration mode SourcePos; -if set, the printer will emit //line comments such that the generated -output contains the original source code position information. The new type -CommentedNode can be -used to provide comments associated with an arbitrary -ast.Node (until now only -ast.File carried comment information). -

- -

-The type names of the go/doc package have been -streamlined by removing the Doc suffix: PackageDoc -is now Package, ValueDoc is Value, etc. -Also, all types now consistently have a Name field (or Names, -in the case of type Value) and Type.Factories has become -Type.Funcs. -Instead of calling doc.NewPackageDoc(pkg, importpath), -documentation for a package is created with: -

- -
-    doc.New(pkg, importpath, mode)
-
- -

-where the new mode parameter specifies the operation mode: -if set to AllDecls, all declarations -(not just exported ones) are considered. -The function NewFileDoc was removed, and the function -CommentText has become the method -Text of -ast.CommentGroup. -

- -

-In package go/token, the -token.FileSet method Files -(which originally returned a channel of *token.Files) has been replaced -with the iterator Iterate that -accepts a function argument instead. -

- -

-In package go/build, the API -has been nearly completely replaced. -The package still computes Go package information -but it does not run the build: the Cmd and Script -types are gone. -(To build code, use the new -go command instead.) -The DirInfo type is now named -Package. -FindTree and ScanDir are replaced by -Import -and -ImportDir. -

- -

-Updating: -Code that uses packages in go will have to be updated by hand; the -compiler will reject incorrect uses. Templates used in conjunction with any of the -go/doc types may need manual fixes; the renamed fields will lead -to run-time errors. -

- -

The hash package

- -

-In Go 1, the definition of hash.Hash includes -a new method, BlockSize. This new method is used primarily in the -cryptographic libraries. -

- -

-The Sum method of the -hash.Hash interface now takes a -[]byte argument, to which the hash value will be appended. -The previous behavior can be recreated by adding a nil argument to the call. -

- -

-Updating: -Existing implementations of hash.Hash will need to add a -BlockSize method. Hashes that process the input one byte at -a time can implement BlockSize to return 1. -Running go fix will update calls to the Sum methods of the various -implementations of hash.Hash. -

- -

-Updating: -Since the package's functionality is new, no updating is necessary. -

- -

The http package

- -

-In Go 1 the http package is refactored, -putting some of the utilities into a -httputil subdirectory. -These pieces are only rarely needed by HTTP clients. -The affected items are: -

- -
    -
  • ClientConn
  • -
  • DumpRequest
  • -
  • DumpRequestOut
  • -
  • DumpResponse
  • -
  • NewChunkedReader
  • -
  • NewChunkedWriter
  • -
  • NewClientConn
  • -
  • NewProxyClientConn
  • -
  • NewServerConn
  • -
  • NewSingleHostReverseProxy
  • -
  • ReverseProxy
  • -
  • ServerConn
  • -
- -

-The Request.RawURL field has been removed; it was a -historical artifact. -

- -

-The Handle and HandleFunc -functions, and the similarly-named methods of ServeMux, -now panic if an attempt is made to register the same pattern twice. -

- -

-Updating: -Running go fix will update the few programs that are affected except for -uses of RawURL, which must be fixed by hand. -

- -

The image package

- -

-The image package has had a number of -minor changes, rearrangements and renamings. -

- -

-Most of the color handling code has been moved into its own package, -image/color. -For the elements that moved, a symmetry arises; for instance, -each pixel of an -image.RGBA -is a -color.RGBA. -

- -

-The old image/ycbcr package has been folded, with some -renamings, into the -image -and -image/color -packages. -

- -

-The old image.ColorImage type is still in the image -package but has been renamed -image.Uniform, -while image.Tiled has been removed. -

- -

-This table lists the renamings. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OldNew

image.Color color.Color
image.ColorModel color.Model
image.ColorModelFunc color.ModelFunc
image.PalettedColorModel color.Palette

image.RGBAColor color.RGBA
image.RGBA64Color color.RGBA64
image.NRGBAColor color.NRGBA
image.NRGBA64Color color.NRGBA64
image.AlphaColor color.Alpha
image.Alpha16Color color.Alpha16
image.GrayColor color.Gray
image.Gray16Color color.Gray16

image.RGBAColorModel color.RGBAModel
image.RGBA64ColorModel color.RGBA64Model
image.NRGBAColorModel color.NRGBAModel
image.NRGBA64ColorModel color.NRGBA64Model
image.AlphaColorModel color.AlphaModel
image.Alpha16ColorModel color.Alpha16Model
image.GrayColorModel color.GrayModel
image.Gray16ColorModel color.Gray16Model

ycbcr.RGBToYCbCr color.RGBToYCbCr
ycbcr.YCbCrToRGB color.YCbCrToRGB
ycbcr.YCbCrColorModel color.YCbCrModel
ycbcr.YCbCrColor color.YCbCr
ycbcr.YCbCr image.YCbCr

ycbcr.SubsampleRatio444 image.YCbCrSubsampleRatio444
ycbcr.SubsampleRatio422 image.YCbCrSubsampleRatio422
ycbcr.SubsampleRatio420 image.YCbCrSubsampleRatio420

image.ColorImage image.Uniform
- -

-The image package's New functions -(NewRGBA, -NewRGBA64, etc.) -take an image.Rectangle as an argument -instead of four integers. -

- -

-Finally, there are new predefined color.Color variables -color.Black, -color.White, -color.Opaque -and -color.Transparent. -

- -

-Updating: -Running go fix will update almost all code affected by the change. -

- -

The log/syslog package

- -

-In Go 1, the syslog.NewLogger -function returns an error as well as a log.Logger. -

- -

-Updating: -What little code is affected will be caught by the compiler and must be updated by hand. -

- -

The mime package

- -

-In Go 1, the FormatMediaType function -of the mime package has been simplified to make it -consistent with -ParseMediaType. -It now takes "text/html" rather than "text" and "html". -

- -

-Updating: -What little code is affected will be caught by the compiler and must be updated by hand. -

- -

The net package

- -

-In Go 1, the various SetTimeout, -SetReadTimeout, and SetWriteTimeout methods -have been replaced with -SetDeadline, -SetReadDeadline, and -SetWriteDeadline, -respectively. Rather than taking a timeout value in nanoseconds that -apply to any activity on the connection, the new methods set an -absolute deadline (as a time.Time value) after which -reads and writes will time out and no longer block. -

- -

-There are also new functions -net.DialTimeout -to simplify timing out dialing a network address and -net.ListenMulticastUDP -to allow multicast UDP to listen concurrently across multiple listeners. -The net.ListenMulticastUDP function replaces the old -JoinGroup and LeaveGroup methods. -

- -

-Updating: -Code that uses the old methods will fail to compile and must be updated by hand. -The semantic change makes it difficult for the fix tool to update automatically. -

- -

The os package

- -

-The Time function has been removed; callers should use -the Time type from the -time package. -

- -

-The Exec function has been removed; callers should use -Exec from the syscall package, where available. -

- -

-The ShellExpand function has been renamed to ExpandEnv. -

- -

-The NewFile function -now takes a uintptr fd, instead of an int. -The Fd method on files now -also returns a uintptr. -

- -

-There are no longer error constants such as EINVAL -in the os package, since the set of values varied with -the underlying operating system. There are new portable functions like -IsPermission -to test common error properties, plus a few new error values -with more Go-like names, such as -ErrPermission -and -ErrNotExist. -

- -

-The Getenverror function has been removed. To distinguish -between a non-existent environment variable and an empty string, -use os.Environ or -syscall.Getenv. -

- - -

-The Process.Wait method has -dropped its option argument and the associated constants are gone -from the package. -Also, the function Wait is gone; only the method of -the Process type persists. -

- -

-The Waitmsg type returned by -Process.Wait -has been replaced with a more portable -ProcessState -type with accessor methods to recover information about the -process. -Because of changes to Wait, the ProcessState -value always describes an exited process. -Portability concerns simplified the interface in other ways, but the values returned by the -ProcessState.Sys and -ProcessState.SysUsage -methods can be type-asserted to underlying system-specific data structures such as -syscall.WaitStatus and -syscall.Rusage on Unix. -

- -

-Updating: -Running go fix will drop a zero argument to Process.Wait. -All other changes will be caught by the compiler and must be updated by hand. -

- -

The os.FileInfo type

- -

-Go 1 redefines the os.FileInfo type, -changing it from a struct to an interface: -

- -
-    type FileInfo interface {
-        Name() string       // base name of the file
-        Size() int64        // length in bytes
-        Mode() FileMode     // file mode bits
-        ModTime() time.Time // modification time
-        IsDir() bool        // abbreviation for Mode().IsDir()
-        Sys() interface{}   // underlying data source (can return nil)
-    }
-
- -

-The file mode information has been moved into a subtype called -os.FileMode, -a simple integer type with IsDir, Perm, and String -methods. -

- -

-The system-specific details of file modes and properties such as (on Unix) -i-number have been removed from FileInfo altogether. -Instead, each operating system's os package provides an -implementation of the FileInfo interface, which -has a Sys method that returns the -system-specific representation of file metadata. -For instance, to discover the i-number of a file on a Unix system, unpack -the FileInfo like this: -

- -
-    fi, err := os.Stat("hello.go")
-    if err != nil {
-        log.Fatal(err)
-    }
-    // Check that it's a Unix file.
-    unixStat, ok := fi.Sys().(*syscall.Stat_t)
-    if !ok {
-        log.Fatal("hello.go: not a Unix file")
-    }
-    fmt.Printf("file i-number: %d\n", unixStat.Ino)
-
- -

-Assuming (which is unwise) that "hello.go" is a Unix file, -the i-number expression could be contracted to -

- -
-    fi.Sys().(*syscall.Stat_t).Ino
-
- -

-The vast majority of uses of FileInfo need only the methods -of the standard interface. -

- -

-The os package no longer contains wrappers for the POSIX errors -such as ENOENT. -For the few programs that need to verify particular error conditions, there are -now the boolean functions -IsExist, -IsNotExist -and -IsPermission. -

- -{{code "/doc/progs/go1.go" `/os\.Open/` `/}/`}} - -

-Updating: -Running go fix will update code that uses the old equivalent of the current os.FileInfo -and os.FileMode API. -Code that needs system-specific file details will need to be updated by hand. -Code that uses the old POSIX error values from the os package -will fail to compile and will also need to be updated by hand. -

- -

The os/signal package

- -

-The os/signal package in Go 1 replaces the -Incoming function, which returned a channel -that received all incoming signals, -with the selective Notify function, which asks -for delivery of specific signals on an existing channel. -

- -

-Updating: -Code must be updated by hand. -A literal translation of -

-
-c := signal.Incoming()
-
-

-is -

-
-c := make(chan os.Signal, 1)
-signal.Notify(c) // ask for all signals
-
-

-but most code should list the specific signals it wants to handle instead: -

-
-c := make(chan os.Signal, 1)
-signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT)
-
- -

The path/filepath package

- -

-In Go 1, the Walk function of the -path/filepath package -has been changed to take a function value of type -WalkFunc -instead of a Visitor interface value. -WalkFunc unifies the handling of both files and directories. -

- -
-    type WalkFunc func(path string, info os.FileInfo, err error) error
-
- -

-The WalkFunc function will be called even for files or directories that could not be opened; -in such cases the error argument will describe the failure. -If a directory's contents are to be skipped, -the function should return the value filepath.SkipDir -

- -{{code "/doc/progs/go1.go" `/STARTWALK/` `/ENDWALK/`}} - -

-Updating: -The change simplifies most code but has subtle consequences, so affected programs -will need to be updated by hand. -The compiler will catch code using the old interface. -

- -

The regexp package

- -

-The regexp package has been rewritten. -It has the same interface but the specification of the regular expressions -it supports has changed from the old "egrep" form to that of -RE2. -

- -

-Updating: -Code that uses the package should have its regular expressions checked by hand. -

- -

The runtime package

- -

-In Go 1, much of the API exported by package -runtime has been removed in favor of -functionality provided by other packages. -Code using the runtime.Type interface -or its specific concrete type implementations should -now use package reflect. -Code using runtime.Semacquire or runtime.Semrelease -should use channels or the abstractions in package sync. -The runtime.Alloc, runtime.Free, -and runtime.Lookup functions, an unsafe API created for -debugging the memory allocator, have no replacement. -

- -

-Before, runtime.MemStats was a global variable holding -statistics about memory allocation, and calls to runtime.UpdateMemStats -ensured that it was up to date. -In Go 1, runtime.MemStats is a struct type, and code should use -runtime.ReadMemStats -to obtain the current statistics. -

- -

-The package adds a new function, -runtime.NumCPU, that returns the number of CPUs available -for parallel execution, as reported by the operating system kernel. -Its value can inform the setting of GOMAXPROCS. -The runtime.Cgocalls and runtime.Goroutines functions -have been renamed to runtime.NumCgoCall and runtime.NumGoroutine. -

- -

-Updating: -Running go fix will update code for the function renamings. -Other code will need to be updated by hand. -

- -

The strconv package

- -

-In Go 1, the -strconv -package has been significantly reworked to make it more Go-like and less C-like, -although Atoi lives on (it's similar to -int(ParseInt(x, 10, 0)), as does -Itoa(x) (FormatInt(int64(x), 10)). -There are also new variants of some of the functions that append to byte slices rather than -return strings, to allow control over allocation. -

- -

-This table summarizes the renamings; see the -package documentation -for full details. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Old callNew call

Atob(x) ParseBool(x)

Atof32(x) ParseFloat(x, 32)§
Atof64(x) ParseFloat(x, 64)
AtofN(x, n) ParseFloat(x, n)

Atoi(x) Atoi(x)
Atoi(x) ParseInt(x, 10, 0)§
Atoi64(x) ParseInt(x, 10, 64)

Atoui(x) ParseUint(x, 10, 0)§
Atoui64(x) ParseUint(x, 10, 64)

Btoi64(x, b) ParseInt(x, b, 64)
Btoui64(x, b) ParseUint(x, b, 64)

Btoa(x) FormatBool(x)

Ftoa32(x, f, p) FormatFloat(float64(x), f, p, 32)
Ftoa64(x, f, p) FormatFloat(x, f, p, 64)
FtoaN(x, f, p, n) FormatFloat(x, f, p, n)

Itoa(x) Itoa(x)
Itoa(x) FormatInt(int64(x), 10)
Itoa64(x) FormatInt(x, 10)

Itob(x, b) FormatInt(int64(x), b)
Itob64(x, b) FormatInt(x, b)

Uitoa(x) FormatUint(uint64(x), 10)
Uitoa64(x) FormatUint(x, 10)

Uitob(x, b) FormatUint(uint64(x), b)
Uitob64(x, b) FormatUint(x, b)
- -

-Updating: -Running go fix will update almost all code affected by the change. -
Atoi persists but Atoui and Atof32 do not, so -they may require -a cast that must be added by hand; the go fix tool will warn about it. -

- - -

The template packages

- -

-The template and exp/template/html packages have moved to -text/template and -html/template. -More significant, the interface to these packages has been simplified. -The template language is the same, but the concept of "template set" is gone -and the functions and methods of the packages have changed accordingly, -often by elimination. -

- -

-Instead of sets, a Template object -may contain multiple named template definitions, -in effect constructing -name spaces for template invocation. -A template can invoke any other template associated with it, but only those -templates associated with it. -The simplest way to associate templates is to parse them together, something -made easier with the new structure of the packages. -

- -

-Updating: -The imports will be updated by fix tool. -Single-template uses will be otherwise be largely unaffected. -Code that uses multiple templates in concert will need to be updated by hand. -The examples in -the documentation for text/template can provide guidance. -

- -

The testing package

- -

-The testing package has a type, B, passed as an argument to benchmark functions. -In Go 1, B has new methods, analogous to those of T, enabling -logging and failure reporting. -

- -{{code "/doc/progs/go1.go" `/func.*Benchmark/` `/^}/`}} - -

-Updating: -Existing code is unaffected, although benchmarks that use println -or panic should be updated to use the new methods. -

- -

The testing/script package

- -

-The testing/script package has been deleted. It was a dreg. -

- -

-Updating: -No code is likely to be affected. -

- -

The unsafe package

- -

-In Go 1, the functions -unsafe.Typeof, unsafe.Reflect, -unsafe.Unreflect, unsafe.New, and -unsafe.NewArray have been removed; -they duplicated safer functionality provided by -package reflect. -

- -

-Updating: -Code using these functions must be rewritten to use -package reflect. -The changes to encoding/gob and the protocol buffer library -may be helpful as examples. -

- -

The url package

- -

-In Go 1 several fields from the url.URL type -were removed or replaced. -

- -

-The String method now -predictably rebuilds an encoded URL string using all of URL's -fields as necessary. The resulting string will also no longer have -passwords escaped. -

- -

-The Raw field has been removed. In most cases the String -method may be used in its place. -

- -

-The old RawUserinfo field is replaced by the User -field, of type *net.Userinfo. -Values of this type may be created using the new net.User -and net.UserPassword -functions. The EscapeUserinfo and UnescapeUserinfo -functions are also gone. -

- -

-The RawAuthority field has been removed. The same information is -available in the Host and User fields. -

- -

-The RawPath field and the EncodedPath method have -been removed. The path information in rooted URLs (with a slash following the -schema) is now available only in decoded form in the Path field. -Occasionally, the encoded data may be required to obtain information that -was lost in the decoding process. These cases must be handled by accessing -the data the URL was built from. -

- -

-URLs with non-rooted paths, such as "mailto:dev@golang.org?subject=Hi", -are also handled differently. The OpaquePath boolean field has been -removed and a new Opaque string field introduced to hold the encoded -path for such URLs. In Go 1, the cited URL parses as: -

- -
-    URL{
-        Scheme: "mailto",
-        Opaque: "dev@golang.org",
-        RawQuery: "subject=Hi",
-    }
-
- -

-A new RequestURI method was -added to URL. -

- -

-The ParseWithReference function has been renamed to ParseWithFragment. -

- -

-Updating: -Code that uses the old fields will fail to compile and must be updated by hand. -The semantic changes make it difficult for the fix tool to update automatically. -

- -

The go command

- -

-Go 1 introduces the go command, a tool for fetching, -building, and installing Go packages and commands. The go command -does away with makefiles, instead using Go source code to find dependencies and -determine build conditions. Most existing Go programs will no longer require -makefiles to be built. -

- -

-See How to Write Go Code for a primer on the -go command and the go command documentation -for the full details. -

- -

-Updating: -Projects that depend on the Go project's old makefile-based build -infrastructure (Make.pkg, Make.cmd, and so on) should -switch to using the go command for building Go code and, if -necessary, rewrite their makefiles to perform any auxiliary build tasks. -

- -

The cgo command

- -

-In Go 1, the cgo command -uses a different _cgo_export.h -file, which is generated for packages containing //export lines. -The _cgo_export.h file now begins with the C preamble comment, -so that exported function definitions can use types defined there. -This has the effect of compiling the preamble multiple times, so a -package using //export must not put function definitions -or variable initializations in the C preamble. -

- -

Packaged releases

- -

-One of the most significant changes associated with Go 1 is the availability -of prepackaged, downloadable distributions. -They are available for many combinations of architecture and operating system -(including Windows) and the list will grow. -Installation details are described on the -Getting Started page, while -the distributions themselves are listed on the -downloads page.