Golang: case statements with an OR clause

Sat, Nov 26, 2022 One-minute read

Golang: case statements with an OR clause

TIL how to use Go’s switch and case statement with || (logical OR) like functionality:

switch foo {
  case "thing", "things":
    println("captured both")
  default:
    println(foo)
}

Reference:

Tags:

#go