Created
November 30, 2021 16:34
-
-
Save dillonstreator/ef831f496e1f705b40e9858b436d5c66 to your computer and use it in GitHub Desktop.
generate mocks for golang interfaces in mocks.go files using mockery and goconcat binaries in shell scripts by finding internal and pkg
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
#!/usr/bin/env bash | |
cd "$(dirname "$0")" | |
find internal pkg -type d -print0 | | |
while IFS= read -r -d '' path; do | |
rm -f $path/mock_*.go || exit 1 | |
rm -f $path/mocks.go || exit 1 | |
mockery --dir $path --inpackage --name '(.*)' --quiet || exit 1 | |
if ls $path/mock_*.go 1> /dev/null 2>&1; then | |
./bin/goconcat-$(uname)-$(uname -m) -k -p "$(basename $path)" $path/mock_*.go > $path/mocks.go || exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment