Skip to content

Instantly share code, notes, and snippets.

@zadykian
Created October 14, 2024 19:04
Show Gist options
  • Save zadykian/0de29d65cb8d668c87f6fa567f6f5002 to your computer and use it in GitHub Desktop.
Save zadykian/0de29d65cb8d668c87f6fa567f6f5002 to your computer and use it in GitHub Desktop.
Shell script to run go tools
#!/bin/bash
# Check if a file path is provided
if [ -z "$1" ]; then
echo "Error: No file path provided."
echo "Usage: $0 <file-path>"
exit 1
fi
FILE=$1
# Check if the file exists
if [ ! -f "$FILE" ]; then
echo "Error: File '$FILE' not found."
exit 1
fi
# Run gci on the file
echo "Running gci on $FILE..."
gci write $FILE --skip-generated -s standard -s default
# Check if gci was successful
if [ $? -ne 0 ]; then
echo "gci failed."
exit 1
fi
# Run gofumpt on the file
echo "Running gofumpt on $FILE..."
gofumpt -w $FILE
# Check if gofumpt was successful
if [ $? -ne 0 ]; then
echo "gofumpt failed."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment