I am coding with Go 1.2 on Ubuntu 12.04 LTS machine - using LiteIDE (very pleased with it).
I downloaded and installed the go termbox package - built the demo keyboard.go - built fine.
But when I run from LiteIDE, I get this panic - same happens with all the termbox demos:
panic: open /dev/tty: no such device or address
Any clues would be helpful....
OK, that's completely reasonable: interactive terminal applications require, well, terminal to be available. Terminals may be real—hardware—or virtual (like Linux virtual terminals you see on a typical x86 box when you hit Ctrl-Alt-F1) or emulated (like those provided by xterm, rxvt, GNOME Terminal and a ton of others).
Contrary to Windows, in which running a program of type "console" forces a console window to be created and an application attached to it, on POSIX systems there's no "types" of applications, and if an aplication wants a real terminal available for its I/O it performs a special check for this, and if that fails, the application signals an error and quits1. Very few folks have access to real hardware terminals these days so most of the time emulation is used, and then we talk about the so-called pseudo terminals. Linux virtual terminals and GUI terminal emulators and terminal console multiplexors like screen
and tmux
—all of them allocate pseudo terminals for running programs they control.
So basically you have these options:
Find a setting in your IDE which makes it allocate a pseudo-terminal when running your program. Some programs are able to do that by embedding a terminal emulator into their UI or by running it explicitly.
Teach your IDE to run your program in a terminal emulator. Most of them obey the convention established by the venerable xterm
and accept the -e <program>
command-line option, so instead of
./myprogram
your IDE should run
xterm -e ./myprogram
If you're on a Debian system or its derivative, you might get away with
x-terminal-emulator -e ./myprogram
which is supposed to spawn your preferred terminal emulator program.
Stop running the code in the IDE and do it in a terminal emulator using the regular
go build
./myprogram
workflow.
I've never used LiteIDE so have no immediate experience with how to do that in it—you'll have to do your own research.
1 Some programs may happily work with or without being attached to a terminal, with shells (like bash
or zsh
) and interpreters (like Tcl
or Python
) being good examples: when they detect a terminal device available, they go into interactive mode, enable line editing and so on, otherwise they just read the code from their standard input and execute it. Another good example is Git: its high-level programs detect if they're attached to a terminal and if so they might enable colouring of their output and automatically spawn a pager program if their output if about to overflow the single screenful of lines; otherwise they cut the fuss and just dump their output to their standard output stream.