2022-07-19 04:14:28 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Check goimports
|
|
|
|
echo "==> Checking the code complies with goimports requirements..."
|
|
|
|
target_files=$(git diff --name-only origin/main | grep "\.go")
|
|
|
|
|
|
|
|
if [[ -z ${target_files} ]]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2022-08-02 09:08:38 -05:00
|
|
|
goimports_files=$(goimports -w -l "${target_files}")
|
2022-07-19 04:14:28 -05:00
|
|
|
if [[ -n ${goimports_files} ]]; then
|
|
|
|
echo 'goimports needs running on the following files:'
|
|
|
|
echo "${goimports_files}"
|
2022-08-02 09:08:38 -05:00
|
|
|
echo "You can use the command and flags \`goimports -w -l\` to reformat the code"
|
2022-07-19 04:14:28 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|