How sgrumley/gotex works
Project Type and Purpose
• Gotex is a cross-platform TUI test explorer for Go projects, aimed at simplifying test navigation and execution directly from the terminal.
• The project’s purpose is clearly to provide an interactive user interface (TUI) for running and managing Go tests, incorporating features like fuzzy search, keybindings (Vim-like), test discovery, and result management.
File Structure
• The project has a clear separation between the command-line entry point and its internal logic:
• "cmd/gotex/main.go" – This file is the main application entry point which bootstraps and starts the TUI application.
• The "internal" directory contains the UI components. For example:
• internal/components/app.go, config_modal.go, console_panel.go, events.go, etc. Each file here likely represents a different panel or widget within the TUI (e.g., search modal, test tree panel, results panel, and keybinding setup).
• The "pkg" directory hosts various libraries and utilities:
• pkg/config – Handles configuration (with a default YAML file included).
• pkg/finder – Contains modules for discovering tests, files, functions etc. (includes logic for fuzzy search and test package discovery).
• pkg/runner – Contains logic for running tests.
• pkg/logging and pkg/ansi – Likely provide logging utilities and ANSI code handling for terminal formatting.
• Auxiliary files include the Dockerfile (for containerization), testdata (for testing purposes), and configuration files.
README Insights
• The README makes it clear that Gotex provides a TUI with Vim-like keybindings, fuzzy search, and test control actions.
• Dependencies mentioned: it uses the [tview](https://github.com/rivo/tview) library for building the TUI.
• The installation and usage instructions indicate that the application is started from within a Go project directory, suggesting it interacts with the Go test ecosystem.
a. Main Components:
• TUI Application Core: Represents the main application logic (cmd/gotex/main.go) that bootstraps the interface.
• UI Components: Under internal/components, include panels for configuration (config_modal), test results (results_panel), test tree (testTree_panel), console (console_panel), and help (help_panel).
• Service/Logic Layer: Provided by packages such as:
• pkg/config – Manages configuration settings.
• pkg/finder – Discovers test files, functions, and Go packages.
• pkg/runner – Executes the tests and gathers results.
• pkg/logging – Handles logging across the application.
• pkg/ansi – Manages ANSI codes for terminal output.
b. Relationships and Interactions:
• The TUI Application Core initializes and orchestrates the UI components.
• UI components (panels) display dynamic information (test lists, search results, logs) by invoking functions from pkg/finder, pkg/runner, and pkg/config.
• User actions (e.g., pressing a key to run tests) are captured by the TUI and sent to the runner (pkg/runner) to execute tests.
• Configuration is loaded via pkg/config (possibly reading a YAML file) and then injected into relevant parts of the system.
• Logging and ANSI handling are utilities that support both the UI and backend processes.
c. Architectural Patterns/Design Principles:
• Separation of Concerns: Clear boundary between the UI (internal/components) and the backend logic (pkg/*). This separation enhances maintainability.
• Modular Design: Each aspect (test discovery, configuration, test execution) is handled by its own package/module.
• MVC-like Approach: The TUI (view) interacts with underlying packages (controllers/services) for business logic, while data (the test cases and configurations) are managed separately.
d. Specify Relevant Technologies/Frameworks:
• Go language (with modules as seen in go.mod and go.sum).
• tview library for TUI.
• YAML configuration (pkg/config).
• Standard Go testing mechanisms supported by pkg/finder and pkg/runner.