Skip to content

Instantly share code, notes, and snippets.

@neenjaw
Created November 8, 2019 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neenjaw/71a7f0b058218b9ed62bec12bb2b99db to your computer and use it in GitHub Desktop.
Save neenjaw/71a7f0b058218b9ed62bec12bb2b99db to your computer and use it in GitHub Desktop.
Go test --json massaging
go test --json | \
sed -e 's/^/ /' \
-e '$a\ ]\n]' \
-e '1i[\n [' \
-e '$n; s/$/,/' \
-e '/\(pass\)\|\(fail\)/s/,$/\n ],\n [/'
@neenjaw
Copy link
Author

neenjaw commented Nov 8, 2019

line 1: run test command
line 2: add 4 spaces in front of line
line 3: add trailing brackets
line 4: add leading brackets
line 5: all by last line, add comma
line 6: any line matching pass/fail, remove the comma, add separating brackets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment