func initReadLine() { C.rl_catch_sigwinch = 0 C.rl_catch_signals = 0 c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGWINCH) signal.Notify(c, os.Interrupt) go func() { for sig := range c { switch sig { case syscall.SIGWINCH: C.rl_resize_terminal() case os.Interrupt: C.rl_cleanup_after_signal() default: } } }() }
// Cleanup() frees internal memory and restores terminal // attributes. This function should be called when program execution // stops before the return of a String() call, so as not to leave the // terminal in a corrupted state. func Cleanup() { C.rl_free_line_state() C.rl_cleanup_after_signal() }
func Cleanup() { C.rl_cleanup_after_signal() os.Exit(0) }