Hacker GitHub

← All repos

nishanths/exhaustive

View on GitHub ↗ ★ 350 Go

Check that expression switches and type switches in Go source code are exhaustive.

8 mentions on Hacker News by 8 people: 0 stories, 8 comments · first 2021-12-10 · latest 2024-07-12

Mentions per year 8 mentions · busiest year 2023 (3)
20082026
  1. There are two linters that add those checks: https://github.com/nishanths/exhaustive for values and https://github.com/alecthomas/go-check-sumtype for types. Both are integrated into golangci-lint. I use both a lot and have only a positive…
    comment by aleksi · 2024-07-12 · in Enums in Go
  2. …Like you pointed out, that's an easy place to make mistakes, and this regularly catches them for us https://github.com/nishanths/exhaustive
    comment by derekperkins · 2023-11-04 · in Why people in Google hate Go?
  3. This is an analyzer that will catch this: https://github.com/nishanths/exhaustive I believe it's in golangci-lint.
  4. …annotations to add metadata to properties. [0] https://go.dev/src/net/http/status.go [1] https://pkg.go.dev/github.com/nishanths/exhaustive [2] https://github.com/golangci/awesome-go-linters
    comment by Cthulhu_ · 2023-05-24 · in Why I Use Elm in 2023
  5. …live in go vet). I’ve been playing with Go in a side project and using golint-ci which invokes https://github.com/nishanths/exhaustive - net result, in both go and rust, i get a red line of text annotated at the switch in vscode if i miss…
  6. There are linters available that help you do the "just trust me to" part. Edit: https://github.com/nishanths/exhaustive is available in golangci-lint
    comment by cesnja · 2022-05-14 · in Safer Enums in Go
  7. …an exhaustive type switch that badly, it’s usually a sign that your interface definition is wrong. https://github.com/nishanths/exhaustive here, have fun. You’re gonna write some tests, make new types to satisfy interfaces for testing, and…
    comment by zemo · 2021-12-16 · in Go Replaces Interface{} with 'Any'
  8. …golangci-lint ( https://github.com/golangci/golangci-lint ) is an absolute must, and includes https://github.com/nishanths/exhaustive which will check this for you.
    comment by thegeekpirate · 2021-12-10 · in Notes on the Go translation of Reposurgeon (2020)