-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to generate go protobuf code
Script can be invoked with "go generate", and also adds or corrects the go_package compilation option in the dnstap protobuf spec.
- Loading branch information
Showing
3 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
|
||
go_package() { | ||
local file pkg line script | ||
file=$1; shift | ||
pkg=$1; shift | ||
|
||
line="option go_package = \"$pkg\";" | ||
grep "^$line\$" $file > /dev/null && return | ||
|
||
script="/^package dnstap/|a|$line|.|w|q|" | ||
if grep "^option go_package" $file > /dev/null; then | ||
script="/^option go_package/d|1|${script}" | ||
fi | ||
|
||
echo "$script" | tr '|' '\n' | ed $file || exit | ||
} | ||
|
||
dir=$(dirname $0) | ||
[ -n "$dir" ] && cd $dir | ||
|
||
cd dnstap.pb | ||
|
||
go_package dnstap.proto "github.com/dnstap/golang-dnstap;dnstap" | ||
protoc --go_out=../../../.. dnstap.proto |