golangci-lint: enable perfsprint linter
cli/compose/types/types.go:568:17: fmt.Sprintf can be replaced with faster strconv.FormatBool (perfsprint) return []byte(fmt.Sprintf("%v", e.External)), nil ^ cli/command/formatter/buildcache.go:174:9: fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint) return fmt.Sprintf("%d", c.v.UsageCount) ^ cli/command/formatter/buildcache.go:178:9: fmt.Sprintf can be replaced with faster strconv.FormatBool (perfsprint) return fmt.Sprintf("%t", c.v.InUse) ^ cli/command/formatter/buildcache.go:182:9: fmt.Sprintf can be replaced with faster strconv.FormatBool (perfsprint) return fmt.Sprintf("%t", c.v.Shared) ^ cli/command/formatter/image.go:259:9: fmt.Sprintf can be replaced with faster strconv.FormatInt (perfsprint) return fmt.Sprintf("%d", c.i.Containers) ^ cli/command/formatter/tabwriter/tabwriter_test.go:698:9: fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint) b.Run(fmt.Sprintf("%d", x), func(b *testing.B) { ^ cli/command/formatter/tabwriter/tabwriter_test.go:720:9: fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint) b.Run(fmt.Sprintf("%d", h), func(b *testing.B) { ^ cli/command/image/prune.go:62:31: fmt.Sprintf can be replaced with faster strconv.FormatBool (perfsprint) pruneFilters.Add("dangling", fmt.Sprintf("%v", !options.all)) ^ cli/command/network/formatter.go:92:9: fmt.Sprintf can be replaced with faster strconv.FormatBool (perfsprint) return fmt.Sprintf("%v", c.n.EnableIPv6) ^ cli/command/network/formatter.go:96:9: fmt.Sprintf can be replaced with faster strconv.FormatBool (perfsprint) return fmt.Sprintf("%v", c.n.Internal) ^ cli/command/service/formatter.go:745:9: fmt.Sprintf can be replaced with faster strconv.FormatUint (perfsprint) pub = fmt.Sprintf("%d", pr.pStart) ^ cli/command/service/formatter.go:750:9: fmt.Sprintf can be replaced with faster strconv.FormatUint (perfsprint) tgt = fmt.Sprintf("%d", pr.tStart) ^ cli/command/service/opts.go:49:10: fmt.Sprintf can be replaced with faster strconv.FormatUint (perfsprint) return fmt.Sprintf("%v", *i.value) ^ cli/compose/loader/loader.go:720:36: fmt.Sprint can be replaced with faster strconv.Itoa (perfsprint) v, err := toServicePortConfigs(fmt.Sprint(value)) ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Родитель
8bbdb93cf9
Коммит
391668f57a
|
@ -16,6 +16,7 @@ linters:
|
|||
- misspell
|
||||
- nakedret
|
||||
- nilerr # Detects code that returns nil even if it checks that the error is not nil.
|
||||
- perfsprint # Detects fmt.Sprintf uses that can be replaced with a faster alternative.
|
||||
- predeclared
|
||||
- revive
|
||||
- staticcheck
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package formatter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -171,13 +171,13 @@ func (c *buildCacheContext) LastUsedSince() string {
|
|||
}
|
||||
|
||||
func (c *buildCacheContext) UsageCount() string {
|
||||
return fmt.Sprintf("%d", c.v.UsageCount)
|
||||
return strconv.Itoa(c.v.UsageCount)
|
||||
}
|
||||
|
||||
func (c *buildCacheContext) InUse() string {
|
||||
return fmt.Sprintf("%t", c.v.InUse)
|
||||
return strconv.FormatBool(c.v.InUse)
|
||||
}
|
||||
|
||||
func (c *buildCacheContext) Shared() string {
|
||||
return fmt.Sprintf("%t", c.v.Shared)
|
||||
return strconv.FormatBool(c.v.Shared)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package formatter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/distribution/reference"
|
||||
|
@ -256,7 +256,7 @@ func (c *imageContext) Containers() string {
|
|||
if c.i.Containers == -1 {
|
||||
return "N/A"
|
||||
}
|
||||
return fmt.Sprintf("%d", c.i.Containers)
|
||||
return strconv.FormatInt(c.i.Containers, 10)
|
||||
}
|
||||
|
||||
// VirtualSize shows the virtual size of the image and all of its parent
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -695,7 +696,7 @@ func BenchmarkPyramid(b *testing.B) {
|
|||
for _, x := range [...]int{10, 100, 1000} {
|
||||
// Build a line with x cells.
|
||||
line := bytes.Repeat([]byte("a\t"), x)
|
||||
b.Run(fmt.Sprintf("%d", x), func(b *testing.B) {
|
||||
b.Run(strconv.Itoa(x), func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
|
||||
|
@ -717,7 +718,7 @@ func BenchmarkRagged(b *testing.B) {
|
|||
lines[i] = bytes.Repeat([]byte("a\t"), w)
|
||||
}
|
||||
for _, h := range [...]int{10, 100, 1000} {
|
||||
b.Run(fmt.Sprintf("%d", h), func(b *testing.B) {
|
||||
b.Run(strconv.Itoa(h), func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
|
||||
|
|
|
@ -3,6 +3,7 @@ package image
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
|
@ -59,7 +60,7 @@ Are you sure you want to continue?`
|
|||
|
||||
func runPrune(dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) {
|
||||
pruneFilters := options.filter.Value().Clone()
|
||||
pruneFilters.Add("dangling", fmt.Sprintf("%v", !options.all))
|
||||
pruneFilters.Add("dangling", strconv.FormatBool(!options.all))
|
||||
pruneFilters = command.PruneFilters(dockerCli, pruneFilters)
|
||||
|
||||
warning := danglingWarning
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
|
@ -89,11 +89,11 @@ func (c *networkContext) Scope() string {
|
|||
}
|
||||
|
||||
func (c *networkContext) IPv6() string {
|
||||
return fmt.Sprintf("%v", c.n.EnableIPv6)
|
||||
return strconv.FormatBool(c.n.EnableIPv6)
|
||||
}
|
||||
|
||||
func (c *networkContext) Internal() string {
|
||||
return fmt.Sprintf("%v", c.n.Internal)
|
||||
return strconv.FormatBool(c.n.Internal)
|
||||
}
|
||||
|
||||
func (c *networkContext) Labels() string {
|
||||
|
|
|
@ -3,6 +3,7 @@ package service
|
|||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -742,12 +743,12 @@ func (pr portRange) String() string {
|
|||
if pr.pEnd > pr.pStart {
|
||||
pub = fmt.Sprintf("%d-%d", pr.pStart, pr.pEnd)
|
||||
} else {
|
||||
pub = fmt.Sprintf("%d", pr.pStart)
|
||||
pub = strconv.FormatUint(uint64(pr.pStart), 10)
|
||||
}
|
||||
if pr.tEnd > pr.tStart {
|
||||
tgt = fmt.Sprintf("%d-%d", pr.tStart, pr.tEnd)
|
||||
} else {
|
||||
tgt = fmt.Sprintf("%d", pr.tStart)
|
||||
tgt = strconv.FormatUint(uint64(pr.tStart), 10)
|
||||
}
|
||||
return fmt.Sprintf("*:%s->%s/%s", pub, tgt, pr.protocol)
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ func (i *Uint64Opt) Type() string {
|
|||
// String returns a string repr of this option
|
||||
func (i *Uint64Opt) String() string {
|
||||
if i.value != nil {
|
||||
return fmt.Sprintf("%v", *i.value)
|
||||
return strconv.FormatUint(*i.value, 10)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"path/filepath"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -717,7 +718,7 @@ var transformServicePort TransformerFunc = func(data interface{}) (interface{},
|
|||
for _, entry := range entries {
|
||||
switch value := entry.(type) {
|
||||
case int:
|
||||
v, err := toServicePortConfigs(fmt.Sprint(value))
|
||||
v, err := toServicePortConfigs(strconv.Itoa(value))
|
||||
if err != nil {
|
||||
return data, err
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package types
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -565,7 +566,7 @@ func (e External) MarshalYAML() (interface{}, error) {
|
|||
// MarshalJSON makes External implement json.Marshaller
|
||||
func (e External) MarshalJSON() ([]byte, error) {
|
||||
if e.Name == "" {
|
||||
return []byte(fmt.Sprintf("%v", e.External)), nil
|
||||
return []byte(strconv.FormatBool(e.External)), nil
|
||||
}
|
||||
return []byte(fmt.Sprintf(`{"name": %q}`, e.Name)), nil
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче