Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ysuzuki19/robustruct
Go Lint tool for struct
https://github.com/ysuzuki19/robustruct
Last synced: 20 days ago
JSON representation
Go Lint tool for struct
- Host: GitHub
- URL: https://github.com/ysuzuki19/robustruct
- Owner: ysuzuki19
- Created: 2024-10-31T10:22:40.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-12-13T18:01:15.000Z (about 1 month ago)
- Last Synced: 2024-12-13T19:19:03.898Z (about 1 month ago)
- Language: Go
- Size: 163 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# robustruct
Go Lint tool for struct
This tool is module plugin for `golangci-lint`.
# Features
- `fields_require`
- Check all fields are initialized
- Suggest to use zero value
- `fields_align`
- Check all fields are aligned ordered by struct definition
- Suggest to align fields# Sample
for the following code, robustruct will suggest the following fixes.
```go
package maintype Sample struct {
A int
B string
AA bool
}
```## fields_require
Before fix
```go
func main() {
s := Sample{
A: 1,
B: "hello",
}
}
```After fix
```go
func main() {
s := Sample{
A: 1,
B: "hello",
AA: false,
}
}
```## fields_align
Before fix
```go
func main() {
s := Sample{
B: "hello",
A: 1,
AA: false,
}
}
```After fix
```go
func main() {
s := Sample{
A: 1,
B: "hello",
AA: false,
}
}
```# Ignore
You can disable a check with a comment.
ignore all features.
```go
// ignore:robustruct
```ignore `fields_require`.
```go
// ignore:fields_require
```ignore `fields_align`.
```go
// ignore:fields_align
```## Sample
```go
func main() {
// ignore:robustruct
s := Sample{
B: "hello",
A: 1,
}
}
``````go
func main() {
s := Sample{
A: 1,
B: "hello",
} // ignore:fields_require
}
```