Created
October 14, 2024 19:04
-
-
Save zadykian/0de29d65cb8d668c87f6fa567f6f5002 to your computer and use it in GitHub Desktop.
Shell script to run go tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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