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:
@@ -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
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user