Remove ToString0[T] usage to fix golangci-lint

This commit is contained in:
世界 2022-07-10 22:00:28 +08:00
parent 0ef2e330e3
commit 6048b1e270
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
24 changed files with 59 additions and 99 deletions

View file

@ -414,7 +414,7 @@ func (r *Router) RouteConnection(ctx context.Context, conn net.Conn, metadata ad
return err
}
metadata.DestinationAddresses = addresses
r.dnsLogger.WithContext(ctx).Info("resolved [", strings.Join(common.Map(metadata.DestinationAddresses, F.ToString0[netip.Addr]), " "), "]")
r.dnsLogger.WithContext(ctx).Info("resolved [", strings.Join(F.MapToString(metadata.DestinationAddresses), " "), "]")
}
detour := r.match(ctx, metadata, r.defaultOutboundForConnection)
if !common.Contains(detour.Network(), C.NetworkTCP) {
@ -456,7 +456,7 @@ func (r *Router) RoutePacketConnection(ctx context.Context, conn N.PacketConn, m
return err
}
metadata.DestinationAddresses = addresses
r.dnsLogger.WithContext(ctx).Info("resolved [", strings.Join(common.Map(metadata.DestinationAddresses, F.ToString0[netip.Addr]), " "), "]")
r.dnsLogger.WithContext(ctx).Info("resolved [", strings.Join(F.MapToString(metadata.DestinationAddresses), " "), "]")
}
detour := r.match(ctx, metadata, r.defaultOutboundForPacketConnection)
if !common.Contains(detour.Network(), C.NetworkUDP) {

View file

@ -222,7 +222,7 @@ func (r *DefaultRule) Outbound() string {
}
func (r *DefaultRule) String() string {
return strings.Join(common.Map(r.allItems, F.ToString0[RuleItem]), " ")
return strings.Join(F.MapToString(r.allItems), " ")
}
var _ adapter.Rule = (*LogicalRule)(nil)
@ -310,5 +310,5 @@ func (r *LogicalRule) String() string {
case C.LogicalTypeOr:
op = "||"
}
return "logical(" + strings.Join(common.Map(r.rules, F.ToString0[*DefaultRule]), " "+op+" ") + ")"
return "logical(" + strings.Join(F.MapToString(r.rules), " "+op+" ") + ")"
}

View file

@ -5,7 +5,6 @@ import (
"strings"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing/common"
E "github.com/sagernet/sing/common/exceptions"
F "github.com/sagernet/sing/common/format"
)
@ -70,7 +69,7 @@ func (r *IPCIDRItem) String() string {
if pLen == 1 {
description += r.prefixes[0].String()
} else {
description += "[" + strings.Join(common.Map(r.prefixes, F.ToString0[netip.Prefix]), " ") + "]"
description += "[" + strings.Join(F.MapToString(r.prefixes), " ") + "]"
}
return description
}

View file

@ -183,7 +183,7 @@ func (r *DefaultDNSRule) Outbound() string {
}
func (r *DefaultDNSRule) String() string {
return strings.Join(common.Map(r.allItems, F.ToString0[RuleItem]), " ")
return strings.Join(F.MapToString(r.allItems), " ")
}
var _ adapter.Rule = (*LogicalRule)(nil)
@ -271,5 +271,5 @@ func (r *LogicalDNSRule) String() string {
case C.LogicalTypeOr:
op = "||"
}
return "logical(" + strings.Join(common.Map(r.rules, F.ToString0[*DefaultDNSRule]), " "+op+" ") + ")"
return "logical(" + strings.Join(F.MapToString(r.rules), " "+op+" ") + ")"
}

View file

@ -26,7 +26,7 @@ func NewGeositeItem(router adapter.Router, logger log.Logger, codes []string) *G
}
func (r *GeositeItem) Update() error {
var matchers []adapter.Rule
matchers := make([]adapter.Rule, 0, len(r.codes))
for _, code := range r.codes {
matcher, err := r.router.LoadGeosite(code)
if err != nil {

View file

@ -4,7 +4,6 @@ import (
"strings"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing/common"
F "github.com/sagernet/sing/common/format"
)
@ -47,7 +46,7 @@ func (r *PortItem) String() string {
if pLen == 1 {
description += F.ToString(r.ports[0])
} else {
description += "[" + strings.Join(common.Map(r.ports, F.ToString0[uint16]), " ") + "]"
description += "[" + strings.Join(F.MapToString(r.ports), " ") + "]"
}
return description
}