diff options
author | Rob Pike <r@golang.org> | 2009-01-06 15:49:27 -0800 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2009-01-06 15:49:27 -0800 |
commit | 5df73e8b14d435bcb5f110ca9e2ae6ab7917e8ee (patch) | |
tree | baa8a65017491726042d244d68061a3599ab7741 /doc/progs/server1.go | |
parent | 92743b1fbff6b14864c4ffd200042e5a65a2b1c1 (diff) | |
download | golang-5df73e8b14d435bcb5f110ca9e2ae6ab7917e8ee.tar.gz |
make the tutorial programs run again.
(the text still needs fixing)
add the tutorial programs to the test run.
R=rsc
DELTA=41 (6 added, 0 deleted, 35 changed)
OCL=22174
CL=22174
Diffstat (limited to 'doc/progs/server1.go')
-rw-r--r-- | doc/progs/server1.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/doc/progs/server1.go b/doc/progs/server1.go index d70ddfd9d..b7e489d46 100644 --- a/doc/progs/server1.go +++ b/doc/progs/server1.go @@ -6,7 +6,7 @@ package main type Request struct { a, b int; - replyc *chan int; + replyc chan int; } type BinOp (a, b int) int; @@ -16,7 +16,7 @@ func Run(op *BinOp, request *Request) { request.replyc <- result; } -func Server(op *BinOp, service *chan *Request, quit *chan bool) { +func Server(op *BinOp, service chan *Request, quit chan bool) { for { select { case request := <-service: @@ -27,9 +27,9 @@ func Server(op *BinOp, service *chan *Request, quit *chan bool) { } } -func StartServer(op *BinOp) (service *chan *Request, quit *chan bool) { - service = new(chan *Request); - quit = new(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); return service, quit; } @@ -42,7 +42,7 @@ func main() { req := &reqs[i]; req.a = i; req.b = i + N; - req.replyc = new(chan int); + req.replyc = make(chan int); adder <- req; } for i := N-1; i >= 0; i-- { // doesn't matter what order |