explaingit

netflix/go-expect

Analysis updated 2026-07-22 · repo last pushed 2024-06-15

473GoAudience · developerComplexity · 3/5DormantSetup · moderate

TLDR

A Go library that lets your code automate interactive command-line programs by simulating keystrokes and reading output through a fake terminal, without managing the processes themselves.

Mindmap

mindmap
  root((repo))
    What it does
      Automates CLI programs
      Simulates keystrokes
      Reads program output
    How it works
      Creates fake terminal
      You manage processes
      Focuses on IO only
    Use cases
      Test CLI installers
      Simulate password prompts
      Script text editors
    Audience
      Go developers
      Needs Go knowledge
      Sparse README

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Write automated tests for a CLI installer that walks through every prompt and answer.

USE CASE 2

Simulate typing a password into a tool that asks for one.

USE CASE 3

Script a text editor to open, make changes, and quit without human intervention.

What is it built with?

Go

How does it compare?

netflix/go-expecttastyeffectco/sandboxesmitchellh/panicwrap
Stars473476453
LanguageGoGoGo
Last pushed2024-06-152024-04-05
MaintenanceDormantDormant
Setup difficultymoderatemoderateeasy
Complexity3/54/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

You need to know Go and handle process startup yourself since the library only manages the terminal conversation, not process launching.

No license information is provided in the README, so usage rights are unclear.

In plain English

Netflix's go-expect is a Go library that lets your code automate programs that normally need a human sitting at a keyboard. Think of it as a way to script interactions with command-line tools that ask for input or respond to what you type, like text editors, password prompts, or interactive installers, so you can control them automatically from a program. The way it works is by creating a fake terminal (called a pseudoterminal) that your target program runs inside. Your code can then "send" keystrokes to that program and watch for specific output, just like a person would type and read the screen. What sets this tool apart from similar utilities is that it deliberately doesn't handle starting or managing the processes themselves, you handle that part yourself using Go's standard tools. It focuses purely on the conversation: feeding input in and reading output back. A team building a CLI installer that asks a series of questions could use this to write automated tests that walk through every prompt and answer. Someone testing a tool with a password prompt could simulate typing a password. Or you could script a text editor to open, make changes, and quit, all without human intervention. The README is sparse beyond the two code examples, so you're expected to know some Go to get up and running. The notable design choice is the decision to stay out of process management entirely, which keeps the tool lightweight but means you'll write a bit more wiring code compared to a full-featured alternative.

Copy-paste prompts

Prompt 1
Using Netflix's go-expect in Go, write a test that starts a CLI program with os/exec, connects it to a go-expect console, sends keystrokes to answer three prompts, and asserts the expected output appears.
Prompt 2
Show me a Go example using go-expect to automate a password prompt: start the program, wait for the 'Password:' prompt, send a fake password, and check the program logs in successfully.
Prompt 3
Create a Go test using go-expect that opens a text editor like vim inside a pseudoterminal, types some text, saves, quits, and verifies the file contents on disk.

Frequently asked questions

What is go-expect?

A Go library that lets your code automate interactive command-line programs by simulating keystrokes and reading output through a fake terminal, without managing the processes themselves.

What language is go-expect written in?

Mainly Go. The stack also includes Go.

Is go-expect actively maintained?

Dormant — no commits in 2+ years (last push 2024-06-15).

What license does go-expect use?

No license information is provided in the README, so usage rights are unclear.

How hard is go-expect to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is go-expect for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.