"Fossies" - the Fresh Open Source Software Archive

Member "go/doc/go1.12.html" (9 Sep 2020, 37869 Bytes) of package /windows/misc/go1.14.9.windows-386.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) HTML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 <!--{
    2         "Title": "Go 1.12 Release Notes",
    3         "Path":  "/doc/go1.12",
    4         "Template": true
    5 }-->
    6 
    7 <!--
    8 NOTE: In this document and others in this directory, the convention is to
    9 set fixed-width phrases with non-fixed-width spaces, as in
   10 <code>hello</code> <code>world</code>.
   11 Do not send CLs removing the interior tags from such phrases.
   12 -->
   13 
   14 <style>
   15   main ul li { margin: 0.5em 0; }
   16 </style>
   17 
   18 <h2 id="introduction">Introduction to Go 1.12</h2>
   19 
   20 <p>
   21   The latest Go release, version 1.12, arrives six months after <a href="go1.11">Go 1.11</a>.
   22   Most of its changes are in the implementation of the toolchain, runtime, and libraries.
   23   As always, the release maintains the Go 1 <a href="/doc/go1compat">promise of compatibility</a>.
   24   We expect almost all Go programs to continue to compile and run as before.
   25 </p>
   26 
   27 <h2 id="language">Changes to the language</h2>
   28 
   29 <p>
   30   There are no changes to the language specification.
   31 </p>
   32 
   33 <h2 id="ports">Ports</h2>
   34 
   35 <p><!-- CL 138675 -->
   36   The race detector is now supported on <code>linux/arm64</code>.
   37 </p>
   38 
   39 <p id="freebsd">
   40   Go 1.12 is the last release that is supported on FreeBSD 10.x, which has
   41   already reached end-of-life. Go 1.13 will require FreeBSD 11.2+ or FreeBSD
   42   12.0+.
   43   FreeBSD 12.0+ requires a kernel with the COMPAT_FREEBSD11 option set (this is the default).
   44 </p>
   45 
   46 <p><!-- CL 146898 -->
   47   cgo is now supported on <code>linux/ppc64</code>.
   48 </p>
   49 
   50 <p id="hurd"><!-- CL 146023 -->
   51   <code>hurd</code> is now a recognized value for <code>GOOS</code>, reserved
   52   for the GNU/Hurd system for use with <code>gccgo</code>.
   53 </p>
   54 
   55 <h3 id="windows">Windows</h3>
   56 
   57 <p>
   58   Go's new <code>windows/arm</code> port supports running Go on Windows 10
   59   IoT Core on 32-bit ARM chips such as the Raspberry Pi 3.
   60 </p>
   61 
   62 <h3 id="aix">AIX</h3>
   63 
   64 <p>
   65   Go now supports AIX 7.2 and later on POWER8 architectures (<code>aix/ppc64</code>). External linking, cgo, pprof and the race detector aren't yet supported.
   66 </p>
   67 
   68 <h3 id="darwin">Darwin</h3>
   69 
   70 <p>
   71   Go 1.12 is the last release that will run on macOS 10.10 Yosemite.
   72   Go 1.13 will require macOS 10.11 El Capitan or later.
   73 </p>
   74 
   75 <p><!-- CL 141639 -->
   76   <code>libSystem</code> is now used when making syscalls on Darwin,
   77   ensuring forward-compatibility with future versions of macOS and iOS.
   78   <!-- CL 153338 -->
   79   The switch to <code>libSystem</code> triggered additional App Store
   80   checks for private API usage. Since it is considered private,
   81   <code>syscall.Getdirentries</code> now always fails with
   82   <code>ENOSYS</code> on iOS.
   83   Additionally, <a href="/pkg/syscall/#Setrlimit"><code>syscall.Setrlimit</code></a>
   84   reports <code>invalid</code> <code>argument</code> in places where it historically
   85   succeeded. These consequences are not specific to Go and users should expect
   86   behavioral parity with <code>libSystem</code>'s implementation going forward.
   87 </p>
   88 
   89 <h2 id="tools">Tools</h2>
   90 
   91 <h3 id="vet"><code>go tool vet</code> no longer supported</h3>
   92 
   93 <p>
   94   The <code>go vet</code> command has been rewritten to serve as the
   95   base for a range of different source code analysis tools. See
   96   the <a href="https://godoc.org/golang.org/x/tools/go/analysis">golang.org/x/tools/go/analysis</a>
   97   package for details. A side-effect is that <code>go tool vet</code>
   98   is no longer supported. External tools that use <code>go tool
   99   vet</code> must be changed to use <code>go
  100   vet</code>. Using <code>go vet</code> instead of <code>go tool
  101   vet</code> should work with all supported versions of Go.
  102 </p>
  103 
  104 <p>
  105   As part of this change, the experimental <code>-shadow</code> option
  106   is no longer available with <code>go vet</code>. Checking for
  107   variable shadowing may now be done using
  108 <pre>
  109 go get -u golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
  110 go vet -vettool=$(which shadow)
  111 </pre>
  112 </p>
  113 
  114 <h3 id="tour">Tour</h3>
  115 
  116 <p> <!-- CL 152657 -->
  117 The Go tour is no longer included in the main binary distribution. To
  118 run the tour locally, instead of running <code>go</code> <code>tool</code> <code>tour</code>,
  119 manually install it:
  120 <pre>
  121 go get -u golang.org/x/tour
  122 tour
  123 </pre>
  124 </p>
  125 
  126 <h3 id="gocache">Build cache requirement</h3>
  127 
  128 <p>
  129   The <a href="/cmd/go/#hdr-Build_and_test_caching">build cache</a> is now
  130   required as a step toward eliminating
  131   <code>$GOPATH/pkg</code>. Setting the environment variable
  132   <code>GOCACHE=off</code> will cause <code>go</code> commands that write to the
  133   cache to fail.
  134 </p>
  135 
  136 <h3 id="binary-only">Binary-only packages</h3>
  137 
  138 <p>
  139   Go 1.12 is the last release that will support binary-only packages.
  140 </p>
  141 
  142 <h3 id="cgo">Cgo</h3>
  143 
  144 <p>
  145     Go 1.12 will translate the C type <code>EGLDisplay</code> to the Go type <code>uintptr</code>.
  146     This change is similar to how Go 1.10 and newer treats Darwin's CoreFoundation
  147     and Java's JNI types. See the
  148     <a href="/cmd/cgo/#hdr-Special_cases">cgo documentation</a>
  149     for more information.
  150 </p>
  151 
  152 <p><!-- CL 152657 -->
  153   Mangled C names are no longer accepted in packages that use Cgo. Use the Cgo
  154   names instead. For example, use the documented cgo name <code>C.char</code>
  155   rather than the mangled name <code>_Ctype_char</code> that cgo generates.
  156 </p>
  157 
  158 <h3 id="modules">Modules</h3>
  159 
  160 <p><!-- CL 148517 -->
  161   When <code>GO111MODULE</code> is set to <code>on</code>, the <code>go</code>
  162   command now supports module-aware operations outside of a module directory,
  163   provided that those operations do not need to resolve import paths relative to
  164   the current directory or explicitly edit the <code>go.mod</code> file.
  165   Commands such as <code>go</code> <code>get</code>,
  166   <code>go</code> <code>list</code>, and
  167   <code>go</code> <code>mod</code> <code>download</code> behave as if in a
  168   module with initially-empty requirements.
  169   In this mode, <code>go</code> <code>env</code> <code>GOMOD</code> reports
  170   the system's null device (<code>/dev/null</code> or <code>NUL</code>).
  171 </p>
  172 
  173 <p><!-- CL 146382 -->
  174   <code>go</code> commands that download and extract modules are now safe to
  175   invoke concurrently.
  176   The module cache (<code>GOPATH/pkg/mod</code>) must reside in a filesystem that
  177   supports file locking.
  178 </p>
  179 
  180 <p><!-- CL 147282, 147281 -->
  181   The <code>go</code> directive in a <code>go.mod</code> file now indicates the
  182   version of the language used by the files within that module.
  183   It will be set to the current release
  184   (<code>go</code> <code>1.12</code>) if no existing version is
  185   present.
  186   If the <code>go</code> directive for a module specifies a
  187   version <em>newer</em> than the toolchain in use, the <code>go</code> command
  188   will attempt to build the packages regardless, and will note the mismatch only if
  189   that build fails.
  190 </p>
  191 
  192 <p><!-- CL 147282, 147281 -->
  193   This changed use of the <code>go</code> directive means that if you
  194   use Go 1.12 to build a module, thus recording <code>go 1.12</code>
  195   in the <code>go.mod</code> file, you will get an error when
  196   attempting to build the same module with Go 1.11 through Go 1.11.3.
  197   Go 1.11.4 or later will work fine, as will releases older than Go 1.11.
  198   If you must use Go 1.11 through 1.11.3, you can avoid the problem by
  199   setting the language version to 1.11, using the Go 1.12 go tool,
  200   via <code>go mod edit -go=1.11</code>.
  201 </p>
  202 
  203 <p><!-- CL 152739 -->
  204   When an import cannot be resolved using the active modules,
  205   the <code>go</code> command will now try to use the modules mentioned in the
  206   main module's <code>replace</code> directives before consulting the module
  207   cache and the usual network sources.
  208   If a matching replacement is found but the <code>replace</code> directive does
  209   not specify a version, the <code>go</code> command uses a pseudo-version
  210   derived from the zero <code>time.Time</code> (such
  211   as <code>v0.0.0-00010101000000-000000000000</code>).
  212 </p>
  213 
  214 <h3 id="compiler">Compiler toolchain</h3>
  215 
  216 <p><!-- CL 134155, 134156 -->
  217   The compiler's live variable analysis has improved. This may mean that
  218   finalizers will be executed sooner in this release than in previous
  219   releases. If that is a problem, consider the appropriate addition of a
  220   <a href="/pkg/runtime/#KeepAlive"><code>runtime.KeepAlive</code></a> call.
  221 </p>
  222 
  223 <p><!-- CL 147361 -->
  224   More functions are now eligible for inlining by default, including
  225   functions that do nothing but call another function.
  226   This extra inlining makes it additionally important to use
  227   <a href="/pkg/runtime/#CallersFrames"><code>runtime.CallersFrames</code></a>
  228   instead of iterating over the result of
  229   <a href="/pkg/runtime/#Callers"><code>runtime.Callers</code></a> directly.
  230 <pre>
  231 // Old code which no longer works correctly (it will miss inlined call frames).
  232 var pcs [10]uintptr
  233 n := runtime.Callers(1, pcs[:])
  234 for _, pc := range pcs[:n] {
  235     f := runtime.FuncForPC(pc)
  236     if f != nil {
  237         fmt.Println(f.Name())
  238     }
  239 }
  240 </pre>
  241 <pre>
  242 // New code which will work correctly.
  243 var pcs [10]uintptr
  244 n := runtime.Callers(1, pcs[:])
  245 frames := runtime.CallersFrames(pcs[:n])
  246 for {
  247     frame, more := frames.Next()
  248     fmt.Println(frame.Function)
  249     if !more {
  250         break
  251     }
  252 }
  253 </pre>
  254 </p>
  255 
  256 <p><!-- CL 153477 -->
  257   Wrappers generated by the compiler to implement method expressions
  258   are no longer reported
  259   by <a href="/pkg/runtime/#CallersFrames"><code>runtime.CallersFrames</code></a>
  260   and <a href="/pkg/runtime/#Stack"><code>runtime.Stack</code></a>. They
  261   are also not printed in panic stack traces.
  262 
  263   This change aligns the <code>gc</code> toolchain to match
  264   the <code>gccgo</code> toolchain, which already elided such wrappers
  265   from stack traces.
  266 
  267   Clients of these APIs might need to adjust for the missing
  268   frames. For code that must interoperate between 1.11 and 1.12
  269   releases, you can replace the method expression <code>x.M</code>
  270   with the function literal <code>func (...) { x.M(...) } </code>.
  271 </p>
  272 
  273 <p><!-- CL 144340 -->
  274   The compiler now accepts a <code>-lang</code> flag to set the Go language
  275   version to use. For example, <code>-lang=go1.8</code> causes the compiler to
  276   emit an error if the program uses type aliases, which were added in Go 1.9.
  277   Language changes made before Go 1.12 are not consistently enforced.
  278 </p>
  279 
  280 <p><!-- CL 147160 -->
  281   The compiler toolchain now uses different conventions to call Go
  282   functions and assembly functions. This should be invisible to users,
  283   except for calls that simultaneously cross between Go and
  284   assembly <em>and</em> cross a package boundary. If linking results
  285   in an error like "relocation target not defined for ABIInternal (but
  286   is defined for ABI0)", please refer to the
  287   <a href="https://github.com/golang/proposal/blob/master/design/27539-internal-abi.md#compatibility">compatibility section</a>
  288   of the ABI design document.
  289 </p>
  290 
  291 <p><!-- CL 145179 -->
  292   There have been many improvements to the DWARF debug information
  293   produced by the compiler, including improvements to argument
  294   printing and variable location information.
  295 </p>
  296 
  297 <p><!-- CL 61511 -->
  298   Go programs now also maintain stack frame pointers on <code>linux/arm64</code>
  299   for the benefit of profiling tools like <code>perf</code>. The frame pointer
  300   maintenance has a small run-time overhead that varies but averages around 3%.
  301   To build a toolchain that does not use frame pointers, set
  302   <code>GOEXPERIMENT=noframepointer</code> when running <code>make.bash</code>.
  303 </p>
  304 
  305 <p><!-- CL 142717 -->
  306   The obsolete "safe" compiler mode (enabled by the <code>-u</code> gcflag) has been removed.
  307 </p>
  308 
  309 <h3 id="godoc"><code>godoc</code> and <code>go</code> <code>doc</code></h3>
  310 
  311 <p>
  312   In Go 1.12, <code>godoc</code> no longer has a command-line interface and
  313   is only a web server. Users should use <code>go</code> <code>doc</code>
  314   for command-line help output instead. Go 1.12 is the last release that will
  315   include the <code>godoc</code> webserver; in Go 1.13 it will be available
  316   via <code>go</code> <code>get</code>.
  317 </p>
  318 
  319 <p><!-- CL 141977 -->
  320   <code>go</code> <code>doc</code> now supports the <code>-all</code> flag,
  321   which will cause it to print all exported APIs and their documentation,
  322   as the <code>godoc</code> command line used to do.
  323 </p>
  324 
  325 <p><!-- CL 140959 -->
  326   <code>go</code> <code>doc</code> also now includes the <code>-src</code> flag,
  327   which will show the target's source code.
  328 </p>
  329 
  330 <h3 id="trace">Trace</h3>
  331 
  332 <p><!-- CL 60790 -->
  333   The trace tool now supports plotting mutator utilization curves,
  334   including cross-references to the execution trace. These are useful
  335   for analyzing the impact of the garbage collector on application
  336   latency and throughput.
  337 </p>
  338 
  339 <h3 id="assembler">Assembler</h3>
  340 
  341 <p><!-- CL 147218 -->
  342   On <code>arm64</code>, the platform register was renamed from
  343   <code>R18</code> to <code>R18_PLATFORM</code> to prevent accidental
  344   use, as the OS could choose to reserve this register.
  345 </p>
  346 
  347 <h2 id="runtime">Runtime</h2>
  348 
  349 <p><!-- CL 138959 -->
  350   Go 1.12 significantly improves the performance of sweeping when a
  351   large fraction of the heap remains live. This reduces allocation
  352   latency immediately following a garbage collection.
  353 </p>
  354 
  355 <p><!-- CL 139719 -->
  356   The Go runtime now releases memory back to the operating system more
  357   aggressively, particularly in response to large allocations that
  358   can't reuse existing heap space.
  359 </p>
  360 
  361 <p><!-- CL 146342, CL 146340, CL 146345, CL 146339, CL 146343, CL 146337, CL 146341, CL 146338 -->
  362   The Go runtime's timer and deadline code is faster and scales better
  363   with higher numbers of CPUs. In particular, this improves the
  364   performance of manipulating network connection deadlines.
  365 </p>
  366 
  367 <p><!-- CL 135395 -->
  368   On Linux, the runtime now uses <code>MADV_FREE</code> to release unused
  369   memory. This is more efficient but may result in higher reported
  370   RSS. The kernel will reclaim the unused data when it is needed.
  371   To revert to the Go 1.11 behavior (<code>MADV_DONTNEED</code>), set the
  372   environment variable <code>GODEBUG=madvdontneed=1</code>.
  373 </p>
  374 
  375 <p><!-- CL 149578 -->
  376   Adding cpu.<em>extension</em>=off to the
  377   <a href="/doc/diagnostics.html#godebug">GODEBUG</a> environment
  378   variable now disables the use of optional CPU instruction
  379   set extensions in the standard library and runtime. This is not
  380   yet supported on Windows.
  381 </p>
  382 
  383 <p><!-- CL 158337 -->
  384   Go 1.12 improves the accuracy of memory profiles by fixing
  385   overcounting of large heap allocations.
  386 </p>
  387 
  388 <p><!-- CL 159717 -->
  389   Tracebacks, <code>runtime.Caller</code>,
  390   and <code>runtime.Callers</code> no longer include
  391   compiler-generated initialization functions.  Doing a traceback
  392   during the initialization of a global variable will now show a
  393   function named <code>PKG.init.ializers</code>.
  394 </p>
  395 
  396 <h2 id="library">Core library</h2>
  397 
  398 <h3 id="tls_1_3">TLS 1.3</h3>
  399 
  400 <p>
  401   Go 1.12 adds opt-in support for TLS 1.3 in the <code>crypto/tls</code> package as
  402   specified by <a href="https://www.rfc-editor.org/info/rfc8446">RFC 8446</a>. It can
  403   be enabled by adding the value <code>tls13=1</code> to the <code>GODEBUG</code>
  404   environment variable. It will be enabled by default in Go 1.13.
  405 </p>
  406 
  407 <p>
  408   To negotiate TLS 1.3, make sure you do not set an explicit <code>MaxVersion</code> in
  409   <a href="/pkg/crypto/tls/#Config"><code>Config</code></a> and run your program with
  410   the environment variable <code>GODEBUG=tls13=1</code> set.
  411 </p>
  412 
  413 <p>
  414   All TLS 1.2 features except <code>TLSUnique</code> in
  415   <a href="/pkg/crypto/tls/#ConnectionState"><code>ConnectionState</code></a>
  416   and renegotiation are available in TLS 1.3 and provide equivalent or
  417   better security and performance. Note that even though TLS 1.3 is backwards
  418   compatible with previous versions, certain legacy systems might not work
  419   correctly when attempting to negotiate it. RSA certificate keys too small
  420   to be secure (including 512-bit keys) will not work with TLS 1.3.
  421 </p>
  422 
  423 <p>
  424   TLS 1.3 cipher suites are not configurable. All supported cipher suites are
  425   safe, and if <code>PreferServerCipherSuites</code> is set in
  426   <a href="/pkg/crypto/tls/#Config"><code>Config</code></a> the preference order
  427   is based on the available hardware.
  428 </p>
  429 
  430 <p>
  431   Early data (also called "0-RTT mode") is not currently supported as a
  432   client or server. Additionally, a Go 1.12 server does not support skipping
  433   unexpected early data if a client sends it. Since TLS 1.3 0-RTT mode
  434   involves clients keeping state regarding which servers support 0-RTT,
  435   a Go 1.12 server cannot be part of a load-balancing pool where some other
  436   servers do support 0-RTT. If switching a domain from a server that supported
  437   0-RTT to a Go 1.12 server, 0-RTT would have to be disabled for at least the
  438   lifetime of the issued session tickets before the switch to ensure
  439   uninterrupted operation.
  440 </p>
  441 
  442 <p>
  443   In TLS 1.3 the client is the last one to speak in the handshake, so if it causes
  444   an error to occur on the server, it will be returned on the client by the first
  445   <a href="/pkg/crypto/tls/#Conn.Read"><code>Read</code></a>, not by
  446   <a href="/pkg/crypto/tls/#Conn.Handshake"><code>Handshake</code></a>. For
  447   example, that will be the case if the server rejects the client certificate.
  448   Similarly, session tickets are now post-handshake messages, so are only
  449   received by the client upon its first
  450   <a href="/pkg/crypto/tls/#Conn.Read"><code>Read</code></a>.
  451 </p>
  452 
  453 <h3 id="minor_library_changes">Minor changes to the library</h3>
  454 
  455 <p>
  456   As always, there are various minor changes and updates to the library,
  457   made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
  458   in mind.
  459 </p>
  460 
  461 <!-- TODO: CL 115677: https://golang.org/cl/115677: cmd/vet: check embedded field tags too -->
  462 
  463 <dl id="bufio"><dt><a href="/pkg/bufio/">bufio</a></dt>
  464   <dd>
  465     <p><!-- CL 149297 -->
  466       <code>Reader</code>'s <a href="/pkg/bufio/#Reader.UnreadRune"><code>UnreadRune</code></a> and
  467       <a href="/pkg/bufio/#Reader.UnreadByte"><code>UnreadByte</code></a> methods will now return an error
  468       if they are called after <a href="/pkg/bufio/#Reader.Peek"><code>Peek</code></a>.
  469     </p>
  470 
  471 </dl><!-- bufio -->
  472 
  473 <dl id="bytes"><dt><a href="/pkg/bytes/">bytes</a></dt>
  474   <dd>
  475     <p><!-- CL 137855 -->
  476       The new function <a href="/pkg/bytes/#ReplaceAll"><code>ReplaceAll</code></a> returns a copy of
  477       a byte slice with all non-overlapping instances of a value replaced by another.
  478     </p>
  479 
  480     <p><!-- CL 145098 -->
  481       A pointer to a zero-value <a href="/pkg/bytes/#Reader"><code>Reader</code></a> is now
  482       functionally equivalent to <a href="/pkg/bytes/#NewReader"><code>NewReader</code></a><code>(nil)</code>.
  483       Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases.
  484     </p>
  485 
  486 </dl><!-- bytes -->
  487 
  488 <dl id="crypto/rand"><dt><a href="/pkg/crypto/rand/">crypto/rand</a></dt>
  489   <dd>
  490     <p><!-- CL 139419 -->
  491       A warning will now be printed to standard error the first time
  492       <code>Reader.Read</code> is blocked for more than 60 seconds waiting
  493       to read entropy from the kernel.
  494     </p>
  495 
  496     <p><!-- CL 120055 -->
  497       On FreeBSD, <code>Reader</code> now uses the <code>getrandom</code>
  498       system call if available, <code>/dev/urandom</code> otherwise.
  499     </p>
  500 
  501 </dl><!-- crypto/rand -->
  502 
  503 <dl id="crypto/rc4"><dt><a href="/pkg/crypto/rc4/">crypto/rc4</a></dt>
  504   <dd>
  505     <p><!-- CL 130397 -->
  506       This release removes the assembly implementations, leaving only
  507       the pure Go version. The Go compiler generates code that is
  508       either slightly better or slightly worse, depending on the exact
  509       CPU. RC4 is insecure and should only be used for compatibility
  510       with legacy systems.
  511     </p>
  512 
  513 </dl><!-- crypto/rc4 -->
  514 
  515 <dl id="crypto/tls"><dt><a href="/pkg/crypto/tls/">crypto/tls</a></dt>
  516   <dd>
  517     <p><!-- CL 143177 -->
  518       If a client sends an initial message that does not look like TLS, the server
  519       will no longer reply with an alert, and it will expose the underlying
  520       <code>net.Conn</code> in the new field <code>Conn</code> of
  521       <a href="/pkg/crypto/tls/#RecordHeaderError"><code>RecordHeaderError</code></a>.
  522     </p>
  523 
  524 </dl><!-- crypto/tls -->
  525 
  526 <dl id="database/sql"><dt><a href="/pkg/database/sql/">database/sql</a></dt>
  527   <dd>
  528     <p><!-- CL 145738 -->
  529       A query cursor can now be obtained by passing a
  530       <a href="/pkg/database/sql/#Rows"><code>*Rows</code></a>
  531       value to the <a href="/pkg/database/sql/#Row.Scan"><code>Row.Scan</code></a> method.
  532     </p>
  533 
  534 </dl><!-- database/sql -->
  535 
  536 <dl id="expvar"><dt><a href="/pkg/expvar/">expvar</a></dt>
  537   <dd>
  538     <p><!-- CL 139537 -->
  539       The new <a href="/pkg/expvar/#Map.Delete"><code>Delete</code></a> method allows
  540       for deletion of key/value pairs from a <a href="/pkg/expvar/#Map"><code>Map</code></a>.
  541     </p>
  542 
  543 </dl><!-- expvar -->
  544 
  545 <dl id="fmt"><dt><a href="/pkg/fmt/">fmt</a></dt>
  546   <dd>
  547     <p><!-- CL 142737 -->
  548       Maps are now printed in key-sorted order to ease testing. The ordering rules are:
  549       <ul>
  550         <li>When applicable, nil compares low
  551         <li>ints, floats, and strings order by <
  552         <li>NaN compares less than non-NaN floats
  553         <li>bool compares false before true
  554         <li>Complex compares real, then imaginary
  555         <li>Pointers compare by machine address
  556         <li>Channel values compare by machine address
  557         <li>Structs compare each field in turn
  558         <li>Arrays compare each element in turn
  559         <li>Interface values compare first by <code>reflect.Type</code> describing the concrete type
  560             and then by concrete value as described in the previous rules.
  561       </ul>
  562     </p>
  563 
  564     <p><!-- CL 129777 -->
  565       When printing maps, non-reflexive key values like <code>NaN</code> were previously
  566       displayed as <code>&lt;nil&gt;</code>. As of this release, the correct values are printed.
  567     </p>
  568 
  569 </dl><!-- fmt -->
  570 
  571 <dl id="go/doc"><dt><a href="/pkg/go/doc/">go/doc</a></dt>
  572   <dd>
  573     <p><!-- CL 140958 -->
  574       To address some outstanding issues in <a href="/cmd/doc/"><code>cmd/doc</code></a>,
  575       this package has a new <a href="/pkg/go/doc/#Mode"><code>Mode</code></a> bit,
  576       <code>PreserveAST</code>, which controls whether AST data is cleared.
  577     </p>
  578 
  579 </dl><!-- go/doc -->
  580 
  581 <dl id="go/token"><dt><a href="/pkg/go/token/">go/token</a></dt>
  582   <dd>
  583     <p><!-- CL 134075 -->
  584       The <a href="/pkg/go/token#File"><code>File</code></a> type has a new
  585       <a href="/pkg/go/token#File.LineStart"><code>LineStart</code></a> field,
  586       which returns the position of the start of a given line. This is especially useful
  587       in programs that occasionally handle non-Go files, such as assembly, but wish to use
  588       the <code>token.Pos</code> mechanism to identify file positions.
  589     </p>
  590 
  591 </dl><!-- go/token -->
  592 
  593 <dl id="image"><dt><a href="/pkg/image/">image</a></dt>
  594   <dd>
  595     <p><!-- CL 118755 -->
  596       The <a href="/pkg/image/#RegisterFormat"><code>RegisterFormat</code></a> function is now safe for concurrent use.
  597     </p>
  598 
  599 </dl><!-- image -->
  600 
  601 <dl id="image/png"><dt><a href="/pkg/image/png/">image/png</a></dt>
  602   <dd>
  603     <p><!-- CL 134235 -->
  604       Paletted images with fewer than 16 colors now encode to smaller outputs.
  605     </p>
  606 
  607 </dl><!-- image/png -->
  608 
  609 <dl id="io"><dt><a href="/pkg/io/">io</a></dt>
  610   <dd>
  611     <p><!-- CL 139457 -->
  612       The new <a href="/pkg/io#StringWriter"><code>StringWriter</code></a> interface wraps the
  613       <a href="/pkg/io/#WriteString"><code>WriteString</code></a> function.
  614     </p>
  615 
  616 </dl><!-- io -->
  617 
  618 <dl id="math"><dt><a href="/pkg/math/">math</a></dt>
  619   <dd>
  620     <p><!-- CL 153059 -->
  621       The functions
  622       <a href="/pkg/math/#Sin"><code>Sin</code></a>,
  623       <a href="/pkg/math/#Cos"><code>Cos</code></a>,
  624       <a href="/pkg/math/#Tan"><code>Tan</code></a>,
  625       and <a href="/pkg/math/#Sincos"><code>Sincos</code></a> now
  626       apply Payne-Hanek range reduction to huge arguments. This
  627       produces more accurate answers, but they will not be bit-for-bit
  628       identical with the results in earlier releases.
  629     </p>
  630 </dl><!-- math -->
  631 
  632 <dl id="math/bits"><dt><a href="/pkg/math/bits/">math/bits</a></dt>
  633   <dd>
  634     <p><!-- CL 123157 -->
  635     New extended precision operations <a href="/pkg/math/bits/#Add"><code>Add</code></a>, <a href="/pkg/math/bits/#Sub"><code>Sub</code></a>, <a href="/pkg/math/bits/#Mul"><code>Mul</code></a>, and <a href="/pkg/math/bits/#Div"><code>Div</code></a> are available in <code>uint</code>, <code>uint32</code>, and <code>uint64</code> versions.
  636     </p>
  637 
  638 </dl><!-- math/bits -->
  639 
  640 <dl id="net"><dt><a href="/pkg/net/">net</a></dt>
  641   <dd>
  642     <p><!-- CL 146659 -->
  643       The
  644       <a href="/pkg/net/#Dialer.DualStack"><code>Dialer.DualStack</code></a> setting is now ignored and deprecated;
  645       RFC 6555 Fast Fallback ("Happy Eyeballs") is now enabled by default. To disable, set
  646       <a href="/pkg/net/#Dialer.FallbackDelay"><code>Dialer.FallbackDelay</code></a> to a negative value.
  647     </p>
  648 
  649     <p><!-- CL 107196 -->
  650       Similarly, TCP keep-alives are now enabled by default if
  651       <a href="/pkg/net/#Dialer.KeepAlive"><code>Dialer.KeepAlive</code></a> is zero.
  652       To disable, set it to a negative value.
  653     </p>
  654 
  655     <p><!-- CL 113997 -->
  656       On Linux, the <a href="http://man7.org/linux/man-pages/man2/splice.2.html"><code>splice</code> system call</a> is now used when copying from a
  657       <a href="/pkg/net/#UnixConn"><code>UnixConn</code></a> to a
  658       <a href="/pkg/net/#TCPConn"><code>TCPConn</code></a>.
  659     </p>
  660 </dl><!-- net -->
  661 
  662 <dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
  663   <dd>
  664     <p><!-- CL 143177 -->
  665       The HTTP server now rejects misdirected HTTP requests to HTTPS servers with a plaintext "400 Bad Request" response.
  666     </p>
  667 
  668     <p><!-- CL 130115 -->
  669       The new <a href="/pkg/net/http/#Client.CloseIdleConnections"><code>Client.CloseIdleConnections</code></a>
  670       method calls the <code>Client</code>'s underlying <code>Transport</code>'s <code>CloseIdleConnections</code>
  671       if it has one.
  672     </p>
  673 
  674     <p><!-- CL 145398 -->
  675       The <a href="/pkg/net/http/#Transport"><code>Transport</code></a> no longer rejects HTTP responses which declare
  676       HTTP Trailers but don't use chunked encoding. Instead, the declared trailers are now just ignored.
  677     </p>
  678 
  679     <p><!-- CL 152080 --> <!-- CL 151857 -->
  680       The <a href="/pkg/net/http/#Transport"><code>Transport</code></a> no longer handles <code>MAX_CONCURRENT_STREAMS</code> values
  681       advertised from HTTP/2 servers as strictly as it did during Go 1.10 and Go 1.11. The default behavior is now back
  682       to how it was in Go 1.9: each connection to a server can have up to <code>MAX_CONCURRENT_STREAMS</code> requests
  683       active and then new TCP connections are created as needed. In Go 1.10 and Go 1.11 the <code>http2</code> package
  684       would block and wait for requests to finish instead of creating new connections.
  685       To get the stricter behavior back, import the
  686       <a href="https://godoc.org/golang.org/x/net/http2"><code>golang.org/x/net/http2</code></a> package
  687       directly and set
  688       <a href="https://godoc.org/golang.org/x/net/http2#Transport.StrictMaxConcurrentStreams"><code>Transport.StrictMaxConcurrentStreams</code></a> to
  689       <code>true</code>.
  690     </p>
  691 
  692 </dl><!-- net/http -->
  693 
  694 <dl id="net/url"><dt><a href="/pkg/net/url/">net/url</a></dt>
  695   <dd>
  696     <p><!-- CL 159157, CL 160178 -->
  697       <a href="/pkg/net/url/#Parse"><code>Parse</code></a>,
  698       <a href="/pkg/net/url/#ParseRequestURI"><code>ParseRequestURI</code></a>,
  699       and
  700       <a href="/pkg/net/url/#URL.Parse"><code>URL.Parse</code></a>
  701       now return an
  702       error for URLs containing ASCII control characters, which includes NULL,
  703       tab, and newlines.
  704     </p>
  705 
  706 </dl><!-- net/url -->
  707 
  708 <dl id="net/http/httputil"><dt><a href="/pkg/net/http/httputil/">net/http/httputil</a></dt>
  709   <dd>
  710     <p><!-- CL 146437 -->
  711       The <a href="/pkg/net/http/httputil/#ReverseProxy"><code>ReverseProxy</code></a> now automatically
  712       proxies WebSocket requests.
  713     </p>
  714 
  715 </dl><!-- net/http/httputil -->
  716 
  717 <dl id="os"><dt><a href="/pkg/os/">os</a></dt>
  718   <dd>
  719     <p><!-- CL 125443 -->
  720       The new <a href="/pkg/os/#ProcessState.ExitCode"><code>ProcessState.ExitCode</code></a> method
  721       returns the process's exit code.
  722     </p>
  723 
  724     <p><!-- CL 135075 -->
  725       <code>ModeCharDevice</code> has been added to the <code>ModeType</code> bitmask, allowing for
  726       <code>ModeDevice | ModeCharDevice</code> to be recovered when masking a
  727       <a href="/pkg/os/#FileMode"><code>FileMode</code></a> with <code>ModeType</code>.
  728     </p>
  729 
  730     <p><!-- CL 139418 -->
  731       The new function <a href="/pkg/os/#UserHomeDir"><code>UserHomeDir</code></a> returns the
  732       current user's home directory.
  733     </p>
  734 
  735     <p><!-- CL 146020 -->
  736       <a href="/pkg/os/#RemoveAll"><code>RemoveAll</code></a> now supports paths longer than 4096 characters
  737       on most Unix systems.
  738     </p>
  739 
  740     <p><!-- CL 130676 -->
  741       <a href="/pkg/os/#File.Sync"><code>File.Sync</code></a> now uses <code>F_FULLFSYNC</code> on macOS
  742       to correctly flush the file contents to permanent storage.
  743       This may cause the method to run more slowly than in previous releases.
  744     </p>
  745 
  746     <p><!--CL 155517 -->
  747       <a href="/pkg/os/#File"><code>File</code></a> now supports
  748       a <a href="/pkg/os/#File.SyscallConn"><code>SyscallConn</code></a>
  749       method returning
  750       a <a href="/pkg/syscall/#RawConn"><code>syscall.RawConn</code></a>
  751       interface value. This may be used to invoke system-specific
  752       operations on the underlying file descriptor.
  753     </p>
  754 
  755 </dl><!-- os -->
  756 
  757 <dl id="path/filepath"><dt><a href="/pkg/path/filepath/">path/filepath</a></dt>
  758   <dd>
  759     <p><!-- CL 145220 -->
  760       The <a href="/pkg/path/filepath/#IsAbs"><code>IsAbs</code></a> function now returns true when passed
  761       a reserved filename on Windows such as <code>NUL</code>.
  762       <a href="https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#naming-conventions">List of reserved names.</a>
  763     </p>
  764 
  765 </dl><!-- path/filepath -->
  766 
  767 <dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
  768   <dd>
  769     <p><!-- CL 33572 -->
  770       A new <a href="/pkg/reflect#MapIter"><code>MapIter</code></a> type is
  771       an iterator for ranging over a map. This type is exposed through the
  772       <a href="/pkg/reflect#Value"><code>Value</code></a> type's new
  773       <a href="/pkg/reflect#Value.MapRange"><code>MapRange</code></a> method.
  774       This follows the same iteration semantics as a range statement, with <code>Next</code>
  775       to advance the iterator, and <code>Key</code>/<code>Value</code> to access each entry.
  776     </p>
  777 
  778 </dl><!-- reflect -->
  779 
  780 <dl id="regexp"><dt><a href="/pkg/regexp/">regexp</a></dt>
  781   <dd>
  782     <p><!-- CL 139784 -->
  783       <a href="/pkg/regexp/#Regexp.Copy"><code>Copy</code></a> is no longer necessary
  784       to avoid lock contention, so it has been given a partial deprecation comment.
  785       <a href="/pkg/regexp/#Regexp.Copy"><code>Copy</code></a>
  786       may still be appropriate if the reason for its use is to make two copies with
  787       different <a href="/pkg/regexp/#Regexp.Longest"><code>Longest</code></a> settings.
  788     </p>
  789 
  790 </dl><!-- regexp -->
  791 
  792 <dl id="runtime/debug"><dt><a href="/pkg/runtime/debug/">runtime/debug</a></dt>
  793   <dd>
  794     <p><!-- CL 144220 -->
  795       A new <a href="/pkg/runtime/debug/#BuildInfo"><code>BuildInfo</code></a> type
  796       exposes the build information read from the running binary, available only in
  797       binaries built with module support. This includes the main package path, main
  798       module information, and the module dependencies. This type is given through the
  799       <a href="/pkg/runtime/debug/#ReadBuildInfo"><code>ReadBuildInfo</code></a> function
  800       on <a href="/pkg/runtime/debug/#BuildInfo"><code>BuildInfo</code></a>.
  801     </p>
  802 
  803 </dl><!-- runtime/debug -->
  804 
  805 <dl id="strings"><dt><a href="/pkg/strings/">strings</a></dt>
  806   <dd>
  807     <p><!-- CL 137855 -->
  808       The new function <a href="/pkg/strings/#ReplaceAll"><code>ReplaceAll</code></a> returns a copy of
  809       a string with all non-overlapping instances of a value replaced by another.
  810     </p>
  811 
  812     <p><!-- CL 145098 -->
  813       A pointer to a zero-value <a href="/pkg/strings/#Reader"><code>Reader</code></a> is now
  814       functionally equivalent to <a href="/pkg/strings/#NewReader"><code>NewReader</code></a><code>(nil)</code>.
  815       Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases.
  816     </p>
  817 
  818     <p><!-- CL 122835 -->
  819       The new <a href="/pkg/strings/#Builder.Cap"><code>Builder.Cap</code></a> method returns the capacity of the builder's underlying byte slice.
  820     </p>
  821 
  822     <p><!-- CL 131495 -->
  823       The character mapping functions <a href="/pkg/strings/#Map"><code>Map</code></a>,
  824       <a href="/pkg/strings/#Title"><code>Title</code></a>,
  825       <a href="/pkg/strings/#ToLower"><code>ToLower</code></a>,
  826       <a href="/pkg/strings/#ToLowerSpecial"><code>ToLowerSpecial</code></a>,
  827       <a href="/pkg/strings/#ToTitle"><code>ToTitle</code></a>,
  828       <a href="/pkg/strings/#ToTitleSpecial"><code>ToTitleSpecial</code></a>,
  829       <a href="/pkg/strings/#ToUpper"><code>ToUpper</code></a>, and
  830       <a href="/pkg/strings/#ToUpperSpecial"><code>ToUpperSpecial</code></a>
  831       now always guarantee to return valid UTF-8. In earlier releases, if the input was invalid UTF-8 but no character replacements
  832       needed to be applied, these routines incorrectly returned the invalid UTF-8 unmodified.
  833     </p>
  834 
  835 </dl><!-- strings -->
  836 
  837 <dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
  838   <dd>
  839     <p><!-- CL 138595 -->
  840       64-bit inodes are now supported on FreeBSD 12. Some types have been adjusted accordingly.
  841     </p>
  842 
  843     <p><!-- CL 125456 -->
  844       The Unix socket
  845       (<a href="https://blogs.msdn.microsoft.com/commandline/2017/12/19/af_unix-comes-to-windows/"><code>AF_UNIX</code></a>)
  846       address family is now supported for compatible versions of Windows.
  847     </p>
  848 
  849     <p><!-- CL 147117 -->
  850       The new function  <a href="/pkg/syscall/?GOOS=windows&GOARCH=amd64#Syscall18"><code>Syscall18</code></a>
  851       has been introduced for Windows, allowing for calls with up to 18 arguments.
  852     </p>
  853 
  854 </dl><!-- syscall -->
  855 
  856 <dl id="syscall/js"><dt><a href="/pkg/syscall/js/">syscall/js</a></dt>
  857   <dd>
  858     <p><!-- CL 153559 -->
  859     <p>
  860       The <code>Callback</code> type and <code>NewCallback</code> function have been renamed;
  861       they are now called
  862       <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Func"><code>Func</code></a> and
  863       <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#FuncOf"><code>FuncOf</code></a>, respectively.
  864       This is a breaking change, but WebAssembly support is still experimental
  865       and not yet subject to the
  866       <a href="/doc/go1compat">Go 1 compatibility promise</a>. Any code using the
  867       old names will need to be updated.
  868     </p>
  869 
  870     <p><!-- CL 141644 -->
  871       If a type implements the new
  872       <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Wrapper"><code>Wrapper</code></a>
  873       interface,
  874       <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#ValueOf"><code>ValueOf</code></a>
  875       will use it to return the JavaScript value for that type.
  876     </p>
  877 
  878     <p><!-- CL 143137 -->
  879       The meaning of the zero
  880       <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value"><code>Value</code></a>
  881       has changed. It now represents the JavaScript <code>undefined</code> value
  882       instead of the number zero.
  883       This is a breaking change, but WebAssembly support is still experimental
  884       and not yet subject to the
  885       <a href="/doc/go1compat">Go 1 compatibility promise</a>. Any code relying on
  886       the zero <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value"><code>Value</code></a>
  887       to mean the number zero will need to be updated.
  888     </p>
  889 
  890     <p><!-- CL 144384 -->
  891       The new
  892       <a href="/pkg/syscall/js/?GOOS=js&GOARCH=wasm#Value.Truthy"><code>Value.Truthy</code></a>
  893       method reports the
  894       <a href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy">JavaScript "truthiness"</a>
  895       of a given value.
  896     </p>
  897 
  898 </dl><!-- syscall/js -->
  899 
  900 <dl id="testing"><dt><a href="/pkg/testing/">testing</a></dt>
  901   <dd>
  902     <p><!-- CL 139258 -->
  903     The <a href="/cmd/go/#hdr-Testing_flags"><code>-benchtime</code></a> flag now supports setting an explicit iteration count instead of a time when the value ends with an "<code>x</code>". For example, <code>-benchtime=100x</code> runs the benchmark 100 times.
  904     </p>
  905 
  906 </dl><!-- testing -->
  907 
  908 <dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt>
  909   <dd>
  910     <p><!-- CL 142217 -->
  911       When executing a template, long context values are no longer truncated in errors.
  912     </p>
  913     <p>
  914       <code>executing "tmpl" at <.very.deep.context.v...>: map has no entry for key "notpresent"</code>
  915     </p>
  916     <p>
  917       is now
  918     </p>
  919     <p>
  920       <code>executing "tmpl" at <.very.deep.context.value.notpresent>: map has no entry for key "notpresent"</code>
  921     </p>
  922 
  923   <dd>
  924     <p><!-- CL 143097 -->
  925       If a user-defined function called by a template panics, the
  926       panic is now caught and returned as an error by
  927       the <code>Execute</code> or <code>ExecuteTemplate</code> method.
  928     </p>
  929 </dl><!-- text/template -->
  930 
  931 <dl id="time"><dt><a href="/pkg/time/">time</a></dt>
  932   <dd>
  933     <p><!-- CL 151299 -->
  934       The time zone database in <code>$GOROOT/lib/time/zoneinfo.zip</code>
  935       has been updated to version 2018i. Note that this ZIP file is
  936       only used if a time zone database is not provided by the operating
  937       system.
  938     </p>
  939 
  940 </dl><!-- time -->
  941 
  942 <dl id="unsafe"><dt><a href="/pkg/unsafe/">unsafe</a></dt>
  943   <dd>
  944     <p><!-- CL 146058 -->
  945       It is invalid to convert a nil <code>unsafe.Pointer</code> to <code>uintptr</code> and back with arithmetic.
  946       (This was already invalid, but will now cause the compiler to misbehave.)
  947     </p>
  948 
  949 </dl><!-- unsafe -->