Member-only story

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

Tom Smykowski

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]

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Tom Smykowski
Tom Smykowski

Written by Tom Smykowski

Grab A Free Checklist On How To Build Scalable Angular Apps: https://tomasz-smykowski.com/scalable-angular

Responses (8)

Write a response