Teach it about golang
This commit is contained in:
@@ -27,6 +27,8 @@ function sniff_file_type() {
|
|||||||
file_type="scss"
|
file_type="scss"
|
||||||
elif [[ $ff = *.sh ]]; then
|
elif [[ $ff = *.sh ]]; then
|
||||||
file_type="sh"
|
file_type="sh"
|
||||||
|
elif [[ $ff = *.go ]] ; then
|
||||||
|
file_type="golang"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $file_type
|
echo $file_type
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ elif [[ $file_type == "python" ]]; then
|
|||||||
out=$(pipx run black $file 2>/dev/null && pipx run isort $file 2>/dev/null)
|
out=$(pipx run black $file 2>/dev/null && pipx run isort $file 2>/dev/null)
|
||||||
retval="$?"
|
retval="$?"
|
||||||
success_retval=0
|
success_retval=0
|
||||||
|
elif [[ $file_type == "golang" ]] ; then
|
||||||
|
out=$(gofmt -w "$file" 2>/dev/null)
|
||||||
|
retval="$?"
|
||||||
|
success_retval=0
|
||||||
else
|
else
|
||||||
echo -n "ignoring"
|
echo -n "ignoring"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -42,6 +42,22 @@ elif [[ $file_type == "python" ]]; then
|
|||||||
else
|
else
|
||||||
retval="$isort_retval"
|
retval="$isort_retval"
|
||||||
fi
|
fi
|
||||||
|
elif [[ $file_type == "golang" ]] ; then
|
||||||
|
success_retval=0
|
||||||
|
would_reformat_retval=1
|
||||||
|
syntax_error_retval=2
|
||||||
|
|
||||||
|
out=$(gofmt -l $file)
|
||||||
|
exitval="$?"
|
||||||
|
|
||||||
|
if [[ x"$exitval" = x"$syntax_error_retval" ]] ; then
|
||||||
|
retval="$exitval"
|
||||||
|
elif [[ x"$out" = x"$file" ]] ; then
|
||||||
|
retval="$would_reformat_retval"
|
||||||
|
else
|
||||||
|
# success
|
||||||
|
retval="$exitval"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo -n "ignoring"
|
echo -n "ignoring"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user