Intertype: type analysis for annotated empty interface{}s

What type would you set for a variable that can be either an int or a float64? In this talk I will talk about the empty interface in Go. We will look into why we need the empty interface type and how it is used.

Abstract

What type would you set for a variable that can be either an int or a float64? In this talk I will talk about the empty interface in Go. We will look into why we need the empty interface type and how it is used. One common (mis)usage of the empty interface is to implement sum types (a variable that have multiple possible types, for example, a variable that is either an int or a float64). I will describe an approach for implementing sum types in Go without the empty interface! And finally, I will demo Intertype, which is an experimental type checker for annotated empty interfaces. I will show how we could add type constraints for the dynamic types of an empty interface in our own code and for our dependencies.

Video

Stay connected

You can subscribe to our newsletter to stay updated on the latest news and announcements. Follow us on social media to join our community and engage with other attendees, speakers, and staff. We're on Twitter, Mastodon, Youtube and Facebook. Don't forget to use our official hashtag #GoLab2023 to share your experience and connect with other attendees on social media.

Subscribe to our newsletter

We hate spam just as much as you do, which is why we promise to only send you relevant communications. We respect your privacy and will never share your information with third parties.
©2023 GoLab | The international conference on Go in Florence-Design & devCantiere Creativo-Made withDatoCMS