mirror of
https://github.com/coredns/coredns.git
synced 2025-09-21 05:31:03 +02:00
lint: enable prealloc (#7493)
This commit is contained in:
parent
4d3061a9c4
commit
359632a2f4
@ -14,6 +14,7 @@ linters:
|
|||||||
- ineffassign
|
- ineffassign
|
||||||
- intrange
|
- intrange
|
||||||
- nolintlint
|
- nolintlint
|
||||||
|
- prealloc
|
||||||
- protogetter
|
- protogetter
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- thelper
|
- thelper
|
||||||
|
@ -63,7 +63,7 @@ func newRules(key string, args []string) ([]Rule, error) {
|
|||||||
return nil, fmt.Errorf("unknown flag action=%s, should be set or clear", action)
|
return nil, fmt.Errorf("unknown flag action=%s, should be set or clear", action)
|
||||||
}
|
}
|
||||||
|
|
||||||
var rules []Rule
|
rules := make([]Rule, 0, len(args))
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
flag := strings.ToLower(arg)
|
flag := strings.ToLower(arg)
|
||||||
switch flag {
|
switch flag {
|
||||||
|
@ -224,8 +224,10 @@ func (k *Kubernetes) ExternalReverse(ip string) ([]msg.Service, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (k *Kubernetes) serviceRecordForExternalIP(ip string) []msg.Service {
|
func (k *Kubernetes) serviceRecordForExternalIP(ip string) []msg.Service {
|
||||||
var svcs []msg.Service
|
svcList := k.APIConn.SvcExtIndexReverse(ip)
|
||||||
for _, service := range k.APIConn.SvcExtIndexReverse(ip) {
|
svcLen := len(svcList)
|
||||||
|
svcs := make([]msg.Service, 0, svcLen)
|
||||||
|
for _, service := range svcList {
|
||||||
if len(k.Namespaces) > 0 && !k.namespaceExposed(service.Namespace) {
|
if len(k.Namespaces) > 0 && !k.namespaceExposed(service.Namespace) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -257,8 +257,7 @@ func emitAddressRecord(c chan<- []dns.RR, s msg.Service) string {
|
|||||||
// calcSRVWeight borrows the logic implemented in plugin.SRV for dynamically
|
// calcSRVWeight borrows the logic implemented in plugin.SRV for dynamically
|
||||||
// calculating the srv weight and priority
|
// calculating the srv weight and priority
|
||||||
func calcSRVWeight(numservices int) uint16 {
|
func calcSRVWeight(numservices int) uint16 {
|
||||||
var services []msg.Service
|
services := make([]msg.Service, 0, numservices)
|
||||||
|
|
||||||
for range numservices {
|
for range numservices {
|
||||||
services = append(services, msg.Service{})
|
services = append(services, msg.Service{})
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ func stripZone(host string) string {
|
|||||||
// and in case of filename a resolv.conf like file is (assumed) and parsed and
|
// and in case of filename a resolv.conf like file is (assumed) and parsed and
|
||||||
// the nameservers found are returned.
|
// the nameservers found are returned.
|
||||||
func HostPortOrFile(s ...string) ([]string, error) {
|
func HostPortOrFile(s ...string) ([]string, error) {
|
||||||
var servers []string
|
var servers []string //nolint:prealloc // impossible to know the final length upfront
|
||||||
for _, h := range s {
|
for _, h := range s {
|
||||||
trans, host := Transport(h)
|
trans, host := Transport(h)
|
||||||
if len(host) == 0 {
|
if len(host) == 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user