From 266900235c3ef24ca92b719c1057f1a81e0c7265 Mon Sep 17 00:00:00 2001 From: Daehyeok Mun Date: Tue, 29 Nov 2016 01:17:35 -0700 Subject: [PATCH] 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 --- command/container/stats_helpers.go | 13 +++++-------- command/plugin/create.go | 4 +++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/command/container/stats_helpers.go b/command/container/stats_helpers.go index 4b57e3fe05..8eb7da0fd7 100644 --- a/command/container/stats_helpers.go +++ b/command/container/stats_helpers.go @@ -81,14 +81,11 @@ func collect(ctx context.Context, s *formatter.ContainerStats, cli client.APICli go func() { for { var ( - v *types.StatsJSON - memPercent = 0.0 - cpuPercent = 0.0 - blkRead, blkWrite uint64 // Only used on Linux - mem = 0.0 - memLimit = 0.0 - memPerc = 0.0 - pidsStatsCurrent uint64 + v *types.StatsJSON + memPercent, cpuPercent float64 + blkRead, blkWrite uint64 // Only used on Linux + mem, memLimit, memPerc float64 + pidsStatsCurrent uint64 ) if err := dec.Decode(&v); err != nil { diff --git a/command/plugin/create.go b/command/plugin/create.go index 2aab1e9e4a..82d17af48c 100644 --- a/command/plugin/create.go +++ b/command/plugin/create.go @@ -41,7 +41,9 @@ func validateConfig(path string) error { // validateContextDir validates the given dir and returns abs path on success. func validateContextDir(contextDir string) (string, error) { absContextDir, err := filepath.Abs(contextDir) - + if err != nil { + return "", err + } stat, err := os.Lstat(absContextDir) if err != nil { return "", err