summaryrefslogtreecommitdiff
path: root/doc/progs
diff options
context:
space:
mode:
Diffstat (limited to 'doc/progs')
-rw-r--r--doc/progs/server.go8
-rw-r--r--doc/progs/server1.go8
2 files changed, 8 insertions, 8 deletions
diff --git a/doc/progs/server.go b/doc/progs/server.go
index c3f772bf9..459245316 100644
--- a/doc/progs/server.go
+++ b/doc/progs/server.go
@@ -9,21 +9,21 @@ type request struct {
replyc chan int;
}
-type binOp (a, b int) int;
+type binOp func(a, b int) int;
-func run(op *binOp, req *request) {
+func run(op binOp, req *request) {
reply := op(req.a, req.b);
req.replyc <- reply;
}
-func server(op *binOp, service chan *request) {
+func server(op binOp, service chan *request) {
for {
req := <-service;
go run(op, req); // don't wait for it
}
}
-func startServer(op *binOp) chan *request {
+func startServer(op binOp) chan *request {
req := make(chan *request);
go server(op, req);
return req;
diff --git a/doc/progs/server1.go b/doc/progs/server1.go
index 51362502d..6a1b6f156 100644
--- a/doc/progs/server1.go
+++ b/doc/progs/server1.go
@@ -9,14 +9,14 @@ type request struct {
replyc chan int;
}
-type binOp (a, b int) int;
+type binOp func(a, b int) int;
-func run(op *binOp, req *request) {
+func run(op binOp, req *request) {
reply := op(req.a, req.b);
req.replyc <- reply;
}
-func server(op *binOp, service chan *request, quit chan bool) {
+func server(op binOp, service chan *request, quit chan bool) {
for {
select {
case req := <-service:
@@ -27,7 +27,7 @@ func server(op *binOp, service chan *request, quit chan bool) {
}
}
-func startServer(op *binOp) (service chan *request, quit chan bool) {
+func startServer(op binOp) (service chan *request, quit chan bool) {
service = make(chan *request);
quit = make(chan bool);
go server(op, service, quit);