Skip to content

Commit c075c82

Browse files
committed
Go set up
1 parent 6d2b93f commit c075c82

File tree

5 files changed

+100
-2
lines changed

5 files changed

+100
-2
lines changed

Go/src/client/main.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
import (
4+
"log"
5+
6+
"code.google.com/p/goprotobuf/proto"
7+
"example_mess"
8+
)
9+
10+
func main() {
11+
test := &example_mess.Boring {
12+
Cont: proto.String("wew"),
13+
}
14+
_, err := proto.Marshal(test)
15+
if err != nil {
16+
log.Fatal("marshaling error: ", err)
17+
}
18+
}

Go/src/example_mess/msg.pb.go

+40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Go/src/server/main.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
import (
4+
"log"
5+
6+
"code.google.com/p/goprotobuf/proto"
7+
"example_mess"
8+
)
9+
10+
func main() {
11+
test := &example_mess.Boring {
12+
Cont: proto.String("wew"),
13+
}
14+
_, err := proto.Marshal(test)
15+
if err != nil {
16+
log.Fatal("marshaling error: ", err)
17+
}
18+
}

makefile

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
CPP_BINS = client_sync server_sync server_async
33

4+
GO_BINS = client server
5+
46
# consider also -lboost_thread-mt -lpthread
57
CPP_LIBS = -lboost_system-mt -lprotobuf
68
CPP_FLAGS = -Wall -O2 --std=c++11 -L/usr/local/lib
@@ -11,6 +13,8 @@ CPP: $(CPP_BINS)
1113

1214
Python: Python/gen/msg_pb2.py
1315

16+
Go: $(GO_BINS)
17+
1418
$(CPP_BINS): %: C++/src/%.cc C++/gen/msg.pb.cc C++/src/asio_server.h
1519
clang++ $(CPP_FLAGS) C++/src/$@.cc C++/gen/msg.pb.cc -o C++/bin/$@ $(CPP_LIBS)
1620
cp C++/bin/$@ bin/cpp_$@
@@ -26,6 +30,24 @@ Python/gen/msg_pb2.py: msg.proto
2630
echo "#!/bin/sh\n\npython Python/server.py" > bin/python_server.sh
2731
chmod +x bin/python_server.sh
2832

33+
34+
$(GO_BINS): %: Go/src/%/main.go Go/src/example_mess/msg.pb.go Go/src/code.google.com/p/goprotobuf
35+
GOPATH=$(CURDIR)/Go go install $@
36+
cp Go/bin/$@ bin/go_$@
37+
38+
Go/src/example_mess/msg.pb.go: msg.proto
39+
protoc --go_out=Go/src/example_mess msg.proto
40+
#GOPATH=$(CURDIR)/Go go install pb_message
41+
42+
Go/src/code.google.com/p/goprotobuf:
43+
GOPATH=$(CURDIR)/Go go get code.google.com/p/goprotobuf/proto
44+
45+
2946
.PHONY : clean
3047
clean:
31-
rm -f C++/bin/* C++/gen/* Python/gen/* bin/*
48+
rm -f C++/bin/* C++/gen/* Python/gen/* bin/* Go/pkg/*/example_mess.a Go/bin/*
49+
50+
.PHONY : really_clean
51+
really_clean: clean
52+
rm -rf Go/pkg/* Go/src/code.google.com
53+

msg.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package asio;
1+
package example_mess;
22

33

44
//option optimize_for = LITE_RUNTIME;

0 commit comments

Comments
 (0)