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
20082026
-
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 -
…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? -
This is an analyzer that will catch this: https://github.com/nishanths/exhaustive I believe it's in golangci-lint.
comment by orbz · 2023-09-29 · in Compile-time safety for enumerations in Go -
…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 -
…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…
comment by CraigJPerry · 2022-06-03 · in Rust Is Hard, Or: The Misery of Mainstream Programming -
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 -
…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' -
…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)