Documentation
¶
Overview ¶
Package closewrite provides a go/analysis analyzer that reports a discarded Close error on a file opened for WRITING.
Close is where a write is finally decided. The kernel may defer the failure of an earlier Write until the descriptor is closed — a full disk, a quota, a dropped network filesystem — so a discarded Close error on a written file is the program declaring success over a file that may be truncated, empty, or absent. Eight such defects were found by hand across this fleet; six were real data loss, and every one of them read as a routine `defer f.Close()`.
The rule is deliberately narrow, because a gate that cries wolf is worse than no gate. It fires only where the file's own creation proves the intent to write: os.Create, os.CreateTemp, or os.OpenFile with a write flag. A reader's Close is never reported — nothing is lost by failing to close a file you only read — which keeps the overwhelmingly common `defer f.Close()` after os.Open silent, exactly as it should be.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Analyzer = &analysis.Analyzer{ Name: "closewrite", Doc: "reports a discarded Close error on a file opened for writing, where the loss is real data", Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: run, }
Analyzer reports discarded Close errors on files opened for writing.
var Registration = goyze.Registration{ Name: "closewrite", Categories: []goyze.Category{"errors"}, URL: "https://docs.gomatic.dev/yze/closewrite", Analyzer: Analyzer, }
Registration declares this analyzer to the yze framework.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
closewrite
command
Command yze-go-closewrite runs the closewrite analyzer as a standalone go/analysis checker (text and -json output, and usable as a `go vet -vettool`).
|
Command yze-go-closewrite runs the closewrite analyzer as a standalone go/analysis checker (text and -json output, and usable as a `go vet -vettool`). |