#!/usr/bin/env bash

proto_path="proto"
out_path="pkg/v1/proto"

for file in `ls ${proto_path}/*.proto`; do
    base_name=$(basename ${file} ".proto")
    protoc --gofast_out=plugins=grpc:${out_path} --proto_path=${proto_path} ${file}
    if [ `uname` == "Darwin" ]; then
        sed -i "" "s/package ${base_name}/package proto/g" ${out_path}/${base_name}.pb.go
    else
        sed -i "s/package ${base_name}/package proto/g" ${out_path}/${base_name}.pb.go
    fi
done