Skip to content

Commit 92dcdba

Browse files
committed
gofumpt code
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 65a253d commit 92dcdba

Some content is hidden

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

69 files changed

+505
-457
lines changed

addr_linux.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,15 @@ func addrSubscribeAt(newNs, curNs netns.NsHandle, ch chan<- AddrUpdate, done <-c
410410
continue
411411
}
412412

413-
ch <- AddrUpdate{LinkAddress: *addr.IPNet,
413+
ch <- AddrUpdate{
414+
LinkAddress: *addr.IPNet,
414415
LinkIndex: addr.LinkIndex,
415416
NewAddr: msgType == unix.RTM_NEWADDR,
416417
Flags: addr.Flags,
417418
Scope: addr.Scope,
418419
PreferedLft: addr.PreferedLft,
419-
ValidLft: addr.ValidLft}
420+
ValidLft: addr.ValidLft,
421+
}
420422
}
421423
}
422424
}()

addr_test.go

Lines changed: 5 additions & 6 deletions
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (h *Handle) BridgeVlanList() (map[int32][]*nl.BridgeVlanInfo, error) {
3636
for _, attr := range attrs {
3737
switch attr.Attr.Type {
3838
case unix.IFLA_AF_SPEC:
39-
//nested attr
39+
// nested attr
4040
nestAttrs, err := nl.ParseRouteAttr(attr.Value)
4141
if err != nil {
4242
return nil, fmt.Errorf("failed to parse nested attr %v", err)
@@ -139,7 +139,7 @@ func (h *Handle) bridgeVlanModify(cmd int, link Link, vid, vidEnd uint16, pvid,
139139

140140
vlanEndInfo.Flags |= nl.BRIDGE_VLAN_INFO_RANGE_END
141141
br.AddRtAttr(nl.IFLA_BRIDGE_VLAN_INFO, vlanEndInfo.Serialize())
142-
} else {
142+
} else {
143143
br.AddRtAttr(nl.IFLA_BRIDGE_VLAN_INFO, vlanInfo.Serialize())
144144
}
145145

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
@@ -196,10 +196,12 @@ type ProtoInfo interface {
196196
type ProtoInfoTCP struct {
197197
State uint8
198198
}
199+
199200
// Protocol returns "tcp".
200-
func (*ProtoInfoTCP) Protocol() string {return "tcp"}
201+
func (*ProtoInfoTCP) Protocol() string { return "tcp" }
202+
201203
func (p *ProtoInfoTCP) toNlData() ([]*nl.RtAttr, error) {
202-
ctProtoInfo := nl.NewRtAttr(unix.NLA_F_NESTED | nl.CTA_PROTOINFO, []byte{})
204+
ctProtoInfo := nl.NewRtAttr(unix.NLA_F_NESTED|nl.CTA_PROTOINFO, []byte{})
203205
ctProtoInfoTCP := nl.NewRtAttr(unix.NLA_F_NESTED|nl.CTA_PROTOINFO_TCP, []byte{})
204206
ctProtoInfoTCPState := nl.NewRtAttr(nl.CTA_PROTOINFO_TCP_STATE, nl.Uint8Attr(p.State))
205207
ctProtoInfoTCP.AddChild(ctProtoInfoTCPState)
@@ -209,14 +211,16 @@ func (p *ProtoInfoTCP) toNlData() ([]*nl.RtAttr, error) {
209211
}
210212

211213
// ProtoInfoSCTP only supports the protocol name.
212-
type ProtoInfoSCTP struct {}
214+
type ProtoInfoSCTP struct{}
215+
213216
// Protocol returns "sctp".
214-
func (*ProtoInfoSCTP) Protocol() string {return "sctp"}
217+
func (*ProtoInfoSCTP) Protocol() string { return "sctp" }
215218

216219
// ProtoInfoDCCP only supports the protocol name.
217-
type ProtoInfoDCCP struct {}
220+
type ProtoInfoDCCP struct{}
221+
218222
// Protocol returns "dccp".
219-
func (*ProtoInfoDCCP) Protocol() string {return "dccp"}
223+
func (*ProtoInfoDCCP) Protocol() string { return "dccp" }
220224

221225
// The full conntrack flow structure is very complicated and can be found in the file:
222226
// http://git.netfilter.org/libnetfilter_conntrack/tree/include/internal/object.h
@@ -234,7 +238,6 @@ type IPTuple struct {
234238
// toNlData generates the inner fields of a nested tuple netlink datastructure
235239
// does not generate the "nested"-flagged outer message.
236240
func (t *IPTuple) toNlData(family uint8) ([]*nl.RtAttr, error) {
237-
238241
var srcIPsFlag, dstIPsFlag int
239242
if family == nl.FAMILY_V4 {
240243
srcIPsFlag = nl.CTA_IP_V4_SRC
@@ -258,7 +261,7 @@ func (t *IPTuple) toNlData(family uint8) ([]*nl.RtAttr, error) {
258261
ctTupleProtoSrcPort := nl.NewRtAttr(nl.CTA_PROTO_SRC_PORT, nl.BEUint16Attr(t.SrcPort))
259262
ctTupleProto.AddChild(ctTupleProtoSrcPort)
260263
ctTupleProtoDstPort := nl.NewRtAttr(nl.CTA_PROTO_DST_PORT, nl.BEUint16Attr(t.DstPort))
261-
ctTupleProto.AddChild(ctTupleProtoDstPort, )
264+
ctTupleProto.AddChild(ctTupleProtoDstPort)
262265

263266
return []*nl.RtAttr{ctTupleIP, ctTupleProto}, nil
264267
}
@@ -335,7 +338,7 @@ func (s *ConntrackFlow) toNlData() ([]*nl.RtAttr, error) {
335338
// <len, CTA_TIMEOUT>
336339
// <BEuint64>
337340
// <len, NLA_F_NESTED|CTA_PROTOINFO>
338-
341+
339342
// CTA_TUPLE_ORIG
340343
ctTupleOrig := nl.NewRtAttr(unix.NLA_F_NESTED|nl.CTA_TUPLE_ORIG, nil)
341344
forwardFlowAttrs, err := s.Forward.toNlData(s.FamilyType)
@@ -513,17 +516,16 @@ func parseTimeStamp(r *bytes.Reader, readSize uint16) (tstart, tstop uint64) {
513516
}
514517
}
515518
return
516-
517519
}
518520

519521
func parseProtoInfoTCPState(r *bytes.Reader) (s uint8) {
520522
binary.Read(r, binary.BigEndian, &s)
521-
r.Seek(nl.SizeofNfattr - 1, seekCurrent)
523+
r.Seek(nl.SizeofNfattr-1, seekCurrent)
522524
return s
523525
}
524526

525527
// parseProtoInfoTCP reads the entire nested protoinfo structure, but only parses the state attr.
526-
func parseProtoInfoTCP(r *bytes.Reader, attrLen uint16) (*ProtoInfoTCP) {
528+
func parseProtoInfoTCP(r *bytes.Reader, attrLen uint16) *ProtoInfoTCP {
527529
p := new(ProtoInfoTCP)
528530
bytesRead := 0
529531
for bytesRead < int(attrLen) {
@@ -637,7 +639,7 @@ func parseRawData(data []byte) *ConntrackFlow {
637639
switch t {
638640
case nl.CTA_MARK:
639641
s.Mark = parseConnectionMark(reader)
640-
case nl.CTA_LABELS:
642+
case nl.CTA_LABELS:
641643
s.Labels = parseConnectionLabels(reader)
642644
case nl.CTA_TIMEOUT:
643645
s.TimeOut = parseTimeOut(reader)

0 commit comments

Comments
 (0)