From 709df6a8b7c069cbdcce941d926f5dd3c1941b53 Mon Sep 17 00:00:00 2001 From: imw Date: Tue, 22 Aug 2023 12:27:23 +0200 Subject: [PATCH] fix(tutorial): avoid broken pipe caused by passing non-JSON to jq (#1193) Following the tutorial code results in a broken pipe. This is a simple fixup that adds a call to tail so that jq is only given valid input. --- internal/tutorial/experiment/torsf/chapter01/main.go | 2 +- internal/tutorial/experiment/torsf/chapter03/torsf.go | 2 +- internal/tutorial/experiment/torsf/chapter04/torsf.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/tutorial/experiment/torsf/chapter01/main.go b/internal/tutorial/experiment/torsf/chapter01/main.go index da8c5d67c5..4ce9006b65 100644 --- a/internal/tutorial/experiment/torsf/chapter01/main.go +++ b/internal/tutorial/experiment/torsf/chapter01/main.go @@ -244,7 +244,7 @@ func main() { // You can now run this code as follows: // // ``` -// $ go run ./experiment/torsf/chapter01 | jq +// $ go run ./experiment/torsf/chapter01 | tail -n 1 | jq // [snip] // { // "data_format_version": "", diff --git a/internal/tutorial/experiment/torsf/chapter03/torsf.go b/internal/tutorial/experiment/torsf/chapter03/torsf.go index e48ca3add6..6f23d7e546 100644 --- a/internal/tutorial/experiment/torsf/chapter03/torsf.go +++ b/internal/tutorial/experiment/torsf/chapter03/torsf.go @@ -161,7 +161,7 @@ func (m *Measurer) run(ctx context.Context, // It's now time to run the new code we've written: // // ``` -// $ go run ./experiment/torsf/chapter03 | jq +// $ go run ./experiment/torsf/chapter03 | tail -n 1 | jq // 2021/06/21 21:21:18 info [ 0.1%] torsf experiment is running // 2021/06/21 21:21:19 info [ 0.2%] torsf experiment is running // [...] diff --git a/internal/tutorial/experiment/torsf/chapter04/torsf.go b/internal/tutorial/experiment/torsf/chapter04/torsf.go index d350ee94ab..07cc815c28 100644 --- a/internal/tutorial/experiment/torsf/chapter04/torsf.go +++ b/internal/tutorial/experiment/torsf/chapter04/torsf.go @@ -228,7 +228,7 @@ func (m *Measurer) run(ctx context.Context, // We can now run the code as follows to obtain: // // ``` -// $ go run ./experiment/torsf/chapter04 | jq +// $ go run ./experiment/torsf/chapter04 | tail -n 1 | jq // [...] // Jun 21 23:40:50.000 [notice] Bootstrapped 100% (done): Done // 2021/06/21 23:40:50 info [100.0%] torsf experiment is finished