From 023a6dafdcdfa7068ac83b260ab7f03cd4131aca Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Tue, 30 Oct 2018 00:13:14 +0100 Subject: [PATCH] Make go vet happier --- filter_linux.go | 2 +- link_linux.go | 4 ++-- link_test.go | 16 ++++++++-------- netlink_test.go | 2 +- netns_test.go | 2 +- nl/seg6_linux.go | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/filter_linux.go b/filter_linux.go index f99c89e..90084fa 100644 --- a/filter_linux.go +++ b/filter_linux.go @@ -174,7 +174,7 @@ func (h *Handle) FilterAdd(filter Filter) error { } if filter.Divisor != 0 { if (filter.Divisor-1)&filter.Divisor != 0 { - return fmt.Errorf("illegal divisor %d. Must be a power of 2.", filter.Divisor) + return fmt.Errorf("illegal divisor %d. Must be a power of 2", filter.Divisor) } options.AddRtAttr(nl.TCA_U32_DIVISOR, nl.Uint32Attr(filter.Divisor)) } diff --git a/link_linux.go b/link_linux.go index 5ef7304..4c638c9 100644 --- a/link_linux.go +++ b/link_linux.go @@ -956,14 +956,14 @@ func (h *Handle) linkModify(link Link, flags int) error { tuntap, isTuntap := link.(*Tuntap) if base.Name == "" && !isTuntap { - return fmt.Errorf("LinkAttrs.Name cannot be empty!") + return fmt.Errorf("LinkAttrs.Name cannot be empty") } if isTuntap { // TODO: support user // TODO: support group if tuntap.Mode < unix.IFF_TUN || tuntap.Mode > unix.IFF_TAP { - return fmt.Errorf("Tuntap.Mode %v unknown!", tuntap.Mode) + return fmt.Errorf("Tuntap.Mode %v unknown", tuntap.Mode) } queues := tuntap.Queues diff --git a/link_test.go b/link_test.go index d1ca9f8..11c3b30 100644 --- a/link_test.go +++ b/link_test.go @@ -1087,7 +1087,7 @@ func TestLinkSet(t *testing.T) { } if link.Attrs().MTU != 1400 { - t.Fatal("MTU not changed!") + t.Fatal("MTU not changed") } err = LinkSetTxQLen(link, 500) @@ -1101,7 +1101,7 @@ func TestLinkSet(t *testing.T) { } if link.Attrs().TxQLen != 500 { - t.Fatal("txqlen not changed!") + t.Fatal("txqlen not changed") } addr, err := net.ParseMAC("00:12:34:56:78:AB") @@ -1120,7 +1120,7 @@ func TestLinkSet(t *testing.T) { } if !bytes.Equal(link.Attrs().HardwareAddr, addr) { - t.Fatalf("hardware address not changed!") + t.Fatalf("hardware address not changed") } err = LinkSetAlias(link, "barAlias") @@ -1134,7 +1134,7 @@ func TestLinkSet(t *testing.T) { } if link.Attrs().Alias != "barAlias" { - t.Fatalf("alias not changed!") + t.Fatalf("alias not changed") } link, err = LinkByAlias("barAlias") @@ -1168,7 +1168,7 @@ func TestLinkSetARP(t *testing.T) { } if link.Attrs().RawFlags&unix.IFF_NOARP != uint32(unix.IFF_NOARP) { - t.Fatalf("NOARP was not set!") + t.Fatalf("NOARP was not set") } err = LinkSetARPOn(link) @@ -1182,7 +1182,7 @@ func TestLinkSetARP(t *testing.T) { } if link.Attrs().RawFlags&unix.IFF_NOARP != 0 { - t.Fatalf("NOARP is still set!") + t.Fatalf("NOARP is still set") } } @@ -1958,7 +1958,7 @@ func TestLinkSetAllmulticast(t *testing.T) { } if link.Attrs().RawFlags&unix.IFF_ALLMULTI != uint32(unix.IFF_ALLMULTI) { - t.Fatal("IFF_ALLMULTI was not set!") + t.Fatal("IFF_ALLMULTI was not set") } if err := LinkSetAllmulticastOff(link); err != nil { @@ -1971,7 +1971,7 @@ func TestLinkSetAllmulticast(t *testing.T) { } if link.Attrs().RawFlags&unix.IFF_ALLMULTI != 0 { - t.Fatal("IFF_ALLMULTI is still set!") + t.Fatal("IFF_ALLMULTI is still set") } rawFlagsEnd := link.Attrs().RawFlags diff --git a/netlink_test.go b/netlink_test.go index 5c0ad38..f64c84e 100644 --- a/netlink_test.go +++ b/netlink_test.go @@ -106,7 +106,7 @@ func setUpSEG6NetlinkTest(t *testing.T) tearDownNetlinkTest { key := string("CONFIG_IPV6_SEG6_LWTUNNEL=y") if _, err := grepKey(key, filename); err != nil { msg := "Skipped test because it requires SEG6_LWTUNNEL support." - log.Printf(msg) + log.Println(msg) t.Skip(msg) } // Add CONFIG_IPV6_SEG6_HMAC to support seg6_hamc diff --git a/netns_test.go b/netns_test.go index 3415b9b..37a3afb 100644 --- a/netns_test.go +++ b/netns_test.go @@ -56,7 +56,7 @@ func TestNetNsIdByPid(t *testing.T) { defer func() { err := netns.Set(origNs) if err != nil { - panic("failed to restore network ns, bailing!") + panic("failed to restore network ns, bailing") } runtime.UnlockOSThread() }() diff --git a/nl/seg6_linux.go b/nl/seg6_linux.go index d11fea7..5774cbb 100644 --- a/nl/seg6_linux.go +++ b/nl/seg6_linux.go @@ -112,7 +112,7 @@ func DecodeSEG6Srh(buf []byte) ([]net.IP, error) { } buf = buf[8:] if len(buf)%16 != 0 { - err := fmt.Errorf("DecodeSEG6Srh: error parsing Segment List (buf len: %d)\n", len(buf)) + err := fmt.Errorf("DecodeSEG6Srh: error parsing Segment List (buf len: %d)", len(buf)) return nil, err } for len(buf) > 0 { @@ -124,7 +124,7 @@ func DecodeSEG6Srh(buf []byte) ([]net.IP, error) { func EncodeSEG6Srh(segments []net.IP) ([]byte, error) { nsegs := len(segments) // nsegs: number of segments if nsegs == 0 { - return nil, errors.New("EncodeSEG6Srh: No Segments\n") + return nil, errors.New("EncodeSEG6Srh: No Segments") } b := make([]byte, 8, 8+len(segments)*16) native := NativeEndian()