Skip to content

Commit ad87f21

Browse files
committed
docs: simplify examples
1 parent d7cbfd4 commit ad87f21

13 files changed

Lines changed: 46 additions & 46 deletions

File tree

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ WithContext binds the command to a context.
315315
```go
316316
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
317317
defer cancel()
318-
res, err := execx.Command("go", "env", "GOOS").WithContext(ctx).Run()
319-
fmt.Println(err == nil && res.ExitCode == 0)
318+
res, _ := execx.Command("go", "env", "GOOS").WithContext(ctx).Run()
319+
fmt.Println(res.ExitCode == 0)
320320
// #bool true
321321
```
322322
@@ -325,8 +325,8 @@ fmt.Println(err == nil && res.ExitCode == 0)
325325
WithDeadline binds the command to a deadline.
326326
327327
```go
328-
res, err := execx.Command("go", "env", "GOOS").WithDeadline(time.Now().Add(2 * time.Second)).Run()
329-
fmt.Println(err == nil && res.ExitCode == 0)
328+
res, _ := execx.Command("go", "env", "GOOS").WithDeadline(time.Now().Add(2 * time.Second)).Run()
329+
fmt.Println(res.ExitCode == 0)
330330
// #bool true
331331
```
332332
@@ -335,8 +335,8 @@ fmt.Println(err == nil && res.ExitCode == 0)
335335
WithTimeout binds the command to a timeout.
336336
337337
```go
338-
res, err := execx.Command("go", "env", "GOOS").WithTimeout(2 * time.Second).Run()
339-
fmt.Println(err == nil && res.ExitCode == 0)
338+
res, _ := execx.Command("go", "env", "GOOS").WithTimeout(2 * time.Second).Run()
339+
fmt.Println(res.ExitCode == 0)
340340
// #bool true
341341
```
342342
@@ -493,8 +493,8 @@ fmt.Println(out != "")
493493
Run executes the command and returns the result and any error.
494494
495495
```go
496-
res, err := execx.Command("go", "env", "GOOS").Run()
497-
fmt.Println(err == nil && res.ExitCode == 0)
496+
res, _ := execx.Command("go", "env", "GOOS").Run()
497+
fmt.Println(res.ExitCode == 0)
498498
// #bool true
499499
```
500500
@@ -504,8 +504,8 @@ Start executes the command asynchronously.
504504
505505
```go
506506
proc := execx.Command("go", "env", "GOOS").Start()
507-
res, err := proc.Wait()
508-
fmt.Println(err == nil && res.ExitCode == 0)
507+
res, _ := proc.Wait()
508+
fmt.Println(res.ExitCode == 0)
509509
// #bool true
510510
```
511511
@@ -566,7 +566,7 @@ fmt.Println(out)
566566
567567
### <a id="creationflags"></a>CreationFlags
568568
569-
CreationFlags sets Windows creation flags.
569+
CreationFlags is a no-op on non-Windows platforms.
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 controls window visibility and sets CREATE_NO_WINDOW for console apps.
587+
HideWindow is a no-op on non-Windows platforms.
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 Windows.
605+
Pdeathsig is a no-op on non-Linux Unix platforms.
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 is a no-op on Windows.
630+
Setpgid sets the process group ID behavior.
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 is a no-op on Windows.
655+
Setsid sets the session ID behavior.
656656
657657
_Example: setsid_
658658
@@ -707,11 +707,11 @@ fmt.Println(err == nil && res.Stdout == "ok")
707707
PipeStrict sets strict pipeline semantics.
708708
709709
```go
710-
res, err := execx.Command("false").
710+
res, _ := execx.Command("false").
711711
Pipe("printf", "ok").
712712
PipeStrict().
713713
Run()
714-
fmt.Println(err == nil && res.ExitCode != 0)
714+
fmt.Println(res.ExitCode != 0)
715715
// #bool true
716716
```
717717

examples/creationflags/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
func main() {
12-
// CreationFlags is a no-op on non-Windows platforms.
12+
// CreationFlags sets Windows creation flags.
1313

1414
// Example: creation flags
1515
fmt.Println(execx.Command("go", "env", "GOOS").CreationFlags(0) != nil)

examples/hidewindow/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
func main() {
12-
// HideWindow is a no-op on non-Windows platforms.
12+
// HideWindow controls window visibility and sets CREATE_NO_WINDOW for console apps.
1313

1414
// Example: hide window
1515
fmt.Println(execx.Command("go", "env", "GOOS").HideWindow(true) != nil)

examples/pdeathsig/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
func main() {
12-
// Pdeathsig sets a parent-death signal on Linux.
12+
// Pdeathsig is a no-op on Windows.
1313

1414
// Example: pdeathsig
1515
fmt.Println(execx.Command("go", "env", "GOOS").Pdeathsig(0) != nil)

examples/pipestrict/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ func main() {
1212
// PipeStrict sets strict pipeline semantics.
1313

1414
// Example: strict
15-
res, err := execx.Command("false").
15+
res, _ := execx.Command("false").
1616
Pipe("printf", "ok").
1717
PipeStrict().
1818
Run()
19-
fmt.Println(err == nil && res.ExitCode != 0)
19+
fmt.Println(res.ExitCode != 0)
2020
// #bool true
2121
}

examples/run/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func main() {
1212
// Run executes the command and returns the result and any error.
1313

1414
// Example: run
15-
res, err := execx.Command("go", "env", "GOOS").Run()
16-
fmt.Println(err == nil && res.ExitCode == 0)
15+
res, _ := execx.Command("go", "env", "GOOS").Run()
16+
fmt.Println(res.ExitCode == 0)
1717
// #bool true
1818
}

examples/setpgid/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
func main() {
12-
// Setpgid sets the process group ID behavior.
12+
// Setpgid is a no-op on Windows.
1313

1414
// Example: setpgid
1515
fmt.Println(execx.Command("go", "env", "GOOS").Setpgid(true) != nil)

examples/setsid/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
func main() {
12-
// Setsid sets the session ID behavior.
12+
// Setsid is a no-op on Windows.
1313

1414
// Example: setsid
1515
fmt.Println(execx.Command("go", "env", "GOOS").Setsid(true) != nil)

examples/start/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func main() {
1313

1414
// Example: start
1515
proc := execx.Command("go", "env", "GOOS").Start()
16-
res, err := proc.Wait()
17-
fmt.Println(err == nil && res.ExitCode == 0)
16+
res, _ := proc.Wait()
17+
fmt.Println(res.ExitCode == 0)
1818
// #bool true
1919
}

examples/withcontext/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func main() {
1616
// Example: with context
1717
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
1818
defer cancel()
19-
res, err := execx.Command("go", "env", "GOOS").WithContext(ctx).Run()
20-
fmt.Println(err == nil && res.ExitCode == 0)
19+
res, _ := execx.Command("go", "env", "GOOS").WithContext(ctx).Run()
20+
fmt.Println(res.ExitCode == 0)
2121
// #bool true
2222
}

0 commit comments

Comments
 (0)