Is there a way to detect if a command in go is piped or not?
Example:
cat test.txt | mygocommand #Piped, this is how it should be used
mygocommand # Not piped, this should be blocked
I'm reading from the Stdin reader := bufio.NewReader(os.Stdin)
.
You can do this using
os.Stdin.Stat()
.(Adapted from https://www.socketloop.com/tutorials/golang-check-if-os-stdin-input-data-is-piped-or-from-terminal)