We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
How to write a programming language and shell in Go with 92% test coverage and instant CI/CD-Qi Xiao
Learn how Qi Xiao built a modern shell and programming language in Go with high test coverage. See the architecture, testing approach, and CI/CD implementation that made it possible.
-
Go proved to be an excellent language for implementing Elvish shell, providing garbage collection, goroutines, and standard library features that simplified development
-
The interpreter follows a three-stage process: parsing source code into syntax tree, converting to operation tree, and execution - each stage using divide-and-conquer on tree structures
-
Testing was made extremely easy through recording terminal transcripts in text files, eliminating separate test writing steps and contributing to 92% test coverage
-
Elvish improves on traditional shells by supporting proper data structures (lists, maps), functional programming with lambdas, and concurrent pipeline execution using goroutines
-
The shell provides modern features like syntax highlighting, command history with filtering, file navigation, and programmable prompts using lambdas instead of special sequences
-
CI/CD was implemented using GitHub webhooks and Go HTTP listeners that trigger Elvish scripts to build binaries
-
The terminal app uses a widget-based architecture with event handling and rendering methods, similar to GUI programming patterns
-
Test coverage was achieved by making testing an integral part of development rather than a separate step - manual testing is converted directly into test cases
-
Fuzzing was used effectively to test the parser for crashes and performance issues, as well as ensuring markdown formatting preserved semantics
-
The project leverages Go’s standard library extensively, with many Elvish features mapping directly to Go equivalents (big numbers, string manipulation, etc.)