A static analysis tool for Go codebases that identifies which entrypoints (cloud functions, APIs, etc.) are affected by code changes. This helps developers and QA teams determine what needs to be deployed and tested in a PR.
This tool analyzes call graphs in your codebase to trace paths from source functions (entrypoints) to sink functions (where changes were made). By understanding these connections, you can:
- Identify which cloud functions or API endpoints are impacted by code changes
- Focus testing efforts on affected functionality
- Make more informed deployment decisions
- Clone this repository
- Ensure you have Go installed (version 1.18+ recommended)
- Initialize the Go module and install dependencies:
go mod init functions-tool
go mod tidyRun the tool with the following command:
go run main.go -repo=REPO_NAME -sources=SOURCE_FILES -sinks=SINK_FILES [-test=BOOL]-
-repo: Name of the repository being analyzed (used to construct the module name)- Example:
-repo=ted
- Example:
-
-sources: Comma-separated list of filepath(s) where entrypoints or cloud functions are defined- Example:
-sources="functions.go,src/app/web/mapping.go"
- Example:
-
-sinks: Comma-separated list of filepath(s) that contain code changes- Example:
-sinks="src/core/usecases/videos/save_v2.go"
- Example:
-test: Test mode flag (default: "false")- When set to "true", the tool looks for the repository in the parent directory, this means that the repository to analyze is cloned in the parent directory
- When "false", it uses the current directory
- Example:
-test=true
# Regular mode (analyzing code in current directory)
go run main.go -repo=ted -sources="functions.go,src/app/web/mapping.go" -sinks="src/core/usecases/videos/save_v2.go"
# Test mode (analyzing code in parent directory)
go run main.go -repo=ted -sources="functions.go,src/app/web/mapping.go" -sinks="src/core/usecases/videos/save_v2.go" -test=trueThe tool will output a list of source functions (entrypoints) and the paths through which they reach any sink functions. This helps identify which entrypoints are affected by changes in the sink files.
- Go 1.18 or higher
- golang.org/x/tools package
- Module not found: Ensure you've run
go mod initandgo mod tidy - Directory not found: Check the path construction with the
-testflag - No sources/sinks found: Verify file paths are correct relative to the directory being analyzed