diff options
author | Anthony HAMON <anthony.hamon@iadvize.com> | 2018-08-21 21:48:42 +0200 |
---|---|---|
committer | Anthony HAMON <anthony.hamon@iadvize.com> | 2018-08-26 01:58:19 +0200 |
commit | 7a74bc504bbfe99e7f74ba8981cfc771db4e98a3 (patch) | |
tree | 6ba10ef3f4e123c954fbdead82df36d971bca5b5 | |
parent | 32f4d09e895411216be3b42a66c9e3a424658acd (diff) |
avoid useless allocation
-rw-r--r-- | pkg/commands/os.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/pkg/commands/os.go b/pkg/commands/os.go index 29ec2c654..f84fe5991 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -41,8 +41,10 @@ func (c *OSCommand) RunCommandWithOutput(command string) (string, error) { c.Log.WithField("command", command).Info("RunCommand") splitCmd := str.ToArgv(command) c.Log.Info(splitCmd) - cmdOut, err := exec.Command(splitCmd[0], splitCmd[1:]...).CombinedOutput() - return sanitisedCommandOutput(cmdOut, err) + + return sanitisedCommandOutput( + exec.Command(splitCmd[0], splitCmd[1:]...).CombinedOutput(), + ) } // RunCommand runs a command and just returns the error @@ -57,10 +59,11 @@ func (c *OSCommand) RunDirectCommand(command string) (string, error) { args := str.ToArgv(c.Platform.shellArg + " " + command) c.Log.Info(spew.Sdump(args)) - cmdOut, err := exec. - Command(c.Platform.shell, args...). - CombinedOutput() - return sanitisedCommandOutput(cmdOut, err) + return sanitisedCommandOutput( + exec. + Command(c.Platform.shell, args...). + CombinedOutput(), + ) } func sanitisedCommandOutput(output []byte, err error) (string, error) { |