🏎️ Go 1.20 Released - It’s Like Ayrton Senna Again

Tom Smykowski
3 min readFeb 1, 2023

It was a long wait since August 2022 when Go 1.19 was released. During that time developers using other programming languages enjoyed end of the year releases that mostly offered some satisfactory improvements.

Developers of Go language had to wait a little longer to put their hands on the Go 1.20 release. But after several release candidates it’s here. It was worth waiting for it, because Go 1.20 is a major breakthrough. Let’s look at the most important improvements!

Convert Slices To Arrays Easily

In Go language there are two structures holding multiple elements. One is an array — it holds a fixed number of elements. Second is a slice — a primitive structure that can hold variable number of elements.

Since slices are more flexible they are used often. However sometimes you have to convert data between these two types.

Go 1.17 introduced a short form of conversion from a slice to an array pointer.

With Go 1.20 you can also convert a slice to an array easily.

Here’s an example:

var slice = []int{1, 2, 3}
var array = [2]int(slice)
fmt.Println(array) // [1 2]

--

--

Tom Smykowski
Tom Smykowski

Written by Tom Smykowski

Software Engineer & Tech Editor. Top 2% on StackOverflow, 3mil views on Quora. Won Shattered Pixel Dungeon.

Responses (8)