Skip to content

Commit

Permalink
fix: resolve format check
Browse files Browse the repository at this point in the history
  • Loading branch information
zjregee committed Aug 15, 2024
1 parent ada9d16 commit c75ff81
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
8 changes: 4 additions & 4 deletions ahttp/binder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ func TestBinderBindHeaders(t *testing.T) {
c := newTestContextWithJson()
b := &DefaultBinder{}
bindData := map[string]string{}
b.BindHeaders(bindData, c)
_ = b.BindHeaders(bindData, c)
assert.Equal(t, MIMEApplicationJSON, bindData["Content-Type"])
}

func TestBinderBindQueryParams(t *testing.T) {
c := newTestContextWithJson()
b := &DefaultBinder{}
bindData := map[string]string{}
b.BindQueryParams(bindData, c)
_ = b.BindQueryParams(bindData, c)
assert.Equal(t, "test", bindData["name"])
assert.Equal(t, "18", bindData["age"])
}
Expand All @@ -27,7 +27,7 @@ func TestBinderBindBodyJson(t *testing.T) {
c := newTestContextWithJson()
b := &DefaultBinder{}
bindData := &testJsonData{}
b.BindBody(bindData, c)
_ = b.BindBody(bindData, c)
assert.Equal(t, "test", bindData.Name)
assert.Equal(t, 18, bindData.Age)
}
Expand All @@ -36,7 +36,7 @@ func TestBinderBindBodyForm(t *testing.T) {
c := newTestContextWithForm()
b := &DefaultBinder{}
bindData := map[string]string{}
b.BindBody(bindData, c)
_ = b.BindBody(bindData, c)
assert.Equal(t, "test", bindData["name"])
assert.Equal(t, "18", bindData["age"])
}
2 changes: 1 addition & 1 deletion connection_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (c *connection) waitReadUntil(delim byte) ([]byte, error) {
}
}
if index != -1 {
c.inputBuffer.SeekAck(index + 1)
_ = c.inputBuffer.SeekAck(index + 1)
return data[:index+1], nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions connection_reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const (
)

func (c *connection) onRead(n int, err error) {
c.inputBuffer.BookAck(n)
_ = c.inputBuffer.BookAck(n)
c.readTrigger <- err
}

func (c *connection) onWrite(n int, err error) {
c.outputBuffer.SeekAck(n)
_ = c.outputBuffer.SeekAck(n)
c.writeTrigger <- err
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package echoserver
package tcpserver

import (
"context"
Expand All @@ -16,11 +16,13 @@ func runServer(port string, stopChan chan interface{}) {
if err != nil {
panic("shouldn't failed here")
}
go eventLoop.Serve(listener)
go func() {
_ = eventLoop.Serve(listener)
}()

go func() {
<-stopChan
eventLoop.Shutdown(context.Background())
_ = eventLoop.Shutdown(context.Background())
listener.Close()
}()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package echoserver
package tcpserver

import (
"bufio"
Expand All @@ -11,7 +11,7 @@ import (
"github.com/zjregee/anet"
)

func TestEchoServerSerial(t *testing.T) {
func TestTCPServerSerial(t *testing.T) {
port := ":8001"
stopchan := make(chan interface{})
runServer(port, stopchan)
Expand Down Expand Up @@ -46,7 +46,7 @@ func TestEchoServerSerial(t *testing.T) {
}
}

func TestEchoServerConcurrent(t *testing.T) {
func TestTCPServerConcurrent(t *testing.T) {
port := ":8002"
stopchan := make(chan interface{})
runServer(port, stopchan)
Expand Down
6 changes: 4 additions & 2 deletions ring_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type roundRobinLB struct {
}

func (b *roundRobinLB) Pick() (ring Ring) {
if b.rings == nil || len(b.rings) == 0 {
if len(b.rings) == 0 {
return nil
}
index := int(atomic.AddInt32(&b.lastpicked, 1)) % len(b.rings)
Expand Down Expand Up @@ -55,7 +55,9 @@ func (m *manager) Run() error {
errs = append(errs, err)
log.Warnf("error occurred while open ring")
} else {
go ring.Wait()
go func() {
_ = ring.Wait()
}()
rings = append(rings, ring)
}
}
Expand Down

0 comments on commit c75ff81

Please sign in to comment.