How nouuu/gopeek works
Main Components
• CLI Entry Point: Represented by the “cmd/gopeek” directory, which contains the main.go file (plus its associated test file). This is where the program starts.
• Internal Modules:
• Scanner Module: Found under “internal/scanner” (with files like scanner.go, config.go, types.go). This module handles the recursive scanning of directories, file handling, binary detection, file size constraints, and assembling the project tree.
• Ignore Module: Located in “internal/ignore”. This component manages the configurable ignore patterns (e.g., from .gitignore) to filter out unwanted directories or files.
• Logger Module: Present under “internal/logger”. This module is responsible for logging information during execution and likely helps with verbose output and error reporting.
• Supporting Components: Although not directly shown as separate directories, the project configuration files (Makefile, go.mod, GitHub Actions workflow files, etc.) represent the build, test, and release pipeline which are integral for CI/CD but less impactful on runtime architecture.
Relationships and Interactions
• The CLI entry point (main.go) initializes the application, processes command-line flags, and then orchestrates the scanning process.
• It calls upon the scanner module to recursively explore directories and generate the documentation.
• The scanner module, in turn, utilizes the ignore module to filter out directories and files based on user-defined or .gitignore patterns.
• Throughout the process, the logger module is used to log runtime information (debug, error, info) which aids in monitoring the tool’s operation.
• Once the scanning is complete, the scanner module formats the results into a structured Markdown document that encompasses both a project tree view and file contents.
Architectural Patterns and Design Principles
• Modular Design: The system is split into distinct packages (scanner, ignore, logger) to separate concerns and simplify testing.
• CLI Application Design: Uses a clear command-line interface with parsed flags (such as output options and ignore patterns), typical of Go CLI tools, potentially built with Cobra given the README reference.
• Recursion and File I/O Management: The scanner implements recursive directory traversal with conditions for binary file detection and file size handling.
• CI/CD Integration: The GitHub Actions workflows indicate automated builds, linting, tests, and releases, reflecting a robust development lifecycle.
Relevant Technologies and Frameworks
• Programming Language: Go.
• CLI Framework: Likely Cobra, based on the README notes.
• Build and Dependency Management: go.mod, Makefile.
• CI/CD Tools: GitHub Actions workflows (build, lint, tests, security, release).
• Logging: The logger package (could be custom or built atop a known logging library).
• Via the main application flow:
User/CLI Input → CLI Main (cmd/gopeek) → Scanner Module.
• Inside Scanner Module, show two internal interactions:
• Finally, highlight that the Scanner Module’s end function produces the comprehensive Markdown document which is then output to a file.