Skip to content

Commit 701f927

Browse files
committed
gofumpt code
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 3642538 commit 701f927

Some content is hidden

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

66 files changed

+495
-448
lines changed

addr_linux.go

+6-3
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

+5-6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ func DoTestAddr(t *testing.T, FunctionUndertest func(Link, *Addr) error) {
2626
}
2727
// TODO: IFA_F_PERMANENT does not seem to be set by default on older kernels?
2828
// TODO: IFA_F_OPTIMISTIC failing in CI. should we just skip that one check?
29-
var address = &net.IPNet{IP: net.IPv4(127, 0, 0, 2), Mask: net.CIDRMask(32, 32)}
30-
var peer = &net.IPNet{IP: net.IPv4(127, 0, 0, 3), Mask: net.CIDRMask(24, 32)}
31-
var addrTests = []struct {
29+
address := &net.IPNet{IP: net.IPv4(127, 0, 0, 2), Mask: net.CIDRMask(32, 32)}
30+
peer := &net.IPNet{IP: net.IPv4(127, 0, 0, 3), Mask: net.CIDRMask(24, 32)}
31+
addrTests := []struct {
3232
addr *Addr
3333
expected *Addr
3434
}{
@@ -138,16 +138,15 @@ func DoTestAddr(t *testing.T, FunctionUndertest func(Link, *Addr) error) {
138138
t.Fatal("Address not removed properly")
139139
}
140140
}
141-
142141
}
143142

144143
func TestAddrAddReplace(t *testing.T) {
145144
tearDown := setUpNetlinkTest(t)
146145
defer tearDown()
147146

148147
for _, nilLink := range []bool{false, true} {
149-
var address = &net.IPNet{IP: net.IPv4(127, 0, 0, 2), Mask: net.CIDRMask(24, 32)}
150-
var addr = &Addr{IPNet: address}
148+
address := &net.IPNet{IP: net.IPv4(127, 0, 0, 2), Mask: net.CIDRMask(24, 32)}
149+
addr := &Addr{IPNet: address}
151150

152151
link, err := LinkByName("lo")
153152
if err != nil {

bridge_linux.go

+2-2
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

+1-1
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

-1
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

+15-13
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,12 @@ type ProtoInfo interface {
223223
type ProtoInfoTCP struct {
224224
State uint8
225225
}
226+
226227
// Protocol returns "tcp".
227-
func (*ProtoInfoTCP) Protocol() string {return "tcp"}
228+
func (*ProtoInfoTCP) Protocol() string { return "tcp" }
229+
228230
func (p *ProtoInfoTCP) toNlData() ([]*nl.RtAttr, error) {
229-
ctProtoInfo := nl.NewRtAttr(unix.NLA_F_NESTED | nl.CTA_PROTOINFO, []byte{})
231+
ctProtoInfo := nl.NewRtAttr(unix.NLA_F_NESTED|nl.CTA_PROTOINFO, []byte{})
230232
ctProtoInfoTCP := nl.NewRtAttr(unix.NLA_F_NESTED|nl.CTA_PROTOINFO_TCP, []byte{})
231233
ctProtoInfoTCPState := nl.NewRtAttr(nl.CTA_PROTOINFO_TCP_STATE, nl.Uint8Attr(p.State))
232234
ctProtoInfoTCP.AddChild(ctProtoInfoTCPState)
@@ -236,14 +238,16 @@ func (p *ProtoInfoTCP) toNlData() ([]*nl.RtAttr, error) {
236238
}
237239

238240
// ProtoInfoSCTP only supports the protocol name.
239-
type ProtoInfoSCTP struct {}
241+
type ProtoInfoSCTP struct{}
242+
240243
// Protocol returns "sctp".
241-
func (*ProtoInfoSCTP) Protocol() string {return "sctp"}
244+
func (*ProtoInfoSCTP) Protocol() string { return "sctp" }
242245

243246
// ProtoInfoDCCP only supports the protocol name.
244-
type ProtoInfoDCCP struct {}
247+
type ProtoInfoDCCP struct{}
248+
245249
// Protocol returns "dccp".
246-
func (*ProtoInfoDCCP) Protocol() string {return "dccp"}
250+
func (*ProtoInfoDCCP) Protocol() string { return "dccp" }
247251

248252
// The full conntrack flow structure is very complicated and can be found in the file:
249253
// http://git.netfilter.org/libnetfilter_conntrack/tree/include/internal/object.h
@@ -261,7 +265,6 @@ type IPTuple struct {
261265
// toNlData generates the inner fields of a nested tuple netlink datastructure
262266
// does not generate the "nested"-flagged outer message.
263267
func (t *IPTuple) toNlData(family uint8) ([]*nl.RtAttr, error) {
264-
265268
var srcIPsFlag, dstIPsFlag int
266269
if family == nl.FAMILY_V4 {
267270
srcIPsFlag = nl.CTA_IP_V4_SRC
@@ -285,7 +288,7 @@ func (t *IPTuple) toNlData(family uint8) ([]*nl.RtAttr, error) {
285288
ctTupleProtoSrcPort := nl.NewRtAttr(nl.CTA_PROTO_SRC_PORT, nl.BEUint16Attr(t.SrcPort))
286289
ctTupleProto.AddChild(ctTupleProtoSrcPort)
287290
ctTupleProtoDstPort := nl.NewRtAttr(nl.CTA_PROTO_DST_PORT, nl.BEUint16Attr(t.DstPort))
288-
ctTupleProto.AddChild(ctTupleProtoDstPort, )
291+
ctTupleProto.AddChild(ctTupleProtoDstPort)
289292

290293
return []*nl.RtAttr{ctTupleIP, ctTupleProto}, nil
291294
}
@@ -362,7 +365,7 @@ func (s *ConntrackFlow) toNlData() ([]*nl.RtAttr, error) {
362365
// <len, CTA_TIMEOUT>
363366
// <BEuint64>
364367
// <len, NLA_F_NESTED|CTA_PROTOINFO>
365-
368+
366369
// CTA_TUPLE_ORIG
367370
ctTupleOrig := nl.NewRtAttr(unix.NLA_F_NESTED|nl.CTA_TUPLE_ORIG, nil)
368371
forwardFlowAttrs, err := s.Forward.toNlData(s.FamilyType)
@@ -540,17 +543,16 @@ func parseTimeStamp(r *bytes.Reader, readSize uint16) (tstart, tstop uint64) {
540543
}
541544
}
542545
return
543-
544546
}
545547

546548
func parseProtoInfoTCPState(r *bytes.Reader) (s uint8) {
547549
binary.Read(r, binary.BigEndian, &s)
548-
r.Seek(nl.SizeofNfattr - 1, seekCurrent)
550+
r.Seek(nl.SizeofNfattr-1, seekCurrent)
549551
return s
550552
}
551553

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

0 commit comments

Comments
 (0)