Files
Paul Holzinger 51fbf3da9e enable gocritic linter
The linter ensures a common code style.
- use switch/case instead of else if
- use if instead of switch/case for single case statement
- add space between comment and text
- detect the use of defer with os.Exit()
- use short form var += "..." instead of var = var + "..."
- detect problems with append()
```
newSlice := append(orgSlice, val)
```
  This could lead to nasty bugs because the orgSlice will be changed in
  place if it has enough capacity too hold the new elements. Thus we
  newSlice might not be a copy.

Of course most of the changes are just cosmetic and do not cause any
logic errors but I think it is a good idea to enforce a common style.
This should help maintainability.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-26 18:12:22 +02:00

41 lines
701 B
Go

package reports
type PruneReport struct {
Id string `json:"Id"` //nolint
Err error `json:"Err,omitempty"`
Size uint64 `json:"Size"`
}
func PruneReportsIds(r []*PruneReport) []string {
ids := make([]string, 0, len(r))
for _, v := range r {
if v == nil || v.Id == "" {
continue
}
ids = append(ids, v.Id)
}
return ids
}
func PruneReportsErrs(r []*PruneReport) []error {
errs := make([]error, 0, len(r))
for _, v := range r {
if v == nil || v.Err == nil {
continue
}
errs = append(errs, v.Err)
}
return errs
}
func PruneReportsSize(r []*PruneReport) uint64 {
size := uint64(0)
for _, v := range r {
if v == nil {
continue
}
size += v.Size
}
return size
}