Skip to content

Instantly share code, notes, and snippets.

@adibhanna
Created April 12, 2025 17:55
Show Gist options
  • Save adibhanna/50d3f541a26706439fb869f7972f8157 to your computer and use it in GitHub Desktop.
Save adibhanna/50d3f541a26706439fb869f7972f8157 to your computer and use it in GitHub Desktop.
#!/bin/bash
function go_modernize_fzf() {
local go_files=$(find . -name "*.go" -not -path "*/vendor/*" | sort)
if [[ -z "$go_files" ]]; then
echo "No Go files found"
return 1
fi
local selected_files=$(echo "$go_files" | fzf --multi --height 40% --reverse --preview "cat {}")
if [[ -z "$selected_files" ]]; then
return 0
fi
echo "Running modernize on selected files..."
echo "$selected_files" | xargs go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix
}
go_modernize_fzf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment