lotus/scripts/fiximports

23 lines
645 B
Plaintext
Raw Normal View History

2022-06-14 14:39:10 +00:00
#!/usr/bin/env bash
2024-02-14 21:29:39 +00:00
sed_replace='/import (/ {
2022-06-14 14:39:10 +00:00
:1
$!N
s/\n\n/\'$'\n''/
/)/!b1
2024-02-14 21:29:39 +00:00
}'
go_files() {
find . -type f -name \*.go -not -name \*_cbor_gen.go | grep -v './extern/filecoin-ffi' | grep -v './extern/test-vectors'
}
2022-06-14 14:39:10 +00:00
2024-02-14 21:29:39 +00:00
# Because -i works differently on macOS, we need to use a different sed command
if [[ "$OSTYPE" == "darwin"* ]]; then
go_files | xargs -I '{}' sed -i '' -e "$sed_replace" '{}'
else
go_files | xargs -I '{}' sed -i -e "$sed_replace" '{}'
fi
2022-06-14 14:39:10 +00:00
go_files | xargs -I '{}' goimports -w -local "github.com/filecoin-project" '{}'
go_files | xargs -I '{}' goimports -w -local "github.com/filecoin-project/lotus" '{}'