Portable Go Changelog

What's new in Portable Go 1.22.2

Apr 3, 2024
  • Includes a security fix to the net/http package, as well as bug fixes to the compiler, the go command, the linker, and the encoding/gob, go/types, net/http, and runtime/trace packages. See the Go 1.22.2 milestone on our issue tracker for details.

New in Portable Go 1.22.1 (Mar 5, 2024)

  • These minor releases include 5 security fixes following the security policy:
  • crypto/x509: Verify panics on certificates with an unknown public key algorithm:
  • Verifying a certificate chain which contains a certificate with an unknown public
  • key algorithm will cause Certificate.Verify to panic.
  • This affects all crypto/tls clients, and servers that set Config.ClientAuth to
  • VerifyClientCertIfGiven or RequireAndVerifyClientCert. The default behavior is
  • for TLS servers to not verify client certificates.
  • net/http: memory exhaustion in Request.ParseMultipartForm:
  • When parsing a multipart form (either explicitly with Request.ParseMultipartForm or implicitly with Request.FormValue, Request.PostFormValue, or Request.FormFile), limits on the total size of the parsed form were not applied to the memory consumed while reading a single form line. This permitted a maliciously crafted input containing very long lines to cause allocation of arbitrarily large amounts of memory, potentially leading to memory exhaustion.
  • ParseMultipartForm now correctly limits the maximum size of form lines.
  • net/http, net/http/cookiejar: incorrect forwarding of sensitive headers and cookies on HTTP redirect:
  • When following an HTTP redirect to a domain which is not a subdomain match or exact match of the initial domain, an http.Client does not forward sensitive headers such as "Authorization" or "Cookie". For example, a redirect from foo.com to www.foo.com will forward the Authorization header, but a redirect to bar.com will not.
  • A maliciously crafted HTTP redirect could cause sensitive headers to be unexpectedly forwarded.
  • html/template: errors returned from MarshalJSON methods may break template escaping:
  • If errors returned from MarshalJSON methods contain user controlled data, they
  • may be used to break the contextual auto-escaping behavior of the html/template
  • package, allowing for subsequent actions to inject unexpected content into
  • templates.
  • net/mail: comments in display names are incorrectly handled:
  • The ParseAddressList function incorrectly handles comments (text within parentheses) within display names. Since this is a misalignment with conforming address parsers, it can result in different trust decisions being made by programs using different parsers.
  • Thanks to Juho Nurminen of Mattermost and Slonser (https://github.com/Slonser) for reporting this issue.

New in Portable Go 1.22.0 (Feb 6, 2024)

  • Changes to the language:
  • Go 1.22 makes two changes to "for" loops.
  • Previously, the variables declared by a "for" loop were created once and updated by each iteration. In Go 1.22, each iteration of the loop creates new variables, to avoid accidental sharing bugs. The transition support tooling described in the proposal continues to work in the same way it did in Go 1.21.
  • "For" loops may now range over integers. For example:
  • package main
  • import "fmt"
  • func main() {
  • for i := range 10 {
  • fmt.Println(10 - i)
  • fmt.Println("go1.22 has lift-off!")
  • See the spec for details.
  • Go 1.22 includes a preview of a language change we are considering for a future version of Go: range-over-function iterators. Building with GOEXPERIMENT=rangefunc enables this feature.
  • Tools:
  • Go command:
  • Commands in workspaces can now use a vendor directory containing the dependencies of the workspace. The directory is created by go work vendor, and used by build commands when the -mod flag is set to vendor, which is the default when a workspace vendor directory is present.
  • Note that the vendor directory's contents for a workspace are different from those of a single module: if the directory at the root of a workspace also contains one of the modules in the workspace, its vendor directory can contain the dependencies of either the workspace or of the module, but not both.
  • go get is no longer supported outside of a module in the legacy GOPATH mode (that is, with GO111MODULE=off). Other build commands, such as go build and go test, will continue to work indefinitely for legacy GOPATH programs.
  • go mod init no longer attempts to import module requirements from configuration files for other vendoring tools (such as Gopkg.lock).
  • go test -cover now prints coverage summaries for covered packages that do not have their own test files. Prior to Go 1.22 a go test -cover run for such a package would report
  • ? mymod/mypack [no test files]
  • and now with Go 1.22, functions in the package are treated as uncovered:
  • mymod/mypack coverage: 0.0% of statements
  • Note that if a package contains no executable code at all, we can't report a meaningful coverage percentage; for such packages the go tool will continue to report that there are no test files.
  • Trace:
  • The trace tool's web UI has been gently refreshed as part of the work to support the new tracer, resolving several issues and improving the readability of various sub-pages. The web UI now supports exploring traces in a thread-oriented view. The trace viewer also now displays the full duration of all system calls.
  • These improvements only apply for viewing traces produced by programs built with Go 1.22 or newer. A future release will bring some of these improvements to traces produced by older version of Go.
  • Vet:
  • References to loop variables
  • The behavior of the vet tool has changed to match the new semantics (see above) of loop variables in Go 1.22. When analyzing a file that requires Go 1.22 or newer (due to its go.mod file or a per-file build constraint), vetcode> no longer reports references to loop variables from within a function literal that might outlive the iteration of the loop. In Go 1.22, loop variables are created anew for each iteration, so such references are no longer at risk of using a variable after it has been updated by the loop.
  • New warnings for missing values after append
  • The vet tool now reports calls to append that pass no values to be appended to the slice, such as slice = append(slice). Such a statement has no effect, and experience has shown that is nearly always a mistake.
  • New warnings for deferring time.Since
  • The vet tool now reports a non-deferred call to time.Since(t) within a defer statement. This is equivalent to calling time.Now().Sub(t) before the defer statement, not when the deferred function is called. In nearly all cases, the correct code requires deferring the time.Since call. For example:
  • t := time.Now()
  • defer log.Println(time.Since(t)) // non-deferred call to time.Since
  • tmp := time.Since(t); defer log.Println(tmp) // equivalent to the previous defer
  • defer func() {
  • log.Println(time.Since(t)) // a correctly deferred call to time.Since
  • }()
  • New warnings for mismatched key-value pairs in log/slog calls
  • The vet tool now reports invalid arguments in calls to functions and methods in the structured logging package, log/slog, that accept alternating key/value pairs. It reports calls where an argument in a key position is neither a string nor a slog.Attr, and where a final key is missing its value.
  • Runtime:
  • The runtime now keeps type-based garbage collection metadata nearer to each heap object, improving the CPU performance (latency or throughput) of Go programs by 1–3%. This change also reduces the memory overhead of the majority Go programs by approximately 1% by deduplicating redundant metadata. Some programs may see a smaller improvement because this change adjusts the size class boundaries of the memory allocator, so some objects may be moved up a size class.
  • A consequence of this change is that some objects' addresses that were previously always aligned to a 16 byte (or higher) boundary will now only be aligned to an 8 byte boundary. Some programs that use assembly instructions that require memory addresses to be more than 8-byte aligned and rely on the memory allocator's previous alignment behavior may break, but we expect such programs to be rare. Such programs may be built with GOEXPERIMENT=noallocheaders to revert to the old metadata layout and restore the previous alignment behavior, but package owners should update their assembly code to avoid the alignment assumption, as this workaround will be removed in a future release.
  • On the windows/amd64 port, programs linking or loading Go libraries built with -buildmode=c-archive or -buildmode=c-shared can now use the SetUnhandledExceptionFilter Win32 function to catch exceptions not handled by the Go runtime. Note that this was already supported on the windows/386 port.
  • Compiler:
  • Profile-guided Optimization (PGO) builds can now devirtualize a higher proportion of calls than previously possible. Most programs from a representative set of Go programs now see between 2 and 14% improvement from enabling PGO.
  • The compiler now interleaves devirtualization and inlining, so interface method calls are better optimized.
  • Go 1.22 also includes a preview of an enhanced implementation of the compiler's inlining phase that uses heuristics to boost inlinability at call sites deemed "important" (for example, in loops) and discourage inlining at call sites deemed "unimportant" (for example, on panic paths). Building with GOEXPERIMENT=newinliner enables the new call-site heuristics; see issue #61502 for more info and to provide feedback.
  • Linker:
  • The linker's -s and -w flags are now behave more consistently across all platforms. The -w flag suppresses DWARF debug information generation. The -s flag suppresses symbol table generation. The -s flag also implies the -w flag, which can be negated with -w=0. That is, -s -w=0 will generate a binary with DWARF debug information generation but without the symbol table.
  • On ELF platforms, the -B linker flag now accepts a special form: with -B gobuildid, the linker will generate a GNU build ID (the ELF NT_GNU_BUILD_ID note) derived from the Go build ID.
  • On Windows, when building with -linkmode=internal, the linker now preserves SEH information from C object files by copying the .pdata and .xdata sections into the final binary. This helps with debugging and profiling binaries using native tools, such as WinDbg. Note that until now, C functions' SEH exception handlers were not being honored, so this change may cause some programs to behave differently. -linkmode=external is not affected by this change, as external linkers already preserve SEH information.
  • Bootstrap:
  • As mentioned in the Go 1.20 release notes, Go 1.22 now requires the final point release of Go 1.20 or later for bootstrap. We expect that Go 1.24 will require the final point release of Go 1.22 or later for bootstrap.
  • Core library:
  • New math/rand/v2 package:
  • Go 1.22 includes the first “v2” package in the standard library, math/rand/v2. The changes compared to math/rand are detailed in proposal #61716. The most important changes are:
  • The Read method, deprecated in math/rand, was not carried forward for math/rand/v2. (It remains available in math/rand.) The vast majority of calls to Read should use crypto/rand’s Read instead. Otherwise a custom Read can be constructed using the Uint64 method.
  • The global generator accessed by top-level functions is unconditionally randomly seeded. Because the API guarantees no fixed sequence of results, optimizations like per-thread random generator states are now possible.
  • The Source interface now has a single Uint64 method; there is no Source64 interface.
  • Many methods now use faster algorithms that were not possible to adopt in math/rand because they changed the output streams.
  • The Intn, Int31, Int31n, Int63, and Int64n top-level functions and methods from math/rand are spelled more idiomatically in math/rand/v2: IntN, Int32, Int32N, Int64, and Int64N. There are also new top-level functions and methods Uint32, Uint32N, Uint64, Uint64N, Uint, and UintN.
  • The new generic function N is like Int64N or Uint64N but works for any integer type. For example a random duration from 0 up to 5 minutes is rand.N(5*time.Minute).
  • The Mitchell & Reeds LFSR generator provided by math/rand’s Source has been replaced by two more modern pseudo-random generator sources: ChaCha8 PCG. ChaCha8 is a new, cryptographically strong random number generator roughly similar to PCG in efficiency. ChaCha8 is the algorithm used for the top-level functions in math/rand/v2. As of Go 1.22, math/rand's top-level functions (when not explicitly seeded) and the Go runtime also use ChaCha8 for randomness.
  • We plan to include an API migration tool in a future release, likely Go 1.23.
  • New go/version package:
  • The new go/version package implements functions for validating and comparing Go version strings.
  • Enhanced routing patterns:
  • HTTP routing in the standard library is now more expressive. The patterns used by net/http.ServeMux have been enhanced to accept methods and wildcards.
  • Registering a handler with a method, like "POST /items/create", restricts invocations of the handler to requests with the given method. A pattern with a method takes precedence over a matching pattern without one. As a special case, registering a handler with "GET" also registers it with "HEAD".
  • archive/tar:
  • The new method Writer.AddFS adds all of the files from an fs.FS to the archive.
  • archive/zip:
  • The new method Writer.AddFS adds all of the files from an fs.FS to the archive.
  • bufio:
  • When a SplitFunc returns ErrFinalToken with a nil token, Scanner will now stop immediately. Previously, it would report a final empty token before stopping, which was usually not desired. Callers that do want to report a final empty token can do so by returning []byte{} rather than nil.
  • cmp:
  • The new function Or returns the first in a sequence of values that is not the zero value.
  • crypto/tls:
  • ConnectionState.ExportKeyingMaterial will now return an error unless TLS 1.3 is in use, or the extended_master_secret extension is supported by both the server and client. crypto/tls has supported this extension since Go 1.20. This can be disabled with the tlsunsafeekm=1 GODEBUG setting.
  • By default, the minimum version offered by crypto/tls servers is now TLS 1.2 if not specified with config.MinimumVersion, matching the behavior of crypto/tls clients. This change can be reverted with the tls10server=1 GODEBUG setting.
  • By default, cipher suites without ECDHE support are no longer offered by either clients or servers during pre-TLS 1.3 handshakes. This change can be reverted with the tlsrsakex=1 GODEBUG setting.
  • crypto/x509:
  • The new CertPool.AddCertWithConstraint method can be used to add customized constraints to root certificates to be applied during chain building.
  • On Android, root certificates will now be loaded from /data/misc/keychain/certs-added as well as /system/etc/security/cacerts.
  • A new type, OID, supports ASN.1 Object Identifiers with individual components larger than 31 bits. A new field which uses this type, Policies, is added to the Certificate struct, and is now populated during parsing. Any OIDs which cannot be represented using a asn1.ObjectIdentifier will appear in Policies, but not in the old PolicyIdentifiers field. When calling CreateCertificate, the Policies field is ignored, and policies are taken from the PolicyIdentifiers field. Using the x509usepolicies=1 GODEBUG setting inverts this, populating certificate policies from the Policies field, and ignoring the PolicyIdentifiers field. We may change the default value of x509usepolicies in Go 1.23, making Policies the default field for marshaling.
  • database/sql:
  • The new Null[T] type provide a way to scan nullable columns for any column types.
  • debug/elf:
  • Constant R_MIPS_PC32 is defined for use with MIPS64 systems.
  • Additional R_LARCH_* constants are defined for use with LoongArch systems.
  • encoding:
  • The new methods AppendEncode and AppendDecode added to each of the Encoding types in the packages encoding/base32, encoding/base64, and encoding/hex simplify encoding and decoding from and to byte slices by taking care of byte slice buffer management.
  • The methods base32.Encoding.WithPadding and base64.Encoding.WithPadding now panic if the padding argument is a negative value other than NoPadding.
  • encoding/json:
  • Marshaling and encoding functionality now escapes 'b' and 'f' characters as b and f instead of u0008 and u000c.
  • go/ast:
  • The following declarations related to syntactic identifier resolution are now deprecated: Ident.Obj, Object, Scope, File.Scope, File.Unresolved, Importer, Package, NewPackage. In general, identifiers cannot be accurately resolved without type information. Consider, for example, the identifier K in T{K: ""}: it could be the name of a local variable if T is a map type, or the name of a field if T is a struct type. New programs should use the go/types package to resolve identifiers; see Object, Info.Uses, and Info.Defs for details.
  • The new ast.Unparen function removes any enclosing parentheses from an expression.
  • go/types:
  • The new Alias type represents type aliases. Previously, type aliases were not represented explicitly, so a reference to a type alias was equivalent to spelling out the aliased type, and the name of the alias was lost. The new representation retains the intermediate Alias. This enables improved error reporting (the name of a type alias can be reported), and allows for better handling of cyclic type declarations involving type aliases. In a future release, Alias types will also carry type parameter information. The new function Unalias returns the actual type denoted by an Alias type (or any other Type for that matter).
  • Because Alias types may break existing type switches that do not know to check for them, this functionality is controlled by a GODEBUG field named gotypesalias. With gotypesalias=0, everything behaves as before, and Alias types are never created. With gotypesalias=1, Alias types are created and clients must expect them. The default is gotypesalias=0. In a future release, the default will be changed to gotypesalias=1. Clients of go/types are urged to adjust their code as soon as possible to work with gotypesalias=1 to eliminate problems early.
  • The Info struct now exports the FileVersions map which provides per-file Go version information.
  • The new helper method PkgNameOf returns the local package name for the given import declaration.
  • The implementation of SizesFor has been adjusted to compute the same type sizes as the compiler when the compiler argument for SizesFor is "gc". The default Sizes implementation used by the type checker is now types.SizesFor("gc", "amd64").
  • The start position (Pos) of the lexical environment block (Scope) that represents a function body has changed: it used to start at the opening curly brace of the function body, but now starts at the function's func token.
  • html/template:
  • Javascript template literals may now contain Go template actions, and parsing a template containing one will no longer return ErrJSTemplate. Similarly the GODEBUG setting jstmpllitinterp no longer has any effect.
  • The new SectionReader.Outer method returns the ReaderAt, offset, and size passed to NewSectionReader.
  • log/slog:
  • The new SetLogLoggerLevel function controls the level for the bridge between the `slog` and `log` packages. It sets the minimum level for calls to the top-level `slog` logging functions, and it sets the level for calls to `log.Logger` that go through `slog`.
  • math/big:
  • The new method Rat.FloatPrec computes the number of fractional decimal digits required to represent a rational number accurately as a floating-point number, and whether accurate decimal representation is possible in the first place.
  • net:
  • When io.Copy copies from a TCPConn to a UnixConn, it will now use Linux's splice(2) system call if possible, using the new method TCPConn.WriteTo.
  • The Go DNS Resolver, used when building with "-tags=netgo", now searches for a matching name in the Windows hosts file, located at %SystemRoot%System32driversetchosts, before making a DNS query.
  • net/http:
  • The new functions ServeFileFS, FileServerFS, and NewFileTransportFS are versions of the existing ServeFile, FileServer, and NewFileTransport, operating on an fs.FS.
  • The HTTP server and client now reject requests and responses containing an invalid empty Content-Length header. The previous behavior may be restored by setting GODEBUG field httplaxcontentlength=1.
  • The new method Request.PathValue returns path wildcard values from a request and the new method Request.SetPathValue sets path wildcard values on a request.
  • net/http/cgi:
  • When executing a CGI process, the PATH_INFO variable is now always set to the empty string or a value starting with a / character, as required by RFC 3875. It was previously possible for some combinations of Handler.Root and request URL to violate this requirement.
  • net/netip:
  • The new AddrPort.Compare method compares two AddrPorts.
  • os:
  • On Windows, the Stat function now follows all reparse points that link to another named entity in the system. It was previously only following IO_REPARSE_TAG_SYMLINK and IO_REPARSE_TAG_MOUNT_POINT reparse points.
  • On Windows, passing O_SYNC to OpenFile now causes write operations to go directly to disk, equivalent to O_SYNC on Unix platforms.
  • On Windows, the ReadDir, File.ReadDir, File.Readdir, and File.Readdirnames functions now read directory entries in batches to reduce the number of system calls, improving performance up to 30%.
  • When io.Copy copies from a File to a net.UnixConn, it will now use Linux's sendfile(2) system call if possible, using the new method File.WriteTo.
  • os/exec:
  • On Windows, LookPath now ignores empty entries in %PATH%, and returns ErrNotFound (instead of ErrNotExist) if no executable file extension is found to resolve an otherwise-unambiguous name.
  • On Windows, Command and Cmd.Start no longer call LookPath if the path to the executable is already absolute and has an executable file extension. In addition, Cmd.Start no longer writes the resolved extension back to the Path field, so it is now safe to call the String method concurrently with a call to Start.
  • reflect:
  • The Value.IsZero method will now return true for a floating-point or complex negative zero, and will return true for a struct value if a blank field (a field named _) somehow has a non-zero value. These changes make IsZero consistent with comparing a value to zero using the language == operator.
  • The PtrTo function is deprecated, in favor of PointerTo.
  • The new function TypeFor returns the Type that represents the type argument T. Previously, to get the reflect.Type value for a type, one had to use reflect.TypeOf((*T)(nil)).Elem(). This may now be written as reflect.TypeFor[T]().
  • runtime/metrics:
  • Four new histogram metrics /sched/pauses/stopping/gc:seconds, /sched/pauses/stopping/other:seconds, /sched/pauses/total/gc:seconds, and /sched/pauses/total/other:seconds provide additional details about stop-the-world pauses. The "stopping" metrics report the time taken from deciding to stop the world until all goroutines are stopped. The "total" metrics report the time taken from deciding to stop the world until it is started again.
  • The /gc/pauses:seconds metric is deprecated, as it is equivalent to the new /sched/pauses/total/gc:seconds metric.
  • /sync/mutex/wait/total:seconds now includes contention on runtime-internal locks in addition to sync.Mutex and sync.RWMutex.
  • runtime/pprof:
  • Mutex profiles now scale contention by the number of goroutines blocked on the mutex. This provides a more accurate representation of the degree to which a mutex is a bottleneck in a Go program. For instance, if 100 goroutines are blocked on a mutex for 10 milliseconds, a mutex profile will now record 1 second of delay instead of 10 milliseconds of delay.
  • Mutex profiles also now include contention on runtime-internal locks in addition to sync.Mutex and sync.RWMutex. Contention on runtime-internal locks is always reported at runtime._LostContendedRuntimeLock. A future release will add complete stack traces in these cases.
  • CPU profiles on Darwin platforms now contain the process's memory map, enabling the disassembly view in the pprof tool.
  • runtime/trace:
  • The execution tracer has been completely overhauled in this release, resolving several long-standing issues and paving the way for new use-cases for execution traces.
  • Execution traces now use the operating system's clock on most platforms (Windows excluded) so it is possible to correlate them with traces produced by lower-level components. Execution traces no longer depend on the reliability of the platform's clock to produce a correct trace. Execution traces are now partitioned regularly on-the-fly and as a result may be processed in a streamable way. Execution traces now contain complete durations for all system calls. Execution traces now contain information about the operating system threads that goroutines executed on. The latency impact of starting and stopping execution traces has been dramatically reduced. Execution traces may now begin or end during the garbage collection mark phase.
  • To allow Go developers to take advantage of these improvements, an experimental trace reading package is available at golang.org/x/exp/trace. Note that this package only works on traces produced by programs built with Go 1.22 at the moment. Please try out the package and provide feedback on the corresponding proposal issue.
  • If you experience any issues with the new execution tracer implementation, you may switch back to the old implementation by building your Go program with GOEXPERIMENT=noexectracer2. If you do, please file an issue, otherwise this option will be removed in a future release.
  • slices:
  • The new function Concat concatenates multiple slices.
  • Functions that shrink the size of a slice (Delete, DeleteFunc, Compact, CompactFunc, and Replace) now zero the elements between the new length and the old length.
  • Insert now always panics if the argument i is out of range. Previously it did not panic in this situation if there were no elements to be inserted.
  • syscall:
  • The syscall package has been frozen since Go 1.4 and was marked as deprecated in Go 1.11, causing many editors to warn about any use of the package. However, some non-deprecated functionality requires use of the syscall package, such as the os/exec.Cmd.SysProcAttr field. To avoid unnecessary complaints on such code, the syscall package is no longer marked as deprecated. The package remains frozen to most new functionality, and new code remains encouraged to use golang.org/x/sys/unix or golang.org/x/sys/windows where possible.
  • On Linux, the new SysProcAttr.PidFD field allows obtaining a PID FD when starting a child process via StartProcess or os/exec.
  • On Windows, passing O_SYNC to Open now causes write operations to go directly to disk, equivalent to O_SYNC on Unix platforms.
  • testing/slogtest:
  • The new Run function uses sub-tests to run test cases, providing finer-grained control.
  • Wildcards in patterns, like /items/{id}, match segments of the URL path. The actual segment value may be accessed by calling the Request.PathValue method. A wildcard ending in "...", like /files/{path...}, must occur at the end of a pattern and matches all the remaining segments.
  • A pattern that ends in "/" matches all paths that have it as a prefix, as always. To match the exact pattern including the trailing slash, end it with {$}, as in /exact/match/{$}.
  • If two patterns overlap in the requests that they match, then the more specific pattern takes precedence. If neither is more specific, the patterns conflict. This rule generalizes the original precedence rules and maintains the property that the order in which patterns are registered does not matter.
  • This change breaks backwards compatibility in small ways, some obvious—patterns with "{" and "}" behave differently— and some less so—treatment of escaped paths has been improved. The change is controlled by a GODEBUG field named httpmuxgo121. Set httpmuxgo121=1 to restore the old behavior.
  • 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.
  • Ports:
  • Darwin:
  • On macOS on 64-bit x86 architecture (the darwin/amd64 port), the Go toolchain now generates position-independent executables (PIE) by default. Non-PIE binaries can be generated by specifying the -buildmode=exe build flag. On 64-bit ARM-based macOS (the darwin/arm64 port), the Go toolchain already generates PIE by default.
  • Go 1.22 is the last release that will run on macOS 10.15 Catalina. Go 1.23 will require macOS 11 Big Sur or later.
  • Arm:
  • The GOARM environment variable now allows you to select whether to use software or hardware floating point. Previously, valid GOARM values were 5, 6, or 7. Now those same values can be optionally followed by ,softfloat or ,hardfloat to select the floating-point implementation.
  • This new option defaults to softfloat for version 5 and hardfloat for versions 6 and 7.
  • Loong64:
  • The loong64 port now supports passing function arguments and results using registers.
  • The linux/loong64 port now supports the address sanitizer, memory sanitizer, new-style linker relocations, and the plugin build mode.
  • OpenBSD:
  • Go 1.22 adds an experimental port to OpenBSD on big-endian 64-bit PowerPC (openbsd/ppc64).

New in Portable Go 1.21.7 (Feb 6, 2024)

  • fixes to the compiler, the go command, the runtime, and the crypto/x509 package

New in Portable Go 1.21.6 (Jan 9, 2024)

  • Fixes to the compiler, the runtime, and the crypto/tls, maps, and runtime/pprof packages. See the Go 1.21.6 milestone on our issue tracker for details.

New in Portable Go 1.21.4 (Nov 8, 2023)

  • go1.21.4 (released 2023-11-07) includes security fixes to the path/filepath package, as well as bug fixes to the linker, the runtime, the compiler, and the go/types, net/http, and runtime/cgo packages. See the Go 1.21.4 milestone on our issue tracker for details.

New in Portable Go 1.21.3 (Oct 10, 2023)

  • go1.21.3 (released 2023-10-10) includes a security fix to the net/http package.

New in Portable Go 1.21.1 (Sep 7, 2023)

  • go1.21.1 (released 2023-09-06) includes four security fixes to the cmd/go, crypto/tls, and html/template packages, as well as bug fixes to the compiler, the go command, the linker, the runtime, and the context, crypto/tls, encoding/gob, encoding/xml, go/types, net/http, os, and path/filepath packages.

New in Portable Go 1.21.0 (Aug 8, 2023)

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

New in Portable Go 1.20.7 (Aug 1, 2023)

  • go1.20.7 (released 2023-08-01) includes a security fix to the crypto/tls package, as well as bug fixes to the assembler and the compiler. See the Go 1.20.7 milestone on our issue tracker for details.

New in Portable Go 1.20.6 (Jul 11, 2023)

  • go1.20.6 (released 2023-07-11) includes a security fix to the net/http package, as well as bug fixes to the compiler, cgo, the cover tool, the go command, the runtime, and the crypto/ecdsa, go/build, go/printer, net/mail, and text/template packages.

New in Portable Go 1.20.5 (Jun 6, 2023)

  • Includes four security fixes to the cmd/go and runtime packages, as well as bug fixes to the compiler, the go command, the runtime, and the crypto/rsa, net, and os packages

New in Portable Go 1.20.4 (May 2, 2023)

  • go1.20.4 (released 2023-05-02) includes three security fixes to the html/template package, as well as bug fixes to the compiler, the runtime, and the crypto/subtle, crypto/tls, net/http, and syscall packages.

New in Portable Go 1.20.3 (Apr 5, 2023)

  • go1.20.3 (released 2023-04-04) includes security fixes to the go/parser, html/template, mime/multipart, net/http, and net/textproto packages, as well as bug fixes to the compiler, the linker, the runtime, and the time package. See the Go 1.20.3 milestone on our issue tracker for details.

New in Portable Go 1.20.2 (Mar 7, 2023)

  • go1.20.2 (released 2023-03-07) includes a security fix to the crypto/elliptic package, as well as bug fixes to the compiler, the covdata command, the linker, the runtime, and the crypto/ecdh, crypto/rsa, crypto/x509, os, and syscall packages. See the Go 1.20.2 milestone on our issue tracker for details.

New in Portable Go 1.20 (Feb 1, 2023)

  • 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.
  • 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=json (for example, go test -v=json or ./pkg.test -test.v=json) 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.
  • 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:
  • The runtime now has experimental support for memory-safe arena allocation that makes it possible to eagerly free memory in bulk. When used appopriately, it has the potential to improve CPU performance by up to 15% in memory-allocation-heavy applications. To try it out, build your Go program with GOEXPERIMENT=arenas, which will make the arena package visible to your program. Source files that import the arena package must require the goexperiment.arenas build tag.
  • 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 a 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%. 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 bugs and enables local types in generic functions and methods.
  • Linker:
  • 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 ancitipation 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 direct support for Elliptic Curve Diffie-Hellman key exchange over NIST curves and Curve25519.
  • Programs should prefer to use crypto/ecdh or crypto/ecdsa instead of the lower-level functionality in crypto/elliptic.
  • 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 occurrances 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.
  • 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.
  • 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:
  • 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/elliptic:
  • Use of custom Curve implementations not provided by this package (that is, curves other than P224, P256, P384, and P521) is deprecated.
  • crypto/rsa:
  • The new field OAEPOptions.MGFHash allows configuring the MGF1 hash separately for OAEP encryption.
  • crypto/subtle:
  • The new function XORBytes XORs two byte slices together.
  • crypto/tls:
  • The TLS client now shares parsed certificates across all clients actively using that certificate. The 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:
  • CreateCertificateRequest and MarshalPKCS8PrivateKey now support keys of type *crypto/ecdh.PrivateKey. CreateCertificate and MarshalPKIXPublicKey now support keys of type *crypto/ecdh.PublicKey. X.509 unmarshaling continues to unmarshal elliptic curve keys into *ecdsa.PublicKey and *ecdsa.PrivateKey. Use their new ECDH methods to convert to the crypto/ecdh form.
  • The new SetFallbackRoots function allows a program to define a set of fallback root certificates in case the 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 satsifying a constraint from implementing an interface.
  • 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/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.
  • 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 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".
  • 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), 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.
  • The new Clone function allocates a copy of a string.
  • sync:
  • The new Map methods Swap, CompareAndSwap, and CompareAndDelete allow existing map entries to be updated atomically.
  • 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.
  • 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 and Time.UnmarshalJSON methods are 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.

New in Portable Go 1.19.5 (Jan 10, 2023)

  • Includes fixes to the compiler, the linker, and the crypto/x509, net/http, sync/atomic, and syscall packages.

New in Portable Go 1.19.3 (Nov 1, 2022)

  • go1.19.3 (released 2022-11-01) includes security fixes to the os/exec and syscall packages, as well as bug fixes to the compiler and the runtime.

New in Portable Go 1.19.2 (Oct 4, 2022)

  • go1.19.2 (released 2022-10-04) includes security fixes to the archive/tar, net/http/httputil, and regexp packages, as well as bug fixes to the compiler, the linker, the runtime, and the go/types package. See the Go 1.19.2 milestone on our issue tracker for details.

New in Portable Go 1.18.5 (Aug 1, 2022)

  • go1.18.5 (released 2022-08-01) includes security fixes to the encoding/gob and math/big packages, as well as bug fixes to the compiler, the go command, the runtime, and the testing package.

New in Portable Go 1.18.4 (Jul 12, 2022)

  • Includes security fixes to the compress/gzip, encoding/gob, encoding/xml, go/parser, io/fs, net/http, and path/filepath packages, as well as bug fixes to the compiler, the go command, the linker, the runtime, and the runtime/metrics package. See the Go 1.18.4 milestone on our issue tracker for details.

New in Portable Go 1.19.0 Beta 1 (Jun 10, 2022)

  • 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
  • Go 1.19 supports the Loongson 64-bit architecture LoongArch on Linux (GOOS=linux, GOARCH=loong64).
  • 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.
  • 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 riscv64 port now supports passing function arguments and result using registers. Benchmarking shows typical performance improvements of 10% or more on riscv64.
  • 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.
  • 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/rand:
  • Read no longer buffers random data obtained from the operating system between calls.
  • On Plan 9, Read has been reimplemented, replacing the ANSI X9.31 algorithm with fast key erasure.
  • crypto/tls:
  • The tls10default GODEBUG option 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.
  • 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 equality of two CertPools respectively.
  • The new function ParseRevocationList provides a faster, safer to use CRL parser which returns a RevocationList. To support this addition, RevocationList adds new fields RawIssuer, Signature, AuthorityKeyId, and Extensions. The new method RevocationList.CheckSignatureFrom checks that the signature on a CRL is a valid signature from a Certificate. With the new CRL functionality, the existing functions ParseCRL and ParseDERCRL are deprecated. Additionally the method Certificate.CheckCRLSignature is deprecated.
  • When building paths, Certificate.Verify now considers certificates to be equal when the subjects, public keys, and SANs are all equal. Before, it required byte-for-byte equality.
  • crypto/x509/pkix:
  • The types CertificateList and TBSCertificateList have been deprecated. The new crypto/x509 CRL functionality should be used instead.
  • debug:
  • The new EM_LONGARCH 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.
  • 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.
  • 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.
  • 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.

New in Portable Go 1.18.3 (Jun 2, 2022)

  • go1.18.3 (released 2022-06-01) includes security fixes to the crypto/rand, crypto/tls, os/exec, and path/filepath packages, as well as bug fixes to the compiler, and the crypto/tls and text/template/parse packages. See the Go 1.18.3 milestone on our issue tracker for details.

New in Portable Go 1.18 (Mar 16, 2022)

  • 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 Go 1.19.
  • 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 Go 1.19.
  • 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 Go 1.19.
  • 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 Go 1.19.
  • 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.17 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 Go 1.19.
  • 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 Go 1.19.
  • 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 and SHA-1 hashes (MD5WithRSA, SHA1WithRSA, and ECDSAWithSHA1) 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.
  • 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.

New in Portable Go 1.17.8 (Mar 4, 2022)

  • Includes a security fix to the regexp/syntax package, as well as bug fixes to the compiler, runtime, the go command, and the crypto/x509, and net packages.

New in Portable Go 1.17.7 (Feb 11, 2022)

  • go1.17.7 (released 2022-02-10) includes security fixes to the crypto/elliptic, math/big packages and to the go command, as well as bug fixes to the compiler, linker, runtime, the go command, and the debug/macho, debug/pe, and net/http/httptest packages. See the Go 1.17.7 milestone on our issue tracker for details.

New in Portable Go 1.17.6 (Jan 7, 2022)

  • Includes fixes to the compiler, linker, runtime, and the crypto/x509, net/http, and reflect packages. See the Go 1.17.6 milestone on our issue tracker for details.

New in Portable Go 1.17.5 (Dec 9, 2021)

  • Includes security fixes to the syscall and net/http packages. See the Go 1.17.5 milestone on our issue tracker for details.

New in Portable Go 1.17.4 (Dec 3, 2021)

  • go1.17.4 (released 2021-12-02) includes fixes to the compiler, linker, runtime, and the go/types, net/http, and time packages. See the Go 1.17.4 milestone on our issue tracker for details.

New in Portable Go 1.17.3 (Nov 4, 2021)

  • Includes security fixes to the archive/zip and debug/macho packages, as well as bug fixes to the compiler, linker, runtime, the go command, the misc/wasm directory, and to the net/http and syscall packages. See the Go 1.17.3 milestone [https://github.com/golang/go/issues?q=milestone%3AGo1.17.3+label%3ACherryPickApproved] on our issue tracker for details.

New in Portable Go 1.17 (Aug 16, 2021)

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

New in Portable Go 1.16.6 (Jul 13, 2021)

  • go1.16.6 (released 2021-07-12) includes a security fix to the crypto/tls package, as well as bug fixes to the compiler, and the net and net/http packages.

New in Portable Go 1.16.5 (Jun 4, 2021)

  • go1.16.5 (released 2021-06-03) includes security fixes to the archive/zip, math/big, net, and net/http/httputil packages, as well as bug fixes to the linker, the go command, and the net/http package. See the Go 1.16.5 milestone on our issue tracker for details.

New in Portable Go 1.16.3 (Apr 2, 2021)

  • Runtime: "invalid pc-encoded table" throw caused by bad cgo traceback [1.16 backport] CherryPickApproved
  • 45303 by gopherbot was closed 2 days ago
  • Cmd/compile: fix long RMW bit operations on AMD64 [1.16 backport] CherryPickApproved
  • 45253 by randall77 was closed 2 days ago
  • All: run.{bash,bat,rc} sets GOPATH inconsistently [1.16 backport] CherryPickApproved Testing
  • 45240 by gopherbot was closed 3 days ago
  • Strange behaviour with loops [1.16 backport] CherryPickApproved
  • 45192 by randall77 was closed 2 days ago
  • @randall77
  • Cmd/link: go 1.16 plugin does not initialize global variables correctly when not used directly [1.16 backport] CherryPickApproved
  • 45030 by gopherbot was closed 7 days ago
  • Testing: Helper line number has changed in 1.16 [1.16 backport] CherryPickApproved
  • 44888 by gopherbot was closed 8 days ago
  • Cmd/go: import paths ending with '+' are rejected (affects executable like g++ or clang++) [1.16 backport] CherryPickApproved release-blocker
  • 44885 by gopherbot was closed 2 days ago
  • Time, runtime: zero duration timer takes 2 minutes to fire [1.16 backport] CherryPickApproved release-blocker
  • 44869 by gopherbot was closed 20 days ago
  • Cmd/go: documentation at golang.org for cmd/go has confusing formatting [1.16 backport] CherryPickApproved Documentation
  • 44860 by gopherbot was closed 20 days ago
  • Cmd/go: 'go get' does not add missing hash to go.sum when ziphash file missing from cache [1.16 backport] CherryPickApproved release-blocker
  • 44812 by gopherbot was closed 7 days ago
  • Cmd/link: fail to build when using time/tzdata on ARM [1.16 backport] CherryPickApproved
  • 44640 by gopherbot was closed 7 days ago

New in Portable Go 1.16.2 (Mar 11, 2021)

  • cmd/go: mod tidy should ignore missing standard library packages [1.16 backport] CherryPickApproved release-blocker
  • by gopherbot was closed yesterday
  • cmd/go: improve error message when outside a module from "working directory is not part of a module" [1.16 backport] CherryPickApproved
  • by gopherbot was closed yesterday
  • cmd/go: warning message when getting a retracted module version is missing a trailing newline [1.16 backport] CherryPickApproved
  • by gopherbot was closed 10 days ago
  • runtime: marked free object in span [1.16 backport] CherryPickApproved
  • by gopherbot was closed 10 days ago
  • cmd/go: "malformed import path" in Go 1.16 for packages with path elements containing a leading dot [1.16 backport] CherryPickApproved release-blocker
  • by gopherbot was closed 8 days ago
  • cmd/link: runtime crash, unexpected fault address 0xffffffffffffffff, h2_bundle.go, when using plugin [1.16 backport] CherryPickApproved
  • by gopherbot was closed 10 days ago
  • time: LoadLocationFromTZData with slim tzdata uses incorrect zone [1.16 backport] CherryPickApproved
  • by gopherbot was closed 10 days ago
  • syscall & x/sys/windows: buffer overflow in GetQueuedCompletionStatus [1.16 backport] CherryPickApproved
  • by gopherbot was closed 10 days ago
  • cmd/go: 'go mod edit -exclude' erroneously rejects '+incompatible' versions [1.16 backport] CherryPickApproved
  • by gopherbot was closed 10 days ago
  • cmd/go: malformed module path with retract v2+ [1.16 backport] CherryPickApproved
  • by gopherbot was closed 8 days ago
  • cmd/compile: ICE on deferred call to syscall.LazyDLL.Call [1.16 backport] CherryPickApproved
  • by gopherbot was closed 10 days ago
  • x/tools/go/analysis, syscall: ptrace redeclared in this block [1.16 backport] CherryPickApproved Tools
  • by gopherbot was closed 14 days ago
  • cmd/compile: Compiler regression in Go 1.16 - internal compiler error: child dcl collision on symbol [1.16 backport] CherryPickApproved
  • by gopherbot was closed 10 days ago
  • @thanm
  • doc: Broken image in readme [1.16 backport] CherryPickApproved Documentation
  • by gopherbot was closed 14 days ago
  • cmd/compile: internal compiler error: Value live at entry. It shouldn't be. [1.16 backport] CherryPickApproved
  • by gopherbot was closed 10 days ago
  • runtime/cgo: cannot build with -Wsign-compare [1.16 backport] CherryPickApproved

New in Portable Go 1.16.1 (Mar 11, 2021)

  • archive/zip: can panic when calling Reader.Open [Go 1.16] CherryPickApproved Security
  • by katiehockman was closed yesterday
  • encoding/xml: infinite loop when using `xml.NewTokenDecoder` with a custom `TokenReader` [Go 1.16]

New in Portable Go 1.16 (Feb 16, 2021)

  • 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.
  • 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/[email protected]). 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:
  • Discard => io.Discard
  • NopCloser => io.NopCloser
  • ReadAll => io.ReadAll
  • ReadDir => os.ReadDir (note: returns a slice of os.DirEntry rather than a slice of fs.FileInfo)
  • ReadFile => os.ReadFile
  • TempDir => os.MkdirTemp
  • TempFile => os.CreateTemp
  • WriteFile => os.WriteFile
  • 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.
  • 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.

New in Portable Go 1.15.8 (Feb 4, 2021)

  • go1.15.8 (released 2021/02/04) includes fixes to the compiler, linker, runtime, the go command, and the net/http package

New in Portable Go 1.15.7 (Jan 20, 2021)

  • Security fixes

New in Portable Go 1.15.6 (Dec 3, 2020)

  • Includes fixes to the compiler, linker, runtime, the go command, and the io package. See the Go 1.15.6 milestone on our issue tracker for details.

New in Portable Go 1.15.5 (Nov 12, 2020)

  • Includes security fixes to the cmd/go and math/big packages. See the Go 1.15.5 milestone on our issue tracker for details.

New in Portable Go 1.15.4 (Nov 5, 2020)

  • Includes fixes to cgo, the compiler, linker, runtime, and the compress/flate, net/http, reflect, and time packages. See the Go 1.15.4 milestone on our issue tracker for details.

New in Portable Go 1.15.3 (Oct 14, 2020)

  • go1.15.3 (released 2020/10/14) includes fixes to cgo, the compiler, runtime, the go command, and the bytes, plugin, and testing packages

New in Portable Go 1.5.0 (Aug 25, 2015)

  • 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.
  • 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.
  • 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.
  • 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
  • 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.
  • 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.
  • 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;
  • 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.
  • 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 (+, -, 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.

New in Portable Go 1.4.2 (Feb 18, 2015)

  • includes bug fixes to the go command, the compiler and linker, and the runtime, syscall, reflect, and math/big packages.

New in Portable Go 1.4.1 (Jan 16, 2015)

  • Includes bug fixes to the linker and the log, syscall, and runtime packages.

New in Portable Go 1.4 (Dec 11, 2014)

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

New in Portable Go 1.3.3 (Dec 11, 2014)

  • includes further bug fixes to cgo, the runtime package, and the nacl port.

New in Portable Go 1.3.2 (Dec 11, 2014)

  • includes bug fixes to cgo and the crypto/tls packages.

New in Portable Go 1.3.1 (Dec 11, 2014)

  • includes bug fixes to the compiler and the runtime, net, and crypto/rsa packages.

New in Portable Go 1.2.2 (Dec 11, 2014)

  • includes a security fix that affects the tour binary included in the binary distributions.

New in Portable Go 1.1.2 (Dec 11, 2014)

  • Includes fixes to the gc compiler and cgo, and the bufio, runtime, syscall, and time packages. See the change history for details. If you use package syscall's Getrlimit and Setrlimit functions under Linux on the ARM or 386 architectures, please note change 55ac276af5a7 that fixes issue 5949.

New in Portable Go 1.0.3 (Jun 13, 2013)

  • Includes minor code and documentation fixes.

New in Portable Go 1.0.2 (Jun 13, 2013)

  • Was issued to fix two bugs in the implementation of maps using struct or array keys: issue 3695 and issue 3573. It also includes many minor code and documentation fixes.

New in Portable Go 1.0.1 (Apr 27, 2012)

  • fix an escape analysis bug that can lead to memory corruption