1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

fix: os.go/ExecCommand make error the last return value

This commit is contained in:
dudaodong
2022-01-17 16:57:38 +08:00
parent 764a6fe107
commit 261370e30d
6 changed files with 12 additions and 8 deletions

View File

@@ -51,7 +51,7 @@ func CompareOsEnv(key, comparedEnv string) bool {
}
// ExecCommand use shell /bin/bash -c to execute command
func ExecCommand(command string) (err error, stdout, stderr string) {
func ExecCommand(command string) (stdout, stderr string, err error) {
var out bytes.Buffer
var errout bytes.Buffer

View File

@@ -23,10 +23,12 @@ func TestOsEnvOperation(t *testing.T) {
func TestExecCommand(t *testing.T) {
assert := internal.NewAssert(t, "TestExecCommand")
err, out, errout := ExecCommand("ls")
out, errout, err := ExecCommand("ls")
t.Log("std out: ", out)
t.Log("std err: ", errout)
assert.IsNil(err)
err, out, errout = ExecCommand("abc")
out, errout, err = ExecCommand("abc")
t.Log("std out: ", out)
t.Log("std err: ", errout)
if err != nil {