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

These are the easiest programming languags to learn

Integrating Natural Language Parsing into a MEAN stack Application

Websockets: Blazing Fast Data Exchange

SLAE32 — Assingment-5.3(Analyze Msfpayload for linux/x86)

Getting Started With Cross-Platform App Development In 2019

Setting Up Your Home Media Server (Part One)

Install OpenShift 4.2 on KVM

Scheduling and concurrency

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. 🤓 elliotchance@gmail.com

More from Medium

Mutex Examples in Go

Go Diagnostics 101

The main idea of ​​implementing a binary tree with Golang

Integrating README.md and Makefile with makedown