Skip to content

Commit a4ecee5

Browse files
committed
gofumpt code
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 38b1229 commit a4ecee5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+496
-447
lines changed

addr_linux.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ func AddrSubscribeWithOptions(ch chan<- AddrUpdate, done <-chan struct{}, option
341341
}
342342

343343
func addrSubscribeAt(newNs, curNs netns.NsHandle, ch chan<- AddrUpdate, done <-chan struct{}, cberr func(error), listExisting bool,
344-
rcvbuf int, rcvTimeout *unix.Timeval, rcvBufForce bool) error {
344+
rcvbuf int, rcvTimeout *unix.Timeval, rcvBufForce bool,
345+
) error {
345346
s, err := nl.SubscribeAt(newNs, curNs, unix.NETLINK_ROUTE, unix.RTNLGRP_IPV4_IFADDR, unix.RTNLGRP_IPV6_IFADDR)
346347
if err != nil {
347348
return err
@@ -420,13 +421,15 @@ func addrSubscribeAt(newNs, curNs netns.NsHandle, ch chan<- AddrUpdate, done <-c
420421
continue
421422
}
422423

423-
ch <- AddrUpdate{LinkAddress: *addr.IPNet,
424+
ch <- AddrUpdate{
425+
LinkAddress: *addr.IPNet,
424426
LinkIndex: addr.LinkIndex,
425427
NewAddr: msgType == unix.RTM_NEWADDR,
426428
Flags: addr.Flags,
427429
Scope: addr.Scope,
428430
PreferedLft: addr.PreferedLft,
429-
ValidLft: addr.ValidLft}
431+
ValidLft: addr.ValidLft,
432+
}
430433
}
431434
}
432435
}()

addr_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ func DoTestAddr(t *testing.T, FunctionUndertest func(Link, *Addr) error) {
5353

5454
// TODO: IFA_F_PERMANENT does not seem to be set by default on older kernels?
5555
// TODO: IFA_F_OPTIMISTIC failing in CI. should we just skip that one check?
56-
var address = &net.IPNet{IP: net.IPv4(127, 0, 0, 2), Mask: net.CIDRMask(32, 32)}
57-
var peer = &net.IPNet{IP: net.IPv4(127, 0, 0, 3), Mask: net.CIDRMask(24, 32)}
58-
var addrTests = []addrTest{
56+
address := &net.IPNet{IP: net.IPv4(127, 0, 0, 2), Mask: net.CIDRMask(32, 32)}
57+
peer := &net.IPNet{IP: net.IPv4(127, 0, 0, 3), Mask: net.CIDRMask(24, 32)}
58+
addrTests := []addrTest{
5959
{
6060
name: "lo_uni_perm", addr: &Addr{IPNet: address},
6161
expected: &Addr{IPNet: address, Label: "lo", Scope: unix.RT_SCOPE_UNIVERSE, Flags: unix.IFA_F_PERMANENT},
@@ -167,16 +167,15 @@ func DoTestAddr(t *testing.T, FunctionUndertest func(Link, *Addr) error) {
167167
}
168168
})
169169
}
170-
171170
}
172171

173172
func TestAddrAddReplace(t *testing.T) {
174173
tearDown := setUpNetlinkTest(t)
175174
defer tearDown()
176175

177176
for _, nilLink := range []bool{false, true} {
178-
var address = &net.IPNet{IP: net.IPv4(127, 0, 0, 2), Mask: net.CIDRMask(24, 32)}
179-
var addr = &Addr{IPNet: address}
177+
address := &net.IPNet{IP: net.IPv4(127, 0, 0, 2), Mask: net.CIDRMask(24, 32)}
178+
addr := &Addr{IPNet: address}
180179

181180
link, err := LinkByName("lo")
182181
if err != nil {

bridge_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (h *Handle) BridgeVlanList() (map[int32][]*nl.BridgeVlanInfo, error) {
4343
for _, attr := range attrs {
4444
switch attr.Attr.Type {
4545
case unix.IFLA_AF_SPEC:
46-
//nested attr
46+
// nested attr
4747
nestAttrs, err := nl.ParseRouteAttr(attr.Value)
4848
if err != nil {
4949
return nil, fmt.Errorf("failed to parse nested attr %v", err)
@@ -146,7 +146,7 @@ func (h *Handle) bridgeVlanModify(cmd int, link Link, vid, vidEnd uint16, pvid,
146146

147147
vlanEndInfo.Flags |= nl.BRIDGE_VLAN_INFO_RANGE_END
148148
br.AddRtAttr(nl.IFLA_BRIDGE_VLAN_INFO, vlanEndInfo.Serialize())
149-
} else {
149+
} else {
150150
br.AddRtAttr(nl.IFLA_BRIDGE_VLAN_INFO, vlanInfo.Serialize())
151151
}
152152

bridge_linux_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestBridgeVlan(t *testing.T) {
8080
}
8181

8282
func TestBridgeGroupFwdMask(t *testing.T) {
83-
minKernelRequired(t, 4, 15) //minimal release for per-port group_fwd_mask
83+
minKernelRequired(t, 4, 15) // minimal release for per-port group_fwd_mask
8484
tearDown := setUpNetlinkTest(t)
8585
defer tearDown()
8686
if err := remountSysfs(); err != nil {

class_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,5 +679,4 @@ func TestClassHfsc(t *testing.T) {
679679
if err := ClassChange(hfscClass); err != nil {
680680
t.Fatal(err)
681681
}
682-
683682
}

conntrack_linux.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,12 @@ type ProtoInfo interface {
225225
type ProtoInfoTCP struct {
226226
State uint8
227227
}
228+
228229
// Protocol returns "tcp".
229-
func (*ProtoInfoTCP) Protocol() string {return "tcp"}
230+
func (*ProtoInfoTCP) Protocol() string { return "tcp" }
231+
230232
func (p *ProtoInfoTCP) toNlData() ([]*nl.RtAttr, error) {
231-
ctProtoInfo := nl.NewRtAttr(unix.NLA_F_NESTED | nl.CTA_PROTOINFO, []byte{})
233+
ctProtoInfo := nl.NewRtAttr(unix.NLA_F_NESTED|nl.CTA_PROTOINFO, []byte{})
232234
ctProtoInfoTCP := nl.NewRtAttr(unix.NLA_F_NESTED|nl.CTA_PROTOINFO_TCP, []byte{})
233235
ctProtoInfoTCPState := nl.NewRtAttr(nl.CTA_PROTOINFO_TCP_STATE, nl.Uint8Attr(p.State))
234236
ctProtoInfoTCP.AddChild(ctProtoInfoTCPState)
@@ -238,14 +240,16 @@ func (p *ProtoInfoTCP) toNlData() ([]*nl.RtAttr, error) {
238240
}
239241

240242
// ProtoInfoSCTP only supports the protocol name.
241-
type ProtoInfoSCTP struct {}
243+
type ProtoInfoSCTP struct{}
244+
242245
// Protocol returns "sctp".
243-
func (*ProtoInfoSCTP) Protocol() string {return "sctp"}
246+
func (*ProtoInfoSCTP) Protocol() string { return "sctp" }
244247

245248
// ProtoInfoDCCP only supports the protocol name.
246-
type ProtoInfoDCCP struct {}
249+
type ProtoInfoDCCP struct{}
250+
247251
// Protocol returns "dccp".
248-
func (*ProtoInfoDCCP) Protocol() string {return "dccp"}
252+
func (*ProtoInfoDCCP) Protocol() string { return "dccp" }
249253

250254
// The full conntrack flow structure is very complicated and can be found in the file:
251255
// http://git.netfilter.org/libnetfilter_conntrack/tree/include/internal/object.h
@@ -263,7 +267,6 @@ type IPTuple struct {
263267
// toNlData generates the inner fields of a nested tuple netlink datastructure
264268
// does not generate the "nested"-flagged outer message.
265269
func (t *IPTuple) toNlData(family uint8) ([]*nl.RtAttr, error) {
266-
267270
var srcIPsFlag, dstIPsFlag int
268271
if family == nl.FAMILY_V4 {
269272
srcIPsFlag = nl.CTA_IP_V4_SRC
@@ -287,7 +290,7 @@ func (t *IPTuple) toNlData(family uint8) ([]*nl.RtAttr, error) {
287290
ctTupleProtoSrcPort := nl.NewRtAttr(nl.CTA_PROTO_SRC_PORT, nl.BEUint16Attr(t.SrcPort))
288291
ctTupleProto.AddChild(ctTupleProtoSrcPort)
289292
ctTupleProtoDstPort := nl.NewRtAttr(nl.CTA_PROTO_DST_PORT, nl.BEUint16Attr(t.DstPort))
290-
ctTupleProto.AddChild(ctTupleProtoDstPort, )
293+
ctTupleProto.AddChild(ctTupleProtoDstPort)
291294

292295
return []*nl.RtAttr{ctTupleIP, ctTupleProto}, nil
293296
}
@@ -364,7 +367,7 @@ func (s *ConntrackFlow) toNlData() ([]*nl.RtAttr, error) {
364367
// <len, CTA_TIMEOUT>
365368
// <BEuint64>
366369
// <len, NLA_F_NESTED|CTA_PROTOINFO>
367-
370+
368371
// CTA_TUPLE_ORIG
369372
ctTupleOrig := nl.NewRtAttr(unix.NLA_F_NESTED|nl.CTA_TUPLE_ORIG, nil)
370373
forwardFlowAttrs, err := s.Forward.toNlData(s.FamilyType)
@@ -542,17 +545,16 @@ func parseTimeStamp(r *bytes.Reader, readSize uint16) (tstart, tstop uint64) {
542545
}
543546
}
544547
return
545-
546548
}
547549

548550
func parseProtoInfoTCPState(r *bytes.Reader) (s uint8) {
549551
binary.Read(r, binary.BigEndian, &s)
550-
r.Seek(nl.SizeofNfattr - 1, seekCurrent)
552+
r.Seek(nl.SizeofNfattr-1, seekCurrent)
551553
return s
552554
}
553555

554556
// parseProtoInfoTCP reads the entire nested protoinfo structure, but only parses the state attr.
555-
func parseProtoInfoTCP(r *bytes.Reader, attrLen uint16) (*ProtoInfoTCP) {
557+
func parseProtoInfoTCP(r *bytes.Reader, attrLen uint16) *ProtoInfoTCP {
556558
p := new(ProtoInfoTCP)
557559
bytesRead := 0
558560
for bytesRead < int(attrLen) {
@@ -666,7 +668,7 @@ func parseRawData(data []byte) *ConntrackFlow {
666668
switch t {
667669
case nl.CTA_MARK:
668670
s.Mark = parseConnectionMark(reader)
669-
case nl.CTA_LABELS:
671+
case nl.CTA_LABELS:
670672
s.Labels = parseConnectionLabels(reader)
671673
case nl.CTA_TIMEOUT:
672674
s.TimeOut = parseTimeOut(reader)

0 commit comments

Comments
 (0)