aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/Makefile
diff options
context:
space:
mode:
authorGravatar Tim Swast <swast@google.com>2015-11-20 15:32:53 -0800
committerGravatar Tim Swast <swast@google.com>2015-11-25 10:46:35 -0800
commit7e31c4d930efa3f80d0f03c93e788ba73b847fd8 (patch)
tree9e3980cce5ad25c42e013b51d28d503cd4b7891c /examples/Makefile
parentf1e14fba2300010d6f2966b2e32d4aa0842cdffb (diff)
Add a Go language example.
This follows the other examples so that it can be used as a tutorial, such as the ones at: https://developers.google.com/protocol-buffers/docs/tutorials Even though Go generally does not use Makefiles, I added targets for the Go examples to be consistent with the other languages. Edit: Fix Travis run. Change to use $HOME instead of ~. Add protoc to path. GOPATH entry cannot start with shell metacharacter '~': "~/gocode" Edit(2): Fix Go code style to address comments.
Diffstat (limited to 'examples/Makefile')
-rw-r--r--examples/Makefile21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/Makefile b/examples/Makefile
index 8dc90836..51f13426 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -5,6 +5,8 @@
all: cpp java python
cpp: add_person_cpp list_people_cpp
+go: add_person_go list_people_go
+gotest: add_person_gotest list_people_gotest
java: add_person_java list_people_java
python: add_person_python list_people_python
@@ -13,6 +15,8 @@ clean:
rm -f javac_middleman AddPerson*.class ListPeople*.class com/example/tutorial/*.class
rm -f protoc_middleman addressbook.pb.cc addressbook.pb.h addressbook_pb2.py com/example/tutorial/AddressBookProtos.java
rm -f *.pyc
+ rm -f protoc_middleman_go tutorial/*.pb.go add_person_go list_people_go
+ rmdir tutorial 2>/dev/null || true
rmdir com/example/tutorial 2>/dev/null || true
rmdir com/example 2>/dev/null || true
rmdir com 2>/dev/null || true
@@ -21,6 +25,11 @@ protoc_middleman: addressbook.proto
protoc --cpp_out=. --java_out=. --python_out=. addressbook.proto
@touch protoc_middleman
+protoc_middleman_go: addressbook.proto
+ mkdir tutorial # make directory for go package
+ protoc --go_out=tutorial addressbook.proto
+ @touch protoc_middleman_go
+
add_person_cpp: add_person.cc protoc_middleman
pkg-config --cflags protobuf # fails if protobuf is not installed
c++ add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf`
@@ -29,6 +38,18 @@ list_people_cpp: list_people.cc protoc_middleman
pkg-config --cflags protobuf # fails if protobuf is not installed
c++ list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf`
+add_person_go: add_person.go protoc_middleman_go
+ go build -o add_person_go add_person.go
+
+add_person_gotest: add_person_test.go add_person_go
+ go test add_person.go add_person_test.go
+
+list_people_go: list_people.go protoc_middleman_go
+ go build -o list_people_go list_people.go
+
+list_people_gotest: list_people.go list_people_go
+ go test list_people.go list_people_test.go
+
javac_middleman: AddPerson.java ListPeople.java protoc_middleman
javac AddPerson.java ListPeople.java com/example/tutorial/AddressBookProtos.java
@touch javac_middleman