Last active
December 25, 2023 13:30
-
-
Save yangyang5214/32dcff31bd425dcf95452ad908880e1f to your computer and use it in GitHub Desktop.
protoc add bson tag
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
#!/bin/bash | |
function add_tag() { | |
if [[ $(uname) == "Darwin" ]]; then | |
# macOS | |
sed -i '' -E 's/json:"([^"]*)"(.*)$/json:"\1" bson:"\1"\2/g' "$1" | |
else | |
# Linux | |
sed -i -E 's/json:"([^"]*)"(.*)$/json:"\1" bson:"\1"\2/g' "$1" | |
fi | |
} | |
# api is protoc out dir | |
files=$(find api -type f -name '*.pb.go' ! -name "*http.pb.go" ! -name "*grpc.pb.go") | |
for proto in $files ; do | |
echo 'add bson tag: '$proto | |
add_tag "$proto" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment