The Startup
Published in

The Startup

Check All Enums Exist in a Switch in Go

Photo by Javier Allegue Barros on Unsplash

Go does not have any concept of enums like some other languages. There are arguments for and against this approach which I won’t go into here. However, there are times when you want to check that switch statements contain all enum values. Especially if you intend to add new enum values in the future and want to catch existing code that now needs to be updated accordingly.




Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +756K followers.

Recommended from Medium

Linux Yak First (Part 1): Installation

Day 13 of my journey to becoming a Unity game developer

Clouds that Compute…

There is not Cloud, Its just someone else’s computer.

Difference Between IAM PassRole and IAM AssumeRole (EN | ID)

Amazing skills that can make programmers more money

Celebrating 100,000 Telegram Members

Looking forward to 2019

The Evolution of Recruiting, Evaluating, and Compensating Software Engineers

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Elliot Chance

Elliot Chance

I’m a data nerd and TDD enthusiast originally from Sydney. Currently working for Uber in New York. My thoughts here are my own. 🤓

More from Medium

Nil Pointer Method Receivers In Go

Fuzz Testing in Go

Golang Dependency Injection Using Wire

OO in Go(Go)