We'll start with a simple version of a pseudo-terminal by creating an input manager, then by creating a command selector, and finally by creating the command execution.
Creating a basic PTY
Input management
The standard input can be used to receive user commands. We can start by using a buffered input to read lines and print them. In order to read a line, there is a useful command, bufio.Scanner, that already provides a line reader. The code will look similar to the following code snippet:
s := bufio.NewScanner(os.Stdin)
w := os.Stdout
fmt.Fprint(w, "Some welcome message\n")
for {
s.Scan() // get next the token
fmt.Fprint(w, "You wrote \"")
w.Write(s.Bytes())
fmt.Fprintln(w, "...