From f61302d25f144ffb63d1da04ac522455047b1803 Mon Sep 17 00:00:00 2001 From: eson Date: Thu, 26 Nov 2020 17:26:19 +0800 Subject: [PATCH] style(ginmode): set gin mode release --- client.go | 2 ++ client_test.go | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/client.go b/client.go index 9cc6edf..f7a4dd6 100644 --- a/client.go +++ b/client.go @@ -169,6 +169,8 @@ func (cli *Client) Connect() { cli.port = fmt.Sprintf("%d", listener.Addr().(*net.TCPAddr).Port) router := gin.Default() + gin.SetMode(gin.ReleaseMode) + router.POST("/:label", func(c *gin.Context) { label := c.Param("label") if f, ok := cli.register.Load(label); ok { diff --git a/client_test.go b/client_test.go index 1e3e076..03de8b8 100644 --- a/client_test.go +++ b/client_test.go @@ -5,8 +5,30 @@ import ( "log" "net/http" "testing" + "time" ) +func TestSelectChan(t *testing.T) { + var a chan string = make(chan string) + var b chan string = make(chan string) + + go func() { + time.Sleep(time.Second * 2) + a <- "1" + time.Sleep(time.Second * 2) + b <- "2" + }() + + select { + case s := <-a: + log.Println("a", s) + case s := <-b: + log.Println("b", s) + case <-time.After(time.Second * 5): + log.Println("timeout 5s") + } +} + func TestPort(t *testing.T) { cli := New("http://localhost:7123")