mirror of https://github.com/docker/cli.git
Refactoring ineffectual assignments
This patch fixed below 4 types of code line 1. Remove unnecessary variable assignment 2. Use variables declaration instead of explicit initial zero value 3. Change variable name to underbar when variable not used 4. Add erro check and return for ignored error Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
This commit is contained in:
parent
ce20950422
commit
266900235c
|
@ -82,12 +82,9 @@ func collect(ctx context.Context, s *formatter.ContainerStats, cli client.APICli
|
||||||
for {
|
for {
|
||||||
var (
|
var (
|
||||||
v *types.StatsJSON
|
v *types.StatsJSON
|
||||||
memPercent = 0.0
|
memPercent, cpuPercent float64
|
||||||
cpuPercent = 0.0
|
|
||||||
blkRead, blkWrite uint64 // Only used on Linux
|
blkRead, blkWrite uint64 // Only used on Linux
|
||||||
mem = 0.0
|
mem, memLimit, memPerc float64
|
||||||
memLimit = 0.0
|
|
||||||
memPerc = 0.0
|
|
||||||
pidsStatsCurrent uint64
|
pidsStatsCurrent uint64
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,9 @@ func validateConfig(path string) error {
|
||||||
// validateContextDir validates the given dir and returns abs path on success.
|
// validateContextDir validates the given dir and returns abs path on success.
|
||||||
func validateContextDir(contextDir string) (string, error) {
|
func validateContextDir(contextDir string) (string, error) {
|
||||||
absContextDir, err := filepath.Abs(contextDir)
|
absContextDir, err := filepath.Abs(contextDir)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
stat, err := os.Lstat(absContextDir)
|
stat, err := os.Lstat(absContextDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
Loading…
Reference in New Issue