Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qawatake/fsel
Linter: fsel flags field access with unverified nil errors
https://github.com/qawatake/fsel
go golang linter staticanalysis
Last synced: about 1 month ago
JSON representation
Linter: fsel flags field access with unverified nil errors
- Host: GitHub
- URL: https://github.com/qawatake/fsel
- Owner: qawatake
- License: mit
- Created: 2023-11-12T06:04:17.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-22T14:00:23.000Z (8 months ago)
- Last Synced: 2024-05-22T15:27:44.918Z (8 months ago)
- Topics: go, golang, linter, staticanalysis
- Language: Go
- Homepage: https://pkg.go.dev/github.com/qawatake/fsel
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fsel
[![Go Reference](https://pkg.go.dev/badge/github.com/qawatake/fsel.svg)](https://pkg.go.dev/github.com/qawatake/fsel)
[![test](https://github.com/qawatake/fsel/actions/workflows/test.yaml/badge.svg)](https://github.com/qawatake/fsel/actions/workflows/test.yaml)Linter: `fsel` flags field access with unverified nil errors.
```go
func bad() error {
s, err := doSomething()
fmt.Println(s.X) // <- field address without checking nilness of err
return err
}func good() error {
s, err := doSomething()
if err != nil {
return err
}
fmt.Println(s.X) // ok because err is definitely nil
return nil
}func doSomething() (*S, error) {
return nil, errors.New("error")
}type S struct {
X int
}
```You can try an example by running `make run.example`.
## How to use
```sh
go install github.com/qawatake/fsel/cmd/fsel@latest
fsel ./...
```## False Positives
To ignore a false positive, add a comment `//lint:ignore fsel reason` to the line.
```go
func f() error {
s, err := doSomething()
if isNotNil(err) {
return err
}
fmt.Println(s.X) //lint:ignore fsel reason
return nil
}
```