linter: enable makezero

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2022-03-21 15:07:06 +01:00
parent 0f12b6fe55
commit 68b94338ba
5 changed files with 6 additions and 7 deletions

View File

@@ -39,7 +39,6 @@ linters:
- gofumpt
- gci
- godot
- makezero
- dupl
- funlen
- gochecknoglobals

View File

@@ -1149,7 +1149,7 @@ func (c *Container) inspectJoinedNetworkNS(networkns string) (q types.StatusBloc
// result
func resultToBasicNetworkConfig(result types.StatusBlock) (define.InspectBasicNetworkConfig, error) {
config := define.InspectBasicNetworkConfig{}
interfaceNames := make([]string, len(result.Interfaces))
interfaceNames := make([]string, 0, len(result.Interfaces))
for interfaceName := range result.Interfaces {
interfaceNames = append(interfaceNames, interfaceName)
}

View File

@@ -43,7 +43,7 @@ func PruneImages(w http.ResponseWriter, r *http.Request) {
return
}
idr := make([]types.ImageDeleteResponseItem, len(imagePruneReports))
idr := make([]types.ImageDeleteResponseItem, 0, len(imagePruneReports))
var reclaimedSpace uint64
var errorMsg bytes.Buffer
for _, p := range imagePruneReports {

2
pkg/env/env.go vendored
View File

@@ -26,7 +26,7 @@ func DefaultEnvVariables() map[string]string {
// Slice transforms the specified map of environment variables into a
// slice. If a value is non-empty, the key and value are joined with '='.
func Slice(m map[string]string) []string {
env := make([]string, len(m))
env := make([]string, 0, len(m))
for k, v := range m {
var s string
if len(v) > 0 {

View File

@@ -579,9 +579,9 @@ func (q Quantity) MarshalJSON() ([]byte, error) {
// if CanonicalizeBytes needed more space than our slice provided, we may need to allocate again so use
// append
result = result[:1]
result = append(result, number...)
result = append(result, suffix...)
result = append(result, '"')
result = append(result, number...) // nolint: makezero
result = append(result, suffix...) // nolint: makezero
result = append(result, '"') // nolint: makezero
return result, nil
}