Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kyosu-1/boolcmp

static analysis tool for Go that detects variables with bool values that use comparison operators.
https://github.com/kyosu-1/boolcmp

go static-analysis

Last synced: 26 days ago
JSON representation

static analysis tool for Go that detects variables with bool values that use comparison operators.

Awesome Lists containing this project

README

        

# boolcmp

The boolcmp tool is a static analysis tool for Go that detects variables with bool values that use comparison operators, and reports them as potentially simplifiable.

# install

```
$ go install github.com/kyosu-1/boolcmp
```

# Usage

```
$ go vet -vettool=$(which boolcmp) path/to/your/package
```

# Example

Consider the following Go code:

```go
package main

func main() {
var a bool = true
if a == true {
// do something
}
}
```

The boolcmp tool will detect the comparison `a == true` and report it as a warning. The output might look something like this:

```
main.go:5:10: bool value used in comparison
```

The warning indicates that the comparison `a == true` can be simplified to just a. This can make the code more concise and easier to read, since the comparison with `true` is unnecessary.