Skip to content

Latest commit

 

History

History
103 lines (82 loc) · 3.27 KB

new-in-go.org

File metadata and controls

103 lines (82 loc) · 3.27 KB

What’s New in Go (November 2023)

Who?

  • I’m Terin!
  • Software Developer at Cloudflare
  • Been developing in Go since Go 1.4

Point Releases

Go 1.21.4 and Go 1.20.11

  • Fix to net/http’s Pusher implementation causing connection resets in Firefox and Safari.
  • Various bug fixes to the compiler, linker, and runtime.

Two security fixes to path/filepath package on Windows:

  • Incorrect parse of path prefix \??\, leading to arbitrary file access.
  • Incorrect detection of reserved file names (eg, COM1 and LPT1) as local in some circumstances.

Road to Go 1.22

Revised API for math/rand/v2

  • First standard library package to get a “v2” redesign.
  • Top-level functions were modified to make it easier to use.

Focsed on being a psuedo-random number generate for non-cryptographic use cases (eg, simulations).

  • Removes ability to get random bytes by removing Rand.Read.
  • Removes top-level Seed, Rand.Seed, and Source.Seed.
  • Replaces Source.Int63 with Source.Uint64.
  • Removes the original Linear-Feedback Shift Register source, and adds PCG-DXSM and ChaCha8 as source options.

Experiment to extend for-range

  • Add compiler support for new for-range loops behind GOEXPERIMENT=range flag.

range over integers

The C-style loop over integers like

for x := 0; x < 10; x++ { }

would become

for x := range 10 {
	// x will be in the range 0..n-1
}

range over functions

Allows looping over coroutine functions.

type f function(yield func(T1, T2) bool) bool

for x, y := range f {
	// the control statements "break", "continue", "return"
	// still work like normal within this for loop.
}

TCP Keepalive Configuration

  • Go sets the TCP keepalive timeout (TCP_KEEPINTVL) to 15 seconds.
    • Setting KeepAlive on net.Dialer allows sending keepalives more often.
    • Reports from mobile users that this keeps devices and radios awake.
  • Proposal adds KeepAliveConfig option to net.Dialer, and adds SetKeepAliveConfig on TCPConn.

Example configuring an HTTP client

client := http.Client{
	Transport: &http.Transport{
		DialContext: &net.Dialer{
			KeepAliveConfig: net.KeepAliveConfig{
				Enable:   true,
				Idle:     5*time.Second,
				Interval: 30*time.Second,
				Count:    3,
			}
		}
	}
}

Adds unique package to intern values

  • Allows creating a weak reference to values by retaining references to Lisp-like symbols.
  • Brings a version of go4.org/intern to the standard library.
  • Can be used to weakly store one-copy of a string, with fast comparison.
func (ip Addr) WithZone(zone string) Addr {
    ip.z = unique.Make(zone)
}

Miscellenous Proposals