Output golang cmdline tools to stdout and file using tee

Some golang-based tools I’ve used (or even written) use the builtin log package that output logs to stderr by default. I also use tee for piping console outputs to file for later viewing. This is the command I generally use:

# Example tool:
$ sometool --flag1 --flag2 2>&1 | tee out.txt

# 2>&1 <-- redirect stderr to stdout
# tee <-- pipe the console output to out.txt while retaining the actual console logs during command execution
---
If you have any questions or feedback, please reach out @flowerinthenyt.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.