Repository navigation
v0.3.0
Highlights
field-nil-store is on by default
field-nil-store reports nil stored into a pointer field: S{F: nil}, S{1, nil}, s.F = nil, or a nil that reaches the store on some path. It is now on without a flag.
A nil written into a field says the field is absent there, so each report is right. Without exhaustruct, a field left out of a composite literal is not seen. The rule then misses more, but it reports nothing wrong.
| Rule | 0.2.0 | 0.3.0 |
|---|---|---|
field-nil-store |
Off | On |
field-nil-compare |
Off | Off |
return-error |
Off | Off |
field-nil-compare stays off. It also reports a field set on first use, and a check made just in case on a field that is never nil. There the fix is to delete the check, not to make the field an mo.Option.
Run inside golangci-lint
molint can be built into golangci-lint as a module plugin. It is not bundled with golangci-lint, so build a binary that holds it.
.custom-gcl.yml:
version: v2.13.1
plugins:
- module: github.com/mpyw/molint
import: github.com/mpyw/molint/plugin
version: v0.3.0.golangci.yml:
version: "2"
linters:
enable:
- molint
settings:
custom:
molint:
type: module
description: Enforces samber/mo.
settings:
field-nil-compare: truegolangci-lint custom # writes ./custom-gcl
./custom-gcl run ./...Each key under settings is a rule's name, as the flags take it. A rule left out keeps its default. An unknown name stops the run.
Breaking change
Upgrading from 0.2.0 reports nil stores into pointer fields that were silent before. To keep the old behavior, pass -field-nil-store=false, or set field-nil-store: false in the plugin's settings.
Pull requests
- #11 feat: turn field-nil-store on by default, and add a golangci-lint module plugin
Full Changelog: v0.2.0...v0.3.0