The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8033
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === * use String() method with stdout and stderr * simplified IsTrue function
From 17b76d350d2cdbbae294ee1d8fe14332b43dd414 Mon Sep 17 00:00:00 2001 From: Tim Rots <tim.r...@protonmail.ch> Date: Thu, 15 Oct 2020 00:14:21 +0200 Subject: [PATCH] shared/util.go: use string method with stdout and stderr some small changes: * use String() method with stdout and stderr * simplified IsTrue function --- shared/util.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/shared/util.go b/shared/util.go index 8b5bb9f4db..ed0bc08553 100644 --- a/shared/util.go +++ b/shared/util.go @@ -649,11 +649,7 @@ func Uint64InSlice(key uint64, list []uint64) bool { } func IsTrue(value string) bool { - if StringInSlice(strings.ToLower(value), []string{"true", "1", "yes", "on"}) { - return true - } - - return false + return StringInSlice(strings.ToLower(value), []string{"true", "1", "yes", "on"}) } // StringMapHasStringKey returns true if any of the supplied keys are present in the map. @@ -898,15 +894,15 @@ func RunCommandSplit(env []string, filesInherit []*os.File, name string, arg ... err := cmd.Run() if err != nil { err := RunError{ - msg: fmt.Sprintf("Failed to run: %s %s: %s", name, strings.Join(arg, " "), strings.TrimSpace(string(stderr.Bytes()))), - Stdout: string(stdout.Bytes()), - Stderr: string(stderr.Bytes()), + msg: fmt.Sprintf("Failed to run: %s %s: %s", name, strings.Join(arg, " "), strings.TrimSpace(stderr.String())), + Stdout: stdout.String(), + Stderr: stderr.String(), Err: err, } - return string(stdout.Bytes()), string(stderr.Bytes()), err + return stdout.String(), stderr.String(), err } - return string(stdout.Bytes()), string(stderr.Bytes()), nil + return stdout.String(), stderr.String(), nil } // RunCommand runs a command with optional arguments and returns stdout. If the command fails to
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel