Skip to content

Commit

Permalink
fmt: remove empty imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Norton committed Jan 8, 2024
1 parent 8244497 commit 3603838
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/remove_empty_imports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# remove all blank lines in go 'imports' statements,

if [ $# != 1 ] ; then
echo "usage: $0 <filename>"
exit 1
fi

if [[ "$(uname -o)" == "Darwin" ]]; then
sed -i '' '
/^import/,/)/ {
/^$/ d
}
' $1
else
sed -i'' '
/^import/,/)/ {
/^$/ d
}
' $1
fi

1 change: 1 addition & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ tasks:

go:fmt:
cmds:
- find . -type f -name "*.go" -exec .github/remove_empty_imports.sh "{}" \;
- goimports -w .
- gofmt -w .
- go mod tidy

0 comments on commit 3603838

Please sign in to comment.