woodpecker/vendor/github.com/nishanths/exhaustive
6543 56a854fe14
Update deps (#789)
* update github.com/docker/cli

* update github.com/docker/distribution

* update github.com/docker/docker

* update github.com/gin-gonic/gin

* update github.com/golang-jwt/jwt/v4

* update github.com/golangci/golangci-lint

* update github.com/gorilla/securecookie

* update github.com/mattn/go-sqlite3

* update github.com/moby/moby

* update github.com/prometheus/client_golang

* update github.com/xanzy/go-gitlab
2022-02-24 17:33:24 +01:00
..
.gitignore Update deps (#789) 2022-02-24 17:33:24 +01:00
comment.go Update deps (#789) 2022-02-24 17:33:24 +01:00
enum.go Update deps (#789) 2022-02-24 17:33:24 +01:00
exhaustive.go Update deps (#789) 2022-02-24 17:33:24 +01:00
fact.go Update deps (#789) 2022-02-24 17:33:24 +01:00
go.mod Update deps (#789) 2022-02-24 17:33:24 +01:00
go.sum Update deps (#789) 2022-02-24 17:33:24 +01:00
LICENSE Add golangci-lint (#502) 2021-11-14 21:01:54 +01:00
Makefile Update deps (#789) 2022-02-24 17:33:24 +01:00
README.md Update deps (#789) 2022-02-24 17:33:24 +01:00
switch.go Update deps (#789) 2022-02-24 17:33:24 +01:00

exhaustive Godoc

Check exhaustiveness of enum switch statements in Go source code.

go install github.com/nishanths/exhaustive/cmd/exhaustive@latest

For docs on the flags, the definition of enum, and the definition of exhaustiveness, see godocs.io.

For the changelog, see CHANGELOG in the wiki.

The package provides an Analyzer that follows the guidelines in the go/analysis package; this should make it possible to integrate exhaustive with your own analysis driver program.

Example

Given the enum

package token

type Token int

const (
	Add Token = iota
	Subtract
	Multiply
	Quotient
	Remainder
)

and the switch statement

package calc

import "token"

func f(t token.Token) {
	switch t {
	case token.Add:
	case token.Subtract:
	case token.Multiply:
	default:
	}
}

running exhaustive will print

calc.go:6:2: missing cases in switch of type token.Token: Quotient, Remainder

Contributing

Issues and pull requests are welcome. Before making a substantial change, please discuss it in an issue.