Skip to content

Commit

Permalink
replaced strings.Join usage with join func
Browse files Browse the repository at this point in the history
  • Loading branch information
dreadl0ck committed Jan 12, 2019
1 parent 53ee0ab commit 582d271
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 43 deletions.
2 changes: 1 addition & 1 deletion types/ciscoDiscovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (a CiscoDiscovery) CSVRecord() []string {
formatInt32(a.Version), // int32
formatInt32(a.TTL), // int32
formatInt32(a.Checksum), // int32
strings.Join(vals, "|"), // []*CiscoDiscoveryValue
join(vals...), // []*CiscoDiscoveryValue
})
}

Expand Down
54 changes: 27 additions & 27 deletions types/ciscoDiscoveryInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,32 +64,32 @@ func (a CiscoDiscoveryInfo) CSVRecord() []string {
}
return filter([]string{
formatTimestamp(a.Timestamp),
a.CDPHello.ToString(), // *CDPHello
a.DeviceID, // string
strings.Join(a.Addresses, "|"), // []string
a.PortID, // string
a.Capabilities.ToString(), // *CDPCapabilities
a.Version, // string
a.Platform, // string
strings.Join(ipNets, "|"), // []*IPNet
a.VTPDomain, // string
formatInt32(a.NativeVLAN), // int32
strconv.FormatBool(a.FullDuplex), // bool
a.VLANReply.ToString(), // *CDPVLANDialogue
a.VLANQuery.ToString(), // *CDPVLANDialogue
formatInt32(a.PowerConsumption), // int32
formatUint32(a.MTU), // uint32
formatInt32(a.ExtendedTrust), // int32
formatInt32(a.UntrustedCOS), // int32
a.SysName, // string
a.SysOID, // string
strings.Join(a.MgmtAddresses, "|"), // []string
a.Location.ToString(), // *CDPLocation
a.PowerRequest.ToString(), // *CDPPowerDialogue
a.PowerAvailable.ToString(), // *CDPPowerDialogue
a.SparePairPoe.ToString(), // *CDPSparePairPoE
a.EnergyWise.ToString(), // *CDPEnergyWise
strings.Join(vals, "|"), // []*CiscoDiscoveryValue
a.CDPHello.ToString(), // *CDPHello
a.DeviceID, // string
join(a.Addresses...), // []string
a.PortID, // string
a.Capabilities.ToString(), // *CDPCapabilities
a.Version, // string
a.Platform, // string
join(ipNets...), // []*IPNet
a.VTPDomain, // string
formatInt32(a.NativeVLAN), // int32
strconv.FormatBool(a.FullDuplex), // bool
a.VLANReply.ToString(), // *CDPVLANDialogue
a.VLANQuery.ToString(), // *CDPVLANDialogue
formatInt32(a.PowerConsumption), // int32
formatUint32(a.MTU), // uint32
formatInt32(a.ExtendedTrust), // int32
formatInt32(a.UntrustedCOS), // int32
a.SysName, // string
a.SysOID, // string
join(a.MgmtAddresses...), // []string
a.Location.ToString(), // *CDPLocation
a.PowerRequest.ToString(), // *CDPPowerDialogue
a.PowerAvailable.ToString(), // *CDPPowerDialogue
a.SparePairPoe.ToString(), // *CDPSparePairPoE
a.EnergyWise.ToString(), // *CDPEnergyWise
join(vals...), // []*CiscoDiscoveryValue
})
}

Expand Down Expand Up @@ -197,7 +197,7 @@ func (c CDPPowerDialogue) ToString() string {
b.WriteString(sep)
b.WriteString(formatInt32(c.MgmtID))
b.WriteString(sep)
b.WriteString(strings.Join(vals, "|"))
b.WriteString(join(vals...))
b.WriteString(end)

return b.String()
Expand Down
2 changes: 1 addition & 1 deletion types/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (q DNSResourceRecord) ToString() string {
b.WriteString(sep)
b.WriteString(q.MX.ToString())
b.WriteString(sep)
b.WriteString(strings.Join(txts, "/"))
b.WriteString(join(txts...))
b.WriteString(end)
return b.String()
}
Expand Down
6 changes: 1 addition & 5 deletions types/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@

package types

import (
"strings"
)

func (h HTTP) CSVHeader() []string {
return filter([]string{
"Timestamp",
Expand Down Expand Up @@ -44,7 +40,7 @@ func (h HTTP) CSVRecord() []string {
h.Host,
h.UserAgent,
h.Referer,
strings.Join(h.ReqCookies, "/"),
join(h.ReqCookies),
formatInt32(h.ReqContentLength),
h.URL,
formatInt32(h.ResContentLength),
Expand Down
4 changes: 2 additions & 2 deletions types/igmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (i IGMP) CSVRecord() []string {
strconv.FormatBool(i.SupressRouterProcessing), // bool
formatInt32(i.RobustnessValue), // int32
formatUint64(i.IntervalTime), // uint64
strings.Join(i.SourceAddresses, "/"), // []string
join(i.SourceAddresses...), // []string
formatInt32(i.NumberOfGroupRecords), // int32
formatInt32(i.NumberOfSources), // int32
strings.Join(records, ""), // []*IGMPv3GroupRecord
Expand All @@ -75,7 +75,7 @@ func (i IGMPv3GroupRecord) ToString() string {
b.WriteString(sep)
b.WriteString(i.MulticastAddress)
b.WriteString(sep)
b.WriteString(strings.Join(i.SourceAddresses, "/"))
b.WriteString(join(i.SourceAddresses...))
b.WriteString(end)

return b.String()
Expand Down
9 changes: 4 additions & 5 deletions types/lld.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package types

import (
"encoding/hex"
"strings"
)

func (l LinkLayerDiscovery) CSVHeader() []string {
Expand All @@ -35,10 +34,10 @@ func (l LinkLayerDiscovery) CSVRecord() []string {
}
return filter([]string{
formatTimestamp(l.Timestamp),
l.ChassisID.ToString(), // *LLDPChassisID
l.PortID.ToString(), // *LLDPPortID
formatInt32(l.TTL), // int32
strings.Join(values, "/"), // []*LinkLayerDiscoveryValue
l.ChassisID.ToString(), // *LLDPChassisID
l.PortID.ToString(), // *LLDPPortID
formatInt32(l.TTL), // int32
join(values...), // []*LinkLayerDiscoveryValue
})
}

Expand Down
3 changes: 1 addition & 2 deletions types/sip.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package types

import (
"strconv"
"strings"
)

func (s SIP) CSVHeader() []string {
Expand All @@ -32,7 +31,7 @@ func (s SIP) CSVRecord() []string {
s.Timestamp, // string `protobuf:"bytes,1,opt,name=Timestamp,proto3" json:"Timestamp,omitempty"`
formatInt32(s.Version), // int32 `protobuf:"varint,2,opt,name=Version,proto3" json:"Version,omitempty"`
formatInt32(s.Method), // int32 `protobuf:"varint,3,opt,name=Method,proto3" json:"Method,omitempty"`
strings.Join(s.Headers, "/"), // []string `protobuf:"bytes,4,rep,name=Headers,proto3" json:"Headers,omitempty"`
join(s.Headers...), // []string `protobuf:"bytes,4,rep,name=Headers,proto3" json:"Headers,omitempty"`
strconv.FormatBool(s.IsResponse), // bool `protobuf:"varint,5,opt,name=IsResponse,proto3" json:"IsResponse,omitempty"`
formatInt32(s.ResponseCode), // int32 `protobuf:"varint,6,opt,name=ResponseCode,proto3" json:"ResponseCode,omitempty"`
s.ResponseStatus, // string `protobuf
Expand Down

0 comments on commit 582d271

Please sign in to comment.