diff --git a/netascii/netascii_test.go b/netascii/netascii_test.go index 7dab8cc..16cdf95 100644 --- a/netascii/netascii_test.go +++ b/netascii/netascii_test.go @@ -21,7 +21,7 @@ func TestTo(t *testing.T) { for text, netascii := range basic { to := ToReader(strings.NewReader(text)) n, _ := ioutil.ReadAll(to) - if bytes.Compare(n, []byte(netascii)) != 0 { + if !bytes.Equal(n, []byte(netascii)) { t.Errorf("%q to netascii: %q != %q", text, n, netascii) } } diff --git a/receiver.go b/receiver.go index 7389d5f..9a25e99 100644 --- a/receiver.go +++ b/receiver.go @@ -248,7 +248,7 @@ func (r *receiver) buildTransferStats() TransferStats { Tid: r.tid, Mode: r.mode, Opts: r.opts, - Duration: time.Now().Sub(r.startTime), + Duration: time.Since(r.startTime), DatagramsSent: r.datagramsSent, DatagramsAcked: r.datagramsAcked, } diff --git a/sender.go b/sender.go index cee468a..de9d673 100644 --- a/sender.go +++ b/sender.go @@ -262,15 +262,15 @@ func (s *sender) sendDatagram(l int) (*net.UDPAddr, error) { func (s *sender) buildTransferStats() TransferStats { return TransferStats{ - RemoteAddr: s.addr.IP, - Filename: s.filename, - Tid: s.tid, + RemoteAddr: s.addr.IP, + Filename: s.filename, + Tid: s.tid, SenderAnticipateEnabled: s.sendA.enabled, - Mode: s.mode, - Opts: s.opts, - Duration: time.Now().Sub(s.startTime), - DatagramsSent: s.datagramsSent, - DatagramsAcked: s.datagramsAcked, + Mode: s.mode, + Opts: s.opts, + Duration: time.Since(s.startTime), + DatagramsSent: s.datagramsSent, + DatagramsAcked: s.datagramsAcked, } } diff --git a/server.go b/server.go index 8e06b55..5299161 100644 --- a/server.go +++ b/server.go @@ -36,7 +36,7 @@ func NewServer(readHandler func(filename string, rf io.ReaderFrom) error, // OS providing methods to inspect the underlying UDP and IP packets // directly. type RequestPacketInfo interface { - // LocalAddr returns the IP address we are servicing the request on. + // LocalIP returns the IP address we are servicing the request on. // If it is unable to determine what address that is, the returned // net.IP will be nil. LocalIP() net.IP diff --git a/tftp_test.go b/tftp_test.go index 12bb33b..3b57feb 100644 --- a/tftp_test.go +++ b/tftp_test.go @@ -94,15 +94,13 @@ func packUnpack(t *testing.T, filename, mode string, opts options) { t.Errorf("mode mismatch (%s): '%x' vs '%x'", mode, m, mode) } - if opts != nil { - for name, value := range opts { - v, ok := o[name] - if !ok { - t.Errorf("missing %s option", name) - } - if v != value { - t.Errorf("option %s mismatch: '%x' vs '%x'", name, v, value) - } + for name, value := range opts { + v, ok := o[name] + if !ok { + t.Errorf("missing %s option", name) + } + if v != value { + t.Errorf("option %s mismatch: '%x' vs '%x'", name, v, value) } } }