all: Even more boring linter fixes (#5501)

This commit is contained in:
Jakob Borg
2019-02-02 11:45:17 +01:00
committed by GitHub
parent df5c1eaf01
commit 0b2cabbc31
28 changed files with 131 additions and 104 deletions

View File

@@ -132,8 +132,8 @@ func getTCPConnectionPair() (net.Conn, net.Conn, error) {
}
// Set the buffer sizes etc as usual
dialer.SetTCPOptions(conn0)
dialer.SetTCPOptions(conn1)
_ = dialer.SetTCPOptions(conn0)
_ = dialer.SetTCPOptions(conn1)
return conn0, conn1, nil
}

View File

@@ -35,7 +35,7 @@ func repeatedDeviceID(v byte) (d DeviceID) {
func NewDeviceID(rawCert []byte) DeviceID {
var n DeviceID
hf := sha256.New()
hf.Write(rawCert)
_, _ = hf.Write(rawCert)
hf.Sum(n[:0])
return n
}

View File

@@ -64,9 +64,13 @@ func TestMarshallingDeviceID(t *testing.T) {
n2 := DeviceID{}
bs, _ := n0.MarshalText()
n1.UnmarshalText(bs)
if err := n1.UnmarshalText(bs); err != nil {
t.Fatal(err)
}
bs, _ = n1.MarshalText()
n2.UnmarshalText(bs)
if err := n2.UnmarshalText(bs); err != nil {
t.Fatal(err)
}
if n2.String() != n0.String() {
t.Errorf("String marshalling error; %q != %q", n2.String(), n0.String())

View File

@@ -7,12 +7,9 @@ import (
"encoding/binary"
"encoding/hex"
"io"
"regexp"
"testing"
)
var spaceRe = regexp.MustCompile(`\s`)
func TestVersion14Hello(t *testing.T) {
// Tests that we can send and receive a version 0.14 hello message.

View File

@@ -175,7 +175,6 @@ type rawConnection struct {
closed chan struct{}
closeOnce sync.Once
sendCloseOnce sync.Once
writerExited chan struct{}
compression Compression
}
@@ -227,7 +226,10 @@ func NewConnection(deviceID DeviceID, reader io.Reader, writer io.Writer, receiv
// Start creates the goroutines for sending and receiving of messages. It must
// be called exactly once after creating a connection.
func (c *rawConnection) Start() {
go c.readerLoop()
go func() {
err := c.readerLoop()
c.internalClose(err)
}()
go c.writerLoop()
go c.pingSender()
go c.pingReceiver()
@@ -336,10 +338,6 @@ func (c *rawConnection) ping() bool {
}
func (c *rawConnection) readerLoop() (err error) {
defer func() {
c.internalClose(err)
}()
fourByteBuf := make([]byte, 4)
state := stateInitial
for {

View File

@@ -69,8 +69,8 @@ func TestClose(t *testing.T) {
t.Error("Ping should not return true")
}
c0.Index("default", nil)
c0.Index("default", nil)
_ = c0.Index("default", nil)
_ = c0.Index("default", nil)
if _, err := c0.Request("default", "foo", 0, 0, nil, 0, false); err == nil {
t.Error("Request should return an error")
@@ -225,8 +225,8 @@ func testMarshal(t *testing.T, prefix string, m1, m2 message) bool {
bs1, _ := json.MarshalIndent(m1, "", " ")
bs2, _ := json.MarshalIndent(m2, "", " ")
if !bytes.Equal(bs1, bs2) {
ioutil.WriteFile(prefix+"-1.txt", bs1, 0644)
ioutil.WriteFile(prefix+"-2.txt", bs2, 0644)
_ = ioutil.WriteFile(prefix+"-1.txt", bs1, 0644)
_ = ioutil.WriteFile(prefix+"-2.txt", bs2, 0644)
return false
}