Upgrade Go to the latest version via Homebrew and update all go.mod files in the examples directory. Use when the user mentions upgrading Go, updating Go version, or wants to use the latest Go.
This skill automates upgrading Go to the latest version and updating all example projects in the repository.
go directive in all example go.mod filesgo mod tidy to update dependenciesThe skill updates these example projects:
examples/flow/examples/ip-counter/examples/netkit/examples/netkit-ipv6/Note: examples/trace-kills/ is skipped (no go.mod file)
brew update
brew upgrade go
Display the output to the user. If Go is already at the latest version, Homebrew will indicate this.
go version
Parse the output to extract the version number. The output format is:
go version go1.25.2 darwin/arm64
Extract the version number (e.g., "1.25.2") from the string after "go version go".
IMPORTANT: Use absolute paths to avoid shell session issues
First, get the repository root directory:
pwd
Then for each example directory, use the absolute path to update the Go version and tidy dependencies:
cd /absolute/path/to/xcnf/examples/flow && go mod edit -go=<VERSION> && go mod tidy
cd /absolute/path/to/xcnf/examples/ip-counter && go mod edit -go=<VERSION> && go mod tidy
cd /absolute/path/to/xcnf/examples/netkit && go mod edit -go=<VERSION> && go mod tidy
cd /absolute/path/to/xcnf/examples/netkit-ipv6 && go mod edit -go=<VERSION> && go mod tidy
Replace:
/absolute/path/to/xcnf with the output from pwd (e.g., /Users/username/code/xcnf)<VERSION> with the detected version (e.g., "1.25.4")Why use absolute paths?
cd commands don't persist across different tool callsWhy combined commands?
go mod edit -go=X.Y.Z updates the go directive using Go's official toolinggo mod tidy immediately updates dependencies for the new version&& ensures consistency and stops on errorsShow the user a summary:
Go Upgrade Summary
==================
Old version: 1.25.1
New version: 1.25.2
Updated go.mod files:
ā examples/flow/go.mod
ā examples/ip-counter/go.mod
ā examples/netkit/go.mod
ā examples/netkit-ipv6/go.mod
All dependencies tidied successfully.
If brew command is not found:
Error: Homebrew is not installed. Please install Homebrew first:
https://brew.sh
If brew upgrade go fails, display the error and stop.
If unable to parse go version output:
Error: Could not detect Go version. Please verify Go is installed correctly.
If any go mod edit command fails, display the error for that specific example and continue with others.
If go mod tidy fails for any example, display the error and diagnostic information.
&& to chain commands so failures stop executionProblem: Commands like cd examples/flow && ... fail when run in parallel.
Explanation: Each Bash tool call runs in a separate shell session. When you make parallel calls:
# Call 1 - succeeds
cd examples/flow && go mod edit -go=1.25.4 && go mod tidy
# Call 2 - fails (separate shell, starts from original pwd)
cd examples/ip-counter && go mod edit -go=1.25.4 && go mod tidy
Solution: Always use absolute paths constructed from pwd:
# Get repo root first
REPO_ROOT=$(pwd)
# Then use absolute paths
cd $REPO_ROOT/examples/flow && go mod edit -go=1.25.4 && go mod tidy
cd $REPO_ROOT/examples/ip-counter && go mod edit -go=1.25.4 && go mod tidy
cd $REPO_ROOT/examples/netkit && go mod edit -go=1.25.4 && go mod tidy
cd $REPO_ROOT/examples/netkit-ipv6 && go mod edit -go=1.25.4 && go mod tidy
This ensures each command starts from the correct location regardless of shell session.
User: "Upgrade go to the latest version"
Assistant:
brew update && brew upgrade go