https://github.com/adamdecaf/xmlencoderclose
Go linter to check xml.Encoders are closed
https://github.com/adamdecaf/xmlencoderclose
encoder go-linter golangci-lint xml
Last synced: 4 months ago
JSON representation
Go linter to check xml.Encoders are closed
- Host: GitHub
- URL: https://github.com/adamdecaf/xmlencoderclose
- Owner: adamdecaf
- License: apache-2.0
- Created: 2023-06-07T22:05:01.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-06T03:08:10.000Z (4 months ago)
- Last Synced: 2025-03-06T04:20:27.479Z (4 months ago)
- Topics: encoder, go-linter, golangci-lint, xml
- Language: Go
- Homepage:
- Size: 45.9 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xmlencoderclose
[](https://godoc.org/github.com/adamdecaf/xmlencoderclose)
[](https://github.com/adamdecaf/xmlencoderclose/actions)
[](https://codecov.io/gh/adamdecaf/xmlencoderclose)
[](https://goreportcard.com/report/github.com/adamdecaf/xmlencoderclose)
[](https://raw.githubusercontent.com/adamdecaf/xmlencoderclose/master/LICENSE)xmlencoderclose is a Go linter to check that `encoding/xml.Encoder` type has its `Close()` method called. This linter is similar to [`bodyclose`](https://github.com/timakin/bodyclose) and [`sqlclosecheck`](https://github.com/ryanrolds/sqlclosecheck) with inspiration from [gostaticanalysis/sqlrows](https://github.com/gostaticanalysis/sqlrows)
## Install
```
go get github.com/adamdecaf/xmlencoderclose
```## Example
```go
type Document struct {
A string `xml:"a"`
}func Encode() (string, error) {
var buf bytes.Buffer
err := xml.NewEncoder(&buf).Encode(Document{ // want "Encoder.Close must be called"
A: "abc123",
})
if err != nil {
return "", err
}
return buf.String(), nil
}
```## Supported and tested platforms
- 64-bit Linux (Ubuntu, Debian), macOS, and Windows
## License
Apache License 2.0 - See [LICENSE](LICENSE) for details.