@@ -566,7 +566,7 @@ fmt.Println(out)
566566
567567# ## <a id="creationflags"></a>CreationFlags
568568
569- CreationFlags is a no-op on non- Windows platforms .
569+ CreationFlags sets Windows creation flags .
570570
571571_Example: creation flags_
572572
@@ -584,7 +584,7 @@ fmt.Println(execx.Command("go", "env", "GOOS").CreationFlags(0) != nil)
584584
585585# ## <a id="hidewindow"></a>HideWindow
586586
587- HideWindow is a no-op on non-Windows platforms .
587+ HideWindow controls window visibility and sets CREATE_NO_WINDOW for console apps .
588588
589589_Example: hide window_
590590
@@ -602,7 +602,7 @@ fmt.Println(execx.Command("go", "env", "GOOS").HideWindow(true) != nil)
602602
603603# ## <a id="pdeathsig"></a>Pdeathsig
604604
605- Pdeathsig is a no-op on non-Linux Unix platforms .
605+ Pdeathsig is a no-op on Windows .
606606
607607_Example: pdeathsig_
608608
@@ -627,7 +627,7 @@ fmt.Println(execx.Command("go", "env", "GOOS").Pdeathsig(0) != nil)
627627
628628# ## <a id="setpgid"></a>Setpgid
629629
630- Setpgid sets the process group ID behavior .
630+ Setpgid is a no-op on Windows .
631631
632632_Example: setpgid_
633633
@@ -652,7 +652,7 @@ fmt.Println(execx.Command("go", "env", "GOOS").Setpgid(true) != nil)
652652
653653# ## <a id="setsid"></a>Setsid
654654
655- Setsid sets the session ID behavior .
655+ Setsid is a no-op on Windows .
656656
657657_Example: setsid_
658658
@@ -734,8 +734,7 @@ fmt.Println(err == nil && len(results) == 2)
734734GracefulShutdown sends a signal and escalates to kill after the timeout.
735735
736736` ` ` go
737- proc := execx.Command(" sleep" , " 2" ).
738- Start ()
737+ proc := execx.Command(" sleep" , " 2" ).Start()
739738_ = proc.GracefulShutdown(os.Interrupt, 100* time.Millisecond)
740739res, err := proc.Wait ()
741740fmt.Println(err ! = nil || res.ExitCode ! = 0)
@@ -747,8 +746,7 @@ fmt.Println(err != nil || res.ExitCode != 0)
747746Interrupt sends an interrupt signal to the process.
748747
749748` ` ` go
750- proc := execx.Command(" sleep" , " 2" ).
751- Start ()
749+ proc := execx.Command(" sleep" , " 2" ).Start()
752750_ = proc.Interrupt ()
753751res, err := proc.Wait ()
754752fmt.Println(err ! = nil || res.ExitCode ! = 0)
@@ -760,8 +758,7 @@ fmt.Println(err != nil || res.ExitCode != 0)
760758KillAfter terminates the process after the given duration.
761759
762760` ` ` go
763- proc := execx.Command(" sleep" , " 2" ).
764- Start ()
761+ proc := execx.Command(" sleep" , " 2" ).Start()
765762proc.KillAfter(100 * time.Millisecond)
766763res, err := proc.Wait ()
767764fmt.Println(err ! = nil || res.ExitCode ! = 0)
@@ -773,8 +770,7 @@ fmt.Println(err != nil || res.ExitCode != 0)
773770Send sends a signal to the process.
774771
775772` ` ` go
776- proc := execx.Command(" sleep" , " 2" ).
777- Start ()
773+ proc := execx.Command(" sleep" , " 2" ).Start()
778774_ = proc.Send(os.Interrupt)
779775res, err := proc.Wait ()
780776fmt.Println(err ! = nil || res.ExitCode ! = 0)
@@ -786,8 +782,7 @@ fmt.Println(err != nil || res.ExitCode != 0)
786782Terminate kills the process immediately.
787783
788784` ` ` go
789- proc := execx.Command(" sleep" , " 2" ).
790- Start ()
785+ proc := execx.Command(" sleep" , " 2" ).Start()
791786_ = proc.Terminate ()
792787res, err := proc.Wait ()
793788fmt.Println(err ! = nil || res.ExitCode ! = 0)
@@ -800,8 +795,8 @@ Wait waits for the command to complete and returns the result and any error.
800795
801796` ` ` go
802797proc := execx.Command(" go" , " env" , " GOOS" ).Start()
803- res, err := proc.Wait ()
804- fmt.Println(err == nil && res.ExitCode == 0)
798+ res, _ := proc.Wait ()
799+ fmt.Println(res.ExitCode == 0)
805800// # bool true
806801` ` `
807802
@@ -812,8 +807,8 @@ fmt.Println(err == nil && res.ExitCode == 0)
812807IsExitCode reports whether the exit code matches.
813808
814809` ` ` go
815- res, err := execx.Command(" go" , " env" , " GOOS" ).Run()
816- fmt.Println(err == nil && res.IsExitCode(0))
810+ res, _ := execx.Command(" go" , " env" , " GOOS" ).Run()
811+ fmt.Println(res.IsExitCode(0))
817812// # bool true
818813` ` `
819814
@@ -822,18 +817,18 @@ fmt.Println(err == nil && res.IsExitCode(0))
822817IsSignal reports whether the command terminated due to a signal.
823818
824819` ` ` go
825- res, err := execx.Command(" go" , " env" , " GOOS" ).Run()
826- fmt.Println(err == nil && res.IsSignal(os.Interrupt))
827- // # bool false
820+ res, _ := execx.Command(" go" , " env" , " GOOS" ).Run()
821+ fmt.Println(res.IsSignal(os.Interrupt))
822+ // false
828823` ` `
829824
830825# ## <a id="ok"></a>OK
831826
832827OK reports whether the command exited cleanly without errors.
833828
834829` ` ` go
835- res, err := execx.Command(" go" , " env" , " GOOS" ).Run()
836- fmt.Println(err == nil && res.OK ())
830+ res, _ := execx.Command(" go" , " env" , " GOOS" ).Run()
831+ fmt.Println(res.OK ())
837832// # bool true
838833` ` `
839834
@@ -846,23 +841,27 @@ OnStderr registers a line callback for stderr.
846841` ` ` go
847842var lines []string
848843_, err := execx.Command(" go" , " env" , " -badflag" ).
849- OnStderr(func(line string) { lines = append(lines, line) }).
844+ OnStderr(func(line string) {
845+ lines = append(lines, line)
846+ fmt.Println(line)
847+ }).
850848 Run ()
851- fmt.Println(err == nil && len(lines) == 1)
852- // # bool true
849+ fmt.Println(err == nil)
850+ // flag provided but not defined: -badflag
851+ // usage: go env [-json] [-changed] [-u] [-w] [var ...]
852+ // Run ' go help env' for details.
853+ // false
853854` ` `
854855
855856# ## <a id="onstdout"></a>OnStdout
856857
857858OnStdout registers a line callback for stdout.
858859
859860` ` ` go
860- var lines []string
861- _, err := execx.Command(" go" , " env" , " GOOS" ).
862- OnStdout(func(line string) { lines = append(lines, line) }).
861+ _, _ = execx.Command(" go" , " env" , " GOOS" ).
862+ OnStdout(func(line string) { fmt.Println(line) }).
863863 Run ()
864- fmt.Println(err == nil && len(lines) > 0)
865- // # bool true
864+ // darwin
866865` ` `
867866
868867# ## <a id="stderrwriter"></a>StderrWriter
@@ -874,8 +873,12 @@ var out strings.Builder
874873_, err := execx.Command(" go" , " env" , " -badflag" ).
875874 StderrWriter(& out).
876875 Run ()
877- fmt.Println(err == nil && out.Len () > 0)
878- // # bool true
876+ fmt.Print(out.String ())
877+ fmt.Println(err == nil)
878+ // flag provided but not defined: -badflag
879+ // usage: go env [-json] [-changed] [-u] [-w] [var ...]
880+ // Run ' go help env' for details.
881+ // false
879882` ` `
880883
881884# ## <a id="stdoutwriter"></a>StdoutWriter
0 commit comments