Skip to content

Instantly share code, notes, and snippets.

@asim
Created January 28, 2020 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asim/d5a8541cf04d96a78f2cb12cb96b066c to your computer and use it in GitHub Desktop.
Save asim/d5a8541cf04d96a78f2cb12cb96b066c to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
function trap_handler {
MYSELF="$0" # equals to my script name
LASTLINE="$1" # argument 1: last line of error occurence
LASTERR="$2" # argument 2: error code of last command
echo "Error: line ${LASTLINE} - exit status of last command: ${LASTERR}"
exit $2
}
trap 'trap_handler ${LINENO} ${$?}' ERR
echo "Checking dependencies..."
which protoc
which protoc-gen-go
echo "Building protobuf code..."
DIR=`pwd`
SRCDIR=`cd $DIR && cd ../../../.. && pwd`
echo "DIR $DIR"
echo "SRCDIR $SRCDIR"
find $DIR/proto -name '*.pb.go' -exec rm {} \;
find $DIR/proto -name '*.micro.go' -exec rm {} \;
find $DIR/proto -name '*.proto' -exec echo {} \;
find $DIR/proto -name '*.proto' -exec protoc --proto_path=$SRCDIR --micro_out=${SRCDIR} --go_out=${SRCDIR} {} \;
#find $DIR/proto -name '*.proto' -exec protoc --proto_path=$SRCDIR --micro_out=${SRCDIR} --go_out=plugins=grpc:${SRCDIR} {} \;
echo "Complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment