Anonymous user
Check output device is a terminal: Difference between revisions
Check output device is a terminal (view source)
Revision as of 22:08, 16 September 2020
, 3 years ago→{{header|Go}}: A solution without the use of external libraries. I'm 95% sure this isn't any worse than the previous version (both would have corner cases)
Thundergnat (talk | contribs) m (Promote to task, lots of examples, little real controversy, most concerns have been addressed) |
(→{{header|Go}}: A solution without the use of external libraries. I'm 95% sure this isn't any worse than the previous version (both would have corner cases)) |
||
Line 235:
=={{header|Go}}==
Tells a ''terminal'' apart from a ''pipe'' on Linux and Mac, which is probably exactly what you need.
<lang go>package main
Line 241 ⟶ 242:
"os"
"fmt"
)
func main() {
if
fmt.Println("Hello terminal")
} else {
fmt.Println("Who are you?
}
}</lang>
Line 256:
Hello terminal
> hello | cat
Who are you?
</pre>
|