diff options
| author | Paul Buetow <paul@buetow.org> | 2023-06-18 12:19:03 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-06-18 12:19:03 +0300 |
| commit | e3c903c49c798531124a1c59859f47d04d4534b9 (patch) | |
| tree | 641b0df3c3ed06c844e8bda48bc6b386d68e8e1f /internal | |
| parent | 6fe2579b65eaf78573d8b08c94dc1b313c20b9d9 (diff) | |
fix lint errors
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/client/tcpclient.go | 4 | ||||
| -rw-r--r-- | internal/config/config.go | 4 | ||||
| -rw-r--r-- | internal/quorum/quorum.go | 2 | ||||
| -rw-r--r-- | internal/server/tcpserver.go | 4 |
4 files changed, 8 insertions, 6 deletions
diff --git a/internal/client/tcpclient.go b/internal/client/tcpclient.go index f521ee3..1a76ad6 100644 --- a/internal/client/tcpclient.go +++ b/internal/client/tcpclient.go @@ -3,7 +3,7 @@ package client import ( "context" "fmt" - "io/ioutil" + "io" "log" "net" @@ -36,7 +36,7 @@ func tcpClientRun(ctx context.Context, node string, ch <-chan vote.Vote) error { return err } - response, err := ioutil.ReadAll(conn) + response, err := io.ReadAll(conn) if err != nil { return err } diff --git a/internal/config/config.go b/internal/config/config.go index 90435e5..fe23cbc 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -3,7 +3,7 @@ package config import ( "encoding/json" "fmt" - "io/ioutil" + "io" "log" "net" "os" @@ -27,7 +27,7 @@ func New(configFile string) (Config, error) { } defer file.Close() - bytes, err := ioutil.ReadAll(file) + bytes, err := io.ReadAll(file) if err != nil { return c, err } diff --git a/internal/quorum/quorum.go b/internal/quorum/quorum.go index dfeabe6..20fbe8a 100644 --- a/internal/quorum/quorum.go +++ b/internal/quorum/quorum.go @@ -85,7 +85,7 @@ func (quo Quorum) score() (scores []Score) { continue } for _, id := range vote.IDs { - score, _ := scoreMap[id] + score := scoreMap[id] scoreMap[id] = score + 1 } } diff --git a/internal/server/tcpserver.go b/internal/server/tcpserver.go index 2eb2422..b6d2ede 100644 --- a/internal/server/tcpserver.go +++ b/internal/server/tcpserver.go @@ -61,7 +61,9 @@ func handleConnection(ctx context.Context, conn net.Conn, cb handlerCb) { log.Println("server: received message", remoteAddr, message) response := cb(message) - conn.Write([]byte(response)) + if _, err := conn.Write([]byte(response)); err != nil { + log.Println("error:", err) + } } } } |
