From 5f0a7b666c99d9170c41d0c704a3cd9e7dbff971 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Mon, 2 Oct 2023 14:24:02 +0100 Subject: [PATCH] Add "context" to examples A context is now required for the execute method to enable cancellation. Thanks to @josegonzalez for bringing this to my attention Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 64bbc27..7f8788e 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ import ( "fmt" execute "github.com/alexellis/go-execute/v2" + "context" ) func main() { @@ -69,7 +70,7 @@ func main() { StreamStdio: false, } - res, err := cmd.Execute() + res, err := cmd.Execute(context.Background()) if err != nil { panic(err) } @@ -82,7 +83,6 @@ func main() { } ``` - ## Example with "shell" and exit-code 0 ```golang @@ -92,6 +92,7 @@ import ( "fmt" execute "github.com/alexellis/go-execute/v2" + "context" ) func main() { @@ -100,7 +101,7 @@ func main() { Args: []string{"-l"}, Shell: true, } - res, err := ls.Execute() + res, err := ls.Execute(context.Background()) if err != nil { panic(err) } @@ -117,6 +118,7 @@ package main import ( "fmt" + "context" execute "github.com/alexellis/go-execute/v2" ) @@ -125,7 +127,7 @@ func main() { Command: "exit 1", Shell: true, } - res, err := ls.Execute() + res, err := ls.Execute(context.Background()) if err != nil { panic(err) }