diff --git a/gomore/27_messages/message.go b/gomore/27_messages/message.go index edecbec..6051d36 100644 --- a/gomore/27_messages/message.go +++ b/gomore/27_messages/message.go @@ -76,7 +76,7 @@ func (s *Subscription) Receive(out *Message) error { case <-s.ctx.Done(): return errors.New("Topic has been closed") default: - *out <- s.Inbox + *out = <-s.Inbox } return nil } diff --git a/gomore/27_messages/message_test.go b/gomore/27_messages/message_test.go index cd2887f..69838ed 100644 --- a/gomore/27_messages/message_test.go +++ b/gomore/27_messages/message_test.go @@ -26,7 +26,7 @@ func TestMessageSubAndPub(t *testing.T) { //订阅成功了 go func() { - EXIT + EXIT: for { select { case <-exit: @@ -56,7 +56,7 @@ func TestMessageSubAndPub(t *testing.T) { //订阅成功了 //发送一个消息 go func() { - EXIT + EXIT: for { select { case <-exit: diff --git a/gomore/29_context/context_test.go b/gomore/29_context/context_test.go index 30bd4b8..0676e5c 100644 --- a/gomore/29_context/context_test.go +++ b/gomore/29_context/context_test.go @@ -15,8 +15,8 @@ func TestContext(t *testing.T) { time.Sleep(time.Second) - reqest, err := http.NewRequest("GET", "http://localhost:8099/hello", nil) // http client get 请求 - assertEq(nil, err) + reqest, _ := http.NewRequest("GET", "http://localhost:8099/hello", nil) // http client get 请求 + client := &http.Client{} ctx, cancel := context.WithCancel(context.Background()) reqest = reqest.WithContext(ctx) @@ -28,7 +28,7 @@ func TestContext(t *testing.T) { } }() - response, err := client.Do(reqest) + client.Do(reqest) }